Re: Print pg_lsn as a number? - Mailing list pgsql-general

From Michael Paquier
Subject Re: Print pg_lsn as a number?
Date
Msg-id 20180613001821.GC3138@paquier.xyz
Whole thread Raw
In response to Re: Print pg_lsn as a number?  (Andres Freund <andres@anarazel.de>)
Responses Re: Print pg_lsn as a number?  (Andres Freund <andres@anarazel.de>)
List pgsql-general
On Tue, Jun 12, 2018 at 10:39:43AM -0700, Andres Freund wrote:
> On 2018-06-12 09:31:49 -0700, Scott Stroupe wrote:
>> According to the documentation[1], pg_lsn is a 64-bit integer that's
>> printed as two hex numbers separated by a slash, e.g. 68/1225BB70. Is
>> there a way to get the 64-bit integer in a common numeric
>> representation instead of the peculiar hex-slash-hex representation?
>
> What do you want to do with the LSN?

While fixing the slot advance stuff, I would have liked to get an
automatic test able to reproduce the crash where the slot is first
advanced at a page boundary, and then again moved forward.  However it
happens that it is not that easy to do so, so I would be rather
supportive to at least the following operations:
pg_lsn + numeric = pg_lsn.
pg_lsn % numeric = numeric.

We map pg_wal_lsn_diff result to a numeric, so that could make sense to
use numeric as well here, which is not the greatest choice by the way as
that's an int64 internally, but that's more portable for any
(unlikely-to-happen) future changes.

Using the segment size value in pg_settings, you could also advance the
LSN worth a full segment for example...
--
Michael

Attachment

pgsql-general by date:

Previous
From: Jerry Sievers
Date:
Subject: Re: pg_upgrade 10.2
Next
From: Andres Freund
Date:
Subject: Re: Print pg_lsn as a number?