debug_print_parse

A GUC controlling whether the parse tree of a query is logged

debug_print_parse is a GUC controlling whether the parse tree of a query is logged.

debug_print_parse was added in PostgreSQL 7.1 (commit 6a68f426).

Default

Default value for debug_print_parse is: off

Notes

As far as it's possible to ascertain, debug_print_parse was added in feature commit (commit 6a68f426), in which PostgreSQL's Grand Unified Configuration system was introduced.

Examples

Sample output with an arbitrary query (here an INSERT into a partitioned table):

[2020-08-16 14:32:05 UTC] psql postgres postgres LOG:  00000: statement: INSERT INTO part_parent VALUES(1,'foo')  RETURNING *;
[2020-08-16 14:32:05 UTC] psql postgres postgres LOCATION:  exec_simple_query, postgres.c:1044
[2020-08-16 14:32:05 UTC] psql postgres postgres LOG:  00000: parse tree:
[2020-08-16 14:32:05 UTC] psql postgres postgres DETAIL:     {QUERY 
	   :commandType 3 
	   :querySource 0 
	   :canSetTag true 
	   :utilityStmt <> 
	   :resultRelation 1 
	   :hasAggs false 
	   :hasWindowFuncs false 
	   :hasTargetSRFs false 
	   :hasSubLinks false 
	   :hasDistinctOn false 
	   :hasRecursive false 
	   :hasModifyingCTE false 
	   :hasForUpdate false 
	   :hasRowSecurity false 
	   :cteList <> 
	   :rtable (
	      {RTE 
	      :alias <> 
	      :eref 
	         {ALIAS 
	         :aliasname part_parent 
	         :colnames ("id" "val")
	         }
	      :rtekind 0 
	      :relid 16490 
	      :relkind p 
	      :rellockmode 3 
	      :tablesample <> 
	      :lateral false 
	      :inh false 
	      :inFromCl false 
	      :requiredPerms 3 
	      :checkAsUser 0 
	      :selectedCols (b 8 9)
	      :insertedCols (b 8 9)
	      :updatedCols (b)
	      :extraUpdatedCols (b)
	      :securityQuals <>
	      }
	   )
	   :jointree 
	      {FROMEXPR 
	      :fromlist <> 
	      :quals <>
	      }
	   :targetList (
	      {TARGETENTRY 
	      :expr 
	         {CONST 
	         :consttype 23 
	         :consttypmod -1 
	         :constcollid 0 
	         :constlen 4 
	         :constbyval true 
	         :constisnull false 
	         :location 31 
	         :constvalue 4 [ 1 0 0 0 0 0 0 0 ]
	         }
	      :resno 1 
	      :resname id 
	      :ressortgroupref 0 
	      :resorigtbl 0 
	      :resorigcol 0 
	      :resjunk false
	      }
	      {TARGETENTRY 
	      :expr 
	         {FUNCEXPR 
	         :funcid 669 
	         :funcresulttype 1043 
	         :funcretset false 
	         :funcvariadic false 
	         :funcformat 2 
	         :funccollid 100 
	         :inputcollid 100 
	         :args (
	            {CONST 
	            :consttype 1043 
	            :consttypmod -1 
	            :constcollid 100 
	            :constlen -1 
	            :constbyval false 
	            :constisnull false 
	            :location 33 
	            :constvalue 7 [ 28 0 0 0 102 111 111 ]
	            }
	            {CONST 
	            :consttype 23 
	            :consttypmod -1 
	            :constcollid 0 
	            :constlen 4 
	            :constbyval true 
	            :constisnull false 
	            :location -1 
	            :constvalue 4 [ 36 0 0 0 0 0 0 0 ]
	            }
	            {CONST 
	            :consttype 16 
	            :consttypmod -1 
	            :constcollid 0 
	            :constlen 1 
	            :constbyval true 
	            :constisnull false 
	            :location -1 
	            :constvalue 1 [ 0 0 0 0 0 0 0 0 ]
	            }
	         )
	         :location -1
	         }
	      :resno 2 
	      :resname val 
	      :ressortgroupref 0 
	      :resorigtbl 0 
	      :resorigcol 0 
	      :resjunk false
	      }
	   )
	   :override 0 
	   :onConflict <> 
	   :returningList (
	      {TARGETENTRY 
	      :expr 
	         {VAR 
	         :varno 1 
	         :varattno 1 
	         :vartype 23 
	         :vartypmod -1 
	         :varcollid 0 
	         :varlevelsup 0 
	         :varnosyn 1 
	         :varattnosyn 1 
	         :location 51
	         }
	      :resno 1 
	      :resname id 
	      :ressortgroupref 0 
	      :resorigtbl 16490 
	      :resorigcol 1 
	      :resjunk false
	      }
	      {TARGETENTRY 
	      :expr 
	         {VAR 
	         :varno 1 
	         :varattno 2 
	         :vartype 1043 
	         :vartypmod 36 
	         :varcollid 100 
	         :varlevelsup 0 
	         :varnosyn 1 
	         :varattnosyn 2 
	         :location 51
	         }
	      :resno 2 
	      :resname val 
	      :ressortgroupref 0 
	      :resorigtbl 16490 
	      :resorigcol 2 
	      :resjunk false
	      }
	   )
	   :groupClause <> 
	   :groupingSets <> 
	   :havingQual <> 
	   :windowClause <> 
	   :distinctClause <> 
	   :sortClause <> 
	   :limitOffset <> 
	   :limitCount <> 
	   :limitOption 0 
	   :rowMarks <> 
	   :setOperations <> 
	   :constraintDeps <> 
	   :withCheckOptions <> 
	   :stmt_location 0 
	   :stmt_len 52
	   }
	
[2020-08-16 14:32:05 UTC] psql postgres postgres LOCATION:  elog_node_display, print.c:85

Categories

GUC configuration item, Logging, Planner, PostgreSQL internals

See also

debug_print_rewritten, debug_print_plan, debug_pretty_print