pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Add support for COPY TO callback functions
3+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2022-10-11 94fd253d56 Fix compilation warning in test_copy_callbacks
* pgsql: Add support for COPY TO callback functions
@ 2022-10-11 02:47 Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Paquier @ 2022-10-11 02:47 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Add support for COPY TO callback functions
@ 2022-10-11 22:42 Andres Freund <andres@anarazel.de>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 3+ messages in thread
From: Andres Freund @ 2022-10-11 22:42 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-committers@lists.postgresql.org
Hi,
On 2022-10-11 02:47:56 +0000, Michael Paquier wrote:
> 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.
New warning with msvc 2022:
C:\dev\postgres-meson\src\test\modules\test_copy_callbacks\test_copy_callbacks.c(40,73): warning C4047: 'function': 'bool' differs in levels of indirection from 'void *' [C:\dev\postgres-meson\build-msbuild-2022\src\test\modules\test_copy_callbacks\7d667bc@@test_copy_callbacks@sha.vcxproj]
C:\dev\postgres-meson\src\test\modules\test_copy_callbacks\test_copy_callbacks.c(40,69): warning C4024: 'BeginCopyTo': different types for formal and actual parameter 6 [C:\dev\postgres-meson\build-msbuild-2022\src\test\modules\test_copy_callbacks\7d667bc@@test_copy_callbacks@sha.vcxproj]
Looks quite justified. Passing NULL to bool is_program isn't right.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: Add support for COPY TO callback functions
@ 2022-10-11 23:53 Michael Paquier <michael@paquier.xyz>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Paquier @ 2022-10-11 23:53 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-committers@lists.postgresql.org
On Tue, Oct 11, 2022 at 03:42:21PM -0700, Andres Freund wrote:
> Looks quite justified. Passing NULL to bool is_program isn't right.
Justified it is. Thanks!
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-10-11 23:53 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 02:47 pgsql: Add support for COPY TO callback functions Michael Paquier <michael@paquier.xyz>
2022-10-11 22:42 ` Andres Freund <andres@anarazel.de>
2022-10-11 23:53 ` Michael Paquier <michael@paquier.xyz>
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