@@ -121,7 +121,7 @@ create_partial_tempscan_path(PlannerInfo *root, RelOptInfo *rel,
121
121
pathnode -> parent = rel ;
122
122
pathnode -> pathtarget = rel -> reltarget ;
123
123
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 */
125
125
126
126
pathnode -> parallel_safe = true;
127
127
pathnode -> parallel_workers = path -> parallel_workers ;
@@ -276,6 +276,9 @@ ExecTempScan(CustomScanState *node)
276
276
*/
277
277
ts -> node .ss .ps .plan -> parallel_aware = false;
278
278
279
+ /* Forbid rescanning */
280
+ ts -> initialized = true;
281
+
279
282
if (!IsParallelWorker ())
280
283
{
281
284
TupleTableSlot * slot ;
@@ -370,19 +373,16 @@ EndTempScan(CustomScanState *node)
370
373
static void
371
374
ReScanTempScan (CustomScanState * node )
372
375
{
373
- PlanState * child ;
374
-
375
- ExecClearTuple (node -> ss .ps .ps_ResultTupleSlot );
376
+ ParallelTempScanState * ts = (ParallelTempScanState * )node ;
376
377
377
- child = (PlanState * )linitial (node -> custom_ps );
378
+ if (ts -> initialized )
379
+ elog (PANIC ,"Parallel TempScan feature Doesn't support any sort of rescanning" );
378
380
379
- if (! child )
381
+ if (IsParallelWorker () )
380
382
return ;
381
383
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 ));
386
386
}
387
387
388
388
/*
@@ -411,7 +411,7 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
411
411
if (set_rel_pathlist_hook_next )
412
412
(* set_rel_pathlist_hook_next )(root ,rel ,rti ,rte );
413
413
414
- if (!tempscan_enable || rel -> consider_parallel )
414
+ if (!tempscan_enable || rel -> consider_parallel || rel -> lateral_relids )
415
415
return ;
416
416
417
417
if (rte -> rtekind != RTE_RELATION ||
@@ -460,11 +460,20 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
460
460
foreach (lc ,parallel_safe_lst )
461
461
{
462
462
Path * path = lfirst (lc );
463
+ Path * cpath ;
463
464
464
465
if (!path -> parallel_safe )
465
466
continue ;
466
467
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 ));
468
477
}
469
478
470
479
list_free (parallel_safe_lst );