nbtree: Remove useless row compare arg.

Use of a RowCompare key makes nbtree index scans ineligible to use
pstate.forcenonrequired following recent bugfix commit 5f4d98d4.
There's no longer any need for _bt_check_rowcompare to accept a
forcenonrequired argument, so remove it.
pull/232/head
Peter Geoghegan 3 weeks ago
parent e6f98d8848
commit 54c6ea8c81
  1. 23
      src/backend/access/nbtree/nbtutils.c

@ -63,7 +63,7 @@ static bool _bt_check_compare(IndexScanDesc scan, ScanDirection dir,
bool *continuescan, int *ikey); bool *continuescan, int *ikey);
static bool _bt_check_rowcompare(ScanKey skey, static bool _bt_check_rowcompare(ScanKey skey,
IndexTuple tuple, int tupnatts, TupleDesc tupdesc, IndexTuple tuple, int tupnatts, TupleDesc tupdesc,
ScanDirection dir, bool forcenonrequired, bool *continuescan); ScanDirection dir, bool *continuescan);
static void _bt_checkkeys_look_ahead(IndexScanDesc scan, BTReadPageState *pstate, static void _bt_checkkeys_look_ahead(IndexScanDesc scan, BTReadPageState *pstate,
int tupnatts, TupleDesc tupdesc); int tupnatts, TupleDesc tupdesc);
static int _bt_keep_natts(Relation rel, IndexTuple lastleft, static int _bt_keep_natts(Relation rel, IndexTuple lastleft,
@ -2902,8 +2902,10 @@ _bt_check_compare(IndexScanDesc scan, ScanDirection dir,
/* row-comparison keys need special processing */ /* row-comparison keys need special processing */
if (key->sk_flags & SK_ROW_HEADER) if (key->sk_flags & SK_ROW_HEADER)
{ {
Assert(!forcenonrequired); /* forbidden by _bt_set_startikey */
if (_bt_check_rowcompare(key, tuple, tupnatts, tupdesc, dir, if (_bt_check_rowcompare(key, tuple, tupnatts, tupdesc, dir,
forcenonrequired, continuescan)) continuescan))
continue; continue;
return false; return false;
} }
@ -3060,8 +3062,7 @@ _bt_check_compare(IndexScanDesc scan, ScanDirection dir,
*/ */
static bool static bool
_bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts, _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts,
TupleDesc tupdesc, ScanDirection dir, TupleDesc tupdesc, ScanDirection dir, bool *continuescan)
bool forcenonrequired, bool *continuescan)
{ {
ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument); ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument);
int32 cmpresult = 0; int32 cmpresult = 0;
@ -3101,11 +3102,7 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts,
if (isNull) if (isNull)
{ {
if (forcenonrequired) if (subkey->sk_flags & SK_BT_NULLS_FIRST)
{
/* treating scan's keys as non-required */
}
else if (subkey->sk_flags & SK_BT_NULLS_FIRST)
{ {
/* /*
* Since NULLs are sorted before non-NULLs, we know we have * Since NULLs are sorted before non-NULLs, we know we have
@ -3159,11 +3156,7 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts,
*/ */
Assert(subkey != (ScanKey) DatumGetPointer(skey->sk_argument)); Assert(subkey != (ScanKey) DatumGetPointer(skey->sk_argument));
subkey--; subkey--;
if (forcenonrequired) if ((subkey->sk_flags & SK_BT_REQFWD) &&
{
/* treating scan's keys as non-required */
}
else if ((subkey->sk_flags & SK_BT_REQFWD) &&
ScanDirectionIsForward(dir)) ScanDirectionIsForward(dir))
*continuescan = false; *continuescan = false;
else if ((subkey->sk_flags & SK_BT_REQBKWD) && else if ((subkey->sk_flags & SK_BT_REQBKWD) &&
@ -3216,7 +3209,7 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts,
break; break;
} }
if (!result && !forcenonrequired) if (!result)
{ {
/* /*
* Tuple fails this qual. If it's a required qual for the current * Tuple fails this qual. If it's a required qual for the current

Loading…
Cancel
Save