Re: concerns around pg_lsn - Mailing list pgsql-hackers

From Jeevan Ladhe
Subject Re: concerns around pg_lsn
Date
Msg-id CAOgcT0NSs2yO56kGf1qfVvXSS9KkK3G4R_dZKbPHeMOguxCD5w@mail.gmail.com
Whole thread Raw
In response to Re: concerns around pg_lsn  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: concerns around pg_lsn
List pgsql-hackers


On Tue, Jul 30, 2019 at 6:06 PM Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Jul 30, 2019 at 4:52 AM Jeevan Ladhe
<jeevan.ladhe@enterprisedb.com> wrote:
> My only concern was something that we internally treat as invalid, why do
> we allow, that as a valid value for that type. While I am not trying to
> reinvent the wheel here, I am trying to understand if there had been any
> idea behind this and I am missing it.

Well, the word "invalid" can mean more than one thing.  Something can
be valid or invalid depending on context.  I can't have -2 dollars in
my wallet, but I could have -2 dollars in my bank account, because the
bank will allow me to pay out slightly more money than I actually have
on the idea that I will pay them back later (and with interest!).  So
as an amount of money in my wallet, -2 is invalid, but as an amount of
money in my bank account, it is valid.

0/0 is not a valid LSN in the sense that (in current releases) we
never write a WAL record there, but it's OK to compute with it.
Subtracting '0/0'::pg_lsn seems useful as a way to convert an LSN to
an absolute byte-index in the WAL stream.

Thanks Robert for such a nice and detailed explanation.
I now understand why LSN '0/0' can still be useful.

Regards,
Jeevan Ladhe

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: how to run encoding-dependent tests by default
Next
From: Etsuro Fujita
Date:
Subject: Re: partition routing layering in nodeModifyTable.c