Re: Allow COPY to use parameters

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, 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 17:53:32
Message-ID: CAHyXU0wcWkyLvZUXYCe5aYkj=Fu-=Y0iaE4hgZ-et=Ycf=n2cQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 27, 2016 at 11:36 AM, Corey Huinker <corey(dot)huinker(at)gmail(dot)com> 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 need a function with special
behaviors, let's make a function with special behaviors, hopefully not
called 'string()'...for example, format_safe(). Furthermore, we
already have functions to deal with safe string injection,
quote_ident/literal, and I'm not sure it's a good divert users away
from using those functions.

Either way, I don't think we should mix improvements to EXECUTE with
this patch, which I think addresses the problems I have with COPY
nicely (at least as it pertains to my pain points)...so +1 to Andrew's
proposal. I would rarely have to use dynamic SQL for COPY with that
in place. Other utility commands (off the top of my head) tend not to
be a problem for me (NOTIFY would be, but pg_notify handles that
case).

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-05-27 18:58:53 Hard to maintain duplication in contain_volatile_functions_not_nextval_walker
Previous Message Tom Lane 2016-05-27 17:20:20 Re: Parallel pg_dump's error reporting doesn't work worth squat