1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

autho_explain: Add GUC to log query parameters

auto_explain.log_parameter_max_length is a new GUC part of the
extension, similar to the corresponding core setting, that controls the
inclusion of query parameters in the logged explain output.

More tests are added to check the behavior of this new parameter: when
parameters logged in full (the default of -1), when disabled (value of
0) and when partially truncated (value different than the two others).

Author: Dagfinn Ilmari Mannsåker
Discussion: https://postgr.es/m/87ee09mohb.fsf@wibble.ilmari.org
This commit is contained in:
Michael Paquier
2022-07-06 09:55:30 +09:00
parent 08385ed261
commit d4bfe41281
5 changed files with 105 additions and 0 deletions

View File

@ -972,6 +972,28 @@ ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
ExplainPropertyText("Query Text", queryDesc->sourceText, es);
}
/*
* ExplainQueryParameters -
* add a "Query Parameters" node that describes the parameters of the query
*
* The caller should have set up the options fields of *es, as well as
* initializing the output buffer es->str.
*
*/
void
ExplainQueryParameters(ExplainState *es, ParamListInfo params, int maxlen)
{
char *str;
/* This check is consistent with errdetail_params() */
if (params == NULL || params->numParams <= 0 || maxlen == 0)
return;
str = BuildParamLogString(params, NULL, maxlen);
if (str && str[0] != '\0')
ExplainPropertyText("Query Parameters", str, es);
}
/*
* report_triggers -
* report execution stats for a single relation's triggers