Re: psql's \copy incompatible with :variables - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: psql's \copy incompatible with :variables
Date
Msg-id 201110140139.p9E1dHN00659@momjian.us
Whole thread Raw
In response to psql's \copy incompatible with :variables  (Josh Berkus <josh@agliodbs.com>)
Responses Re: psql's \copy incompatible with :variables  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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. +

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Re: BUG #6050: Dump and restore of view after a schema change: can't restore the view
Next
From: Tom Lane
Date:
Subject: Re: psql's \copy incompatible with :variables