diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 8d047d8873f..878f4b2e7b8 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -1800,6 +1800,12 @@ _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate, all_required_satisfied = true, all_satisfied = true; + /* + * Unset so->scanBehind in case it is still set from back when we dealt + * with the previous page's high key/finaltup + */ + so->scanBehind = false; + if (sktrig_required) { /* @@ -1808,8 +1814,6 @@ _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate, Assert(!_bt_tuple_before_array_skeys(scan, dir, tuple, tupdesc, tupnatts, false, 0, NULL)); - so->scanBehind = false; /* reset */ - /* * Required scan key wasn't satisfied, so required arrays will have to * advance. Invalidate page-level state that tracks whether the