mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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.
This commit is contained in:
parent
51126ccdb1
commit
17742a0511
@ -34,6 +34,7 @@ _hash_doinsert(Relation rel, IndexTuple itup)
|
|||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
BlockNumber oldblkno = InvalidBlockNumber;
|
BlockNumber oldblkno = InvalidBlockNumber;
|
||||||
bool retry = false;
|
bool retry = false;
|
||||||
|
Page metapage;
|
||||||
Page page;
|
Page page;
|
||||||
HashPageOpaque pageopaque;
|
HashPageOpaque pageopaque;
|
||||||
Size itemsz;
|
Size itemsz;
|
||||||
@ -53,7 +54,8 @@ _hash_doinsert(Relation rel, IndexTuple itup)
|
|||||||
|
|
||||||
/* Read the metapage */
|
/* Read the metapage */
|
||||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
|
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
|
* 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.
|
* XXX this is useless code if we are only storing hash keys.
|
||||||
*/
|
*/
|
||||||
if (itemsz > HashMaxItemSize((Page) metap))
|
if (itemsz > HashMaxItemSize(metapage))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||||
errmsg("index row size %zu exceeds hash maximum %zu",
|
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.")));
|
errhint("Values larger than a buffer page cannot be indexed.")));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user