Skip to content

Commit dab4464

Browse files
danolivorasifr
authored andcommitted
Prevent debug_query_string from producing garbage in apply worker logs
Initialize debug_query_string to NULL at apply worker startup, since it is not a regular backend and has no client query string. Also clear debug_query_string in execute_sql_command_error_cb after the errcontext call, which already includes the SQL statement, to prevent it from appearing a second time in the LOG output.
1 parent a7a439d commit dab4464

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/spock_apply.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,12 @@ static void
32823282
execute_sql_command_error_cb(void *arg)
32833283
{
32843284
errcontext("during execution of queued SQL statement: %s", (char *) arg);
3285+
/*
3286+
* The errcontext above already includes the SQL statement, so clear
3287+
* debug_query_string to prevent it from appearing a second time in
3288+
* the LOG output.
3289+
*/
3290+
debug_query_string = NULL;
32853291
}
32863292

32873293
/*
@@ -4145,6 +4151,13 @@ spock_apply_main(Datum main_arg)
41454151
apply_api.multi_insert_finish = spock_apply_spi_mi_finish;
41464152
}
41474153

4154+
/*
4155+
* The apply worker is not a regular backend and has no client query
4156+
* string. Initialize debug_query_string to NULL so that LOG reports
4157+
* do not print arbitrary memory contents.
4158+
*/
4159+
debug_query_string = NULL;
4160+
41484161
/* Setup synchronous commit according to the user's wishes */
41494162
SetConfigOption("synchronous_commit",
41504163
spock_synchronous_commit ? "local" : "off",

0 commit comments

Comments
 (0)