pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedpsql's \copy incompatible with :variables
7+ messages / 4 participants
[nested] [flat]
* psql's \copy incompatible with :variables
@ 2011-06-07 23:18 The Fuzzy Chef <fuzzy@fuzzychef.org>
0 siblings, 0 replies; 7+ messages in thread
From: The Fuzzy Chef @ 2011-06-07 23:18 UTC (permalink / raw)
To: pgsql-bugs
Summary: \copy interprets psql's :variables as literal strings
Tested On: 8.4.4, 9.0.4
Severity: Annoyance
Steps to Reproduce:
psql
\set filename 'test.csv'
\copy pg_class to :filename with csv
\q
ls
:filename
Note that psql variables work perfectly fine with COPY. It's just \copy
which seems to be misbehaving.
--Josh
^ permalink raw reply [nested|flat] 7+ messages in thread
* psql's \copy incompatible with :variables
@ 2011-06-08 00:22 Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 7+ messages in thread
From: Josh Berkus @ 2011-06-08 00:22 UTC (permalink / raw)
To: pgsql-bugs
Summary: \copy interprets psql's :variables as literal strings
Tested On: 8.4.4, 9.0.4
Severity: Annoyance
Steps to Reproduce:
psql
\set filename 'test.csv'
\copy pg_class to :filename with csv
\q
ls
:filename
Note that psql variables work perfectly fine with COPY. It's just \copy
which seems to be misbehaving.
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: psql's \copy incompatible with :variables
@ 2011-10-14 01:39 Bruce Momjian <bruce@momjian.us>
parent: Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 7+ messages in thread
From: Bruce Momjian @ 2011-10-14 01:39 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-bugs
Josh Berkus wrote:
> Summary: \copy interprets psql's :variables as literal strings
>
> Tested On: 8.4.4, 9.0.4
>
> Severity: Annoyance
>
> Steps to Reproduce:
>
> psql
>
> \set filename 'test.csv'
>
> \copy pg_class to :filename with csv
>
> \q
>
> ls
>
> :filename
>
> Note that psql variables work perfectly fine with COPY. It's just \copy
> which seems to be misbehaving.
The problem is that none of the backslash commands interpret variables:
test=> \set x '''y'''
test=> select :x;
?column?
----------
y
(1 row)
test=> \d :y
Did not find any relation named ":y".
Should they?
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: psql's \copy incompatible with :variables
@ 2011-10-14 02:10 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 2 replies; 7+ messages in thread
From: Tom Lane @ 2011-10-14 02:10 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Josh Berkus <josh@agliodbs.com>; pgsql-bugs
Bruce Momjian <bruce@momjian.us> writes:
> Josh Berkus wrote:
>> Note that psql variables work perfectly fine with COPY. It's just \copy
>> which seems to be misbehaving.
> The problem is that none of the backslash commands interpret variables:
Nonsense.
regression=# \set foo bar
regression=# \d foo
Did not find any relation named "foo".
regression=# \d :foo
Did not find any relation named "bar".
\copy is different because it uses OT_WHOLE_LINE mode to read the
argument, and that doesn't expand :variable references. I'd be a bit
leery of changing that.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: psql's \copy incompatible with :variables
@ 2011-10-14 02:13 Bruce Momjian <bruce@momjian.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 7+ messages in thread
From: Bruce Momjian @ 2011-10-14 02:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Josh Berkus <josh@agliodbs.com>; pgsql-bugs
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Josh Berkus wrote:
> >> Note that psql variables work perfectly fine with COPY. It's just \copy
> >> which seems to be misbehaving.
>
> > The problem is that none of the backslash commands interpret variables:
>
> Nonsense.
>
> regression=# \set foo bar
> regression=# \d foo
> Did not find any relation named "foo".
> regression=# \d :foo
> Did not find any relation named "bar".
>
> \copy is different because it uses OT_WHOLE_LINE mode to read the
> argument, and that doesn't expand :variable references. I'd be a bit
> leery of changing that.
Oh, I see. My tests were wrong. Thanks.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: psql's \copy incompatible with :variables
@ 2011-10-14 17:15 Josh Berkus <josh@agliodbs.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 7+ messages in thread
From: Josh Berkus @ 2011-10-14 17:15 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bruce Momjian <bruce@momjian.us>; pgsql-bugs
> \copy is different because it uses OT_WHOLE_LINE mode to read the
> argument, and that doesn't expand :variable references. I'd be a bit
> leery of changing that.
So, doc warning then?
--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: psql's \copy incompatible with :variables
@ 2011-10-14 18:54 Bruce Momjian <bruce@momjian.us>
parent: Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 7+ messages in thread
From: Bruce Momjian @ 2011-10-14 18:54 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
Josh Berkus wrote:
>
> > \copy is different because it uses OT_WHOLE_LINE mode to read the
> > argument, and that doesn't expand :variable references. I'd be a bit
> > leery of changing that.
>
> So, doc warning then?
I don't think enough people have hit this problem to warrant that.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2011-10-14 18:54 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-06-07 23:18 psql's \copy incompatible with :variables The Fuzzy Chef <fuzzy@fuzzychef.org>
2011-06-08 00:22 psql's \copy incompatible with :variables Josh Berkus <josh@agliodbs.com>
2011-10-14 01:39 ` Bruce Momjian <bruce@momjian.us>
2011-10-14 02:10 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-10-14 02:13 ` Bruce Momjian <bruce@momjian.us>
2011-10-14 17:15 ` Josh Berkus <josh@agliodbs.com>
2011-10-14 18:54 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox