diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-04-12 15:13:23 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-04-12 15:13:34 -0400 |
commit | 003d80f3dfadd57c6aac8480436ff53ee2c978bd (patch) | |
tree | 0d8c430e9f9a262eddf5f27e6f1963c95c85f6c1 /src/backend/optimizer/plan/planner.c | |
parent | 35b5f7b608fa1ae12d07cd475c382c5f1341648d (diff) | |
download | postgresql-003d80f3dfadd57c6aac8480436ff53ee2c978bd.tar.gz postgresql-003d80f3dfadd57c6aac8480436ff53ee2c978bd.zip |
Mark finished Plan nodes with parallel_safe flags.
We'd managed to avoid doing this so far, but it seems pretty obvious
that it would be forced on us some day, and this is much the cleanest
way of approaching the open problem that parallel-unsafe subplans are
being transmitted to parallel workers. Anyway there's no space cost
due to alignment considerations, and the time cost is pretty minimal
since we're just copying the flag from the corresponding Path node.
(At least in most cases ... some of the klugier spots in createplan.c
have to work a bit harder.)
In principle we could perhaps get rid of SubPlan.parallel_safe,
but I thought it better to keep that in case there are reasons to
consider a SubPlan unsafe even when its child plan is parallel-safe.
This patch doesn't actually do anything with the new flags, but
I thought I'd commit it separately anyway.
Note: although this touches outfuncs/readfuncs, there's no need for
a catversion bump because Plan trees aren't stored on disk.
Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 4d5ee01b248..649a233e119 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -351,11 +351,9 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) /* * Optionally add a Gather node for testing purposes, provided this is - * actually a safe thing to do. (Note: we assume adding a Material node - * above did not change the parallel safety of the plan, so we can still - * rely on best_path->parallel_safe.) + * actually a safe thing to do. */ - if (force_parallel_mode != FORCE_PARALLEL_OFF && best_path->parallel_safe) + if (force_parallel_mode != FORCE_PARALLEL_OFF && top_plan->parallel_safe) { Gather *gather = makeNode(Gather); @@ -378,6 +376,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) gather->plan.plan_rows = top_plan->plan_rows; gather->plan.plan_width = top_plan->plan_width; gather->plan.parallel_aware = false; + gather->plan.parallel_safe = false; /* use parallel mode for parallel plans. */ root->glob->parallelModeNeeded = true; |