Re: PQsendQuery+PQgetResult+PQsetSingleRowMode limitations and support - Mailing list pgsql-hackers

From Shulgin, Oleksandr
Subject Re: PQsendQuery+PQgetResult+PQsetSingleRowMode limitations and support
Date
Msg-id CACACo5T0=gCj1Sjwn1P22PLzjVoVp-yk_O3RLgXzzE3ss7kS-Q@mail.gmail.com
Whole thread Raw
In response to Re: PQsendQuery+PQgetResult+PQsetSingleRowMode limitations and support  ("Karl O. Pinc" <kop@meme.com>)
Responses Re: PQsendQuery+PQgetResult+PQsetSingleRowMode limitations and support  ("Karl O. Pinc" <kop@meme.com>)
List pgsql-hackers
On Mon, Apr 11, 2016 at 7:15 PM, Karl O. Pinc <kop@meme.com> wrote:
>
> Should I submit a regression test or something to ensure
> that this usage is officially supported?  (A grep for
> PQsetSingleRowMode in src/test/ finds no hits.)
> Can I assume because it's documented it'll continue to work?

Pretty much.

> > Not sure about the part
> > where you call PQsetSingleRowMode() again after seeing
> > PGRES_TUPLES_OK: doesn't look to me like you need or want to do
> > that.  You should only call it immediately after PQsendQuery().
>
> You're quite right.  All but the first PQsetSingleRowMode()
> calls fail.
>
> This seems unfortunate.   What if I submit several SQL statements
> with one PQsendQuery() call and I only want some of the statements
> executed in single row mode?

I would assume that if you know for which of the statements you want the single row mode, then you as well can submit them as separate PQsendQuery() calls.
 
> I'm not sure what the use case
> would be but it seems sad that PQsetSingleRowMode() is per
> libpq call and not per sql statement.

It is per query, where query == "argument to PQsendQuery()" :-)

> When the docs here say "query" what they really mean is "set of
> statements submitted in a single libpq call".

Which are the same things more or less, I'm not sure that the extended explanation you suggest makes it less confusing.

--
Regards,
Alex

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [BUGS] Breakage with VACUUM ANALYSE + partitions
Next
From: Kevin Grittner
Date:
Subject: Re: pgsql: Add the "snapshot too old" feature