Skip to content

Commit 4908f53

Browse files
committed
Draft-4
1 parent 64b5856 commit 4908f53

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

contrib/tempscan/nodeCustomTempScan.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ create_partial_tempscan_path(PlannerInfo *root, RelOptInfo *rel,
121121
pathnode->parent = rel;
122122
pathnode->pathtarget = rel->reltarget;
123123
pathnode->rows = path->rows; /* Don't use rel->rows! Remember semantics of this field in the parallel case */
124-
pathnode->param_info = path->param_info;
124+
pathnode->param_info = NULL; /* Can't use parameterisation, at least for now */
125125

126126
pathnode->parallel_safe = true;
127127
pathnode->parallel_workers = path->parallel_workers;
@@ -276,6 +276,9 @@ ExecTempScan(CustomScanState *node)
276276
*/
277277
ts->node.ss.ps.plan->parallel_aware = false;
278278

279+
/* Forbid rescanning */
280+
ts->initialized = true;
281+
279282
if (!IsParallelWorker())
280283
{
281284
TupleTableSlot *slot;
@@ -370,19 +373,16 @@ EndTempScan(CustomScanState *node)
370373
static void
371374
ReScanTempScan(CustomScanState *node)
372375
{
373-
PlanState *child;
374-
375-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
376+
ParallelTempScanState *ts = (ParallelTempScanState *) node;
376377

377-
child = (PlanState *) linitial(node->custom_ps);
378+
if (ts->initialized)
379+
elog(PANIC, "Parallel TempScan feature Doesn't support any sort of rescanning");
378380

379-
if (!child)
381+
if (IsParallelWorker())
380382
return;
381383

382-
if (node->ss.ps.chgParam != NULL)
383-
UpdateChangedParamSet(child, node->ss.ps.chgParam);
384-
385-
ExecReScan(child);
384+
Assert(list_length(ts->node.custom_ps) == 1);
385+
ExecReScan(linitial(ts->node.custom_ps));
386386
}
387387

388388
/*
@@ -411,7 +411,7 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
411411
if (set_rel_pathlist_hook_next)
412412
(*set_rel_pathlist_hook_next)(root, rel, rti, rte);
413413

414-
if (!tempscan_enable || rel->consider_parallel)
414+
if (!tempscan_enable || rel->consider_parallel || rel->lateral_relids)
415415
return;
416416

417417
if (rte->rtekind != RTE_RELATION ||
@@ -460,11 +460,20 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
460460
foreach(lc, parallel_safe_lst)
461461
{
462462
Path *path = lfirst(lc);
463+
Path *cpath;
463464

464465
if (!path->parallel_safe)
465466
continue;
466467

467-
add_path(rel, (Path *) create_partial_tempscan_path(root, rel, path));
468+
cpath = (Path *) create_partial_tempscan_path(root, rel, path);
469+
470+
/*
471+
* Need materialisation here. Do the absence of internal parameters and
472+
* lateral references guarantees we don't need to change any parameters
473+
* on a ReScan?
474+
*/
475+
add_path(rel, (Path *)
476+
create_material_path(cpath->parent, (Path *) cpath));
468477
}
469478

470479
list_free(parallel_safe_lst);

0 commit comments

Comments
 (0)