From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Merlin Moncure <mmoncure(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Allow COPY to use parameters |
Date: | 2016-05-27 14:17:20 |
Message-ID: | CAKFQuwYu97aOvpunL4+BKrYzWOGoUFriHdBnv97djt5-Ar_28Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, May 27, 2016 at 6:02 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> 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 %I TO %L', 'testtable', 'testfile.txt');
<(conceptually similar to: EXECUTE format('COPY %I TO %L', 'testtable',
'testfile.txt')>
This doesn't solve the knowledge problem but at least provides an
idiomatic way to execute dynamic SQL without pl/pgsql and without forcing
the client library to take responsibility for proper data massaging in
order to eliminate sql injection.
As an extension making:
PREPARE name STRING('COPY %I TO %L', ?, ?);
EXECUTE name STRING USING ('testtable', 'testfile.txt');
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2016-05-27 14:58:27 | Re: [HACKERS] Re: pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold < |
Previous Message | Tom Lane | 2016-05-27 13:53:56 | Re: COMMENT ON, psql and access methods |