pathkeys, required_outer));
}
- /* If consider_parallel is false, there should be no partial paths. */
- Assert(sub_final_rel->consider_parallel ||
- sub_final_rel->partial_pathlist == NIL);
-
- /* Same for partial paths. */
- foreach(lc, sub_final_rel->partial_pathlist)
+ /* If outer rel allows parallelism, do same for partial paths. */
+ if (rel->consider_parallel && bms_is_empty(required_outer))
{
- Path *subpath = (Path *) lfirst(lc);
- List *pathkeys;
-
- /* Convert subpath's pathkeys to outer representation */
- pathkeys = convert_subquery_pathkeys(root,
- rel,
- subpath->pathkeys,
- make_tlist_from_pathtarget(subpath->pathtarget));
+ /* If consider_parallel is false, there should be no partial paths. */
+ Assert(sub_final_rel->consider_parallel ||
+ sub_final_rel->partial_pathlist == NIL);
- /* Generate outer path using this subpath */
- add_partial_path(rel, (Path *)
- create_subqueryscan_path(root, rel, subpath,
- pathkeys, required_outer));
+ /* Same for partial paths. */
+ foreach(lc, sub_final_rel->partial_pathlist)
+ {
+ Path *subpath = (Path *) lfirst(lc);
+ List *pathkeys;
+
+ /* Convert subpath's pathkeys to outer representation */
+ pathkeys = convert_subquery_pathkeys(root,
+ rel,
+ subpath->pathkeys,
+ make_tlist_from_pathtarget(subpath->pathtarget));
+
+ /* Generate outer path using this subpath */
+ add_partial_path(rel, (Path *)
+ create_subqueryscan_path(root, rel, subpath,
+ pathkeys,
+ required_outer));
+ }
}
}
/* Check for query cancel. */
CHECK_FOR_INTERRUPTS();
+ /* Path to be added must be parallel safe. */
+ Assert(new_path->parallel_safe);
+
+ /* Relation should be OK for parallelism, too. */
+ Assert(parent_rel->consider_parallel);
+
/*
* As in add_path, throw out any paths which are dominated by the new
* path, but throw out the new path if some existing path dominates it.
------------------------------+---------------------------+-------------+--------------
(0 rows)
+-- test interation between subquery and partial_paths
+SET LOCAL min_parallel_table_scan_size TO 0;
+CREATE VIEW tenk1_vw_sec WITH (security_barrier) AS SELECT * FROM tenk1;
+EXPLAIN (COSTS OFF)
+SELECT 1 FROM tenk1_vw_sec WHERE EXISTS (SELECT 1 WHERE unique1 = 0);
+ QUERY PLAN
+-------------------------------------------------------------------
+ Subquery Scan on tenk1_vw_sec
+ Filter: (alternatives: SubPlan 1 or hashed SubPlan 2)
+ -> Gather
+ Workers Planned: 4
+ -> Parallel Index Only Scan using tenk1_unique1 on tenk1
+ SubPlan 1
+ -> Result
+ One-Time Filter: (tenk1_vw_sec.unique1 = 0)
+ SubPlan 2
+ -> Result
+(10 rows)
+
rollback;