Re: [HACKERS] debugging tools inside postgres

2011-06-25 Thread Martijn van Oosterhout
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   klep...@svana.org   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


signature.asc
Description: Digital signature


Re: [HACKERS] debugging tools inside postgres

2011-06-24 Thread Shigeru Hanada
(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

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


Re: [HACKERS] debugging tools inside postgres

2011-06-24 Thread HuangQi
2011/6/24 Shigeru Hanada shigeru.han...@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


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


Re: [HACKERS] debugging tools inside postgres

2011-06-24 Thread Shigeru Hanada
(2011/06/24 19:14), HuangQi wrote:
 2011/6/24 Shigeru Hanadashigeru.han...@gmail.com
 
 (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

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


Re: [HACKERS] debugging tools inside postgres

2011-06-24 Thread Tom Lane
Shigeru Hanada shigeru.han...@gmail.com 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

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


Re: [HACKERS] debugging tools inside postgres

2011-06-24 Thread HuangQi
On 24 June 2011 23:21, Tom Lane t...@sss.pgh.pa.us wrote:

 Shigeru Hanada shigeru.han...@gmail.com 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



Thanks, Tom, this call pprint() works very nice.
-- 
Best Regards
Huang Qi Victor