Re: Adding Support for Copy callback functionality on COPY TO api

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Adding Support for Copy callback functionality on COPY TO api
Дата
Msg-id Y0SyZe081FFoHazf@paquier.xyz
обсуждение исходный текст
Ответ на Re: Adding Support for Copy callback functionality on COPY TO api  (Nathan Bossart <nathandbossart@gmail.com>)
Ответы Re: Adding Support for Copy callback functionality on COPY TO api  (Nathan Bossart <nathandbossart@gmail.com>)
Список pgsql-hackers
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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: autovacuum_freeze_max_age reloption seems broken
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: Adding Support for Copy callback functionality on COPY TO api