mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user