diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-02-07 11:39:22 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-02-07 11:41:33 -0500 |
commit | 7c944bd903392829608a9fba5b0e68c4fe89abf8 (patch) | |
tree | 258a592bf8ddb522d3522415ad76b0dfa0f8d250 /src/backend/commands/explain.c | |
parent | a1c1af2a1f6099c039f145c1edb52257f315be51 (diff) | |
download | postgresql-7c944bd903392829608a9fba5b0e68c4fe89abf8.tar.gz postgresql-7c944bd903392829608a9fba5b0e68c4fe89abf8.zip |
Introduce a new GUC force_parallel_mode for testing purposes.
When force_parallel_mode = true, we enable the parallel mode restrictions
for all queries for which this is believed to be safe. For the subset of
those queries believed to be safe to run entirely within a worker, we spin
up a worker and run the query there instead of running it in the
original process. When force_parallel_mode = regress, make additional
changes to allow the regression tests to run cleanly even though parallel
workers have been injected under the hood.
Taken together, this facilitates both better user testing and better
regression testing of the parallelism code.
Robert Haas, with help from Amit Kapila and Rushabh Lathia.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 25d8ca075d4..ee13136b7fd 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -23,6 +23,7 @@ #include "foreign/fdwapi.h" #include "nodes/nodeFuncs.h" #include "optimizer/clauses.h" +#include "optimizer/planmain.h" #include "parser/parsetree.h" #include "rewrite/rewriteHandler.h" #include "tcop/tcopprot.h" @@ -572,6 +573,7 @@ void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc) { Bitmapset *rels_used = NULL; + PlanState *ps; Assert(queryDesc->plannedstmt != NULL); es->pstmt = queryDesc->plannedstmt; @@ -580,7 +582,17 @@ ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc) es->rtable_names = select_rtable_names_for_explain(es->rtable, rels_used); es->deparse_cxt = deparse_context_for_plan_rtable(es->rtable, es->rtable_names); - ExplainNode(queryDesc->planstate, NIL, NULL, NULL, es); + + /* + * Sometimes we mark a Gather node as "invisible", which means that it's + * not displayed in EXPLAIN output. The purpose of this is to allow + * running regression tests with force_parallel_mode=regress to get the + * same results as running the same tests with force_parallel_mode=off. + */ + ps = queryDesc->planstate; + if (IsA(ps, GatherState) &&((Gather *) ps->plan)->invisible) + ps = outerPlanState(ps); + ExplainNode(ps, NIL, NULL, NULL, es); } /* |