debugging tools inside postgres
debugging tools inside postgres
От:
HuangQi <huangqiyx@gmail.com>
Дата:
Hi,
I'm trying to debug a modification for the query planner. But I found it seems the data structure of my planned query is incorrect. I was trying to print out the data structure by use the "p" command in gdb which is quite inconvenient and takes time. May I know is there any embedded function in postgres to print out the node data structures, or any other plan related data structures? Thanks.
--
Best Regards
Huang Qi Victor
--
Best Regards
Huang Qi Victor
Re: debugging tools inside postgres
От:
Shigeru Hanada <shigeru.hanada@gmail.com>
Дата:
(2011/06/24 15:35), HuangQi wrote: > Hi, > I'm trying to debug a modification for the query planner. But I found it > seems the data structure of my planned query is incorrect. I was trying to > print out the data structure by use the "p" command in gdb which is quite > inconvenient and takes time. May I know is there any embedded function in > postgres to print out the node data structures, or any other plan related > data structures? Thanks. I think nodeToString() would help. This function converts node tree recursively into a string, and it's applicable for any Node-derived object, such as Expr, Var and Const. ex)elog(DEBUG1, "%s", nodeToString(plan)); Regards, -- Shigeru Hanada
Re: debugging tools inside postgres
От:
HuangQi <huangqiyx@gmail.com>
Дата:
2011/6/24 Shigeru Hanada <shigeru.hanada@gmail.com>
I think nodeToString() would help. This function converts node tree(2011/06/24 15:35), HuangQi wrote:
> Hi,
> I'm trying to debug a modification for the query planner. But I found it
> seems the data structure of my planned query is incorrect. I was trying to
> print out the data structure by use the "p" command in gdb which is quite
> inconvenient and takes time. May I know is there any embedded function in
> postgres to print out the node data structures, or any other plan related
> data structures? Thanks.
recursively into a string, and it's applicable for any Node-derived
object, such as Expr, Var and Const.
ex)
elog(DEBUG1, "%s", nodeToString(plan));
Regards,
--
Shigeru Hanada
Hi,
I don't know why but when I am debugging the query evaluation, the elog function can not output to shell.
--
Best Regards
Huang Qi Victor
--
Best Regards
Huang Qi Victor
Re: debugging tools inside postgres
От:
Shigeru Hanada <shigeru.hanada@gmail.com>
Дата:
(2011/06/24 19:14), HuangQi wrote: > 2011/6/24 Shigeru Hanada > >> (2011/06/24 15:35), HuangQi wrote: >> ex) >> elog(DEBUG1, "%s", nodeToString(plan)); > > Hi, > I don't know why but when I am debugging the query evaluation, the elog > function can not output to shell. What kind of tool do you use to execute the query to be evaluated? If you are using an interactive tool such as psql, please check setting of client_min_messages. Otherwise, please check settings of log_destination, logging_collector and log_min_messages to ensure that elog() prints debugging information into your server log file, or stderr of the terminal which has been used to start PostgreSQL server. Regards, -- Shigeru Hanada
Re: debugging tools inside postgres
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Shigeru Hanada writes: > (2011/06/24 15:35), HuangQi wrote: >> I'm trying to debug a modification for the query planner. But I found it >> seems the data structure of my planned query is incorrect. I was trying to >> print out the data structure by use the "p" command in gdb which is quite >> inconvenient and takes time. May I know is there any embedded function in >> postgres to print out the node data structures, or any other plan related >> data structures? Thanks. > I think nodeToString() would help. For interactive use in gdb, I generally do call pprint(..node pointer..) which prints to the postmaster log. regards, tom lane
Re: debugging tools inside postgres
От:
HuangQi <huangqiyx@gmail.com>
Дата:
On 24 June 2011 23:21, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm trying to debug a modification for the query planner. But I found itFor interactive use in gdb, I generally do
>> seems the data structure of my planned query is incorrect. I was trying to
>> print out the data structure by use the "p" command in gdb which is quite
>> inconvenient and takes time. May I know is there any embedded function in
>> postgres to print out the node data structures, or any other plan related
>> data structures? Thanks.
> I think nodeToString() would help.
call pprint(..node pointer..)
which prints to the postmaster log.
regards, tom lane
Thanks, Tom, this call pprint() works very nice.
--
Best Regards
Huang Qi Victor
Re: debugging tools inside postgres
От:
Martijn van Oosterhout <kleptog@svana.org>
Дата:
On Fri, Jun 24, 2011 at 02:35:08PM +0800, HuangQi wrote: > Hi, > I'm trying to debug a modification for the query planner. But I found it > seems the data structure of my planned query is incorrect. I was trying to > print out the data structure by use the "p" command in gdb which is quite > inconvenient and takes time. May I know is there any embedded function in > postgres to print out the node data structures, or any other plan related > data structures? Thanks. I don't know if anyone has done it, but recent versions of gdb apparenly can use python scripts, and use them to dump c++ library structures in readable formats. I guess someone could write some script to make debugging postgresql nicer (pretty printing snapshots, locks, etc). Have a nice day, -- Martijn van Oosterhout http://svana.org/kleptog/ > Patriotism is when love of your own people comes first; nationalism, > when hate for people other than your own comes first. > - Charles de Gaulle