*** pgsql/contrib/auto_explain/auto_explain.c 2009/07/26 23:34:17 1.6 --- pgsql/contrib/auto_explain/auto_explain.c 2009/08/10 05:46:49 1.7 *************** *** 6,12 **** * Copyright (c) 2008-2009, PostgreSQL Global Development Group * * IDENTIFICATION ! * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.5 2009/06/11 14:48:50 momjian Exp $ * *------------------------------------------------------------------------- */ --- 6,12 ---- * 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 $ * *------------------------------------------------------------------------- */ *************** PG_MODULE_MAGIC; *** 22,29 **** --- 22,37 ---- 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; *************** _PG_init(void) *** 84,89 **** --- 92,108 ---- 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, *************** explain_ExecutorEnd(QueryDesc *queryDesc *** 201,206 **** --- 220,226 ---- 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);