Re: remove redundant check of item pointer

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: remove redundant check of item pointer
Date: 2022-04-28 01:54:10
Message-ID: CAEG8a3LFoXZi5vt5cHmMFHYWomfon514p51g4_S=2DOFLVaZHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

got it, thanks for the explanation.

On Wed, Apr 27, 2022 at 11:34 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Junwang Zhao <zhjwpku(at)gmail(dot)com> writes:
> > In function ItemPointerEquals, the ItemPointerGetBlockNumber
> > already checked the ItemPointer if valid, there is no need
> > to check it again in ItemPointerGetOffset, so use
> > ItemPointerGetOffsetNumberNoCheck instead.
>
> I do not think this change is worth making. The point of
> ItemPointerGetOffsetNumberNoCheck is not to save some cycles,
> it's to be able to fetch the offset field in cases where it might
> validly be zero. The assertion will be compiled out anyway in
> production builds --- and even in assert-enabled builds, I'd kind
> of expect the compiler to optimize away the duplicated tests.
>
> regards, tom lane

--
Regards
Junwang Zhao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2022-04-28 02:27:15 Re: Handle infinite recursion in logical replication setup
Previous Message Andres Freund 2022-04-28 01:31:34 Re: Unstable tests for recovery conflict handling