Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-26 Thread Etsuro Fujita
I wrote: > > I'll reimplement the feature using the PROGRAM keyword: > > > > > COPY TABLE FROM PROGRAM 'command line'; > > > COPY TABLE TO PROGRAM 'command line'; > > I've reimplemented the feature. Attached is an updated version of the patch. I fixed bugs in the previous version of the patc

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-22 Thread Etsuro Fujita
I wrote: > > The biggest problem this patch has had from the very beginning is > > overdesign, and this is more of the same. Let's please just define the > > feature as "popen, not fopen, the given string" and have done. You can > > put all the warning verbiage you want in the documentation. (Bu

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-19 Thread Tom Lane
Robert Haas writes: > On Thu, Nov 15, 2012 at 2:35 PM, Tom Lane wrote: >> The biggest problem this patch has had from the very beginning is >> overdesign, and this is more of the same. Let's please just define the >> feature as "popen, not fopen, the given string" and have done. > ... If we giv

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-19 Thread Robert Haas
On Thu, Nov 15, 2012 at 2:35 PM, Tom Lane wrote: > Robert Haas writes: >> Yeah. If we're going to do this at all, and I'm not convinced it's >> worth the work, I think it's definitely good to support a variant >> where we specify exactly the things that will be passed to exec(). >> There's just

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-16 Thread Etsuro Fujita
> From: Tom Lane [mailto:t...@sss.pgh.pa.us] > Robert Haas writes: > > Yeah. If we're going to do this at all, and I'm not convinced it's > > worth the work, I think it's definitely good to support a variant > > where we specify exactly the things that will be passed to exec(). > > There's just

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-15 Thread Tom Lane
Craig Ringer writes: > I'd still be much happier to have COPY ... FROM PROGRAM - or something - > to clearly make the two different, for clarity as much as security. I don't object to using a PROGRAM keyword rather than something inside the string to select this behavior.

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-15 Thread Craig Ringer
On 11/16/2012 03:35 AM, Tom Lane wrote: > The biggest problem this patch has had from the very beginning is > overdesign, and this is more of the same. Let's please just define the > feature as "popen, not fopen, the given string" and have done. You can > put all the warning verbiage you want in t

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-15 Thread Tom Lane
Robert Haas writes: > Yeah. If we're going to do this at all, and I'm not convinced it's > worth the work, I think it's definitely good to support a variant > where we specify exactly the things that will be passed to exec(). > There's just too many ways to accidentally shoot yourself in the foot

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-15 Thread Robert Haas
On Wed, Nov 14, 2012 at 10:14 PM, Craig Ringer wrote: >> So? You're already handing the keys to the kingdom to anybody who can >> control the contents of that command line, even if it's only to point at >> the wrong program. And one man's "unexpected side-effect" is another >> man's "essential f

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Craig Ringer
On 11/15/2012 10:19 AM, Tom Lane wrote: > > I disagree very very strongly with that. If we prevent use of shell > syntax, we will lose a lot of functionality, for instance > > copy ... from program 'foocopy ... from program 'foo | bar' > > unless you're imagining that we will reimple

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Tom Lane
Craig Ringer writes: > On 11/15/2012 12:46 AM, Tom Lane wrote: >> Agreed, and there's also the question of passing switches etc to the >> program, so the string can't be a bare file name anyway. I proposed >> pipe symbols (|) in the string previously, but if you find that too >> Unix-centric I su

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Craig Ringer
On 11/15/2012 12:46 AM, Tom Lane wrote: > > Agreed, and there's also the question of passing switches etc to the > program, so the string can't be a bare file name anyway. I proposed > pipe symbols (|) in the string previously, but if you find that too > Unix-centric I suppose we could do > >

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Andrew Dunstan
On 11/14/2012 02:37 PM, Tom Lane wrote: What I'm imagining is a very very simple addition to COPY that just allows it to execute popen() instead of fopen() to read or write the data source/sink. What you suggest would require hundreds of lines and create many opportunities for new bugs.

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Tom Lane
Andrew Dunstan writes: > On 11/14/2012 02:05 PM, Peter Eisentraut wrote: >> Why don't you filter the data before it gets to stdin? Some program is >> feeding the data to "stdin" on the client side. Why doesn't that do the >> filtering? I don't see a large advantage in having the data be sent >>

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Andrew Dunstan
On 11/14/2012 02:05 PM, Peter Eisentraut wrote: On 11/14/12 11:50 AM, Andrew Dunstan wrote: COPY table FROM 'some command line |'; COPY table TO '| some command line'; I'd like to be able to filter STDIN if possible - with this syntax how is COPY going to know to hook up STDIN to t

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Peter Eisentraut
On 11/14/12 11:50 AM, Andrew Dunstan wrote: >> COPY table FROM 'some command line |'; >> COPY table TO '| some command line'; >> > > > I'd like to be able to filter STDIN if possible - with this syntax how > is COPY going to know to hook up STDIN to the program? Why don't you filter the

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Andrew Dunstan
On 11/14/2012 11:56 AM, Tom Lane wrote: Andrew Dunstan writes: On 11/14/2012 11:39 AM, Tom Lane wrote: What happened to the previous proposal of treating the COPY target as a pipe specification, ie I'd like to be able to filter STDIN if possible - with this syntax how is COPY going to know t

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Tom Lane
Andrew Dunstan writes: > On 11/14/2012 11:39 AM, Tom Lane wrote: >> What happened to the previous proposal of treating the COPY >> target as a pipe specification, ie > I'd like to be able to filter STDIN if possible - with this syntax how > is COPY going to know to hook up STDIN to the program?

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Andrew Dunstan
On 11/14/2012 11:39 AM, Tom Lane wrote: Andrew Dunstan writes: Yeah, I agree, although the syntax looks a bit unclean. Oh, I had not looked at the syntax closely. I agree, that basically sucks: it's overcomplicated and under-featured, because you can't control the actual program command line

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Tom Lane
Simon Riggs writes: > On 14 November 2012 15:09, Fujii Masao wrote: >> I'd just like to execute >> COPY vmstat_table FROM 'vmstat' WITH ... > If we go ahead with this, I think it needs additional keyword to > indicate that we will execute the file rather than read from it. I > don't think we sho

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Tom Lane
Andrew Dunstan writes: > Yeah, I agree, although the syntax looks a bit unclean. Oh, I had not looked at the syntax closely. I agree, that basically sucks: it's overcomplicated and under-featured, because you can't control the actual program command line very conveniently. Nor do I see a reason

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Simon Riggs
On 14 November 2012 15:09, Fujii Masao wrote: > What about further extending the COPY IN syntax to the following? > > COPY table_name FROM 'progname [ option, ... ]' WITH ... > > I'd just like to execute > > COPY vmstat_table FROM 'vmstat' WITH ... If we go ahead with this, I think it ne

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Simon Riggs
On 14 November 2012 16:20, Tom Lane wrote: > Alvaro Herrera writes: >> Simon Riggs escribió: >>> On 14 November 2012 15:09, Fujii Masao wrote: Here, progname for COPY IN is the user-supplied program that takes filename as its argument and that writes on standard output. > >>> I t

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Andrew Dunstan
On 11/14/2012 11:20 AM, Tom Lane wrote: I disagree with Simon's objection also, because neither reading from nor writing to an external program is likely to fit the model of reading/updating a table very well. For instance, there's no good reason to suppose that reading twice will give the same

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Tom Lane
Alvaro Herrera writes: > Simon Riggs escribió: >> On 14 November 2012 15:09, Fujii Masao wrote: >>> Here, progname for COPY IN is the user-supplied program that takes filename >>> as >>> its argument and that writes on standard output. >> I think we should be using FDWs/SRFs here, not inventing

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Alvaro Herrera
Simon Riggs escribió: > On 14 November 2012 15:09, Fujii Masao wrote: > > >> Here, progname for COPY IN is the user-supplied program that takes > >> filename as > >> its argument and that writes on standard output. > > > > What about further extending the COPY IN syntax to the following? > > > >

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Fujii Masao
On Thu, Nov 15, 2012 at 12:31 AM, Simon Riggs wrote: > On 14 November 2012 15:09, Fujii Masao wrote: > >>> Here, progname for COPY IN is the user-supplied program that takes filename >>> as >>> its argument and that writes on standard output. >> >> What about further extending the COPY IN syntax

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Simon Riggs
On 14 November 2012 15:09, Fujii Masao wrote: >> Here, progname for COPY IN is the user-supplied program that takes filename >> as >> its argument and that writes on standard output. > > What about further extending the COPY IN syntax to the following? > > COPY table_name FROM 'progname [ op

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Fujii Masao
On Wed, Nov 14, 2012 at 8:30 PM, Etsuro Fujita wrote: > I wrote: >> > From: Tom Lane [mailto:t...@sss.pgh.pa.us] >> >> > I wrote: >> > > "Etsuro Fujita" writes: >> > >> I have a question. I think it would be also better to extend the syntax >> > >> for the SQL COPY command in the same way, ie, >

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Simon Riggs
On 13 September 2012 10:13, Etsuro Fujita wrote: > I'd like to add the following options to the SQL COPY command and the psql > \copy > instruction: > > * PREPROCESSOR: Specifies the user-supplied program for COPY IN. The data > from an input file is preprocessed by the program before the da

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-11-14 Thread Etsuro Fujita
I wrote: > > From: Tom Lane [mailto:t...@sss.pgh.pa.us] > > > I wrote: > > > "Etsuro Fujita" writes: > > >> I have a question. I think it would be also better to extend the syntax > > >> for the SQL COPY command in the same way, ie, > > >> COPY foo from '/home/pgsql/decompress.sh /home/pgsql/foo

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Etsuro Fujita
> From: Tom Lane [mailto:t...@sss.pgh.pa.us] > I wrote: > > "Etsuro Fujita" writes: > >> I have a question. I think it would be also better to extend the syntax > >> for the SQL COPY command in the same way, ie, > >> COPY foo from '/home/pgsql/decompress.sh /home/pgsql/foo.csv.gz |' with > >> fo

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Tom Lane
I wrote: > "Etsuro Fujita" writes: >> I have a question. I think it would be also better to extend the syntax for >> the >> SQL COPY command in the same way, ie, >> COPY foo from '/home/pgsql/decompress.sh /home/pgsql/foo.csv.gz |' with >> format >> 'csv' > Yeah, sure --- that case is already

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Tom Lane
"Etsuro Fujita" writes: >> From: Tom Lane [mailto:t...@sss.pgh.pa.us] >> I think it would be better to present this as something like >> \copy foo from '/home/pgsql/decompress.sh /home/pgsql/foo.csv.gz |' with >> format 'csv' > I have a question. I think it would be also better to extend the syn

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Etsuro Fujita
> From: Tom Lane [mailto:t...@sss.pgh.pa.us] > "Etsuro Fujita" writes: > > 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

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Tom Lane
"Etsuro Fujita" writes: > 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 '/

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Etsuro Fujita
> From: Craig Ringer [mailto:ring...@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. Ma

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-18 Thread Craig Ringer
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. Either that, or allow the pre- and post- processors to be programs

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-14 Thread Etsuro Fujita
; pgsql-hackers@postgresql.org > Subject: Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY > > > On 09/13/2012 01:20 PM, Dimitri Fontaine wrote: > > Tom Lane writes: > >> I think it would be a lot better if this were designed so that the > >> proce

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-13 Thread Andrew Dunstan
On 09/13/2012 01:20 PM, Dimitri Fontaine wrote: Tom Lane writes: 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. And pgloader, which already has a part

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-13 Thread Dimitri Fontaine
Tom Lane writes: > 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. And pgloader, which already has a part of that feature with the per column reformatin

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-13 Thread Tom Lane
"Etsuro Fujita" writes: > I'd like to add the following options to the SQL COPY command and the psql > \copy > instruction: > * PREPROCESSOR: Specifies the user-supplied program for COPY IN. The data > from an input file is preprocessed by the program before the data is loaded > into > a p

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-13 Thread Pavel Stehule
2012/9/13 Alvaro Herrera : > Excerpts from Etsuro Fujita's message of jue sep 13 06:13:26 -0300 2012: >> I'd like to add the following options to the SQL COPY command and the psql >> \copy >> instruction: >> >> * PREPROCESSOR: Specifies the user-supplied program for COPY IN. The >> data >> f

Re: [HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-13 Thread Alvaro Herrera
Excerpts from Etsuro Fujita's message of jue sep 13 06:13:26 -0300 2012: > I'd like to add the following options to the SQL COPY command and the psql > \copy > instruction: > > * PREPROCESSOR: Specifies the user-supplied program for COPY IN. The data > from an input file is preprocessed by t

[HACKERS] WIP patch: add (PRE|POST)PROCESSOR options to COPY

2012-09-13 Thread Etsuro Fujita
I'd like to add the following options to the SQL COPY command and the psql \copy instruction: * PREPROCESSOR: Specifies the user-supplied program for COPY IN. The data from an input file is preprocessed by the program before the data is loaded into a postgres table. * POSTPROCESSOR: Speci