From 4f0b0966c866ae9f0e15d7cc73ccf7ce4e1af84b Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 7 Apr 2021 14:03:56 -0400 Subject: Make use of in-core query id added by commit 5fd9dfa5f5 Use the in-core query id computation for pg_stat_activity, log_line_prefix, and EXPLAIN VERBOSE. Similar to other fields in pg_stat_activity, only the queryid from the top level statements are exposed, and if the backends status isn't active then the queryid from the last executed statements is displayed. Add a %Q placeholder to include the queryid in log_line_prefix, which will also only expose top level statements. For EXPLAIN VERBOSE, if a query identifier has been computed, either by enabling compute_query_id or using a third-party module, display it. Bump catalog version. Discussion: https://postgr.es/m/20210407125726.tkvjdbw76hxnpwfi@nol Author: Julien Rouhaud Reviewed-by: Alvaro Herrera, Nitin Jadhav, Zhihong Yu --- src/backend/tcop/postgres.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 50f2f7f2465..ef8fb20429c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -695,6 +695,8 @@ pg_analyze_and_rewrite_params(RawStmt *parsetree, free_parsestate(pstate); + pgstat_report_queryid(query->queryId, false); + if (log_parser_stats) ShowUsage("PARSE ANALYSIS STATISTICS"); @@ -913,6 +915,7 @@ pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions, stmt->utilityStmt = query->utilityStmt; stmt->stmt_location = query->stmt_location; stmt->stmt_len = query->stmt_len; + stmt->queryId = query->queryId; } else { @@ -1029,6 +1032,8 @@ exec_simple_query(const char *query_string) DestReceiver *receiver; int16 format; + pgstat_report_queryid(0, true); + /* * Get the command name for use in status display (it also becomes the * default completion tag, down inside PortalRun). Set ps_status and -- cgit v1.2.3