@@ -119,6 +119,7 @@ initialize_worker_spi(worktable *table)
119119 appendStringInfo (& buf , "select count(*) from pg_namespace where nspname = '%s'" ,
120120 table -> schema );
121121
122+ debug_query_string = buf .data ;
122123 ret = SPI_execute (buf .data , true, 0 );
123124 if (ret != SPI_OK_SELECT )
124125 elog (FATAL , "SPI_execute failed: error code %d" , ret );
@@ -134,6 +135,7 @@ initialize_worker_spi(worktable *table)
134135
135136 if (ntup == 0 )
136137 {
138+ debug_query_string = NULL ;
137139 resetStringInfo (& buf );
138140 appendStringInfo (& buf ,
139141 "CREATE SCHEMA \"%s\" "
@@ -147,15 +149,19 @@ initialize_worker_spi(worktable *table)
147149 /* set statement start time */
148150 SetCurrentStatementStartTimestamp ();
149151
152+ debug_query_string = buf .data ;
150153 ret = SPI_execute (buf .data , false, 0 );
151154
152155 if (ret != SPI_OK_UTILITY )
153156 elog (FATAL , "failed to create my schema" );
157+
158+ debug_query_string = NULL ; /* rest is not statement-specific */
154159 }
155160
156161 SPI_finish ();
157162 PopActiveSnapshot ();
158163 CommitTransactionCommand ();
164+ debug_query_string = NULL ;
159165 pgstat_report_activity (STATE_IDLE , NULL );
160166}
161167
@@ -262,6 +268,7 @@ worker_spi_main(Datum main_arg)
262268 StartTransactionCommand ();
263269 SPI_connect ();
264270 PushActiveSnapshot (GetTransactionSnapshot ());
271+ debug_query_string = buf .data ;
265272 pgstat_report_activity (STATE_RUNNING , buf .data );
266273
267274 /* We can now execute queries via SPI */
@@ -291,6 +298,7 @@ worker_spi_main(Datum main_arg)
291298 SPI_finish ();
292299 PopActiveSnapshot ();
293300 CommitTransactionCommand ();
301+ debug_query_string = NULL ;
294302 pgstat_report_stat (false);
295303 pgstat_report_activity (STATE_IDLE , NULL );
296304 }
0 commit comments