diff options
author | Peter Geoghegan <pg@bowt.ie> | 2024-04-18 11:48:41 -0400 |
---|---|---|
committer | Peter Geoghegan <pg@bowt.ie> | 2024-04-18 11:48:41 -0400 |
commit | f22e17f76cf569a797c45268081feadc8ebd68c7 (patch) | |
tree | fe8dffbeda7311ba5cd91e1fb920ba3f18fa33d6 /src | |
parent | 9e72f6bfae1707fca1a297db433f6145d582a1c2 (diff) | |
download | postgresql-f22e17f76cf569a797c45268081feadc8ebd68c7.tar.gz postgresql-f22e17f76cf569a797c45268081feadc8ebd68c7.zip |
Don't try to fix eliminated nbtree array scan keys.
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 <donghanglin@gmail.com>
Discussion: https://postgr.es/m/CAA=D8a2sHK6CAzZ=0CeafC-Y-MFXbYxnRSHvZTi=+JHu6kAa8Q@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/nbtree/nbtutils.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 2eff34c4aa6..498b8d20358 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -3394,6 +3394,13 @@ _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption) 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); |