pgsql: Fix libpq state machine in pipeline mode

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix libpq state machine in pipeline mode
Date: 2021-06-29 19:06:30
Message-ID: E1lyJ42-0001gC-7v@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix libpq state machine in pipeline mode

The original coding required that PQpipelineSync had been called before
the first call to PQgetResult, and failure to do that would result in an
unexpected NULL result being returned. Fix by setting the right state
when a query is sent, rather than leaving it unchanged and having
PQpipelineSync apply the necessary state change.

A new test case to verify the behavior is added, which relies on the new
PQsendFlushRequest() function added by commit a7192326c74d.

Backpatch to 14, where pipeline mode was added.

Reported-by: Boris Kolpackov <boris(at)codesynthesis(dot)com>
Author: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Discussion: https://postgr.es/m/boris.20210616110321@codesynthesis.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b71a9cb31e46b08aeac35a4355936165648b3c49

Modified Files
--------------
src/interfaces/libpq/fe-exec.c | 19 ++---
src/test/modules/libpq_pipeline/libpq_pipeline.c | 90 +++++++++++++++++++++
.../modules/libpq_pipeline/t/001_libpq_pipeline.pl | 2 +-
.../modules/libpq_pipeline/traces/nosync.trace | 92 ++++++++++++++++++++++
4 files changed, 188 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2021-06-29 20:19:13 pgsql: Fixes for multirange selectivity estimation
Previous Message Alvaro Herrera 2021-06-29 18:38:38 pgsql: Add PQsendFlushRequest to libpq