pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow TRUNCATE command to truncate foreign tables.
Date: Thu, 08 Apr 2021 11:56:46 +0000
Message-ID: <E1lUTHC-0008Aw-0H@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8ff1c94649f5c9184ac5f07981d8aea9dfd7ac19

Modified Files
--------------
contrib/postgres_fdw/connection.c              |   3 +-
contrib/postgres_fdw/deparse.c                 |  38 +++++
contrib/postgres_fdw/expected/postgres_fdw.out | 201 ++++++++++++++++++++++++-
contrib/postgres_fdw/option.c                  |   4 +
contrib/postgres_fdw/postgres_fdw.c            | 103 +++++++++++++
contrib/postgres_fdw/postgres_fdw.h            |   6 +
contrib/postgres_fdw/sql/postgres_fdw.sql      | 101 +++++++++++++
doc/src/sgml/fdwhandler.sgml                   |  61 ++++++++
doc/src/sgml/postgres-fdw.sgml                 |  32 +++-
doc/src/sgml/ref/truncate.sgml                 |   6 +-
src/backend/commands/tablecmds.c               | 151 +++++++++++++++++--
src/backend/replication/logical/worker.c       |  11 +-
src/include/commands/tablecmds.h               |  18 ++-
src/include/foreign/fdwapi.h                   |   8 +
src/include/utils/rel.h                        |   4 +-
src/test/regress/expected/foreign_data.out     |   8 +-
src/tools/pgindent/typedefs.list               |   1 +
17 files changed, 725 insertions(+), 31 deletions(-)



Message-ID: <E1lUTHC-0008Aw-0H@gemulon.postgresql.org>
Permalink:  ../E1lUTHC-0008Aw-0H@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lUTHC-0008Aw-0H@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org
  Subject: Re: pgsql: Allow TRUNCATE command to truncate foreign tables.
  In-Reply-To: <E1lUTHC-0008Aw-0H@gemulon.postgresql.org>
  References: <E1lUTHC-0008Aw-0H@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox