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 --- doc/src/sgml/fdwhandler.sgml | 29 +++++++++++++---------------- doc/src/sgml/postgres-fdw.sgml | 7 +++++++ 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml index 9f9274ce55f..e08441ec8bc 100644 --- a/doc/src/sgml/fdwhandler.sgml +++ b/doc/src/sgml/fdwhandler.sgml @@ -1071,28 +1071,16 @@ EndDirectModify(ForeignScanState *node); void -ExecForeignTruncate(List *rels, List *rels_extra, - DropBehavior behavior, bool restart_seqs); +ExecForeignTruncate(List *rels, + DropBehavior behavior, + bool restart_seqs); Truncate a set of foreign tables specified in rels. This function is called when is executed on foreign tables. rels is the list of Relation data structure that indicates - a foreign table to truncate. rels_extra the list of - int value, which delivers extra information about - a foreign table to truncate. Possible values are - TRUNCATE_REL_CONTEXT_NORMAL, which means that - the foreign table is specified WITHOUT ONLY clause - in TRUNCATE, - TRUNCATE_REL_CONTEXT_ONLY, which means that - the foreign table is specified WITH ONLY clause, - and TRUNCATE_REL_CONTEXT_CASCADING, - which means that the foreign table is not specified explicitly, - but will be truncated due to dependency (for example, partition table). - There is one-to-one mapping between rels and - rels_extra. The number of entries is the same - between the two lists. + a foreign table to truncate. @@ -1111,6 +1099,15 @@ ExecForeignTruncate(List *rels, List *rels_extra, if CONTINUE IDENTITY option is specified. + + Note that the ONLY options specified + in the original TRUNCATE command are not passed to + ExecForeignTruncate. This behavior is similar to + the callback functions of SELECT, + UPDATE and DELETE on + a foreign table. + + TRUNCATE invokes ExecForeignTruncate once per foreign server diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml index 5320accf6f4..b0806c1274e 100644 --- a/doc/src/sgml/postgres-fdw.sgml +++ b/doc/src/sgml/postgres-fdw.sgml @@ -69,6 +69,13 @@ have privileges to do these things.) + + Note that the ONLY option specified in + SELECT, UPDATE, + DELETE or TRUNCATE + has no effect when accessing or modifying the remote table. + + Note that postgres_fdw currently lacks support for INSERT statements with an ON CONFLICT DO -- cgit v1.2.3