Re: PATCH: Batch/pipelining support for libpq
Daniel Verite <daniel@manitou-mail.org>
From: "Daniel Verite" <daniel@manitou-mail.org>
To: "Vaishnavi Prabakaran" <vaishnaviprabakaran@gmail.com>
Cc: "Michael Paquier" <michael.paquier@gmail.com>,"Prabakaran, Vaishnavi"
<VaishnaviP@fast.au.fujitsu.com>,"Craig Ringer"
<craig@2ndquadrant.com>,"Haribabu Kommi"
<kommi.haribabu@gmail.com>,"Tsunakawa, Takayuki"
<tsunakawa.takay@jp.fujitsu.com>,"Dmitry Igrishin"
<dmitigr@gmail.com>,"Andres Freund" <andres@anarazel.de>,"PostgreSQL
Hackers" <pgsql-hackers@postgresql.org>,"Manuel Kniep"
<m.kniep@web.de>,"fujita.etsuro@lab.ntt.co.jp"
<fujita.etsuro@lab.ntt.co.jp>,"Iwata, Aya" <iwata.aya@jp.fujitsu.com>
Date: 2017-03-13T17:19:39Z
Lists: pgsql-hackers
Attachments
- test-singlerow-batch.c (application/octet-stream)
Vaishnavi Prabakaran wrote:
> > while (QbatchQueueProcess(conn)) {
> > r = PQsetSingleRowMode(conn);
> > if (r!=1) {
> > fprintf(stderr, "PQsetSingleRowMode() failed");
> > }
> > ..
> Thanks for investigating the problem, and could you kindly explain what
> "next iteration" you mean here? Because I don't see any problem in
> following sequence of calls - PQbatchQueueProcess(),PQsetSingleRowMode()
> , PQgetResult()
I mean the next iteration of the above while statement. Referring
to the doc, that would be the "next batch entry":
" To get the result of the first batch entry the client must call
PQbatchQueueProcess. It must then call PQgetResult and handle the
results until PQgetResult returns null (or would return null if
called). The result from the next batch entry may then be retrieved
using PQbatchQueueProcess and the cycle repeated"
Attached is a bare-bones testcase showing the problem.
As it is, it works, retrieving results for three "SELECT 1"
in the same batch. Now in order to use the single-row
fetch mode, consider adding this:
r = PQsetSingleRowMode(conn);
if (r!=1) {
fprintf(stderr, "PQsetSingleRowMode() failed for i=%d\n", i);
}
When inserted after the call to PQbatchQueueProcess,
which is what I understand you're saying works for you,
it fails for me when starting to get the results of the 2nd query
and after.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
Commits
-
Add libpq pipeline mode support to pgbench
- 9aa491abbf07 14.0 landed
-
Implement pipeline mode in libpq
- acb7e4eb6b1c 14.0 landed