postgres.git / summary / log / commit / refs

commit    10a0dcfc25fba51b2e0d3bbcb11584ecfb70f848
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 39c0a5d610f..14d9349225e 100644 --- a/src/backend/access/nbtree/nbtpreprocesskeys.c +++ b/src/backend/access/nbtree/nbtpreprocesskeys.c @@ -733,14 +733,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 (;;) { @@ -753,6 +750,8 @@ _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption) break; subkey++; } + + return satisfiable; } return true; [parent: 221423812daa]