diff options
Diffstat (limited to 'src/backend/access/nbtree/nbtutils.c')
-rw-r--r-- | src/backend/access/nbtree/nbtutils.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 76be65123c8..20227989c6d 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -1800,7 +1800,7 @@ _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate, { BTScanOpaque so = (BTScanOpaque) scan->opaque; Relation rel = scan->indexRelation; - ScanDirection dir = pstate ? pstate->dir : ForwardScanDirection; + ScanDirection dir = so->currPos.dir; int arrayidx = 0; bool beyond_end_advance = false, has_required_opposite_direction_only = false, @@ -2400,8 +2400,10 @@ new_prim_scan: /* * End this primitive index scan, but schedule another. * - * Note: If the scan direction happens to change, this scheduled primitive - * index scan won't go ahead after all. + * Note: We make a soft assumption that the current scan direction will + * also be used within _bt_next, when it is asked to step off this page. + * It is up to _bt_next to cancel this scheduled primitive index scan + * whenever it steps to a page in the direction opposite currPos.dir. */ pstate->continuescan = false; /* Tell _bt_readpage we're done... */ so->needPrimScan = true; /* ...but call _bt_first again */ @@ -3458,7 +3460,7 @@ _bt_checkkeys(IndexScanDesc scan, BTReadPageState *pstate, bool arrayKeys, { TupleDesc tupdesc = RelationGetDescr(scan->indexRelation); BTScanOpaque so = (BTScanOpaque) scan->opaque; - ScanDirection dir = pstate->dir; + ScanDirection dir = so->currPos.dir; int ikey = 0; bool res; @@ -4062,7 +4064,8 @@ static void _bt_checkkeys_look_ahead(IndexScanDesc scan, BTReadPageState *pstate, int tupnatts, TupleDesc tupdesc) { - ScanDirection dir = pstate->dir; + BTScanOpaque so = (BTScanOpaque) scan->opaque; + ScanDirection dir = so->currPos.dir; OffsetNumber aheadoffnum; IndexTuple ahead; |