Re: Which parts of src/backend/nodes/print.c are used? - Mailing list pgsql-hackers
From | Paul Jungwirth |
---|---|
Subject | Re: Which parts of src/backend/nodes/print.c are used? |
Date | |
Msg-id | 7e5ddced-fad6-4295-9896-57b100ec17ab@illuminatedcomputing.com Whole thread Raw |
In response to | Re: Which parts of src/backend/nodes/print.c are used? (Tom Lane <tgl@sss.pgh.pa.us>) |
List | pgsql-hackers |
On 12/4/23 05:50, Tom Lane wrote: > Peter Eisentraut <peter@eisentraut.org> writes: >> src/backend/nodes/print.c contains a number of functions that print node >> types, mostly to stdout. Most of these are not actually used anywhere >> in the code. Are they meant to be inserted into the code ad hoc for >> debugging? Is anyone using these? > > Personally, I use pprint() a lot. (I invoke it manually from gdb and > then look into the postmaster log for results.) Its cousins such as > format_node_dump look like they were added by people with slightly > different tastes in output format, so they probably have a > constituency somewhere. > > I tend to agree that print_rt() and the other tree-printing routines > below it (down to, but not including, print_slot) are not as useful > as invoking the outfuncs.c code; but others might think differently. > Sometimes you don't want all the gory detail. I've wondered about these functions for years. I use pprint a lot, and I've wanted to use print_slot/print_rt/print_tl (especially print_slot), but they never seemed to do anything. For instance debugging `SELECT 1;`: (gdb) b ExecResult Breakpoint 1 at 0x5fcc25f1ffcb: file nodeResult.c, line 68. (gdb) c Continuing. Breakpoint 1, ExecResult (pstate=0x5fcc285272f8) at nodeResult.c:68 68 { (gdb) call print_rt(((PlannedStmt *)pstate->plan)->rtable) (gdb) call print_slot(pstate->ps_ResultTupleSlot) (gdb) Even with log_min_messages and client_min_messages set to DEBUG5, nothing appears in psql or the log or gdb. How are you supposed to use these functions? Or if you want a real table, I still see no output after `ExecScanFetch` with: create table s(i) as select generate_series(1,10); select i from s; I even tried dup'ing the backend's stdout to a file, but still got nothing: (gdb) call creat("/tmp/pgout", 0600) $1 = 103 (gdb) call dup2(103, 1) 'dup2' has unknown return type; cast the call to its declared return type (gdb) call (int)dup2(103, 1) $2 = 1 (gdb) b ExecScanFetch Breakpoint 1 at 0x5fcc25ef026e: file execScan.c, line 37. (gdb) c Continuing. Breakpoint 1, ExecScanFetch (node=node@entry=0x5fcc2852d348, accessMtd=accessMtd@entry=0x5fcc25f20b74 <SeqNext>, recheckMtd=recheckMtd@entry=0x5fcc25f20b28 <SeqRecheck>) at execScan.c:37 37 { (gdb) fin Run till exit from #0 ExecScanFetch (node=node@entry=0x5fcc2852d348, accessMtd=accessMtd@entry=0x5fcc25f20b74 <SeqNext>, recheckMtd=recheckMtd@entry=0x5fcc25f20b28 <SeqRecheck>) at execScan.c:37 0x00005fcc25ef044a in ExecScan (node=0x5fcc2852d348, accessMtd=accessMtd@entry=0x5fcc25f20b74 <SeqNext>, recheckMtd=recheckMtd@entry=0x5fcc25f20b28 <SeqRecheck>) at execScan.c:180 180 return ExecScanFetch(node, accessMtd, recheckMtd); Value returned is $3 = (TupleTableSlot *) 0x5fcc2852d538 (gdb) call print_slot($3) (gdb) Yours, -- Paul ~{:-) pj@illuminatedcomputing.com
pgsql-hackers by date: