Обсуждение: Debugging methods

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

Debugging methods

От
M2Y
Дата:
Hello,

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. I will go through code but I would like to know any
debugging methods available to understand what happens for a given
query.

I have searched in the net and I am unable to find them. Sorry if it
is available somewhere and I am asking again.

Thanks,
Srinivas


Re: Debugging methods

От
Markus Wanner
Дата:
Hi,

M2Y wrote:
> I am a beginner to Postgres and I am going through code. I would like
> to know the debugging methods used in development.

Try ./configure with '--enable-debug' and '--enable-cassert', as 
outlined in the developer's FAQ [1], where you certainly find more 
information as well. Then run the postmaster with '-A1 -d5'

Regards

Markus Wanner

[1]: http://wiki.postgresql.org/wiki/Developer_FAQ


Re: Debugging methods

От
Tom Lane
Дата:
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