mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Allow to log raw parse tree.
This commit allows to log the raw parse tree in the same way we currently log the parse tree, rewritten tree, and plan tree. To avoid unnecessary log noise for users not interested in this detail, a new GUC option, "debug_print_raw_parse", has been added. When starting the PostgreSQL process with "-d N", and N is 3 or higher, debug_print_raw_parse is enabled automatically, alongside debug_print_parse. Author: Chao Li <lic@highgo.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Tatsuo Ishii <ishii@postgresql.org> Reviewed-by: John Naylor <johncnaylorls@gmail.com> Discussion: https://postgr.es/m/CAEoWx2mcO0Gpo4vd8kPMAFWeJLSp0MeUUnaLdE1x0tSVd-VzUw%40mail.gmail.com
This commit is contained in:
@@ -7383,6 +7383,11 @@ local0.* /var/log/postgresql
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="guc-debug-print-parse">
|
<varlistentry id="guc-debug-print-parse">
|
||||||
|
<term><varname>debug_print_raw_parse</varname> (<type>boolean</type>)
|
||||||
|
<indexterm>
|
||||||
|
<primary><varname>debug_print_raw_parse</varname> configuration parameter</primary>
|
||||||
|
</indexterm>
|
||||||
|
</term>
|
||||||
<term><varname>debug_print_parse</varname> (<type>boolean</type>)
|
<term><varname>debug_print_parse</varname> (<type>boolean</type>)
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary><varname>debug_print_parse</varname> configuration parameter</primary>
|
<primary><varname>debug_print_parse</varname> configuration parameter</primary>
|
||||||
@@ -7401,8 +7406,8 @@ local0.* /var/log/postgresql
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
These parameters enable various debugging output to be emitted.
|
These parameters enable various debugging output to be emitted.
|
||||||
When set, they print the resulting parse tree, the query rewriter
|
When set, they print the resulting raw parse tree, the parse tree, the query
|
||||||
output, or the execution plan for each executed query.
|
rewriter output, or the execution plan for each executed query.
|
||||||
These messages are emitted at <literal>LOG</literal> message level, so by
|
These messages are emitted at <literal>LOG</literal> message level, so by
|
||||||
default they will appear in the server log but will not be sent to the
|
default they will appear in the server log but will not be sent to the
|
||||||
client. You can change that by adjusting
|
client. You can change that by adjusting
|
||||||
@@ -7422,7 +7427,8 @@ local0.* /var/log/postgresql
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
When set, <varname>debug_pretty_print</varname> indents the messages
|
When set, <varname>debug_pretty_print</varname> indents the messages
|
||||||
produced by <varname>debug_print_parse</varname>,
|
produced by <varname>debug_print_raw_parse</varname>,
|
||||||
|
<varname>debug_print_parse</varname>,
|
||||||
<varname>debug_print_rewritten</varname>, or
|
<varname>debug_print_rewritten</varname>, or
|
||||||
<varname>debug_print_plan</varname>. This results in more readable
|
<varname>debug_print_plan</varname>. This results in more readable
|
||||||
but much longer output than the <quote>compact</quote> format used when
|
but much longer output than the <quote>compact</quote> format used when
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
<acronym>SQL</acronym> statement where the single parts that it is
|
<acronym>SQL</acronym> statement where the single parts that it is
|
||||||
built from are stored separately. These query trees can be shown
|
built from are stored separately. These query trees can be shown
|
||||||
in the server log if you set the configuration parameters
|
in the server log if you set the configuration parameters
|
||||||
|
<varname>debug_print_raw_parse</varname>,
|
||||||
<varname>debug_print_parse</varname>,
|
<varname>debug_print_parse</varname>,
|
||||||
<varname>debug_print_rewritten</varname>, or
|
<varname>debug_print_rewritten</varname>, or
|
||||||
<varname>debug_print_plan</varname>. The rule actions are also
|
<varname>debug_print_plan</varname>. The rule actions are also
|
||||||
|
@@ -649,6 +649,10 @@ pg_parse_query(const char *query_string)
|
|||||||
|
|
||||||
TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
|
TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
|
||||||
|
|
||||||
|
if (Debug_print_raw_parse)
|
||||||
|
elog_node_display(LOG, "raw parse tree", raw_parsetree_list,
|
||||||
|
Debug_pretty_print);
|
||||||
|
|
||||||
return raw_parsetree_list;
|
return raw_parsetree_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3697,7 +3701,10 @@ set_debug_options(int debug_flag, GucContext context, GucSource source)
|
|||||||
if (debug_flag >= 2)
|
if (debug_flag >= 2)
|
||||||
SetConfigOption("log_statement", "all", context, source);
|
SetConfigOption("log_statement", "all", context, source);
|
||||||
if (debug_flag >= 3)
|
if (debug_flag >= 3)
|
||||||
|
{
|
||||||
|
SetConfigOption("debug_print_raw_parse", "true", context, source);
|
||||||
SetConfigOption("debug_print_parse", "true", context, source);
|
SetConfigOption("debug_print_parse", "true", context, source);
|
||||||
|
}
|
||||||
if (debug_flag >= 4)
|
if (debug_flag >= 4)
|
||||||
SetConfigOption("debug_print_plan", "true", context, source);
|
SetConfigOption("debug_print_plan", "true", context, source);
|
||||||
if (debug_flag >= 5)
|
if (debug_flag >= 5)
|
||||||
|
@@ -414,6 +414,12 @@
|
|||||||
ifdef => 'DEBUG_NODE_TESTS_ENABLED',
|
ifdef => 'DEBUG_NODE_TESTS_ENABLED',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ name => 'debug_print_raw_parse', type => 'bool', context => 'PGC_USERSET', group => 'LOGGING_WHAT',
|
||||||
|
short_desc => 'Logs each query\'s raw parse tree.',
|
||||||
|
variable => 'Debug_print_raw_parse',
|
||||||
|
boot_val => 'false',
|
||||||
|
},
|
||||||
|
|
||||||
{ name => 'debug_print_parse', type => 'bool', context => 'PGC_USERSET', group => 'LOGGING_WHAT',
|
{ name => 'debug_print_parse', type => 'bool', context => 'PGC_USERSET', group => 'LOGGING_WHAT',
|
||||||
short_desc => 'Logs each query\'s parse tree.',
|
short_desc => 'Logs each query\'s parse tree.',
|
||||||
variable => 'Debug_print_parse',
|
variable => 'Debug_print_parse',
|
||||||
|
@@ -507,6 +507,7 @@ bool AllowAlterSystem = true;
|
|||||||
bool log_duration = false;
|
bool log_duration = false;
|
||||||
bool Debug_print_plan = false;
|
bool Debug_print_plan = false;
|
||||||
bool Debug_print_parse = false;
|
bool Debug_print_parse = false;
|
||||||
|
bool Debug_print_raw_parse = false;
|
||||||
bool Debug_print_rewritten = false;
|
bool Debug_print_rewritten = false;
|
||||||
bool Debug_pretty_print = true;
|
bool Debug_pretty_print = true;
|
||||||
|
|
||||||
|
@@ -581,6 +581,7 @@
|
|||||||
|
|
||||||
# - What to Log -
|
# - What to Log -
|
||||||
|
|
||||||
|
#debug_print_raw_parse = off
|
||||||
#debug_print_parse = off
|
#debug_print_parse = off
|
||||||
#debug_print_rewritten = off
|
#debug_print_rewritten = off
|
||||||
#debug_print_plan = off
|
#debug_print_plan = off
|
||||||
|
@@ -247,6 +247,7 @@ typedef enum
|
|||||||
/* GUC vars that are actually defined in guc_tables.c, rather than elsewhere */
|
/* GUC vars that are actually defined in guc_tables.c, rather than elsewhere */
|
||||||
extern PGDLLIMPORT bool Debug_print_plan;
|
extern PGDLLIMPORT bool Debug_print_plan;
|
||||||
extern PGDLLIMPORT bool Debug_print_parse;
|
extern PGDLLIMPORT bool Debug_print_parse;
|
||||||
|
extern PGDLLIMPORT bool Debug_print_raw_parse;
|
||||||
extern PGDLLIMPORT bool Debug_print_rewritten;
|
extern PGDLLIMPORT bool Debug_print_rewritten;
|
||||||
extern PGDLLIMPORT bool Debug_pretty_print;
|
extern PGDLLIMPORT bool Debug_pretty_print;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user