Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1e241c

Browse files
nbtree: Demote minus infinity "can't happen" error.
Only a very basic logic bug in a _bt_insertonpg() caller could lead to aviolation of this invariant. Besides, any newitemoff used for aninternal page is sanitized using other "can't happen" errors in_bt_getstackbuf() or its callers, before _bt_insertonpg() even getscalled.Also, move the error/assertion from the insert-without-split path of_bt_insertonpg() to the top of the same function. There is no reasonwhy this invariant only applies to insertions that happen to not resultin a page split; cover every insertion. The assertion naturally belongsnext to the existing generic assertions that document relativelyhigh-level invariants for the item being inserted.
1 parentcacef17 commitd1e241c

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

‎src/backend/access/nbtree/nbtinsert.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,14 @@ _bt_insertonpg(Relation rel,
10821082
IndexRelationGetNumberOfKeyAttributes(rel));
10831083
Assert(!BTreeTupleIsPosting(itup));
10841084

1085+
/*
1086+
* Every internal page should have exactly one negative infinity item at
1087+
* all times. Only _bt_split() and _bt_newroot() should add items that
1088+
* become negative infinity items through truncation, since they're the
1089+
* only routines that allocate new internal pages.
1090+
*/
1091+
Assert(P_ISLEAF(lpageop)||newitemoff>P_FIRSTDATAKEY(lpageop));
1092+
10851093
/* The caller should've finished any incomplete splits already. */
10861094
if (P_INCOMPLETE_SPLIT(lpageop))
10871095
elog(ERROR,"cannot insert to incompletely split page %u",
@@ -1212,18 +1220,6 @@ _bt_insertonpg(Relation rel,
12121220
}
12131221
}
12141222

1215-
/*
1216-
* Every internal page should have exactly one negative infinity item
1217-
* at all times. Only _bt_split() and _bt_newroot() should add items
1218-
* that become negative infinity items through truncation, since
1219-
* they're the only routines that allocate new internal pages. Do not
1220-
* allow a retail insertion of a new item at the negative infinity
1221-
* offset.
1222-
*/
1223-
if (!P_ISLEAF(lpageop)&&newitemoff==P_FIRSTDATAKEY(lpageop))
1224-
elog(ERROR,"cannot insert second negative infinity item in block %u of index \"%s\"",
1225-
itup_blkno,RelationGetRelationName(rel));
1226-
12271223
/* Do the update. No ereport(ERROR) until changes are logged */
12281224
START_CRIT_SECTION();
12291225

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp