Re: BUG #9198: psql -c 'SET; ...' not working - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #9198: psql -c 'SET; ...' not working
Date
Msg-id 5270.1392309900@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #9198: psql -c 'SET; ...' not working  (Christoph Berg <christoph.berg@credativ.de>)
List pgsql-bugs
Christoph Berg <christoph.berg@credativ.de> writes:
> ... I'd propose something like this doc update:

>          <application>psql</application>'s standard input.  Also, only
> !        the result of the last SQL command is returned.  <command>SET</>
> !        commands that modify statement behavior will be ineffective because
> !        they are part of the already running statement.  Most notably,
> !        <literal>psql -c 'SET statement_timeout = 0; SELECT ...'</literal>
> !        will not work as expected.  (Use <literal>echo '...' | psql</literal>
> !        as above instead.)

This is incorrect though; most variables you can set via SET actually
will work unsurprisingly in this context.  statement_timeout is different
because its value is only inspected at the start of a statement (where
"statement" is defined as "query string received from the client").

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #9202: C Functions crash database too easily
Next
From: Tom Lane
Date:
Subject: Re: BUG #9198: psql -c 'SET; ...' not working