Re: Raw parse tree is not dumped to log

Tatsuo Ishii <ishii@postgresql.org>

From: Tatsuo Ishii <ishii@postgresql.org>
To: li.evan.chao@gmail.com
Cc: pgsql-hackers@postgresql.org
Date: 2025-08-18T09:13:15Z
Lists: pgsql-hackers
>> --- a/src/backend/tcop/postgres.c
>> +++ b/src/backend/tcop/postgres.c
>> @@ -649,6 +649,10 @@ pg_parse_query(const char *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);
>> +
>>
>> I'm tempted to change "if (Debug_print_raw_parse)" to:
>>
>> 	if (unlikely(Debug_print_raw_parse))
>>
>> But as we have similar if-statements elsewhere
>> (e.g. Debug_print_parse), maybe we should keep it for a separate
>> commit.
>>
> I have added "unlikely" here. For other places, I can use a separate
> commit to add "unlikely".

--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -649,6 +649,10 @@ pg_parse_query(const char *query_string)
 
 	TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
 
+	if (unlikely(Debug_print_parse))

This should be:

+	if (unlikely(Debug_print_raw_parse))

Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp



Commits

  1. Allow to log raw parse tree.