aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-12-22 13:54:40 -0500
committerRobert Haas <rhaas@postgresql.org>2016-12-22 13:58:46 -0500
commit17742a05110ee0015f2861e9a4e4b1158c7e69cf (patch)
tree7f63f9fc98c6d26523764cc50a9e35ffdd27a7eb /src/backend/access
parent51126ccdb1ce720b674405e11bcb5e7b8fa902fb (diff)
downloadpostgresql-17742a05110ee0015f2861e9a4e4b1158c7e69cf.tar.gz
postgresql-17742a05110ee0015f2861e9a4e4b1158c7e69cf.zip
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.
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/hash/hashinsert.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c
index acd2e647638..4144060cec4 100644
--- a/src/backend/access/hash/hashinsert.c
+++ b/src/backend/access/hash/hashinsert.c
@@ -34,6 +34,7 @@ _hash_doinsert(Relation rel, IndexTuple itup)
BlockNumber blkno;
BlockNumber oldblkno = InvalidBlockNumber;
bool retry = false;
+ Page metapage;
Page page;
HashPageOpaque pageopaque;
Size itemsz;
@@ -53,7 +54,8 @@ _hash_doinsert(Relation rel, IndexTuple itup)
/* Read the metapage */
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
- metap = HashPageGetMeta(BufferGetPage(metabuf));
+ metapage = BufferGetPage(metabuf);
+ metap = HashPageGetMeta(metapage);
/*
* Check whether the item can fit on a hash page at all. (Eventually, we
@@ -62,11 +64,11 @@ _hash_doinsert(Relation rel, IndexTuple itup)
*
* XXX this is useless code if we are only storing hash keys.
*/
- if (itemsz > HashMaxItemSize((Page) metap))
+ if (itemsz > HashMaxItemSize(metapage))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("index row size %zu exceeds hash maximum %zu",
- itemsz, HashMaxItemSize((Page) metap)),
+ itemsz, HashMaxItemSize(metapage)),
errhint("Values larger than a buffer page cannot be indexed.")));
/*