aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/sql
diff options
context:
space:
mode:
authorEtsuro Fujita <efujita@postgresql.org>2019-06-13 17:59:11 +0900
committerEtsuro Fujita <efujita@postgresql.org>2019-06-13 17:59:11 +0900
commit2144601821618ddd007b4ce6b7f081a8ac6f65c9 (patch)
treec391fea7c358a6a7629c0e0c37cedd371c6b2ff1 /contrib/postgres_fdw/sql
parentafaa32daf293163cb9612bdb20a04a5fcb26309d (diff)
downloadpostgresql-2144601821618ddd007b4ce6b7f081a8ac6f65c9.tar.gz
postgresql-2144601821618ddd007b4ce6b7f081a8ac6f65c9.zip
postgres_fdw: Account for triggers in non-direct remote UPDATE planning.
Previously, in postgresPlanForeignModify, we planned an UPDATE operation on a foreign table so that we transmit only columns that were explicitly targets of the UPDATE, so as to avoid unnecessary data transmission, but if there were BEFORE ROW UPDATE triggers on the foreign table, those triggers might change values for non-target columns, in which case we would miss sending changed values for those columns. Prevent optimizing away transmitting all columns if there are BEFORE ROW UPDATE triggers on the foreign table. This is an oversight in commit 7cbe57c34 which added triggers on foreign tables, so apply the patch all the way back to 9.4 where that came in. Author: Shohei Mochizuki Reviewed-by: Amit Langote Discussion: https://postgr.es/m/201905270152.x4R1q3qi014550@toshiba.co.jp
Diffstat (limited to 'contrib/postgres_fdw/sql')
-rw-r--r--contrib/postgres_fdw/sql/postgres_fdw.sql5
1 files changed, 5 insertions, 0 deletions
diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql
index 934b6ffaf2c..a87c57df7bf 100644
--- a/contrib/postgres_fdw/sql/postgres_fdw.sql
+++ b/contrib/postgres_fdw/sql/postgres_fdw.sql
@@ -1481,6 +1481,11 @@ SELECT * from loc1;
UPDATE rem1 set f2 = 'skidoo' RETURNING f2;
SELECT * from loc1;
+EXPLAIN (verbose, costs off)
+UPDATE rem1 set f1 = 10; -- all columns should be transmitted
+UPDATE rem1 set f1 = 10;
+SELECT * from loc1;
+
DELETE FROM rem1;
-- Add a second trigger, to check that the changes are propagated correctly