Re: psql \set vs \copy - bug or expected behaviour?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \set vs \copy - bug or expected behaviour?
Date: 2011-10-21 21:31:41
Message-ID: CA+TgmoZeatJNLCxD-7P=NC2M-hCZZv5JPZjbpBVTvPuo9QgvKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 21, 2011 at 7:24 AM, Richard Huxton <dev(at)archonet(dot)com> wrote:
> It looks like \copy is just passing the text of the query unadjusted to
> "COPY". I get a syntax error on ":x" with the \copy below on both 9.0 and
> 9.1
>
> === test script ===
> \set x '''HELLO'''
> -- Works
> \echo :x
> -- Works
> \o '/tmp/test1.txt'
> COPY (SELECT :x) TO STDOUT;
> -- Doesn't work
> \copy (SELECT :x) TO '/tmp/test2.txt'
> === end script ===

I'm not sure whether that's a bug per se, but I can see where a
behavior change might be an improvement.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-10-21 21:35:31 Re: psql command for bytea output
Previous Message Andrew Dunstan 2011-10-21 21:21:47 Re: psql command for bytea output