From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Bruce Momjian <bruce(at)momjian(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: psql \set vs \copy - bug or expected behaviour? |
Date: | 2012-08-17 17:55:14 |
Message-ID: | 502E8582.3000707@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 17/08/12 18:38, Tom Lane wrote:
> Bruce Momjian<bruce(at)momjian(dot)us> writes:
>> On Fri, Oct 21, 2011 at 05:31:41PM -0400, Robert Haas wrote:
>>> I'm not sure whether that's a bug per se, but I can see where a
>>> behavior change might be an improvement.
>
>> I did some research on this and learned a little more about flex rules.
>
>> Turns out we can allow variable substitution in psql whole-line
>> commands, like \copy and \!, by sharing the variable expansion flex
>> rules with the code that does argument processing.
>
> Well, it'd be nice to allow substitution there ...
>
>> What we can't easily do is to allow quotes to prevent variable
>> substitution in these whole-line commands because we can't process the
>> quotes because that will remove them.
>
> ... but if there is then no way to prevent it, that's absolutely
> unacceptable.
If I'm understanding this correctly, \copy parsing just passes the query
part unaltered as part of a COPY statement back into the top-level
parser. Likewise with the \!shell stuff (but presumably to execve).
To handle variable-substitution correctly for \copy we'd need to
duplicate the full parsing for COPY. For \! we'd need something which
understood shell-syntax (for the various shells out there). Ick.
Or you'd need a separate variable-bracketing {{:x}} syntax that could
work like reverse dollar-quoting. Also Ick.
As far as we know this has only inconvenienced one person (me) badly
enough to report a maybe-bug. Thanks for trying Bruce, but I fear this
is one itch that'll go unscratched.
Rest assured I'm not about to storm off and replace all my installations
with MySQL :-)
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2012-08-17 18:01:25 | Re: psql \set vs \copy - bug or expected behaviour? |
Previous Message | Tom Lane | 2012-08-17 17:38:43 | Re: psql \set vs \copy - bug or expected behaviour? |