diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c new file mode 100644 index ea4f957..2f5a8f7 *** a/contrib/auto_explain/auto_explain.c --- b/contrib/auto_explain/auto_explain.c *************** static bool auto_explain_log_buffers = f *** 28,33 **** --- 28,34 ---- static bool auto_explain_log_triggers = false; static bool auto_explain_log_timing = true; static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT; + static int auto_explain_log_destination = LOG; static bool auto_explain_log_nested_statements = false; static double auto_explain_sample_rate = 1; *************** static const struct config_enum_entry fo *** 39,44 **** --- 40,51 ---- {NULL, 0, false} }; + static const struct config_enum_entry destination_options[] = { + {"log", LOG, false}, + {"notice", NOTICE, false}, + {NULL, 0, false} + }; + /* Current nesting depth of ExecutorRun calls */ static int nesting_level = 0; *************** _PG_init(void) *** 141,146 **** --- 148,165 ---- NULL, NULL); + DefineCustomEnumVariable("auto_explain.log_destination", + "Log destination for the plan.", + NULL, + &auto_explain_log_destination, + LOG, + destination_options, + PGC_SUSET, + 0, + NULL, + NULL, + NULL); + DefineCustomBoolVariable("auto_explain.log_nested_statements", "Log nested statements.", NULL, *************** explain_ExecutorEnd(QueryDesc *queryDesc *** 353,359 **** * reported. This isn't ideal but trying to do it here would * often result in duplication. */ ! ereport(LOG, (errmsg("duration: %.3f ms plan:\n%s", msec, es->str->data), errhidestmt(true))); --- 372,378 ---- * reported. This isn't ideal but trying to do it here would * often result in duplication. */ ! ereport(auto_explain_log_destination, (errmsg("duration: %.3f ms plan:\n%s", msec, es->str->data), errhidestmt(true))); diff --git a/doc/src/sgml/auto-explain.sgml b/doc/src/sgml/auto-explain.sgml new file mode 100644 index 08b67f2..bc1b4d7 *** a/doc/src/sgml/auto-explain.sgml --- b/doc/src/sgml/auto-explain.sgml *************** LOAD 'auto_explain'; *** 189,194 **** --- 189,213 ---- + auto_explain.log_destination (enum) + + auto_explain.log_destination configuration parameter + + + + + auto_explain.log_destination selects where + auto_explain will log the query plan. + The allowed values are log, which logs the plan to the + server log, and notice, which logs it as a NOTICE, which + allows clients to access it. log is the default. + Only superusers can change this setting. + + + + + + auto_explain.log_nested_statements (boolean) auto_explain.log_nested_statements configuration parameter