diff options
| author | Fujii Masao | 2021-04-08 11:56:08 +0000 |
|---|---|---|
| committer | Fujii Masao | 2021-04-08 11:56:08 +0000 |
| commit | 8ff1c94649f5c9184ac5f07981d8aea9dfd7ac19 (patch) | |
| tree | 351ccf9b3a7e2b3256684ba7f73a80b3eac220b1 /src/include/utils | |
| parent | 50e17ad281b8d1c1b410c9833955bc80fbad4078 (diff) | |
Allow TRUNCATE command to truncate foreign tables.
This commit introduces new foreign data wrapper API for TRUNCATE.
It extends TRUNCATE command so that it accepts foreign tables as
the targets to truncate and invokes that API. Also it extends postgres_fdw
so that it can issue TRUNCATE command to foreign servers, by adding
new routine for that TRUNCATE API.
The information about options specified in TRUNCATE command, e.g.,
ONLY, CACADE, etc is passed to FDW via API. The list of foreign tables to
truncate is also passed to FDW. FDW truncates the foreign data sources
that the passed foreign tables specify, based on those information.
For example, postgres_fdw constructs TRUNCATE command using them
and issues it to the foreign server.
For performance, TRUNCATE command invokes the FDW routine for
TRUNCATE once per foreign server that foreign tables to truncate belong to.
Author: Kazutaka Onishi, Kohei KaiGai, slightly modified by Fujii Masao
Reviewed-by: Bharath Rupireddy, Michael Paquier, Zhihong Yu, Alvaro Herrera, Stephen Frost, Ashutosh Bapat, Amit Langote, Daniel Gustafsson, Ibrar Ahmed, Fujii Masao
Discussion: https://postgr.es/m/CAOP8fzb_gkReLput7OvOK+8NHgw-RKqNv59vem7=524krQTcWA@mail.gmail.com
Discussion: https://postgr.es/m/CAJuF6cMWDDqU-vn_knZgma+2GMaout68YUgn1uyDnexRhqqM5Q@mail.gmail.com
Diffstat (limited to 'src/include/utils')
| -rw-r--r-- | src/include/utils/rel.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 9a3a03e5207..34e25eb5978 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -634,7 +634,8 @@ typedef struct ViewOptions * WAL stream. * * We don't log information for unlogged tables (since they don't WAL log - * anyway) and for system tables (their content is hard to make sense of, and + * anyway), for foreign tables (since they don't WAL log, either), + * and for system tables (their content is hard to make sense of, and * it would complicate decoding slightly for little gain). Note that we *do* * log information for user defined catalog tables since they presumably are * interesting to the user... @@ -642,6 +643,7 @@ typedef struct ViewOptions #define RelationIsLogicallyLogged(relation) \ (XLogLogicalInfoActive() && \ RelationNeedsWAL(relation) && \ + (relation)->rd_rel->relkind != RELKIND_FOREIGN_TABLE && \ !IsCatalogRelation(relation)) /* routines in utils/cache/relcache.c */ |
