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

From: Richard Huxton <dev(at)archonet(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: psql \set vs \copy - bug or expected behaviour?
Date: 2011-10-21 11:24:52
Message-ID: 4EA15684.8040508@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 ===

--
Richard Huxton
Archonet Ltd

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-10-21 13:02:14 Re: [v9.2] DROP statement reworks
Previous Message Kohei KaiGai 2011-10-21 09:08:10 Re: [v9.2] DROP statement reworks