Skip to content

Commit f270a16

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 7f71c89 commit f270a16

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
@@ -1395,6 +1395,23 @@ gistSplit(Relation r,
13951395
int i;
13961396
SplitedPageLayout *res = NULL;
13971397

1398+
/* this should never recurse very deeply, but better safe than sorry */
1399+
check_stack_depth();
1400+
1401+
/* there's no point in splitting an empty page */
1402+
Assert(len > 0);
1403+
1404+
/*
1405+
* If a single tuple doesn't fit on a page, no amount of splitting will
1406+
* help.
1407+
*/
1408+
if (len == 1)
1409+
ereport(ERROR,
1410+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1411+
errmsg("index row size %zu exceeds maximum %zu for index \"%s\"",
1412+
IndexTupleSize(itup[0]), GiSTPageSize,
1413+
RelationGetRelationName(r))));
1414+
13981415
memset(v.spl_lisnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
13991416
memset(v.spl_risnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
14001417
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