Cause the output from debug_print_parse, debug_print_rewritten, and
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Aug 2008 18:30:04 +0000 (18:30 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Aug 2008 18:30:04 +0000 (18:30 +0000)
debug_print_plan to appear at LOG message level, not DEBUG1 as historically.
Make debug_pretty_print default to on.  Also, cause plans generated via
EXPLAIN to be subject to debug_print_plan.  This is all to make
debug_print_plan a reasonably comfortable substitute for the former behavior
of EXPLAIN VERBOSE.

doc/src/sgml/config.sgml
src/backend/commands/explain.c
src/backend/tcop/postgres.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample

index 16a309547b17e004e62e8eb0ac07274c28bd88d9..4d8d1aea9a9e81f4e9f64ed63d3021d5752bec0b 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.185 2008/08/15 08:37:41 mha Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.186 2008/08/19 18:30:04 tgl Exp $ -->
 
 <chapter Id="runtime-config">
   <title>Server Configuration</title>
@@ -2817,7 +2817,6 @@ local0.*    /var/log/postgresql
       <term><varname>debug_print_parse</varname> (<type>boolean</type>)</term>
       <term><varname>debug_print_rewritten</varname> (<type>boolean</type>)</term>
       <term><varname>debug_print_plan</varname> (<type>boolean</type>)</term>
-      <term><varname>debug_pretty_print</varname> (<type>boolean</type>)</term>
       <indexterm>
        <primary><varname>debug_print_parse</> configuration parameter</primary>
       </indexterm>
@@ -2827,21 +2826,34 @@ local0.*    /var/log/postgresql
       <indexterm>
        <primary><varname>debug_print_plan</> configuration parameter</primary>
       </indexterm>
+      <listitem>
+       <para>
+        These parameters enable various debugging output to be emitted.
+        When set, they print the resulting parse tree, the query rewriter
+        output, or the execution plan for each executed query.
+        These messages are emitted at <literal>LOG</> message level, so by
+        default they will appear in the server log but will not be sent to the
+        client.  You can change that by adjusting
+        <xref linkend="guc-client-min-messages"> and/or
+        <xref linkend="guc-log-min-messages">.
+        These parameters are off by default.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
+      <term><varname>debug_pretty_print</varname> (<type>boolean</type>)</term>
       <indexterm>
        <primary><varname>debug_pretty_print</> configuration parameter</primary>
       </indexterm>
       <listitem>
        <para>
-        These parameters enable various debugging output to be emitted.
-        For each executed query, they print
-        the resulting parse tree, the query rewriter output, or the
-        execution plan.  <varname>debug_pretty_print</varname> indents
-        these displays to produce a more readable but much longer
-        output format.  <varname>client_min_messages</varname> or
-        <varname>log_min_messages</varname> must be
-        <literal>DEBUG1</literal> or lower to actually send this output
-        to the client or the server log, respectively.
-        These parameters are off by default.
+        When set, <varname>debug_pretty_print</varname> indents the messages
+        produced by <varname>debug_print_parse</varname>,
+        <varname>debug_print_rewritten</varname>, or
+        <varname>debug_print_plan</varname>.  This results in more readable
+        but much longer output than the <quote>compact</> format used when
+        it is off.  It is on by default.
        </para>
       </listitem>
      </varlistentry>
index d0033f436620e6b86f35c6d29938b33d88cecb21..81f1dd0c31fcbf30b63c3178d080450eef160437 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994-5, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.177 2008/08/14 18:47:58 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.178 2008/08/19 18:30:04 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -169,7 +169,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, const char *queryString,
        PlannedStmt *plan;
 
        /* plan the query */
-       plan = planner(query, 0, params);
+       plan = pg_plan_query(query, 0, params);
 
        /* run it (if needed) and produce output */
        ExplainOnePlan(plan, params, stmt, tstate);
index 132d33c5a9df76c0f8973cd1726e6e63bb053ae1..8449cb4d4c172e11c8b0ad881bad91c98edf597e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.555 2008/08/01 13:16:09 alvherre Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.556 2008/08/19 18:30:04 tgl Exp $
  *
  * NOTES
  *   this is the "main" module of the postgres backend and
@@ -630,13 +630,13 @@ pg_rewrite_query(Query *query)
 {
    List       *querytree_list;
 
-   if (log_parser_stats)
-       ResetUsage();
-
    if (Debug_print_parse)
-       elog_node_display(DEBUG1, "parse tree", query,
+       elog_node_display(LOG, "parse tree", query,
                          Debug_pretty_print);
 
+   if (log_parser_stats)
+       ResetUsage();
+
    if (query->commandType == CMD_UTILITY)
    {
        /* don't rewrite utilities, just dump 'em into result list */
@@ -666,7 +666,7 @@ pg_rewrite_query(Query *query)
 #endif
 
    if (Debug_print_rewritten)
-       elog_node_display(DEBUG1, "rewritten parse tree", querytree_list,
+       elog_node_display(LOG, "rewritten parse tree", querytree_list,
                          Debug_pretty_print);
 
    return querytree_list;
@@ -720,7 +720,7 @@ pg_plan_query(Query *querytree, int cursorOptions, ParamListInfo boundParams)
     * Print plan if debugging.
     */
    if (Debug_print_plan)
-       elog_node_display(DEBUG1, "plan", plan, Debug_pretty_print);
+       elog_node_display(LOG, "plan", plan, Debug_pretty_print);
 
    TRACE_POSTGRESQL_QUERY_PLAN_DONE();
 
index 6cc6dcb7e039adacdefe58c5f5110a7bb590ef08..c9fe269326501d3333339ec34fa76ddc01e6c187 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.466 2008/08/15 08:37:40 mha Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.467 2008/08/19 18:30:04 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -316,7 +316,7 @@ bool        log_duration = false;
 bool       Debug_print_plan = false;
 bool       Debug_print_parse = false;
 bool       Debug_print_rewritten = false;
-bool       Debug_pretty_print = false;
+bool       Debug_pretty_print = true;
 
 bool       log_parser_stats = false;
 bool       log_planner_stats = false;
@@ -772,7 +772,7 @@ static struct config_bool ConfigureNamesBool[] =
    },
    {
        {"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
-           gettext_noop("Prints the parse tree to the server log."),
+           gettext_noop("Logs each query's parse tree."),
            NULL
        },
        &Debug_print_parse,
@@ -780,7 +780,7 @@ static struct config_bool ConfigureNamesBool[] =
    },
    {
        {"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
-           gettext_noop("Prints the parse tree after rewriting to server log."),
+           gettext_noop("Logs each query's rewritten parse tree."),
            NULL
        },
        &Debug_print_rewritten,
@@ -788,7 +788,7 @@ static struct config_bool ConfigureNamesBool[] =
    },
    {
        {"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
-           gettext_noop("Prints the execution plan to server log."),
+           gettext_noop("Logs each query's execution plan."),
            NULL
        },
        &Debug_print_plan,
@@ -800,7 +800,7 @@ static struct config_bool ConfigureNamesBool[] =
            NULL
        },
        &Debug_pretty_print,
-       false, NULL, NULL
+       true, NULL, NULL
    },
    {
        {"log_parser_stats", PGC_SUSET, STATS_MONITORING,
index 063d3ec1c4a851ef5b3334d136a0560d44918dd6..342be9d6c3cebc18d9784e54777df79773096caf 100644 (file)
 #debug_print_parse = off
 #debug_print_rewritten = off
 #debug_print_plan = off
-#debug_pretty_print = off
+#debug_pretty_print = on
 #log_checkpoints = off
 #log_connections = off
 #log_disconnections = off