Peter Eisentraut <[EMAIL PROTECTED]> writes:
> psql -c 'select * from pg_class; select * from no_such_table;'
> Shouldn't this at least give me the result of the first select before
> aborting the second?

The behavior you are complaining of is not the backend's fault.
The reason it acts that way is that psql is feeding the entire -c 
string to the backend as one query, and not paying any attention
to the possibility that multiple query results might be available
from the string.

It's a little bit inconsistent that psql feeds a -c string to the
backend as one query, whereas the same input line fed to it from a file
or terminal would be split into per-statement queries.  However,
I'd vote against changing it, since (a) you might break existing
applications that depend on this behavior, and (b) if you do that then
there will be no way to exercise multi-statement query strings from
psql.

It might possibly make sense for psql to stop using PQexec() but
instead use PQsendQuery() and PQgetResult(), so that it could
handle multiple results coming back from a single query string.
If you did that then the first example would work the way you want.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to