@@ -2159,14 +2159,33 @@ static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg)
2159
2159
2160
2160
* errmsg = palloc0 (errlen );
2161
2161
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 */
2163
2163
strncpy (* errmsg , errstr + 8 , errlen - 1 - 8 );
2164
2164
}
2165
2165
2166
2166
PQclear (result );
2167
2167
return ret ;
2168
2168
}
2169
2169
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
+
2170
2189
static void MtmBroadcastUtilityStmt (char const * sql , bool ignoreError )
2171
2190
{
2172
2191
int i = 0 ;
@@ -2195,6 +2214,7 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
2195
2214
elog (ERROR , "Failed to establish connection '%s' to node %d" , Mtm -> nodes [i ].con .connStr , failedNode );
2196
2215
}
2197
2216
}
2217
+ PQsetNoticeReceiver (conns [i ], MtmNoticeReceiver , & i );
2198
2218
}
2199
2219
}
2200
2220
Assert (i == MtmNodes );
0 commit comments