Re: PQsendQuery+PQgetResult+PQsetSingleRowMode limitations and support

From: "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PQsendQuery+PQgetResult+PQsetSingleRowMode limitations and support
Date: 2016-04-11 17:25:20
Message-ID: CACACo5T0=gCj1Sjwn1P22PLzjVoVp-yk_O3RLgXzzE3ss7kS-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 11, 2016 at 7:15 PM, Karl O. Pinc <kop(at)meme(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2016-04-11 17:31:09 Re: pgsql: Add the "snapshot too old" feature
Previous Message Andres Freund 2016-04-11 17:17:42 Re: [HACKERS] Breakage with VACUUM ANALYSE + partitions