postgres.git / summary / log / commit / refs

commit    4732a5c53bd858ed057d52286fb6105385baa2a6
Author:   Peter Geoghegan <pg@bowt.ie>
Date:     Sat Oct 17 15:02:49 2026 +0000
First released in: 18.7, 19.0

    Fix nbtree unsatisfiable row compare assertion failure.
    
    An assertion within nbtree preprocessing's _bt_mark_scankey_required
    function expects the first member key of a row compare to have the same
    strategy as its header key, which its caller passes.  But the first row
    member key won't necessarily have been commuted in cases where the row
    compare is unsatisfiable due to its first member key having a NULL
    argument.  This led to spurious assertion failures in the single key
    fast path call to _bt_mark_scankey_required.
    
    To fix, always commute the row members, even when the row compare is
    unsatisfiable.  That way the header and its members will always agree on
    strategy.
    
    Oversight in commit ec986020, which improved nbtree's unsatisfiable
    RowCompare detection.
    
    Author: Peter Geoghegan <pg@bowt.ie>
    Backpatch-through: 18


src/backend/access/nbtree/nbtpreprocesskeys.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/backend/access/nbtree/nbtpreprocesskeys.c b/src/backend/access/nbtree/nbtpreprocesskeys.c index d09384a813a..b5477cbbe33 100644 --- a/src/backend/access/nbtree/nbtpreprocesskeys.c +++ b/src/backend/access/nbtree/nbtpreprocesskeys.c @@ -731,14 +731,11 @@ _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption) /* If it's a row header, fix row member flags and strategies similarly */ if (skey->sk_flags & SK_ROW_HEADER) { + bool satisfiable; ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument); - if (subkey->sk_flags & SK_ISNULL) - { - /* First row member is NULL, so RowCompare is unsatisfiable */ - Assert(subkey->sk_flags & SK_ROW_MEMBER); - return false; - } + /* If first row member is NULL, RowCompare is unsatisfiable */ + satisfiable = !(subkey->sk_flags & SK_ISNULL); for (;;) { @@ -751,6 +748,8 @@ _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption) break; subkey++; } + + return satisfiable; } return true; [parent: d7938ff30854]