Re: psql command line variables are unknown when -c SQL statement are executed

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql command line variables are unknown when -c SQL statement are executed
Date: 2009-11-18 16:03:25
Message-ID: 162867790911180803o7120387cje6729257a54db198@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2009/11/18 Peter Eisentraut <peter_e(at)gmx(dot)net>:
> On mån, 2009-11-16 at 12:28 +0100, Pavel Stehule wrote:
>> 2009/11/16 Peter Eisentraut <peter_e(at)gmx(dot)net>:
>> > On mån, 2009-11-16 at 10:19 +0100, Pavel Stehule wrote:
>> >> wrong:
>> >>
>> >> pavel(at)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.

ok - thank you. I could to live with it.

Regards
Pavel Stehule
>
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-11-18 17:04:44 Re: BUG #5151: autovacuum process segfaults when max_fsm_pages are too low
Previous Message Peter Eisentraut 2009-11-18 15:47:10 Re: psql command line variables are unknown when -c SQL statement are executed