1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

Separate state from query string in pg_stat_activity

This separates the state (running/idle/idleintransaction etc) into
it's own field ("state"), and leaves the query field containing just
query text.

The query text will now mean "current query" when a query is running
and "last query" in other states. Accordingly,the field has been
renamed from current_query to query.

Since backwards compatibility was broken anyway to make that, the procpid
field has also been renamed to pid - along with the same field in
pg_stat_replication for consistency.

Scott Mead and Magnus Hagander, review work from Greg Smith
This commit is contained in:
Magnus Hagander
2012-01-19 14:19:20 +01:00
parent fa352d662e
commit 4f42b546fd
10 changed files with 380 additions and 87 deletions

View File

@ -809,7 +809,7 @@ exec_simple_query(const char *query_string)
*/
debug_query_string = query_string;
pgstat_report_activity(query_string);
pgstat_report_activity(STATE_RUNNING, query_string);
TRACE_POSTGRESQL_QUERY_START(query_string);
@ -1134,7 +1134,7 @@ exec_parse_message(const char *query_string, /* string to execute */
*/
debug_query_string = query_string;
pgstat_report_activity(query_string);
pgstat_report_activity(STATE_RUNNING, query_string);
set_ps_display("PARSE", false);
@ -1429,7 +1429,7 @@ exec_bind_message(StringInfo input_message)
*/
debug_query_string = psrc->query_string;
pgstat_report_activity(psrc->query_string);
pgstat_report_activity(STATE_RUNNING, psrc->query_string);
set_ps_display("BIND", false);
@ -1836,7 +1836,7 @@ exec_execute_message(const char *portal_name, long max_rows)
*/
debug_query_string = sourceText;
pgstat_report_activity(sourceText);
pgstat_report_activity(STATE_RUNNING, sourceText);
set_ps_display(portal->commandTag, false);
@ -3811,12 +3811,12 @@ PostgresMain(int argc, char *argv[], const char *username)
if (IsAbortedTransactionBlockState())
{
set_ps_display("idle in transaction (aborted)", false);
pgstat_report_activity("<IDLE> in transaction (aborted)");
pgstat_report_activity(STATE_IDLEINTRANSACTION_ABORTED, NULL);
}
else if (IsTransactionOrTransactionBlock())
{
set_ps_display("idle in transaction", false);
pgstat_report_activity("<IDLE> in transaction");
pgstat_report_activity(STATE_IDLEINTRANSACTION, NULL);
}
else
{
@ -3824,7 +3824,7 @@ PostgresMain(int argc, char *argv[], const char *username)
pgstat_report_stat(false);
set_ps_display("idle", false);
pgstat_report_activity("<IDLE>");
pgstat_report_activity(STATE_IDLE, NULL);
}
ReadyForQuery(whereToSendOutput);
@ -3944,7 +3944,7 @@ PostgresMain(int argc, char *argv[], const char *username)
SetCurrentStatementStartTimestamp();
/* Report query to various monitoring facilities. */
pgstat_report_activity("<FASTPATH> function call");
pgstat_report_activity(STATE_FASTPATH, NULL);
set_ps_display("<FASTPATH>", false);
/* start an xact for this function invocation */