Re: Parser abort ignoring following commands

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Parser abort ignoring following commands
Date: 2001-05-26 15:12:31
Message-ID: 22487.990889951@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-05-26 15:31:28 Re: Parser abort ignoring following commands
Previous Message Peter Eisentraut 2001-05-26 14:23:13 Parser abort ignoring following commands