public inbox for [email protected]  
help / color / mirror / Atom feed
From: Paul Jungwirth <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: format_datum debugging function
Date: Fri, 9 Aug 2024 16:04:45 -0700
Message-ID: <[email protected]> (raw)

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              ~{:-)
[email protected]






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: format_datum debugging function
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox