Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2246cd

Browse files
committed
Set debug_query_string in worker_spi.
This makes elog.c emit the string, which is good practice for abackground worker that executes SQL strings.Reviewed by Tom Lane.Discussion:https://postgr.es/m/20201014022636.GA1962668@rfd.leadboat.com
1 parentf90e80b commitd2246cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎src/test/modules/worker_spi/worker_spi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp