Content-Length: 298241 | pFad | http://github.com/postgrespro/postgres/commit/097e41439d69e11fb870e009b1ac64dda4f01c3d

F9 Fix broken error check in _hash_doinsert. · postgrespro/postgres@097e414 · GitHub
Skip to content

Commit 097e414

Browse files
committed
Fix broken error check in _hash_doinsert.
You can't just cast a HashMetaPage to a Page, because the meta page data is stored after the page header, not at offset 0. Fortunately, this didn't break anything because it happens to find hashm_bsize at the offset at which it expects to find pd_pagesize_version, and the values are close enough to the same that this works out. Still, it's a bug, so back-patch to all supported versions. Mithun Cy, revised a bit by me.
1 parent 2f802d9 commit 097e414

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/access/hash/hashinsert.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ _hash_doinsert(Relation rel, IndexTuple itup)
3535
BlockNumber blkno;
3636
BlockNumber oldblkno;
3737
bool retry;
38+
Page metapage;
3839
Page page;
3940
HashPageOpaque pageopaque;
4041
Size itemsz;
@@ -58,7 +59,8 @@ _hash_doinsert(Relation rel, IndexTuple itup)
5859
restart_insert:
5960
/* Read the metapage */
6061
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
61-
metap = HashPageGetMeta(BufferGetPage(metabuf));
62+
metapage = BufferGetPage(metabuf);
63+
metap = HashPageGetMeta(metapage);
6264

6365
/*
6466
* Check whether the item can fit on a hash page at all. (Eventually, we
@@ -67,11 +69,11 @@ _hash_doinsert(Relation rel, IndexTuple itup)
6769
*
6870
* XXX this is useless code if we are only storing hash keys.
6971
*/
70-
if (itemsz > HashMaxItemSize((Page) metap))
72+
if (itemsz > HashMaxItemSize(metapage))
7173
ereport(ERROR,
7274
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
7375
errmsg("index row size %zu exceeds hash maximum %zu",
74-
itemsz, HashMaxItemSize((Page) metap)),
76+
itemsz, HashMaxItemSize(metapage)),
7577
errhint("Values larger than a buffer page cannot be indexed.")));
7678

7779
oldblkno = InvalidBlockNumber;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/097e41439d69e11fb870e009b1ac64dda4f01c3d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy