Re: [HACKERS] Allow COPY to use parameters

2016-05-27 Thread Merlin Moncure
On Fri, May 27, 2016 at 11:36 AM, Corey Huinker wrote: >> >> For the following pretend that "STRING" has the same behavior as the >> "format(...)" function. >> >> EXECUTE STRING('COPY %I TO %L', 'testtable', 'testfile.txt'); > > +1 -1 Why use syntax to do this? If we

Re: [HACKERS] Allow COPY to use parameters

2016-05-27 Thread Corey Huinker
> > > For the following pretend that "STRING" has the same behavior as the > "format(...)" function. > > EXECUTE STRING('COPY %I TO %L', 'testtable', 'testfile.txt');​ > +1 We should make string sanitization easy so that people use it by default. In the mean time, if you're just using psql, the

Re: [HACKERS] Allow COPY to use parameters

2016-05-27 Thread David G. Johnston
On Fri, May 27, 2016 at 6:02 AM, Craig Ringer wrote: > > COPY FROM $1 TO 'myfilename' > > ​Random thought - how about at least making the following work: For the following pretend that "STRING" has the same behavior as the "format(...)" function. EXECUTE STRING('COPY

Re: [HACKERS] Allow COPY to use parameters

2016-05-27 Thread Craig Ringer
On 27 May 2016 at 15:17, Andrew Gierth wrote: > > "Merlin" == Merlin Moncure writes: > > Merlin> Note, the biggest pain point I have with COPY is not being able > Merlin> to parameterize the filename argument. > > Second proof of concept

Re: [HACKERS] Allow COPY to use parameters

2016-05-27 Thread Andrew Gierth
> "Merlin" == Merlin Moncure writes: Merlin> Note, the biggest pain point I have with COPY is not being able Merlin> to parameterize the filename argument. Second proof of concept attached. This goes so far as to allow statements like: do $$ declare t text := 'bar';

Re: [HACKERS] Allow COPY to use parameters

2016-05-24 Thread Andrew Gierth
> "Merlin" == Merlin Moncure writes: Merlin> Hm, what's the use case preparing COPY? Preparing it isn't necessarily the point (and SQL-level PREPARE is not addressed in that patch). The point is to allow parameters, so that a client can do COPY (select blah from

Re: [HACKERS] Allow COPY to use parameters

2016-05-24 Thread Tom Lane
Merlin Moncure writes: > Hm, what's the use case preparing COPY? Note, the biggest pain point > I have with COPY is not being able to parameterize the filename > argument. Yeah. But putting a parameter symbol there (or anywhere in a utility statement that's not part of an

Re: [HACKERS] Allow COPY to use parameters

2016-05-24 Thread Merlin Moncure
On Tue, May 24, 2016 at 3:42 PM, David Fetter wrote: > On Tue, May 24, 2016 at 02:16:40PM -0400, Tom Lane wrote: >> David Fetter writes: >> > Per discussion on IRC and some test code, COPY can't take parameters >> > in a PREPARE, which feature would make it

Re: [HACKERS] Allow COPY to use parameters

2016-05-24 Thread David Fetter
On Tue, May 24, 2016 at 02:16:40PM -0400, Tom Lane wrote: > David Fetter writes: > > Per discussion on IRC and some test code, COPY can't take parameters > > in a PREPARE, which feature would make it even more useful. > > Uh, what? > > regression=# prepare foo as copy c from

Re: [HACKERS] Allow COPY to use parameters

2016-05-24 Thread Tom Lane
David Fetter writes: > Per discussion on IRC and some test code, COPY can't take parameters > in a PREPARE, which feature would make it even more useful. Uh, what? regression=# prepare foo as copy c from stdin; ERROR: syntax error at or near "copy" LINE 1: prepare foo as copy