@@ -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+
21702189static 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