diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-04-11 12:03:12 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-04-11 12:06:01 -0400 |
commit | 4c3b59abf4c476843bca23de7fb66d647627f30e (patch) | |
tree | 9ec159382072d6b1c82ef880a35c2c82a1864895 | |
parent | 28b047875554b29837cded70a19384dae107c61a (diff) | |
download | postgresql-4c3b59abf4c476843bca23de7fb66d647627f30e.tar.gz postgresql-4c3b59abf4c476843bca23de7fb66d647627f30e.zip |
Fix failure when a shared tidbitmap has only one page.
Commit 98e6e89040a0534ca26914c66cae9dd49ef62ad9 made inadequate
provision for the case of a single-page shared tidbitmap. It
allocate space for a shared PagetableEntry, but failed to
initialize it.
Report by Thomas Munro. Patch by Dilip Kumar, with some comment
changes by me.
Discussion: http://postgr.es/m/CAEepm=19Cmnfbi-j2Bw-a6yGPeHE1OVhKvvKz9bRBTJGKfGHMA@mail.gmail.com
-rw-r--r-- | src/backend/nodes/tidbitmap.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c index eab8f683564..c66019e3ba1 100644 --- a/src/backend/nodes/tidbitmap.c +++ b/src/backend/nodes/tidbitmap.c @@ -866,12 +866,14 @@ tbm_prepare_shared_iterate(TIDBitmap *tbm) else if (tbm->status == TBM_ONE_PAGE) { /* - * In one page mode allocate the space for one pagetable entry and - * directly store its index i.e. 0 in page array + * In one page mode allocate the space for one pagetable entry, + * initialize it, and directly store its index (i.e. 0) in the + * page array. */ tbm->dsapagetable = dsa_allocate(tbm->dsa, sizeof(PTEntryArray) + sizeof(PagetableEntry)); ptbase = dsa_get_address(tbm->dsa, tbm->dsapagetable); + memcpy(ptbase->ptentry, &tbm->entry1, sizeof(PagetableEntry)); ptpages->index[0] = 0; } |