Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit902c088

Browse files
committed
pgbench: Fail cleanly when finding a COPY result state
Currently, pgbench aborts when a COPY response is received inreadCommandResponse(). However, as PQgetResult() returns an emptyresult when there is no asynchronous result, through getCopyResult(),the logic done at the end of readCommandResponse() for the error pathleads to an infinite loop.This commit forcefully exits the COPY state with PQendcopy() beforemoving to the error handler when fiding a COPY state, avoiding theinfinite loop. The COPY protocol is not supported by pgbench anyway, asan error is assumed in this case, so giving up is better than having thetool be stuck forever. pgbench was interruptible in this state.A TAP test is added to check that an error happens if trying to useCOPY.Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>Discussion:https://postgr.es/m/CAO6_XqpHyF2m73ifV5a=5jhXxH2chk=XrgefY+eWWPe2Eft3=A@mail.gmail.comBackpatch-through: 13
1 parent25a30bb commit902c088

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎src/bin/pgbench/pgbench.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,20 @@ readCommandResponse(CState *st, MetaCommand meta, char *varprefix)
33593359
PQresultErrorMessage(res));
33603360
break;
33613361

3362+
casePGRES_COPY_IN:
3363+
casePGRES_COPY_OUT:
3364+
casePGRES_COPY_BOTH:
3365+
pg_log_error("COPY is not supported in pgbench, aborting");
3366+
3367+
/*
3368+
* We need to exit the copy state. Otherwise, PQgetResult()
3369+
* will always return an empty PGresult as an effect of
3370+
* getCopyResult(), leading to an infinite loop in the error
3371+
* cleanup done below.
3372+
*/
3373+
PQendcopy(st->con);
3374+
gotoerror;
3375+
33623376
casePGRES_NONFATAL_ERROR:
33633377
casePGRES_FATAL_ERROR:
33643378
st->estatus=getSQLErrorStatus(PQresultErrorField(res,

‎src/bin/pgbench/t/001_pgbench_with_server.pl‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,17 @@ BEGIN
18101810
}
18111811
});
18121812

1813+
# Test copy in pgbench
1814+
$node->pgbench(
1815+
'-t 10',
1816+
2,
1817+
[],
1818+
[qr{COPY is not supported in pgbench, aborting} ],
1819+
'Test copy in script',
1820+
{
1821+
'001_copy'=>q{ COPY pgbench_accounts FROM stdin}
1822+
});
1823+
18131824
# Clean up
18141825
$node->safe_psql('postgres','DROP TABLE counter;');
18151826

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp