Skip to content

Commit ad210e6

Browse files
committed
Second part of review
1 parent 4908f53 commit ad210e6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

contrib/tempscan/nodeCustomTempScan.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static CustomExecMethods exec_methods =
100100

101101
static set_rel_pathlist_hook_type set_rel_pathlist_hook_next = NULL;
102102

103-
static bool tempscan_enable = false;
103+
static bool tempscan_enable = true;
104104

105105
void _PG_init(void);
106106

@@ -414,14 +414,22 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
414414
if (!tempscan_enable || rel->consider_parallel || rel->lateral_relids)
415415
return;
416416

417-
if (rte->rtekind != RTE_RELATION ||
417+
if (rte->rtekind != RTE_RELATION || rel->reloptkind != RELOPT_BASEREL ||
418418
get_rel_persistence(rte->relid) != RELPERSISTENCE_TEMP)
419419
return;
420420

421421
if (!is_parallel_safe(root, (Node *) rel->baserestrictinfo) ||
422422
!is_parallel_safe(root, (Node *) rel->reltarget->exprs))
423423
return;
424424

425+
foreach(lc, rel->reltarget->exprs)
426+
{
427+
Expr *expr = lfirst(lc);
428+
429+
if (IsA(expr, Var) && ((Var *)expr)->varno == ROWID_VAR)
430+
return;
431+
}
432+
425433
/* Enable parallel safe paths generation for this relation */
426434
Assert(rel->partial_pathlist == NIL);
427435
rel->consider_parallel = true;
@@ -439,7 +447,7 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
439447
/*
440448
* Build possibly parallel paths other temporary table
441449
*/
442-
add_path(rel, create_seqscan_path(root, rel, NULL, 0));
450+
add_path(rel, create_seqscan_path(root, rel, rel->lateral_relids, 0));
443451
create_index_paths(root, rel);
444452
create_tidscan_paths(root, rel);
445453

@@ -486,7 +494,7 @@ _PG_init(void)
486494
"Enable feature of the parallel temporary table scan.",
487495
"Right now no any other purpose except debugging",
488496
&tempscan_enable,
489-
false,
497+
true,
490498
PGC_SUSET,
491499
0,
492500
NULL,
@@ -641,5 +649,6 @@ ShutdownTempScan(CustomScanState *node)
641649
{
642650
ParallelTempScanState *ts = (ParallelTempScanState *) node;
643651

644-
dsm_detach(dsm_find_mapping(ts->shared->handle));
652+
if (ts->shared)
653+
dsm_detach(dsm_find_mapping(ts->shared->handle));
645654
}

0 commit comments

Comments
 (0)