Skip to content

Commit c2d620a

Browse files
Error_message
1 parent d8ee895 commit c2d620a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pg_fasttransfer.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,24 @@ xp_RunFastTransfer_secure(PG_FUNCTION_ARGS)
284284
transfer_time = -1;
285285
total_time = -1;
286286

287-
char *line = NULL;
288-
char *saveptr = NULL;
289-
290-
line = strtok_r(result_output->data, "\n", &saveptr);
291-
while (line != NULL)
292-
{
293-
if (strstr(line, "ERROR") != NULL)
294-
{
295-
appendStringInfo(error_output, "%s\n", line);
287+
char *start = result_output->data;
288+
char *end = NULL;
289+
290+
while ((end = strchr(start, '\n')) != NULL) {
291+
*end = '\0';
292+
if (strstr(start, "ERROR") != NULL) {
293+
appendStringInfo(error_output, "%s\n", start);
296294
}
297-
line = strtok_r(NULL, "\n", &saveptr);
295+
start = end + 1;
296+
}
297+
298+
// If the last row doesn't have '\n'
299+
if (*start != '\0' && strstr(start, "ERROR") != NULL) {
300+
appendStringInfo(error_output, "%s\n", start);
298301
}
299302

303+
304+
300305
if (out && out[0] != '\0') {
301306
/* Total rows */
302307
token = strstr(out, "Total rows : ");

0 commit comments

Comments
 (0)