From: | Robert Haas <rhaas(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: postgres_fdw: Check PlaceHolderVars before pushing down a join. |
Date: | 2016-06-14 15:50:15 |
Message-ID: | E1bCqbX-0001Xh-C1@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
postgres_fdw: Check PlaceHolderVars before pushing down a join.
As discovered by Andreas Seltenreich via sqlsmith, it's possible for a
remote join to need to generate a target list which contains a
PlaceHolderVar which would need to be evaluated on the remote server.
This happens when we try to push down a join tree which contains outer
joins and the nullable side of the join contains a subquery which
evauates some expression which can go to NULL above the level of the
join. Since the deparsing logic can't build a remote query that
involves subqueries, it fails while trying to produce an SQL query
that can be sent to the remote side. Detect such cases and don't try
to push down the join at all.
It's actually fine to push down the join if the PlaceHolderVar needs
to be evaluated at the current join level. This patch makes a small
change to build_tlist_to_deparse so that this case will work.
Amit Langote, Ashutosh Bapat, and me.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/131c7e70b4596027992a2f72bfd3765f0fff1b7c
Modified Files
--------------
contrib/postgres_fdw/deparse.c | 4 +-
contrib/postgres_fdw/expected/postgres_fdw.out | 58 ++++++++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c | 34 ++++++++++-----
contrib/postgres_fdw/sql/postgres_fdw.sql | 12 ++++++
4 files changed, 96 insertions(+), 12 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2016-06-14 17:51:25 | pgsql: Update extensions with GIN/GIST support for parallel query. |
Previous Message | Tom Lane | 2016-06-14 14:47:11 | pgsql: Minor fixes in contrib installation scripts. |