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