Thursday, September 4, 2008

Re: [HACKERS] Debugging methods

M2Y <mailtoyahoo@gmail.com> writes:
> I am a beginner to Postgres and I am going through code. I would like
> to know the debugging methods used in development.

> Some of my requirements are; for a given query, how parse structures
> are created in pg_parse_query, how they are analyzed and rewritten in
> pg_analyze_and_rewrite and how the final plan is created in
> pg_plan_queries.

What I tend to do when trying to debug those areas is to set breakpoints
at interesting places with gdb, and then use commands like
"call pprint(node_pointer)" to dump the contents of specific parse or
plan trees to the postmaster log. The reason that outfuncs.c supports
so many node types (many that can't ever appear in stored rules) is
exactly to make it useful for examining internal data structures this
way.

Another possibility is to turn on debug_print_plan and so on, but those
settings only show you the finished results of parsing or planning,
which isn't real helpful for understanding how the code gets from point
A to point B.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

No comments: