Re: psql --command option ignores --variable's - Mailing list pgsql-general

From Tom Lane
Subject Re: psql --command option ignores --variable's
Date
Msg-id 15685.1378134050@sss.pgh.pa.us
Whole thread Raw
In response to psql --command option ignores --variable's  (Tim Kane <tim.kane@gmail.com>)
List pgsql-general
Tim Kane <tim.kane@gmail.com> writes:
> It seems the behaviour of the --command / -c option is such that it will
> ignore any variables set on the command-line.

If memory serves, the string given to -c is just fired off to the server
as-is.  It's not broken into separate commands, and I think we don't do
substitutions on it either, which would explain this result.

There have been some discussions of trying to make it work more like
processing of normal input would do, but people are too afraid of breaking
existing applications by changing the semantics.

I'd suggest something like

echo 'select :TESTVAR;' | psql --variable TESTVAR='123'

            regards, tom lane


pgsql-general by date:

Previous
From: Tim Kane
Date:
Subject: psql --command option ignores --variable's
Next
From: Adrian Klaver
Date:
Subject: Re: psql --command option ignores --variable's