Skip to content

Commit 55d015b

Browse files
Add _bt_binsrch() scantid assertion to nbtree.
Assert that _bt_binsrch() binary searches with scantid set in insertion scankey cannot be performed on leaf pages. Leaf-level binary searches where scantid is set must use _bt_binsrch_insert() instead. _bt_binsrch_insert() is likely to have additional responsibilities in the future, such as searching within GIN-style posting lists using scantid. It seems like a good idea to tighten things up now.
1 parent 3146f52 commit 55d015b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/access/nbtree/nbtsearch.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,14 @@ _bt_binsrch(Relation rel,
347347
int32 result,
348348
cmpval;
349349

350-
/* Requesting nextkey semantics while using scantid seems nonsensical */
351-
Assert(!key->nextkey || key->scantid == NULL);
352-
353350
page = BufferGetPage(buf);
354351
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
355352

353+
/* Requesting nextkey semantics while using scantid seems nonsensical */
354+
Assert(!key->nextkey || key->scantid == NULL);
355+
/* scantid-set callers must use _bt_binsrch_insert() on leaf pages */
356+
Assert(!P_ISLEAF(opaque) || key->scantid == NULL);
357+
356358
low = P_FIRSTDATAKEY(opaque);
357359
high = PageGetMaxOffsetNumber(page);
358360

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