Re: Printing LSN made easy - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: Printing LSN made easy
Date
Msg-id CAGEoWWS0Qa0R20sjfU2zotTELrGZCEtBgiPO4116p0srbH1c_A@mail.gmail.com
Whole thread Raw
In response to Re: Printing LSN made easy  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: Printing LSN made easy  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers


On Wed, Jan 20, 2021 at 11:55 AM Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote:
On 2020-11-27 11:40, Ashutosh Bapat wrote:
> The solution seems to be simple though. In the attached patch, I have
> added two macros
> #define LSN_FORMAT "%X/%X"
> #define LSN_FORMAT_ARG(lsn) (uint32) ((lsn) >> 32), (uint32) (lsn)
>
> which can be used instead.

It looks like we are not getting any consensus on this approach.  One
reduced version I would consider is just the second part, so you'd write
something like

     snprintf(lsnchar, sizeof(lsnchar), "%X/%X",
              LSN_FORMAT_ARGS(lsn));

This would still reduce notational complexity quite a bit but avoid any
funny business with the format strings.

Thanks for looking into this. I would like to keep both the LSN_FORMAT and LSN_FORMAT_ARGS but with a note that the first can not be used in elog() or in messages which require localization. We have many other places doing snprintf() and such stuff, which can use LSN_FORMAT. If we do so, the functions to output string representation will not be needed so they can be removed.
 
--
Best Wishes,
Ashutosh

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Discarding DISCARD ALL
Next
From: "Wesley Aptekar-Cassels"
Date:
Subject: Getting column names/types from select query?