pgsql: Fix interaction of foreign tuple routing with remote triggers.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix interaction of foreign tuple routing with remote triggers.
Date: 2018-05-01 17:39:29
Message-ID: E1fDZFR-0001VV-F2@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix interaction of foreign tuple routing with remote triggers.

Without these fixes, changes to the inserted tuple made by remote
triggers are ignored when building local RETURNING tuples.

In the core code, call ExecInitRoutingInfo at a later point from
within ExecInitPartitionInfo so that the FDW callback gets invoked
after the returning list has been built. But move CheckValidResultRel
out of ExecInitRoutingInfo so that it can happen at an earlier stage.

In postgres_fdw, refactor assorted deparsing functions to work with
the RTE rather than the PlannerInfo, which saves us having to
construct a fake PlannerInfo in cases where we don't have a real one.
Then, we can pass down a constructed RTE that yields the correct
deparse result when no real one exists. Unfortunately, this
necessitates a hack that understands how the core code manages RT
indexes for update tuple routing, which is ugly, but we don't have a
better idea right now.

Original report, analysis, and patch by Etsuro Fujita. Heavily
refactored by me. Then worked over some more by Amit Langote.

Discussion: http://postgr.es/m/5AD4882B.10002@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/37a3058bc7c8224d4c0d8b36176d821636a1f90e

Modified Files
--------------
contrib/postgres_fdw/deparse.c | 58 +++++++---------
contrib/postgres_fdw/expected/postgres_fdw.out | 93 ++++++++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c | 65 ++++++++++++------
contrib/postgres_fdw/postgres_fdw.h | 6 +-
contrib/postgres_fdw/sql/postgres_fdw.sql | 49 ++++++++++++++
src/backend/executor/execPartition.c | 19 +++---
src/backend/executor/nodeModifyTable.c | 14 ++--
7 files changed, 234 insertions(+), 70 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-05-01 20:13:29 Re: pgsql: Prevent infinity and NaN in jsonb/plperl transform
Previous Message Tom Lane 2018-05-01 17:21:22 pgsql: Remove jsonb_plperl test cases for Inf/NaN conversions.