mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
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
This commit is contained in:
@@ -46,6 +46,8 @@
|
||||
#include "parser/parsetree.h"
|
||||
#include "rewrite/rewriteManip.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/queryjumble.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
|
||||
@@ -107,6 +109,7 @@ parse_analyze(RawStmt *parseTree, const char *sourceText,
|
||||
{
|
||||
ParseState *pstate = make_parsestate(NULL);
|
||||
Query *query;
|
||||
JumbleState *jstate = NULL;
|
||||
|
||||
Assert(sourceText != NULL); /* required as of 8.4 */
|
||||
|
||||
@@ -119,8 +122,11 @@ parse_analyze(RawStmt *parseTree, const char *sourceText,
|
||||
|
||||
query = transformTopLevelStmt(pstate, parseTree);
|
||||
|
||||
if (compute_query_id)
|
||||
jstate = JumbleQuery(query, sourceText);
|
||||
|
||||
if (post_parse_analyze_hook)
|
||||
(*post_parse_analyze_hook) (pstate, query);
|
||||
(*post_parse_analyze_hook) (pstate, query, jstate);
|
||||
|
||||
free_parsestate(pstate);
|
||||
|
||||
@@ -140,6 +146,7 @@ parse_analyze_varparams(RawStmt *parseTree, const char *sourceText,
|
||||
{
|
||||
ParseState *pstate = make_parsestate(NULL);
|
||||
Query *query;
|
||||
JumbleState *jstate = NULL;
|
||||
|
||||
Assert(sourceText != NULL); /* required as of 8.4 */
|
||||
|
||||
@@ -152,8 +159,11 @@ parse_analyze_varparams(RawStmt *parseTree, const char *sourceText,
|
||||
/* make sure all is well with parameter types */
|
||||
check_variable_parameters(pstate, query);
|
||||
|
||||
if (compute_query_id)
|
||||
jstate = JumbleQuery(query, sourceText);
|
||||
|
||||
if (post_parse_analyze_hook)
|
||||
(*post_parse_analyze_hook) (pstate, query);
|
||||
(*post_parse_analyze_hook) (pstate, query, jstate);
|
||||
|
||||
free_parsestate(pstate);
|
||||
|
||||
|
Reference in New Issue
Block a user