Re: concerns around pg_lsn

From: Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: concerns around pg_lsn
Date: 2019-08-01 08:40:08
Message-ID: CAOgcT0OLnNo0p1wBiL3+F1Jrk2Y9N=nhE_YTmz_xXCJsmOZd+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael,

On Thu, Aug 1, 2019 at 1:51 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:

> On Thu, Aug 01, 2019 at 12:39:26PM +0530, Jeevan Ladhe wrote:
> > Here is a patch that takes care of addressing the flag issue including
> > pg_lsn_in_internal() and others.
>
> Your original patch for pg_lsn_in_internal() was right IMO, and the
> new one is not. In the numeric and float code paths, we have this
> kind of pattern:
> if (have_error)
> {
> *have_error = true;
> return;
> }
> else
> elog(ERROR, "Boom. Show is over.");
>
> But the pg_lsn.c portion does not have that. have_error cannot be
> NULL or the caller may fall into the trap of setting it to NULL and
> miss some errors at parsing-time. So I think that keeping the
> assertion on (have_error != NULL) is necessary.
>

Thanks for your concern.

In pg_lsn_in_internal() changes, the caller will get the invalid lsn
in case there are errors:

{code}
if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/')
{
if (have_error)
*have_error = true;

return InvalidXLogRecPtr;
}
{code}

The only thing is that, if the caller cares about the error during
the parsing or not. For some callers just making sure if the given
string was valid lsn or not might be ok, and the return value
'InvalidXLogRecPtr' will tell that. That caller may not unnecessary
declare the flag and pass a pointer to it.

Regards,
Jeevan Ladhe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Takuma Hoshiai 2019-08-01 08:42:09 Re: Proposal to suppress errors thrown by to_reg*()
Previous Message Thomas Munro 2019-08-01 08:34:19 Re: range_agg