Re: Trouble with FETCH_COUNT and combined queries in psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
Cc: "Fabien COELHO" <coelho(at)cri(dot)ensmp(dot)fr>, "PostgreSQL Developers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Trouble with FETCH_COUNT and combined queries in psql
Date: 2019-04-23 13:56:39
Message-ID: 28929.1556027799@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Daniel Verite" <daniel(at)manitou-mail(dot)org> writes:
> Fabien COELHO wrote:
>> I added some stuff to extract embedded "\;" for pgbench "\cset", which has
>> been removed though, but it is easy to add back a detection of "\;", and
>> also to detect select. If the position of the last select is known, the
>> cursor can be declared in the right place, which would also solve the
>> problem.

> Thanks, I'll extract the necessary bits from your patch.
> I don't plan to go as far as injecting a DECLARE CURSOR inside
> the query, but rather just forbid the use of the cursor in
> the combined-queries case.

Keep in mind that a large part of the reason why the \cset patch got
bounced was exactly that its detection of \; was impossibly ugly
and broken. Don't expect another patch using the same logic to
get looked on more favorably.

I'm not really sure how far we should go to try to make this case "work".
To my mind, use of \; in this way represents an intentional defeat of
psql's algorithms for deciding where end-of-query is. If that ends up
in behavior you don't like, ISTM that's your fault not psql's.

Having said that, I did like the idea of maybe going over to
PQsetSingleRowMode instead of using an explicit cursor. That
would represent a net decrease of cruftiness here, instead of
layering more cruft on top of what's already a mighty ugly hack.

However ... that'd require using PQsendQuery, which means that the
case at hand with \; would result in a server error rather than
surprising client-side behavior. Is that an acceptable outcome?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2019-04-23 14:22:46 Re: finding changed blocks using WAL scanning
Previous Message Anastasia Lubennikova 2019-04-23 11:08:12 Re: block-level incremental backup