psql --command option ignores --variable's

From: Tim Kane <tim(dot)kane(at)gmail(dot)com>
To: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: psql --command option ignores --variable's
Date: 2013-09-02 14:54:43
Message-ID: CE4A6543.1E278%tim.kane@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

It seems the behaviour of the ‹command / -c option is such that it will
ignore any variables set on the command-line.

:~ psql --variable TESTVAR='123' --command 'select :TESTVAR;'
ERROR: syntax error at or near ":"
LINE 1: select :TESTVAR;
^

:~$ psql --variable TESTVAR='123'
psql (9.1.9)
Type "help" for help.

timk=> select :TESTVAR;
?column?
----------
123
(1 row)

Obviously, there are ways around this, but is this expected behaviour?

Tim

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-09-02 15:00:50 Re: psql --command option ignores --variable's
Previous Message DT 2013-09-02 13:35:46 ALTER TABLE transaction isolation problem