Preprocessing for nbtree index scans allowed array "input" scan keys
already marked eliminated during array-specific preprocessing to be
"fixed up" during preprocessing proper. This allowed eliminated scan
keys on DESC index columns to spurious have their strategy commuted,
causing assertion failures.
To fix, teach _bt_fix_scankey_strategy to ignore these scan keys. This
brings it in line with its only caller, _bt_preprocess_keys.
Oversight in commit
5bf748b8, which enhanced nbtree ScalarArrayOp
execution.
Reported-By: Donghang Lin <[email protected]>
Discussion: https://postgr.es/m/CAA=D8a2sHK6CAzZ=0CeafC-Y-MFXbYxnRSHvZTi=+JHu6kAa8Q@mail.gmail.com
return true;
}
+ if (skey->sk_strategy == InvalidStrategy)
+ {
+ /* Already-eliminated array scan key; don't need to fix anything */
+ Assert(skey->sk_flags & SK_SEARCHARRAY);
+ return true;
+ }
+
/* Adjust strategy for DESC, if we didn't already */
if ((addflags & SK_BT_DESC) && !(skey->sk_flags & SK_BT_DESC))
skey->sk_strategy = BTCommuteStrategyNumber(skey->sk_strategy);