format_datum debugging function - Mailing list pgsql-hackers

From Paul Jungwirth
Subject format_datum debugging function
Date
Msg-id 286814e4-46d4-44d6-be45-c2ee979021e1@illuminatedcomputing.com
Whole thread Raw
Responses Re: format_datum debugging function
List pgsql-hackers
Hi Hackers,

Often in a debugger I've wanted to way to print Datums, in particular non-trivial ones like range 
types. This came up a lot when I was working on multiranges, and I've wished for it lately while 
working on UPDATE/DELETE FOR PORTION OF. But all the obvious approaches are inlined functions or 
preprocessor macros, so they aren't available. Usually I wind up giving up on gdb and adding elog 
statements. Once or twice I've copy/pasted from the three or four levels of nested macros to make 
gdb do what I wanted, but it's a pain.

I assumed printing a Datum was easy, and I was the only one who didn't know how to do it. But 
perhaps not. The conversation about print.c [1] made me think I should propose a way to make it 
easier. This function takes a Datum and the appropriate out function, and returns a char *. So you 
can do this:

(gdb) call format_datum(range_out, $1)
$2 = 0x59162692d938 "[1,4)"

I assume a patch like this doesn't need documentation. Does it need a test? Anything else?

[1] https://www.postgresql.org/message-id/flat/7d023c20-6679-44bd-b5f7-44106659bd5a%40eisentraut.org

Yours,

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: is_superuser versus set_config_option's parallelism check
Next
From: Alvaro Herrera
Date:
Subject: Re: libpq: Fix lots of discrepancies in PQtrace