mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +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:
@ -19,12 +19,14 @@
|
||||
#include "common/pg_prng.h"
|
||||
#include "executor/instrument.h"
|
||||
#include "jit/jit.h"
|
||||
#include "nodes/params.h"
|
||||
#include "utils/guc.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
/* GUC variables */
|
||||
static int auto_explain_log_min_duration = -1; /* msec or -1 */
|
||||
static int auto_explain_log_parameter_max_length = -1; /* bytes or -1 */
|
||||
static bool auto_explain_log_analyze = false;
|
||||
static bool auto_explain_log_verbose = false;
|
||||
static bool auto_explain_log_buffers = false;
|
||||
@ -105,6 +107,18 @@ _PG_init(void)
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomIntVariable("auto_explain.log_parameter_max_length",
|
||||
"Sets the maximum length of query parameters to log.",
|
||||
"Zero logs no query parameters, -1 logs them in full.",
|
||||
&auto_explain_log_parameter_max_length,
|
||||
-1,
|
||||
-1, INT_MAX,
|
||||
PGC_SUSET,
|
||||
GUC_UNIT_BYTE,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DefineCustomBoolVariable("auto_explain.log_analyze",
|
||||
"Use EXPLAIN ANALYZE for plan logging.",
|
||||
NULL,
|
||||
@ -389,6 +403,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
|
||||
|
||||
ExplainBeginOutput(es);
|
||||
ExplainQueryText(es, queryDesc);
|
||||
ExplainQueryParameters(es, queryDesc->params, auto_explain_log_parameter_max_length);
|
||||
ExplainPrintPlan(es, queryDesc);
|
||||
if (es->analyze && auto_explain_log_triggers)
|
||||
ExplainPrintTriggers(es, queryDesc);
|
||||
|
Reference in New Issue
Block a user