diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-11-03 16:16:36 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-11-03 16:16:36 -0500 |
commit | 205f958406cc85f8f73e151906ecd281ff05d80a (patch) | |
tree | 3033bc585412494993912046d3a7d7389c16284d | |
parent | 501035a0ac7f711ee2f899cb08acb2a4237d7f4d (diff) | |
download | postgresql-205f958406cc85f8f73e151906ecd281ff05d80a.tar.gz postgresql-205f958406cc85f8f73e151906ecd281ff05d80a.zip |
Guard against core dump from uninitialized subplan.
If the planner erroneously puts a non-parallel-safe SubPlan into
a parallelized portion of the query tree, nodeSubplan.c will fail
in the worker processes because it finds a null in es_subplanstates,
which it's unable to cope with. It seems worth a test-and-elog to
make that an error case rather than a core dump case.
This probably should have been included in commit 16ebab688, which
was responsible for allowing nulls to appear in es_subplanstates
to begin with. So, back-patch to v10 where that came in.
Discussion: https://postgr.es/m/924226.1604422326@sss.pgh.pa.us
-rw-r--r-- | src/backend/executor/nodeSubplan.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 6b6f4c3f55d..ac3382f917a 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -794,7 +794,15 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent) sstate->planstate = (PlanState *) list_nth(estate->es_subplanstates, subplan->plan_id - 1); - /* ... and to its parent's state */ + /* + * This check can fail if the planner mistakenly puts a parallel-unsafe + * subplan into a parallelized subquery; see ExecSerializePlan. + */ + if (sstate->planstate == NULL) + elog(ERROR, "subplan \"%s\" was not initialized", + subplan->plan_name); + + /* Link to parent's state, too */ sstate->parent = parent; /* Initialize subexpressions */ |