postgres.git / summary / log / commit / refs

commit    55d015bde05311cbaaf16424e3aa05c37946cd8a
Author:   Peter Geoghegan <pg@bowt.ie>
Date:     Mon Sep 09 18:41:19 2019 +0000
First released in: 13.0

    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.


src/backend/access/nbtree/nbtsearch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 7f77ed24c5c..8e512461a0e 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -347,12 +347,14 @@ _bt_binsrch(Relation rel, int32 result, cmpval; - /* Requesting nextkey semantics while using scantid seems nonsensical */ - Assert(!key->nextkey || key->scantid == NULL); - page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); + /* Requesting nextkey semantics while using scantid seems nonsensical */ + Assert(!key->nextkey || key->scantid == NULL); + /* scantid-set callers must use _bt_binsrch_insert() on leaf pages */ + Assert(!P_ISLEAF(opaque) || key->scantid == NULL); + low = P_FIRSTDATAKEY(opaque); high = PageGetMaxOffsetNumber(page); [parent: 3146f5257f16]