diff options
Diffstat (limited to 'src/backend/access/nbtree/nbtutils.c')
-rw-r--r-- | src/backend/access/nbtree/nbtutils.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index fe3ca62193c..a4c9e277b99 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -772,12 +772,9 @@ _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption) * * Depending on the operator type, the key may be required for both scan * directions or just one. Also, if the key is a row comparison header, - * we have to mark the appropriate subsidiary ScanKeys as required. In - * such cases, the first subsidiary key is required, but subsequent ones - * are required only as long as they correspond to successive index columns - * and match the leading column as to sort direction. - * Otherwise the row comparison ordering is different from the index ordering - * and so we can't stop the scan on the basis of those lower-order columns. + * we have to mark its first subsidiary ScanKey as required. (Subsequent + * subsidiary ScanKeys are normally for lower-order columns, and thus + * cannot be required, since they're after the first non-equality scankey.) * * Note: when we set required-key flag bits in a subsidiary scankey, we are * scribbling on a data structure belonging to the index AM's caller, not on @@ -815,24 +812,12 @@ _bt_mark_scankey_required(ScanKey skey) if (skey->sk_flags & SK_ROW_HEADER) { ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument); - AttrNumber attno = skey->sk_attno; - /* First subkey should be same as the header says */ - Assert(subkey->sk_attno == attno); - - for (;;) - { - Assert(subkey->sk_flags & SK_ROW_MEMBER); - if (subkey->sk_attno != attno) - break; /* non-adjacent key, so not required */ - if (subkey->sk_strategy != skey->sk_strategy) - break; /* wrong direction, so not required */ - subkey->sk_flags |= addflags; - if (subkey->sk_flags & SK_ROW_END) - break; - subkey++; - attno++; - } + /* First subkey should be same column/operator as the header */ + Assert(subkey->sk_flags & SK_ROW_MEMBER); + Assert(subkey->sk_attno == skey->sk_attno); + Assert(subkey->sk_strategy == skey->sk_strategy); + subkey->sk_flags |= addflags; } } |