Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c3eb6bf

Browse files
knizhnikkelvich
authored andcommitted
More casrefully handle trucation of error message
1 parent 4868a4f commit c3eb6bf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

multimaster.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,11 +2710,12 @@ static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg)
27102710
if (!ret) {
27112711
char *errstr = PQresultErrorMessage(result);
27122712
int errlen = strlen(errstr);
2713+
if (errlen > 9) {
2714+
*errmsg = palloc0(errlen);
27132715

2714-
*errmsg = palloc0(errlen);
2715-
2716-
/* Strip "ERROR: " from beginning and "\n" from end of error string */
2717-
strncpy(*errmsg, errstr + 8, errlen - 1 - 8);
2716+
/* Strip "ERROR: " from beginning and "\n" from end of error string */
2717+
strncpy(*errmsg, errstr + 8, errlen - 1 - 8);
2718+
}
27182719
}
27192720

27202721
PQclear(result);
@@ -2781,7 +2782,7 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
27812782
do {
27822783
PQfinish(conns[i]);
27832784
} while (--i >= 0);
2784-
elog(ERROR, "Failed to establish connection '%s' to node %d", Mtm->nodes[failedNode].con.connStr, failedNode);
2785+
elog(ERROR, "Failed to establish connection '%s' to node %d", Mtm->nodes[failedNode].con.connStr, failedNode+1);
27852786
}
27862787
}
27872788
PQsetNoticeReceiver(conns[i], MtmNoticeReceiver, &i);

0 commit comments

Comments
 (0)