Обсуждение: printing raw parse tree

Поиск
Список
Период
Сортировка

printing raw parse tree

От
Tatsuo Ishii
Дата:
Very often I find it is useful to print raw parse trees for debugging
and/or understanding PostgreSQL internals and I personally modify
pg_parse_query() to accomplish it. If this is common among developers,
I would like to post small patches. Opinion?
--
Tatsuo Ishii
SRA OSS, Inc. Japan


Re: printing raw parse tree

От
Tom Lane
Дата:
Tatsuo Ishii <ishii@postgresql.org> writes:
> Very often I find it is useful to print raw parse trees for debugging
> and/or understanding PostgreSQL internals and I personally modify
> pg_parse_query() to accomplish it. If this is common among developers,
> I would like to post small patches. Opinion?

Isn't the post-parse-analysis tree far more interesting?  There's
already debug support for printing that.

Of course, you can call pprint() from anyplace using gdb, so for
occasional debugging needs I think no special code support is needed.
I think what you are proposing is something equivalent to the
debug_print_parse GUC, and I'm not sure it's worth that.
        regards, tom lane


Re: printing raw parse tree

От
Tatsuo Ishii
Дата:
> Isn't the post-parse-analysis tree far more interesting?  There's
> already debug support for printing that.

It's interesting too. But I think compraring raw parse tree and
post-parse-analysis tree is sometimes usefull to understand the source
code.

> Of course, you can call pprint() from anyplace using gdb, so for
> occasional debugging needs I think no special code support is
> needed.  I think what you are proposing is something equivalent to
> the debug_print_parse GUC, and I'm not sure it's worth that.
> regards, tom lane

Yes, that's what I mean. However if I'm the only one who is
interesting in the raw parse tree, I can live with gdb/pprint().

Another issue is, some node types are not supported in outfuncs.c.

WARNING:  could not dump unrecognized node type: 911

I could post patches for this if there's enough interest.
--
Tatsuo Ishii
SRA OSS, Inc. Japan


Re: printing raw parse tree

От
Tom Lane
Дата:
Tatsuo Ishii <ishii@postgresql.org> writes:
> Another issue is, some node types are not supported in outfuncs.c.
> WARNING:  could not dump unrecognized node type: 911

Yeah.  I think there's an unofficial policy for post-analysis parse
trees that we don't bother writing outfuncs for utility-statement
nodes (there are too many of 'em and they're not interesting enough)
but anything that can appear in or under DML commands should be
dumpable.  I'd favor the equivalent rule for raw parse trees --- if
we're missing anything DML-ish let's add it.
        regards, tom lane


Re: printing raw parse tree

От
Rafsun Masud
Дата:
> Yeah.  I think there's an unofficial policy for post-analysis parse
> trees that we don't bother writing outfuncs for utility-statement
> nodes (there are too many of 'em and they're not interesting enough)
> but anything that can appear in or under DML commands should be
> dumpable.  I'd favor the equivalent rule for raw parse trees --- if
> we're missing anything DML-ish let's add it.
>
>             regards, tom lane
Is there a way to make debug_print_parse output in JSON format?
--
Regards,
Rafsun Masud