git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ccf4e27)
Fix calculation of how much shared memory is required to store a TOC.
2021年1月15日 03:44:17 +0000 (12:44 +0900)
2021年1月15日 03:44:17 +0000 (12:44 +0900)
Commit ac883ac453 refactored shm_toc_estimate() but changed its calculation
of shared memory size for TOC incorrectly. Previously this could cause too
large memory to be allocated.

Back-patch to v11 where the bug was introduced.

Author: Takayuki Tsunakawa
Discussion: https://postgr.es/m/TYAPR01MB2990BFB73170E2C4921E2C4DFEA80@TYAPR01MB2990.jpnprd01.prod.outlook.com


diff --git a/src/backend/storage/ipc/shm_toc.c b/src/backend/storage/ipc/shm_toc.c
index 83c7928d8821722ddb88251f314dc7ccb8d4c72d..863b98bf0545d13aa214ee34c0f17664e9e29991 100644 (file)
--- a/src/backend/storage/ipc/shm_toc.c
+++ b/src/backend/storage/ipc/shm_toc.c
@@ -265,8 +265,8 @@ shm_toc_estimate(shm_toc_estimator *e)
Size sz;
sz = offsetof(shm_toc, toc_entry);
- sz += add_size(sz, mul_size(e->number_of_keys, sizeof(shm_toc_entry)));
- sz += add_size(sz, e->space_for_chunks);
+ sz = add_size(sz, mul_size(e->number_of_keys, sizeof(shm_toc_entry)));
+ sz = add_size(sz, e->space_for_chunks);
return BUFFERALIGN(sz);
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /