Fix libpq state machine in pipeline mode
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 29 Jun 2021 19:01:29 +0000 (15:01 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 29 Jun 2021 19:01:29 +0000 (15:01 -0400)
commitb71a9cb31e46b08aeac35a4355936165648b3c49
treebb28756047b99b421650db9a7cb07571a72f3c17
parenta7192326c74da417d024a189da4d33c1bf1b40b6
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@codesynthesis.com>
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/boris.20210616110321@codesynthesis.com
src/interfaces/libpq/fe-exec.c
src/test/modules/libpq_pipeline/libpq_pipeline.c
src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
src/test/modules/libpq_pipeline/traces/nosync.trace [new file with mode: 0644]