pgsql: Fix testing of parallel-safety of SubPlans.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix testing of parallel-safety of SubPlans.
Date: 2017-04-18 19:44:07
Message-ID: E1d0Z2l-0005vL-0l@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix testing of parallel-safety of SubPlans.

is_parallel_safe() supposed that the only relevant property of a SubPlan
was the parallel safety of the referenced subplan tree. This is wrong:
the testexpr or args subtrees might contain parallel-unsafe stuff, as
demonstrated by the test case added here. However, just recursing into the
subtrees fails in a different way: we'll typically find PARAM_EXEC Params
representing the subplan's output columns in the testexpr. The previous
coding supposed that any Param must be treated as parallel-restricted, so
that a naive attempt at fixing this disabled parallel pushdown of SubPlans
altogether. We must instead determine, for any visited Param, whether it
is one that would be computed by a surrounding SubPlan node; if so, it's
safe to push down along with the SubPlan node.

We might later be able to extend this logic to cope with Params used for
correlated subplans and other cases; but that's a task for v11 or beyond.

Tom Lane and Amit Kapila

Discussion: https://postgr.es/m/7064.1492022469@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/39151781c8cd2c8bf6057496426fb9c07178eda5

Modified Files
--------------
src/backend/optimizer/util/clauses.c | 44 ++++++++++++++++++++++++---
src/include/nodes/primnodes.h | 3 +-
src/test/regress/expected/select_parallel.out | 12 ++++++++
src/test/regress/sql/select_parallel.sql | 4 +++
4 files changed, 57 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2017-04-19 18:47:05 pgsql: Fix typo in docs on SASL authentication.
Previous Message Tom Lane 2017-04-18 18:22:00 pgsql: Doc: improve markup in self-signed certificate example.