diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 445d4ae72c2..fd70196a160 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3086,6 +3086,20 @@ readCommandResponse(CState *st, MetaCommand meta, char *varprefix) PQresultErrorMessage(res)); break; + case PGRES_COPY_IN: + case PGRES_COPY_OUT: + case PGRES_COPY_BOTH: + pg_log_error("COPY is not supported in pgbench, aborting"); + + /* + * We need to exit the copy state. Otherwise, PQgetResult() + * will always return an empty PGresult as an effect of + * getCopyResult(), leading to an infinite loop in the error + * cleanup done below. + */ + PQendcopy(st->con); + goto error; + default: /* anything else is unexpected */ pg_log_error("client %d script %d aborted in command %d query %d: %s", diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index fbd45c766cc..52bcf8fec14 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -1315,6 +1315,17 @@ $node->pgbench( check_pgbench_logs($bdir, '001_pgbench_log_3', 1, 10, 10, qr{^0 \d{1,2} \d+ \d \d+ \d+$}); +# Test copy in pgbench +$node->pgbench( + '-t 10', + 2, + [], + [ qr{COPY is not supported in pgbench, aborting} ], + 'Test copy in script', + { + '001_copy' => q{ COPY pgbench_accounts FROM stdin } + }); + # done $node->safe_psql('postgres', 'DROP TABLESPACE regress_pgbench_tap_1_ts'); $node->stop;