Skip to content

Commit f04b112

Browse files
committed
Check for GiST index tuples that don't fit on a page.
The page splitting code would go into infinite recursion if you try to insert an index tuple that doesn't fit even on an empty page. Per analysis and suggested fix by Andrew Gierth. Fixes bug #11555, reported by Bryan Seitz (analysis happened over IRC). Backpatch to all supported versions.
1 parent 98a68b4 commit f04b112

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/backend/access/gist/gist.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,23 @@ gistSplit(Relation r,
948948
int i;
949949
SplitedPageLayout *res = NULL;
950950

951+
/* this should never recurse very deeply, but better safe than sorry */
952+
check_stack_depth();
953+
954+
/* there's no point in splitting an empty page */
955+
Assert(len > 0);
956+
957+
/*
958+
* If a single tuple doesn't fit on a page, no amount of splitting will
959+
* help.
960+
*/
961+
if (len == 1)
962+
ereport(ERROR,
963+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
964+
errmsg("index row size %zu exceeds maximum %zu for index \"%s\"",
965+
IndexTupleSize(itup[0]), GiSTPageSize,
966+
RelationGetRelationName(r))));
967+
951968
memset(v.spl_lisnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
952969
memset(v.spl_risnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
953970
gistSplitByKey(r, page, itup, len, giststate, &v, 0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy