From: Michael Paquier <michael@paquier.xyz>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Soumyadeep Chakraborty <soumyadeep2007@gmail.com>
Cc: Sanaba, Bilva <bilvas@amazon.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Adding Support for Copy callback functionality on COPY TO api
Date: Tue, 11 Oct 2022 09:01:41 +0900
Message-ID: <Y0SyZe081FFoHazf@paquier.xyz> (raw)
In-Reply-To: <20221010163859.GA993859@nathanxps13>
References: <CAE-ML+_ebFzUnsgj-4MLshLGFfT05Lo15KK6rpcUt8-ZZKL1XQ@mail.gmail.com>
<20200930074151.GR1996@paquier.xyz>
<20220802234919.GA841243@nathanxps13>
<Yz/L+3aC6CJ/hZ65@paquier.xyz>
<20221007214824.GA814385@nathanxps13>
<Y0EGighrcVgNnp30@paquier.xyz>
<20221008173741.GB882834@nathanxps13>
<20221008211404.GA893744@nathanxps13>
<CALj2ACXnEd6t1DQkaW7=QLyrvsYtd=+OeYMfxTwM+ZmV6EUC_A@mail.gmail.com>
<20221010163859.GA993859@nathanxps13>
On Mon, Oct 10, 2022 at 09:38:59AM -0700, Nathan Bossart wrote:
> This new callback allows the use of COPY TO's machinery in extensions. A
> couple of generic use-cases are listed upthread [0], and one concrete
> use-case is the aws_s3 extension [1].
FWIW, I understand that the proposal is to have an easier control of
how, what and where to the data is processed. COPY TO PROGRAM
provides that with exactly the same kind of interface (data input, its
length) once you have a program able to process the data piped out the
same way. However, it is in the shape of an external process that
receives the data through a pipe hence it provides a much wider attack
surface which is something that all cloud provider care about. The
thing is that this allows extension developers to avoid arbitrary
commands on the backend as the OS user running the Postgres instance,
while still being able to process the data the way they want
(auditing, analytics, whatever) within the strict context of the
process running an extension code. I'd say that this is a very cheap
change to allow people to have more fun with the backend engine
(similar to the recent changes with archive libraries for
archive_command, but much less complex):
src/backend/commands/copy.c | 2 +-
src/backend/commands/copyto.c | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
(Not to mention that we've had our share of CVEs regarding COPY
PROGRAM even if it is superuser-only).
> I really doubt that this small test case is going to cause anything
> approaching undue maintenance burden. I think it's important to ensure
> this functionality continues to work as expected long into the future.
I like these toy modules, they provide test coverage while acting as a
template for new developers. I am wondering whether it should have
something for the copy from callback, actually, as it is named
"test_copy_callbacks" but I see no need to extend the module more than
necessary in the context of this thread (logical decoding uses it,
anyway).
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
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-hackers@postgresql.org
Cc: michael@paquier.xyz, nathandbossart@gmail.com, bharath.rupireddyforpostgres@gmail.com, soumyadeep2007@gmail.com, bilvas@amazon.com
Subject: Re: Adding Support for Copy callback functionality on COPY TO api
In-Reply-To: <Y0SyZe081FFoHazf@paquier.xyz>
References: <CAE-ML+_ebFzUnsgj-4MLshLGFfT05Lo15KK6rpcUt8-ZZKL1XQ@mail.gmail.com> <20200930074151.GR1996@paquier.xyz> <20220802234919.GA841243@nathanxps13> <Yz/L+3aC6CJ/hZ65@paquier.xyz> <20221007214824.GA814385@nathanxps13> <Y0EGighrcVgNnp30@paquier.xyz> <20221008173741.GB882834@nathanxps13> <20221008211404.GA893744@nathanxps13> <CALj2ACXnEd6t1DQkaW7=QLyrvsYtd=+OeYMfxTwM+ZmV6EUC_A@mail.gmail.com> <20221010163859.GA993859@nathanxps13> <Y0SyZe081FFoHazf@paquier.xyz>
* 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