Skip to content

Commit 7a86d88

Browse files
committed
print notices
1 parent b7d599e commit 7a86d88

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

contrib/mmts/multimaster.c

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

21602160
*errmsg = palloc0(errlen);
21612161

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy