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

Commit19d4f9f

Browse files
committed
pgbench: Fix error reporting in readCommandResponse().
pgbench uses readCommandResponse() to process server responses.When readCommandResponse() encounters an error during a call toPQgetResult() to fetch the current result, it attempts to report itwith an additional error message from PQerrorMessage(). However,previously, this extra error message could be lost or become incorrect.The cause was that after fetching the current result (and detectingan error), readCommandResponse() called PQgetResult() again topeek at the next result. This second call could overwrite the libpqconnection's error message before the original error was reported,causing the error message retrieved from PQerrorMessage() to belost or overwritten.This commit fixes the issue by updating readCommandResponse()to use PQresultErrorMessage() instead of PQerrorMessage()to retrieve the error message generated when the PQgetResult()for the current result causes an error, ensuring the correct messageis reported.Backpatch to all supported versions.Author: Yugo Nagata <nagata@sraoss.co.jp>Reviewed-by: Chao Li <lic@highgo.com>Reviewed-by: Fujii Masao <masao.fujii@gmail.com>Discussion:https://postgr.es/m/20250925110940.ebacc31725758ec47d5432c6@sraoss.co.jpBackpatch-through: 13
1 parent91df046 commit19d4f9f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/bin/pgbench/pgbench.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,7 +3356,7 @@ readCommandResponse(CState *st, MetaCommand meta, char *varprefix)
33563356
st->num_syncs--;
33573357
if (st->num_syncs==0&&PQexitPipelineMode(st->con)!=1)
33583358
pg_log_error("client %d failed to exit pipeline mode: %s",st->id,
3359-
PQerrorMessage(st->con));
3359+
PQresultErrorMessage(res));
33603360
break;
33613361

33623362
casePGRES_NONFATAL_ERROR:
@@ -3366,7 +3366,7 @@ readCommandResponse(CState *st, MetaCommand meta, char *varprefix)
33663366
if (canRetryError(st->estatus))
33673367
{
33683368
if (verbose_errors)
3369-
commandError(st,PQerrorMessage(st->con));
3369+
commandError(st,PQresultErrorMessage(res));
33703370
gotoerror;
33713371
}
33723372
/* fall through */
@@ -3375,7 +3375,7 @@ readCommandResponse(CState *st, MetaCommand meta, char *varprefix)
33753375
/* anything else is unexpected */
33763376
pg_log_error("client %d script %d aborted in command %d query %d: %s",
33773377
st->id,st->use_file,st->command,qrynum,
3378-
PQerrorMessage(st->con));
3378+
PQresultErrorMessage(res));
33793379
gotoerror;
33803380
}
33813381

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp