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

Commit 5cce0cb

Browse files
committed
print notices
1 parent a095c69 commit 5cce0cb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

multimaster.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,14 +2158,33 @@ static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg)
21582158

21592159
*errmsg = palloc0(errlen);
21602160

2161-
/* Strip "ERROR:\t" from beginning and "\n" from end of error string */
2161+
/* Strip "ERROR: " from beginning and "\n" from end of error string */
21622162
strncpy(*errmsg, errstr + 8, errlen - 1 - 8);
21632163
}
21642164

21652165
PQclear(result);
21662166
return ret;
21672167
}
21682168

2169+
void MtmNoticeReceiver(void *i, const PGresult *res)
2170+
{
2171+
char *notice = PQresultErrorMessage(res);
2172+
char *stripped_notice;
2173+
int len = strlen(notice);
2174+
2175+
/* Skip notices from other nodes */
2176+
if ( (*(int *)i) != MtmNodeId - 1)
2177+
return;
2178+
2179+
stripped_notice = palloc0(len);
2180+
2181+
/* Strip "NOTICE: " from beginning and "\n" from end of error string */
2182+
strncpy(stripped_notice, notice + 9, len - 1 - 9);
2183+
2184+
elog(NOTICE, stripped_notice);
2185+
pfree(stripped_notice);
2186+
}
2187+
21692188
static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
21702189
{
21712190
int i = 0;
@@ -2194,6 +2213,7 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
21942213
elog(ERROR, "Failed to establish connection '%s' to node %d", Mtm->nodes[i].con.connStr, failedNode);
21952214
}
21962215
}
2216+
PQsetNoticeReceiver(conns[i], MtmNoticeReceiver, &i);
21972217
}
21982218
}
21992219
Assert(i == MtmNodes);

0 commit comments

Comments
 (0)