]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pgbench: Fail cleanly when finding a COPY result state
authorMichael Paquier <michael@paquier.xyz>
Fri, 3 Oct 2025 05:03:55 +0000 (14:03 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 3 Oct 2025 05:03:55 +0000 (14:03 +0900)
commit902c08887aa183100b161ef48f1a2434af079213
tree599076d11917a02a2cda9da426207710f9f50a9f
parent25a30bbd4235a49c854036c84fe90f2bc5a87652
pgbench: Fail cleanly when finding a COPY result state

Currently, pgbench aborts when a COPY response is received in
readCommandResponse().  However, as PQgetResult() returns an empty
result when there is no asynchronous result, through getCopyResult(),
the logic done at the end of readCommandResponse() for the error path
leads to an infinite loop.

This commit forcefully exits the COPY state with PQendcopy() before
moving to the error handler when fiding a COPY state, avoiding the
infinite loop.  The COPY protocol is not supported by pgbench anyway, as
an error is assumed in this case, so giving up is better than having the
tool be stuck forever.  pgbench was interruptible in this state.

A TAP test is added to check that an error happens if trying to use
COPY.

Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/CAO6_XqpHyF2m73ifV5a=5jhXxH2chk=XrgefY+eWWPe2Eft3=A@mail.gmail.com
Backpatch-through: 13
src/bin/pgbench/pgbench.c
src/bin/pgbench/t/001_pgbench_with_server.pl