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

Commit845d335

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 parent89b661b commit845d335

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
@@ -578,7 +578,8 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
578578
{
579579
charbuf[256];
580580

581-
PQcancel(cancel,buf,sizeof(buf));
581+
if (!PQcancel(cancel,buf,sizeof(buf)))
582+
fprintf(stderr,"PQcancel failed: %s\n",buf);
582583

583584
/* Be sure to consume the error message. */
584585
while ((res=PQgetResult(conn))!=NULL)
@@ -771,14 +772,26 @@ try_complete_step(Step * step, int flags)
771772
printf("WARNING: this step had a leftover error message\n");
772773
printf("%s\n",step->errormsg);
773774
}
774-
/* Detail may contain xid values, so just show primary. */
775-
step->errormsg=malloc(5+
776-
strlen(PQresultErrorField(res,PG_DIAG_SEVERITY))+
777-
strlen(PQresultErrorField(res,
778-
PG_DIAG_MESSAGE_PRIMARY)));
779-
sprintf(step->errormsg,"%s: %s",
780-
PQresultErrorField(res,PG_DIAG_SEVERITY),
781-
PQresultErrorField(res,PG_DIAG_MESSAGE_PRIMARY));
775+
776+
/*
777+
* Detail may contain XID values, so we want to just show
778+
* primary. Beware however that libpq-generated error results
779+
* may not contain subfields, only an old-style message.
780+
*/
781+
{
782+
constchar*sev=PQresultErrorField(res,
783+
PG_DIAG_SEVERITY);
784+
constchar*msg=PQresultErrorField(res,
785+
PG_DIAG_MESSAGE_PRIMARY);
786+
787+
if (sev&&msg)
788+
{
789+
step->errormsg=malloc(5+strlen(sev)+strlen(msg));
790+
sprintf(step->errormsg,"%s: %s",sev,msg);
791+
}
792+
else
793+
step->errormsg=strdup(PQresultErrorMessage(res));
794+
}
782795
break;
783796
default:
784797
printf("unexpected result status: %s\n",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp