nbtree: Demote incomplete split "can't happen" error.
authorPeter Geoghegan <pg@bowt.ie>
Sun, 15 Nov 2020 19:53:37 +0000 (11:53 -0800)
committerPeter Geoghegan <pg@bowt.ie>
Sun, 15 Nov 2020 19:53:37 +0000 (11:53 -0800)
Only a basic logic bug in a _bt_insertonpg() caller could lead to a
violation of this invariant (index corruption won't do it).  A "can't
happen" error seems inappropriate (it is arbitrary at best).

Demote the error to a simple assertion.  This matches similar nearby
sanity checks.

src/backend/access/nbtree/nbtinsert.c

index d36f7557c87c8f27cd5884628cba8d8fb9c52aaa..1c4b0fd4b814981b1a0709eb3f9384ad9b708e61 100644 (file)
@@ -1129,6 +1129,8 @@ _bt_insertonpg(Relation rel,
           IndexRelationGetNumberOfKeyAttributes(rel));
    Assert(!BTreeTupleIsPosting(itup));
    Assert(MAXALIGN(IndexTupleSize(itup)) == itemsz);
+   /* Caller must always finish incomplete split for us */
+   Assert(!P_INCOMPLETE_SPLIT(lpageop));
 
    /*
     * Every internal page should have exactly one negative infinity item at
@@ -1138,11 +1140,6 @@ _bt_insertonpg(Relation rel,
     */
    Assert(P_ISLEAF(lpageop) || newitemoff > P_FIRSTDATAKEY(lpageop));
 
-   /* The caller should've finished any incomplete splits already. */
-   if (P_INCOMPLETE_SPLIT(lpageop))
-       elog(ERROR, "cannot insert to incompletely split page %u",
-            BufferGetBlockNumber(buf));
-
    /*
     * Do we need to split an existing posting list item?
     */