Skip to content

Commit 677fde0

Browse files
committed
Minor robustness improvements for isolationtester.
Notice and complain about PQcancel() failures. Also, don't dump core if an error PGresult doesn't contain severity and message subfields, as it might not if it was generated by libpq itself. (We have a longstanding TODO item to improve that, but in the meantime isolationtester had better cope.) I tripped across the latter item while investigating a trouble report on buildfarm member spoonbill. As for the former, there's no evidence that PQcancel failure is actually involved in spoonbill's problem, but it still seems like a bad idea to ignore an error return code.
1 parent 114fca5 commit 677fde0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/test/isolation/isolationtester.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,22 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
311311
break;
312312

313313
case PGRES_FATAL_ERROR:
314-
/* Detail may contain xid values, so just show primary. */
315-
printf("%s: %s\n", PQresultErrorField(res, PG_DIAG_SEVERITY),
316-
PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY));
314+
/*
315+
* Detail may contain XID values, so we want to just show
316+
* primary. Beware however that libpq-generated error results
317+
* may not contain subfields, only an old-style message.
318+
*/
319+
{
320+
const char *sev = PQresultErrorField(res,
321+
PG_DIAG_SEVERITY);
322+
const char *msg = PQresultErrorField(res,
323+
PG_DIAG_MESSAGE_PRIMARY);
324+
325+
if (sev && msg)
326+
printf("%s: %s\n", sev, msg);
327+
else
328+
printf("%s", PQresultErrorMessage(res));
329+
}
317330
break;
318331

319332
default:

0 commit comments

Comments
 (0)