1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-22 14:32:25 +03:00

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
This commit is contained in:
Fujii Masao
2021-04-27 14:41:27 +09:00
parent 3fa17d3771
commit 8e9ea08bae
11 changed files with 60 additions and 83 deletions

View File

@@ -21,16 +21,6 @@
#include "storage/lock.h"
#include "utils/relcache.h"
/*
* These values indicate how a relation was specified as the target to
* truncate in TRUNCATE command.
*/
#define TRUNCATE_REL_CONTEXT_NORMAL 1 /* specified without ONLY clause */
#define TRUNCATE_REL_CONTEXT_ONLY 2 /* specified with ONLY clause */
#define TRUNCATE_REL_CONTEXT_CASCADING 3 /* not specified but truncated
* due to dependency (e.g.,
* partition table) */
struct AlterTableUtilityContext; /* avoid including tcop/utility.h here */
@@ -68,7 +58,6 @@ extern void CheckTableNotInUse(Relation rel, const char *stmt);
extern void ExecuteTruncate(TruncateStmt *stmt);
extern void ExecuteTruncateGuts(List *explicit_rels,
List *relids,
List *relids_extra,
List *relids_logged,
DropBehavior behavior,
bool restart_seqs);