Re: psql command line variables are unknown when -c SQL statement are executed
| От | Peter Eisentraut |
|---|---|
| Тема | Re: psql command line variables are unknown when -c SQL statement are executed |
| Дата | |
| Msg-id | 1258559230.3497.48.camel@fsopti579.F-Secure.com обсуждение исходный текст |
| Ответ на | Re: psql command line variables are unknown when -c SQL statement are executed (Pavel Stehule <pavel.stehule@gmail.com>) |
| Ответы |
Re: psql command line variables are unknown when -c SQL
statement are executed
|
| Список | pgsql-bugs |
On mån, 2009-11-16 at 12:28 +0100, Pavel Stehule wrote:
> 2009/11/16 Peter Eisentraut <peter_e@gmx.net>:
> > On mån, 2009-11-16 at 10:19 +0100, Pavel Stehule wrote:
> >> wrong:
> >>
> >> pavel@nemesis ~]$ psql postgres -v x=10 -c "select :x"
> >> ERROR: syntax error at or near ":"
> >> LINE 1: select :x
> >> ^
> >
> > This is documented in the psql man page.
>
> I don't see it, Peter?
-c command
--command command
Specifies that psql is to execute one command string,
command, and then exit. This is useful in shell scripts.
command must be either a command string that is
completely parsable by the server (i.e., it contains no psql specific
features), or a single backslash command. Thus you cannot
mix SQL and psql meta-commands with this option.
> Is it some reason for it? I don't understand, why this order is correct:
>
> execute statement
> process external variables
> finish
Well, -c works a bit different so that it is possible at all to send a
command to the server without any psql processing in the way. It's a
poor excuse, from a user's point of view, but that's historically why
it's been kept that way.
В списке pgsql-bugs по дате отправления: