From 8e9ea08bae93a754d5075b7bc9c0b2bc71958bfd Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Tue, 27 Apr 2021 14:41:27 +0900 Subject: Don't pass "ONLY" options specified in TRUNCATE to foreign data wrapper. Commit 8ff1c94649 allowed TRUNCATE command to truncate foreign tables. Previously the information about "ONLY" options specified in TRUNCATE command were passed to the foreign data wrapper. Then postgres_fdw constructed the TRUNCATE command to issue the remote server and included "ONLY" options in it based on the passed information. On the other hand, "ONLY" options specified in SELECT, UPDATE or DELETE have no effect when accessing or modifying the remote table, i.e., are not passed to the foreign data wrapper. So it's inconsistent to make only TRUNCATE command pass the "ONLY" options to the foreign data wrapper. Therefore this commit changes the TRUNCATE command so that it doesn't pass the "ONLY" options to the foreign data wrapper, for the consistency with other statements. Also this commit changes postgres_fdw so that it always doesn't include "ONLY" options in the TRUNCATE command that it constructs. Author: Fujii Masao Reviewed-by: Bharath Rupireddy, Kyotaro Horiguchi, Justin Pryzby, Zhihong Yu Discussion: https://postgr.es/m/551ed8c1-f531-818b-664a-2cecdab99cd8@oss.nttdata.com --- contrib/postgres_fdw/postgres_fdw.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'contrib/postgres_fdw/postgres_fdw.c') diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index e201b5404e6..8bcdc8d6160 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -401,7 +401,6 @@ static void postgresExplainForeignModify(ModifyTableState *mtstate, static void postgresExplainDirectModify(ForeignScanState *node, ExplainState *es); static void postgresExecForeignTruncate(List *rels, - List *rels_extra, DropBehavior behavior, bool restart_seqs); static bool postgresAnalyzeForeignTable(Relation relation, @@ -2881,7 +2880,6 @@ postgresExplainDirectModify(ForeignScanState *node, ExplainState *es) */ static void postgresExecForeignTruncate(List *rels, - List *rels_extra, DropBehavior behavior, bool restart_seqs) { @@ -2964,7 +2962,7 @@ postgresExecForeignTruncate(List *rels, /* Construct the TRUNCATE command string */ initStringInfo(&sql); - deparseTruncateSql(&sql, rels, rels_extra, behavior, restart_seqs); + deparseTruncateSql(&sql, rels, behavior, restart_seqs); /* Issue the TRUNCATE command to remote server */ do_sql_command(conn, sql.data); -- cgit v1.2.3