Skip to content

Commit 5c01135

Browse files
committed
Use normal ExecReScan to reset SkipScan child
Just a draft generated by the Hallucination Machine to run CI against it and see what breaks. Logically this brings us even closer to our understanding of SkipScan as restarting a correlated subquery with LIMIT 1, which is already reflected in the cost model.
1 parent 5ebc0fa commit 5c01135

4 files changed

Lines changed: 3564 additions & 3574 deletions

File tree

tsl/src/nodes/skip_scan/exec.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
#include <access/genam.h>
9393
#include <access/nbtree.h>
94+
#include <executor/executor.h>
9495
#include <nodes/extensible.h>
9596
#include <nodes/pg_list.h>
9697
#include <utils/datum.h>
@@ -99,8 +100,6 @@
99100

100101
#include "guc.h"
101102
#include "nodes/columnar_scan/columnar_scan.h"
102-
#include "nodes/columnar_scan/compressed_batch.h"
103-
#include "nodes/columnar_scan/exec.h"
104103

105104
typedef enum SkipScanStage
106105
{
@@ -281,24 +280,15 @@ skip_scan_rescan_index(SkipScanState *state)
281280
* any ScanKey changes we did */
282281
if (*state->scan_desc)
283282
{
284-
index_rescan(*state->scan_desc,
285-
*state->scan_keys,
286-
*state->num_scan_keys,
287-
NULL /*orderbys*/,
288-
0 /*norderbys*/);
289-
290-
/* Discard current compressed index tuple as we are ready to move to the next compressed
291-
* tuple via SkipScan */
283+
/*
284+
* The skip quals were updated in place in the scan keys of the index
285+
* scan node, so the standard rescan of the child picks them up. For a
286+
* ColumnarScan child this also resets its batch queue, discarding the
287+
* remaining decompressed tuples of the current batch, and rescans the
288+
* compressed index scan below it.
289+
*/
292290
ScanState *child = linitial(state->cscan_state.custom_ps);
293-
if (ts_is_columnar_scan_plan(state->child_plan))
294-
{
295-
ColumnarScanState *ds = (ColumnarScanState *) child;
296-
TupleTableSlot *slot = ds->batch_queue->funcs->top_tuple(ds->batch_queue);
297-
if (slot)
298-
{
299-
compressed_batch_discard_tuples((DecompressBatchState *) slot);
300-
}
301-
}
291+
ExecReScan(&child->ps);
302292
}
303293
state->needs_rescan = false;
304294
}

0 commit comments

Comments
 (0)