@@ -100,7 +100,7 @@ static CustomExecMethods exec_methods =
100
100
101
101
static set_rel_pathlist_hook_type set_rel_pathlist_hook_next = NULL ;
102
102
103
- static bool tempscan_enable = false ;
103
+ static bool tempscan_enable = true ;
104
104
105
105
void _PG_init (void );
106
106
@@ -414,14 +414,22 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
414
414
if (!tempscan_enable || rel -> consider_parallel || rel -> lateral_relids )
415
415
return ;
416
416
417
- if (rte -> rtekind != RTE_RELATION ||
417
+ if (rte -> rtekind != RTE_RELATION || rel -> reloptkind != RELOPT_BASEREL ||
418
418
get_rel_persistence (rte -> relid ) != RELPERSISTENCE_TEMP )
419
419
return ;
420
420
421
421
if (!is_parallel_safe (root , (Node * ) rel -> baserestrictinfo ) ||
422
422
!is_parallel_safe (root , (Node * ) rel -> reltarget -> exprs ))
423
423
return ;
424
424
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
+
425
433
/* Enable parallel safe paths generation for this relation */
426
434
Assert (rel -> partial_pathlist == NIL );
427
435
rel -> consider_parallel = true;
@@ -439,7 +447,7 @@ try_partial_tempscan(PlannerInfo *root, RelOptInfo *rel, Index rti,
439
447
/*
440
448
* Build possibly parallel paths other temporary table
441
449
*/
442
- add_path (rel , create_seqscan_path (root , rel , NULL , 0 ));
450
+ add_path (rel , create_seqscan_path (root , rel , rel -> lateral_relids , 0 ));
443
451
create_index_paths (root , rel );
444
452
create_tidscan_paths (root , rel );
445
453
@@ -486,7 +494,7 @@ _PG_init(void)
486
494
"Enable feature of the parallel temporary table scan." ,
487
495
"Right now no any other purpose except debugging" ,
488
496
& tempscan_enable ,
489
- false ,
497
+ true ,
490
498
PGC_SUSET ,
491
499
0 ,
492
500
NULL ,
@@ -641,5 +649,6 @@ ShutdownTempScan(CustomScanState *node)
641
649
{
642
650
ParallelTempScanState * ts = (ParallelTempScanState * ) node ;
643
651
644
- dsm_detach (dsm_find_mapping (ts -> shared -> handle ));
652
+ if (ts -> shared )
653
+ dsm_detach (dsm_find_mapping (ts -> shared -> handle ));
645
654
}
0 commit comments