From 5fd9dfa5f50e4906c35133a414ebec5b6d518493 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 7 Apr 2021 13:06:47 -0400 Subject: Move pg_stat_statements query jumbling to core. Add compute_query_id GUC to control whether a query identifier should be computed by the core (off by default). It's thefore now possible to disable core queryid computation and use pg_stat_statements with a different algorithm to compute the query identifier by using a third-party module. To ensure that a single source of query identifier can be used and is well defined, modules that calculate a query identifier should throw an error if compute_query_id specified to compute a query id and if a query idenfitier was already calculated. Discussion: https://postgr.es/m/20210407125726.tkvjdbw76hxnpwfi@nol Author: Julien Rouhaud Reviewed-by: Alvaro Herrera, Nitin Jadhav, Zhihong Yu --- src/backend/tcop/postgres.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 330ec5b0288..50f2f7f2465 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -668,6 +668,7 @@ pg_analyze_and_rewrite_params(RawStmt *parsetree, ParseState *pstate; Query *query; List *querytree_list; + JumbleState *jstate = NULL; Assert(query_string != NULL); /* required as of 8.4 */ @@ -686,8 +687,11 @@ pg_analyze_and_rewrite_params(RawStmt *parsetree, query = transformTopLevelStmt(pstate, parsetree); + if (compute_query_id) + jstate = JumbleQuery(query, query_string); + if (post_parse_analyze_hook) - (*post_parse_analyze_hook) (pstate, query); + (*post_parse_analyze_hook) (pstate, query, jstate); free_parsestate(pstate); -- cgit v1.2.3