Re: Viewing Parse Tree of a query from front end - Mailing list pgsql-hackers

From Jonathan Gardner
Subject Re: Viewing Parse Tree of a query from front end
Date
Msg-id 200311271009.43600.jgardner@jonathangardner.net
Whole thread Raw
In response to Re: Viewing Parse Tree of a query from front end  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 27 November 2003 1:12 am, Peter Eisentraut wrote:
> Jonathan Gardner writes:
> > I know this sounds kind of silly, but I think I would like to be able
> > to send a query to PostgreSQL, and have it parse it into a tree, and
> > then pass the tree back to me somehow. Of course, I don't want the
> > query to actually execute.
>
> There is a configuration parameter that make each statement print out the
> parse tree.  I think it's show_parse_tree or something like that.

I found it. Thanks for pointing out where it was.

=> SET client_min_messages=debug1;
=> SET debug_print_parse=on;
=> select * from test;
DEBUG:  parse tree:
DETAIL:  {QUERY :commandType 1 :querySource 0 :canSetTag true :utilityStmt
<>
:resultRelation 0 :into <> :hasAggs false :hasSubLinks false :rtable ({RTE
:alias <> :eref {ALIAS :aliasname test :colnames ("id" "test")} :rtekind 0
:relid 17145 :inh true :inFromCl true :checkForRead true :checkForWrite
false
:checkAsUser 0}) :jointree {FROMEXPR :fromlist ({RANGETBLREF :rtindex 1})
:quals <>} :rowMarks () :targetList ({TARGETENTRY :resdom {RESDOM :resno 1
:restype 23 :restypmod -1 :resname id :ressortgroupref 0 :resorigtbl 17145
:resorigcol 1 :resjunk false} :expr {VAR :varno 1 :varattno 1 :vartype 23
:vartypmod -1 :varlevelsup 0 :varnoold 1 :varoattno 1}} {TARGETENTRY :resdom
{RESDOM :resno 2 :restype 16 :restypmod -1 :resname test :ressortgroupref 0
:resorigtbl 17145 :resorigcol 2 :resjunk false} :expr {VAR :varno 1
:varattno
2 :vartype 16 :vartypmod -1 :varlevelsup 0 :varnoold 1 :varoattno 2}})
:groupClause <> :havingQual <> :distinctClause <> :sortClause <>
:limitOffset
<> :limitCount <> :setOperations <> :resultRelations ()}

(and the results follow)

This is seriously cool.

- --
Jonathan Gardner
jgardner@jonathangardner.net
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/xj3mWgwF3QvpWNwRAlCUAKClIhCEkeZZK7r29RHvEnkB8mIX7gCfeMlq
SeM7RD13b9qfhp8wAckZvXU=
=gKET
-----END PGP SIGNATURE-----



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: 7.5 Plans
Next
From: Alvaro Herrera
Date:
Subject: Re: 7.5 Plans