diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-10 05:46:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-10 05:46:50 +0000 |
commit | 9bd27b7c9e998087f390774bd0f43916813a2847 (patch) | |
tree | ee2b7fa2b2e77c53c87a53a786163dae1b0e6538 /contrib/auto_explain/auto_explain.c | |
parent | 18894c401f1f5ec5af1d08a12da1f183599e8560 (diff) | |
download | postgresql-9bd27b7c9e998087f390774bd0f43916813a2847.tar.gz postgresql-9bd27b7c9e998087f390774bd0f43916813a2847.zip |
Extend EXPLAIN to support output in XML or JSON format.
There are probably still some adjustments to be made in the details
of the output, but this gets the basic structure in place.
Robert Haas
Diffstat (limited to 'contrib/auto_explain/auto_explain.c')
-rw-r--r-- | contrib/auto_explain/auto_explain.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index eb2bc04aed9..6d3435be1f7 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -6,7 +6,7 @@ * Copyright (c) 2008-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.6 2009/07/26 23:34:17 tgl Exp $ + * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.7 2009/08/10 05:46:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,8 +22,16 @@ PG_MODULE_MAGIC; static int auto_explain_log_min_duration = -1; /* msec or -1 */ static bool auto_explain_log_analyze = false; static bool auto_explain_log_verbose = false; +static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT; static bool auto_explain_log_nested_statements = false; +static const struct config_enum_entry format_options[] = { + {"text", EXPLAIN_FORMAT_TEXT, false}, + {"xml", EXPLAIN_FORMAT_XML, false}, + {"json", EXPLAIN_FORMAT_JSON, false}, + {NULL, 0, false} +}; + /* Current nesting depth of ExecutorRun calls */ static int nesting_level = 0; @@ -84,6 +92,17 @@ _PG_init(void) NULL, NULL); + DefineCustomEnumVariable("auto_explain.log_format", + "EXPLAIN format to be used for plan logging.", + NULL, + &auto_explain_log_format, + EXPLAIN_FORMAT_TEXT, + format_options, + PGC_SUSET, + 0, + NULL, + NULL); + DefineCustomBoolVariable("auto_explain.log_nested_statements", "Log nested statements.", NULL, @@ -201,6 +220,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc) ExplainInitState(&es); es.analyze = (queryDesc->doInstrument && auto_explain_log_analyze); es.verbose = auto_explain_log_verbose; + es.format = auto_explain_log_format; ExplainPrintPlan(&es, queryDesc); |