From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add support for COPY TO callback functions
Date: Tue, 11 Oct 2022 02:47:56 +0000
Message-ID: <E1oi5JD-001pmx-Gv@gemulon.postgresql.org> (raw)
Add support for COPY TO callback functions
This is useful as a way for extensions to process COPY TO rows in the
way they see fit (say auditing, analytics, backend, etc.) without the
need to invoke an external process running as the OS user running the
backend through PROGRAM that requires superuser rights. COPY FROM
already provides a similar callback for logical replication. For COPY
TO, the callback is triggered when we are ready to send a row in
CopySendEndOfRow(), which is the same code path as when sending a row
to a frontend or a pipe/file.
A small test module, test_copy_callbacks, is added to provide some
coverage for this facility.
Author: Bilva Sanaba, Nathan Bossart
Discussion: https://postgr.es/m/253C21D1-FCEB-41D9-A2AF-E6517015B7D7@amazon.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/9fcdf2c787ac6da330165ea3cd50ec5155943a2b
Modified Files
--------------
src/backend/commands/copy.c | 2 +-
src/backend/commands/copyto.c | 31 +++++++++++--
src/include/commands/copy.h | 3 +-
src/test/modules/Makefile | 1 +
src/test/modules/meson.build | 1 +
src/test/modules/test_copy_callbacks/.gitignore | 4 ++
src/test/modules/test_copy_callbacks/Makefile | 23 ++++++++++
.../expected/test_copy_callbacks.out | 13 ++++++
src/test/modules/test_copy_callbacks/meson.build | 34 +++++++++++++++
.../sql/test_copy_callbacks.sql | 4 ++
.../test_copy_callbacks--1.0.sql | 8 ++++
.../test_copy_callbacks/test_copy_callbacks.c | 51 ++++++++++++++++++++++
.../test_copy_callbacks.control | 4 ++
src/tools/pgindent/typedefs.list | 1 +
14 files changed, 175 insertions(+), 5 deletions(-)
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: michael@paquier.xyz
Subject: Re: pgsql: Add support for COPY TO callback functions
In-Reply-To: <E1oi5JD-001pmx-Gv@gemulon.postgresql.org>
References: <E1oi5JD-001pmx-Gv@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