psql: Fix assertion failures with pipeline mode
authorMichael Paquier <[email protected]>
Thu, 24 Apr 2025 03:22:53 +0000 (12:22 +0900)
committerMichael Paquier <[email protected]>
Thu, 24 Apr 2025 03:22:53 +0000 (12:22 +0900)
commit3631612eae9c2def99151c4f36b1b3771f53cba7
treeab808935d3d4c4e621760c447bbcfd28acf2d77c
parent923ae50cf55986efb5f3feb0f15253a69a5e224c
psql: Fix assertion failures with pipeline mode

A correct cocktail of COPY FROM, SELECT and/or DML queries and
\syncpipeline was able to break the logic in charge of discarding
results of a pipeline, done in discardAbortedPipelineResults().  Such
sequence make the backend generate a FATAL, due to a protocol
synchronization loss.

This problem comes down to the fact that we did not consider the case of
libpq returning a PGRES_FATAL_ERROR when discarding the results of an
aborted pipeline.  The discarding code is changed so as this result
status is handled as a special case, with the caller of
discardAbortedPipelineResults() being responsible for consuming the
result.

A couple of tests are added to cover the problems reported, bringing an
interesting gain in coverage as there were no tests in the tree covering
the case of protocol synchronization loss.

Issue introduced by 41625ab8ea3d.

Reported-by: Alexander Kozhemyakin <[email protected]>
Author: Anthonin Bonnefoy <[email protected]>
Co-authored-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/ebf6ce77-b180-4d6b-8eab-71f641499ddf@postgrespro.ru
src/bin/psql/common.c
src/bin/psql/t/001_basic.pl