Skip to content

Commit 925e10d

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 80f9a36 commit 925e10d

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
@@ -1265,6 +1265,23 @@ gistSplit(Relation r,
12651265
int i;
12661266
SplitedPageLayout *res = NULL;
12671267

1268+
/* this should never recurse very deeply, but better safe than sorry */
1269+
check_stack_depth();
1270+
1271+
/* there's no point in splitting an empty page */
1272+
Assert(len > 0);
1273+
1274+
/*
1275+
* If a single tuple doesn't fit on a page, no amount of splitting will
1276+
* help.
1277+
*/
1278+
if (len == 1)
1279+
ereport(ERROR,
1280+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1281+
errmsg("index row size %zu exceeds maximum %zu for index \"%s\"",
1282+
IndexTupleSize(itup[0]), GiSTPageSize,
1283+
RelationGetRelationName(r))));
1284+
12681285
memset(v.spl_lisnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
12691286
memset(v.spl_risnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
12701287
gistSplitByKey(r, page, itup, len, giststate, &v, 0);

0 commit comments

Comments
 (0)