diff --git a/src/spock_apply.c b/src/spock_apply.c index b93b3db9..ae308ab7 100644 --- a/src/spock_apply.c +++ b/src/spock_apply.c @@ -1226,6 +1226,13 @@ handle_insert(StringInfo s) */ xact_had_exception = true; exception_command_counter++; + + /* + * Clear the local tuple pointer if it was left over from a + * previous operation. + */ + exception_log_ptr[my_exception_log_index].local_tuple = NULL; + log_insert_exception(true, "Spock can't find relation", NULL, NULL, NULL, "INSERT"); end_replication_step(); @@ -3259,6 +3266,12 @@ static void execute_sql_command_error_cb(void *arg) { errcontext("during execution of queued SQL statement: %s", (char *) arg); + /* + * The errcontext above already includes the SQL statement, so clear + * debug_query_string to prevent it from appearing a second time in + * the LOG output. + */ + debug_query_string = NULL; } /* @@ -3779,6 +3792,13 @@ spock_apply_main(Datum main_arg) Assert(MySpockWorker->worker_type == SPOCK_WORKER_APPLY); MyApplyWorker = &MySpockWorker->worker.apply; + /* + * The apply worker is not a regular backend and has no client query + * string. Initialize debug_query_string to NULL so that LOG reports + * do not print arbitrary memory contents. + */ + debug_query_string = NULL; + /* Setup synchronous commit according to the user's wishes */ SetConfigOption("synchronous_commit", spock_synchronous_commit ? "local" : "off",