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

Commit be2865e

Browse files
committed
More casrefully handle trucation of error message
1 parent f8a7766 commit be2865e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

contrib/mmts/multimaster.c

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

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

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

0 commit comments

Comments
 (0)