Re: WIP patch: add (PRE|POST)PROCESSOR options to COPY - Mailing list pgsql-hackers

From Etsuro Fujita
Subject Re: WIP patch: add (PRE|POST)PROCESSOR options to COPY
Date
Msg-id 009101cd957a$e37189b0$aa549d10$@lab.ntt.co.jp
Whole thread Raw
In response to Re: WIP patch: add (PRE|POST)PROCESSOR options to COPY  (Craig Ringer <ringerc@ringerc.id.au>)
Responses Re: WIP patch: add (PRE|POST)PROCESSOR options to COPY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> From: Craig Ringer [mailto:ringerc@ringerc.id.au]

> On 09/13/2012 10:25 PM, Tom Lane wrote:
> > I think it would be a lot better if this were designed so that the
> > processor programs executed on client side.  Which would probably make
> > it not a COPY patch at all, but something in psql.

Maybe my explanation was insufficient.  Let me add one thing to my earlier
explanation.  The submitted patch allows the psql \copy instruction to be
executed like:

$ echo '/bin/gunzip -c $1' > decompress.sh
$ chmod +x decompress.sh

postgres=# \copy foo FROM '/home/pgsql/foo.csv.gz' WITH (format 'csv',
preprocessor '/home/pgsql/decompress.sh')

In this example, command "/home/pgsql/decompress.sh /home/pgsql/foo.csv.gz" is
executed on client side, by using popen(), and command "COPY foo FROM STDIN WITH
(format 'csv')" is sent to backend.  I apologize for not providing you with
enough explanation.

> Either that, or allow the pre- and post- processors to be programs
> written in a (possibly trusted) PL.

I would like to add the hooks not only for the psql \copy instrucntion, but also
for the SQL COPY command, because I think the hooks for the SQL COPY command
would allow to realize variants of contrib/file_fdw such as compressed file FDW
and Hadoop HDFS FDW, etc., which I think would be useful especially for DWH
environments.

Thanks,

Best regards,
Etsuro Fujita




pgsql-hackers by date:

Previous
From: Florian.Schoppmann@emc.com (Florian Schoppmann)
Date:
Subject: Invalid optimization of VOLATILE function in WHERE clause?
Next
From: Hitoshi Harada
Date:
Subject: Re: [PATCH]Tablesample Submission