Re: psql \set vs \copy - bug or expected behaviour? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: psql \set vs \copy - bug or expected behaviour?
Date
Msg-id 20120825231247.GF10814@momjian.us
Whole thread Raw
In response to Re: psql \set vs \copy - bug or expected behaviour?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
On Fri, Aug 17, 2012 at 02:01:25PM -0400, Bruce Momjian wrote:
> 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.

Patch withdrawn.  Seems documentation was already in place --- I
clarified \! limitations match \copy.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +



pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: Re: PATCH: pgbench - random sampling of transaction written into log
Next
From: Tomas Vondra
Date:
Subject: Re: PATCH: pgbench - random sampling of transaction written into log