mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Revert "nbtree: Remove useless row compare arg."
This reverts commit54c6ea8c81
. Further analysis has shown that the forcenonrequired row compare behavior is in fact necessary, despite the new restrictions on RowCompares imposed by _bt_set_startikey following commit5f4d98d4
. Discussion: https://postgr.es/m/CAH2-Wzm3bKcz3TbHGem3_+SinEyG=VZVPbApQghp7YiZj+MM3g@mail.gmail.com
This commit is contained in:
@ -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 *continuescan);
|
ScanDirection dir, bool forcenonrequired, 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,10 +2902,8 @@ _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,
|
||||||
continuescan))
|
forcenonrequired, continuescan))
|
||||||
continue;
|
continue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3062,7 +3060,8 @@ _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, bool *continuescan)
|
TupleDesc tupdesc, ScanDirection dir,
|
||||||
|
bool forcenonrequired, bool *continuescan)
|
||||||
{
|
{
|
||||||
ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument);
|
ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument);
|
||||||
int32 cmpresult = 0;
|
int32 cmpresult = 0;
|
||||||
@ -3102,7 +3101,11 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts,
|
|||||||
|
|
||||||
if (isNull)
|
if (isNull)
|
||||||
{
|
{
|
||||||
if (subkey->sk_flags & SK_BT_NULLS_FIRST)
|
if (forcenonrequired)
|
||||||
|
{
|
||||||
|
/* 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
|
||||||
@ -3156,8 +3159,12 @@ _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 ((subkey->sk_flags & SK_BT_REQFWD) &&
|
if (forcenonrequired)
|
||||||
ScanDirectionIsForward(dir))
|
{
|
||||||
|
/* treating scan's keys as non-required */
|
||||||
|
}
|
||||||
|
else if ((subkey->sk_flags & SK_BT_REQFWD) &&
|
||||||
|
ScanDirectionIsForward(dir))
|
||||||
*continuescan = false;
|
*continuescan = false;
|
||||||
else if ((subkey->sk_flags & SK_BT_REQBKWD) &&
|
else if ((subkey->sk_flags & SK_BT_REQBKWD) &&
|
||||||
ScanDirectionIsBackward(dir))
|
ScanDirectionIsBackward(dir))
|
||||||
@ -3209,7 +3216,7 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, int tupnatts,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
if (!result && !forcenonrequired)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
|
Reference in New Issue
Block a user