Re: Add a bound check to TidRangeEval

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add a bound check to TidRangeEval
Date: 2025-06-14 04:10:32
Message-ID: CAEG8a3J8LygFptwhJa6pMcAk2JQ+XBGuyeZ6XMvUcvnEVOY6zg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi David,

On Sat, Jun 14, 2025 at 11:27 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Wed, 11 Jun 2025 at 14:26, Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
> > This is not a common case, it's just a corner case while
> > playing around the TidRangeScan.
> >
> > I'm not saying this is an optimization, it just makes me a little
> > confused when I see the lowerBound > upperBound and
> > it still returns true.
> >
> > The comments say "Returns true if it's possible for the
> > range to contain tuples." This seems not fully accurate?
>
> The word "possible" there is meant to convey that false negatives are
> *not* ok, but false positives are fine. I'm certainly open to making
> the comment better if that's not clear.
>
> How about adding "We don't bother validating that trss_mintid is less
> than or equal to trss_maxtid, as the scan_set_tidrange() table AM
> function will detect that."

Sounds good to me. This will naturally direct readers to the
comments in scan_set_tidrange.

>
> The scan_set_tidrange function does document that it's the
> implementation's responsibility to check this, as the comment in the
> declaration of struct TableAmRoutine reads:
>
> * Implementations of scan_set_tidrange must themselves handle
> * ItemPointers of any value. i.e, they must handle each of the following:
> *
> * 1) mintid or maxtid is beyond the end of the table; and
> * 2) mintid is above maxtid; and
> * 3) item offset for mintid or maxtid is beyond the maximum offset
> * allowed by the AM.
>
> So I'm not keen to add code to TidRangeEval to check for this as it
> would result in additional overhead for valid usages of TID Range
> scans.

Agree, thanks for the explanation.

>
> David

--
Regards
Junwang Zhao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-06-14 04:46:04 Re: Logical Replication slot disappeared after promote Standby
Previous Message Andy Fan 2025-06-14 03:33:25 Re: Expression push down from Join Node to below node.