| From: | Bruce Momjian <bruce(at)momjian(dot)us> |
|---|---|
| To: | Richard Huxton <dev(at)archonet(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(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 18:01:25 |
| Message-ID: | 20120817180125.GC3371@momjian.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Aug 17, 2012 at 06:55:14PM +0100, Richard Huxton wrote:
> >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 :-)
Good analysis. Basically we can't hope to fully understand COPY or
shell quoting syntax well enough to properly replace only unquoted psql
variable references.
Therefore, unless I hear otherwise, I will just document the limitation
and withdraw the patch.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2012-08-17 18:58:22 | NOT NULL constraints in foreign tables |
| Previous Message | Richard Huxton | 2012-08-17 17:55:14 | Re: psql \set vs \copy - bug or expected behaviour? |