From: Etsuro Fujita <efujita@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Disable support for partitionwise joins in problematic cases.
Date: Fri, 31 Aug 2018 11:48:39 +0000
Message-ID: <E1fvhup-000272-9H@gemulon.postgresql.org> (raw)
Disable support for partitionwise joins in problematic cases.
Commit f49842d, which added support for partitionwise joins, built the
child's tlist by applying adjust_appendrel_attrs() to the parent's. So in
the case where the parent's included a whole-row Var for the parent, the
child's contained a ConvertRowtypeExpr. To cope with that, that commit
added code to the planner, such as setrefs.c, but some code paths still
assumed that the tlist for a scan (or join) rel would only include Vars
and PlaceHolderVars, which was true before that commit, causing errors:
* When creating an explicit sort node for an input path for a mergejoin
path for a child join, prepare_sort_from_pathkeys() threw the 'could not
find pathkey item to sort' error.
* When deparsing a relation participating in a pushed down child join as a
subquery in contrib/postgres_fdw, get_relation_column_alias_ids() threw
the 'unexpected expression in subquery output' error.
* When performing set_plan_references() on a local join plan generated by
contrib/postgres_fdw for EvalPlanQual support for a pushed down child
join, fix_join_expr() threw the 'variable not found in subplan target
lists' error.
To fix these, two approaches have been proposed: one by Ashutosh Bapat and
one by me. While the former keeps building the child's tlist with a
ConvertRowtypeExpr, the latter builds it with a whole-row Var for the
child not to violate the planner assumption, and tries to fix it up later,
But both approaches need more work, so refuse to generate partitionwise
join paths when whole-row Vars are involved, instead. We don't need to
handle ConvertRowtypeExprs in the child's tlists for now, so this commit
also removes the changes to the planner.
Previously, partitionwise join computed attr_needed data for each child
separately, and built the child join's tlist using that data, which also
required an extra step for adding PlaceHolderVars to that tlist, but it
would be more efficient to build it from the parent join's tlist through
the adjust_appendrel_attrs() transformation. So this commit builds that
list that way, and simplifies build_joinrel_tlist() and placeholder.c as
well as part of set_append_rel_size() to basically what they were before
partitionwise join went in.
Back-patch to PG11 where partitionwise join was introduced.
Report by Rajkumar Raghuwanshi. Analysis by Ashutosh Bapat, who also
provided some of regression tests. Patch by me, reviewed by Robert Haas.
Discussion: https://postgr.es/m/CAKcux6ktu-8tefLWtQuuZBYFaZA83vUzuRd7c1YHC-yEWyYFpg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/7cfdc77023ad50731723e85c215a4127436ed09c
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 71 +++++++++---
contrib/postgres_fdw/sql/postgres_fdw.sql | 14 ++-
src/backend/nodes/outfuncs.c | 1 +
src/backend/optimizer/path/allpaths.c | 78 ++++++--------
src/backend/optimizer/path/joinrels.c | 7 ++
src/backend/optimizer/plan/setrefs.c | 58 +---------
src/backend/optimizer/util/placeholder.c | 58 ----------
src/backend/optimizer/util/relnode.c | 125 +++++++++++-----------
src/include/nodes/relation.h | 8 +-
src/test/regress/expected/partition_aggregate.out | 32 ++++++
src/test/regress/expected/partition_join.out | 57 +++++++---
src/test/regress/sql/partition_aggregate.sql | 5 +
src/test/regress/sql/partition_join.sql | 8 +-
13 files changed, 266 insertions(+), 256 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: efujita@postgresql.org
Subject: Re: pgsql: Disable support for partitionwise joins in problematic cases.
In-Reply-To: <E1fvhup-000272-9H@gemulon.postgresql.org>
References: <E1fvhup-000272-9H@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox