It has been pointed out to me that the command deparsing in postgres_fdw
does not support the INSERT OVERRIDING clause that was added in PG10.
Here is a patch that seems to fix that.  I don't know much about this,
whether anything else needs to be added or whether there should be
tests.  Perhaps someone more familiar with postgres_fdw details can
check it.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 097ecf61a9c2740b02a21be19a92aed92388346a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Tue, 31 Oct 2017 11:44:14 -0400
Subject: [PATCH] postgres_fdw: Add support for INSERT OVERRIDING clause

---
 contrib/postgres_fdw/deparse.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 2af8364010..8eb227605f 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -1573,7 +1573,21 @@ deparseInsertSql(StringInfo buf, PlannerInfo *root,
                        deparseColumnRef(buf, rtindex, attnum, root, false);
                }
 
-               appendStringInfoString(buf, ") VALUES (");
+               appendStringInfoString(buf, ") ");
+
+               switch (root->parse->override)
+               {
+                       case OVERRIDING_USER_VALUE:
+                               appendStringInfoString(buf, "OVERRIDING USER 
VALUE ");
+                               break;
+                       case OVERRIDING_SYSTEM_VALUE:
+                               appendStringInfoString(buf, "OVERRIDING SYSTEM 
VALUE ");
+                               break;
+                       default:
+                               break;
+               }
+
+               appendStringInfoString(buf, "VALUES (");
 
                pindex = 1;
                first = true;
-- 
2.14.3

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to