Skip to content

Commit 32a85ee

Browse files
committed
Don't fail on libpq-generated error reports in pg_amcheck.
An error PGresult generated by libpq itself, such as a report of connection loss, won't have broken-down error fields. should_processing_continue() blithely assumed that PG_DIAG_SEVERITY_NONLOCALIZED would always be present, and would dump core if it wasn't. Per grepping to see if 6d157e7's mistake was repeated elsewhere.
1 parent a5dbca4 commit 32a85ee

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/bin/pg_amcheck/pg_amcheck.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,8 @@ should_processing_continue(PGresult *res)
958958
/* This is expected but requires closer scrutiny */
959959
case PGRES_FATAL_ERROR:
960960
severity = PQresultErrorField(res, PG_DIAG_SEVERITY_NONLOCALIZED);
961+
if (severity == NULL)
962+
return false; /* libpq failure, probably lost connection */
961963
if (strcmp(severity, "FATAL") == 0)
962964
return false;
963965
if (strcmp(severity, "PANIC") == 0)

0 commit comments

Comments
 (0)