Re: BUG #5048: psql: \g doesn't redirect COPY TO STDOUT, but redirects next query

Lists: pgsql-bugs
From: "Andrew Deryabin" <andrew(at)deryabin(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5048: psql: \g doesn't redirect COPY TO STDOUT, but redirects next query
Date: 2009-09-10 14:04:16
Message-ID: 200909101404.n8AE4GhN053742@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5048
Logged by: Andrew Deryabin
Email address: andrew(at)deryabin(dot)com
PostgreSQL version: 8.4
Operating system: FreeBSD
Description: psql: \g doesn't redirect COPY TO STDOUT, but redirects
next query
Details:

[pgsql(at)localhost:site]=# COPY (SELECT 1) TO STDOUT \g filename.ext
1
Time: 0.370 ms
[pgsql(at)localhost:site]=# SELECT 2;
Time: 0.290 ms
[pgsql(at)localhost:site]=# SELECT 3;
?column?
----------
3
(1 row)

Time: 0.295 ms
^Z
$ cat filename.ext
?column?
----------
2
(1 row)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrew Deryabin" <andrew(at)deryabin(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5048: psql: \g doesn't redirect COPY TO STDOUT, but redirects next query
Date: 2009-09-10 14:16:12
Message-ID: 23179.1252592172@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Andrew Deryabin" <andrew(at)deryabin(dot)com> writes:
> [pgsql(at)localhost:site]=# COPY (SELECT 1) TO STDOUT \g filename.ext

The way you're supposed to do that is with \copy.
It might be more consistent to do it as above, but I'm not sure
anyone will take the time to make it happen ...

regards, tom lane