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

Commite084b14

Browse files
committed
Minor robustness improvements for isolationtester.
Notice and complain about PQcancel() failures. Also, don't dump core ifan error PGresult doesn't contain severity and message subfields, as itmight not if it was generated by libpq itself. (We have a longstandingTODO item to improve that, but in the meantime isolationtester had bettercope.)I tripped across the latter item while investigating a trouble report onbuildfarm member spoonbill. As for the former, there's no evidence thatPQcancel failure is actually involved in spoonbill's problem, but it stillseems like a bad idea to ignore an error return code.
1 parent73c1227 commite084b14

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
572572
{
573573
charbuf[256];
574574

575-
PQcancel(cancel,buf,sizeof(buf));
575+
if (!PQcancel(cancel,buf,sizeof(buf)))
576+
fprintf(stderr,"PQcancel failed: %s\n",buf);
576577

577578
/* Be sure to consume the error message. */
578579
while ((res=PQgetResult(conn))!=NULL)
@@ -764,14 +765,26 @@ try_complete_step(Step * step, int flags)
764765
printf("WARNING: this step had a leftover error message\n");
765766
printf("%s\n",step->errormsg);
766767
}
767-
/* Detail may contain xid values, so just show primary. */
768-
step->errormsg=malloc(5+
769-
strlen(PQresultErrorField(res,PG_DIAG_SEVERITY))+
770-
strlen(PQresultErrorField(res,
771-
PG_DIAG_MESSAGE_PRIMARY)));
772-
sprintf(step->errormsg,"%s: %s",
773-
PQresultErrorField(res,PG_DIAG_SEVERITY),
774-
PQresultErrorField(res,PG_DIAG_MESSAGE_PRIMARY));
768+
769+
/*
770+
* Detail may contain XID values, so we want to just show
771+
* primary. Beware however that libpq-generated error results
772+
* may not contain subfields, only an old-style message.
773+
*/
774+
{
775+
constchar*sev=PQresultErrorField(res,
776+
PG_DIAG_SEVERITY);
777+
constchar*msg=PQresultErrorField(res,
778+
PG_DIAG_MESSAGE_PRIMARY);
779+
780+
if (sev&&msg)
781+
{
782+
step->errormsg=malloc(5+strlen(sev)+strlen(msg));
783+
sprintf(step->errormsg,"%s: %s",sev,msg);
784+
}
785+
else
786+
step->errormsg=strdup(PQresultErrorMessage(res));
787+
}
775788
break;
776789
default:
777790
printf("unexpected result status: %s\n",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp