Re: Trouble with FETCH_COUNT and combined queries in psql

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, 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 17:30:38
Message-ID: alpine.DEB.2.21.1904231920100.3407@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Tom,

> 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.

Although I do not claim that my implementation was very good, I must admit
that I'm not sure why there would be an issue if the lexer API is made
aware of the position of embedded \;, if this information is useful for a
feature.

> 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.

I do not understand: the lexer knows where all queries ends, it just does
not say so currently?

> If that ends up in behavior you don't like, ISTM that's your fault not
> psql's.

ISTM that the user is not responsible for non orthogonal features provided
by psql or pgbench (we implemented this great feature, but not in all
cases).

> 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.

Possibly, but, without having looked precisely at the implementation, I'm
afraid that it would result in more messages. Maybe I'm wrong. Also, I'm
ensure how returning new pg results for each row (as I understood the mode
from the doc) would interact with \;, i.e. how to know whether the current
query has changed. Maybe all this has simple answer.

> 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?

I've sent a patch to replace the existing PQexec by PQsendQuery for a not
directly related feature, see https://commitfest.postgresql.org/23/2096/

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-04-23 17:31:25 Re: Unhappy about API changes in the no-fsm-for-small-rels patch
Previous Message Andres Freund 2019-04-23 17:28:57 Re: Unhappy about API changes in the no-fsm-for-small-rels patch