pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bug in heap_get_root_tuples
4+ messages / 3 participants
[nested] [flat]

* Bug in heap_get_root_tuples
@ 2026-07-15 13:37  Konstantin Knizhnik <knizhnik@garret.ru>
  0 siblings, 1 reply; 4+ messages in thread

From: Konstantin Knizhnik @ 2026-07-15 13:37 UTC (permalink / raw)
  To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>; Peter Geoghegan <pg@bowt.ie>

Commit c7aeb775df895db240dcd6f47242f7e08899adfb contains the following 
change:

-                       /* Sanity check */
-                       if (nextoffnum < FirstOffsetNumber || nextoffnum 
 > maxoff)
+                       /* Sanity check (pure paranoia) */
+                       if (offnum < FirstOffsetNumber)
+                               break;
+
+                       /*
+                        * An offset past the end of page's line pointer 
array is possible
+                        * when the array was truncated
+                        */
+                       if (offnum > maxoff)
                                 break;

                         lp = PageGetItemId(page, nextoffnum);


So it checks `offnum` and uses `nextoffnum`.







^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Bug in heap_get_root_tuples
@ 2026-07-16 00:29  Richard Guo <guofenglinux@gmail.com>
  parent: Konstantin Knizhnik <knizhnik@garret.ru>
  0 siblings, 1 reply; 4+ messages in thread

From: Richard Guo @ 2026-07-16 00:29 UTC (permalink / raw)
  To: Konstantin Knizhnik <knizhnik@garret.ru>; +Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>; Peter Geoghegan <pg@bowt.ie>

On Wed, Jul 15, 2026 at 10:37 PM Konstantin Knizhnik <knizhnik@garret.ru> wrote:
> Commit c7aeb775df895db240dcd6f47242f7e08899adfb contains the following
> change:
>
> -                       /* Sanity check */
> -                       if (nextoffnum < FirstOffsetNumber || nextoffnum
>  > maxoff)
> +                       /* Sanity check (pure paranoia) */
> +                       if (offnum < FirstOffsetNumber)
> +                               break;
> +
> +                       /*
> +                        * An offset past the end of page's line pointer
> array is possible
> +                        * when the array was truncated
> +                        */
> +                       if (offnum > maxoff)
>                                  break;
>
>                          lp = PageGetItemId(page, nextoffnum);
>
>
> So it checks `offnum` and uses `nextoffnum`.

Nice catch.  Seems like a copy/pasted typo.

- Richard





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Bug in heap_get_root_tuples
@ 2026-07-16 01:26  Peter Geoghegan <pg@bowt.ie>
  parent: Richard Guo <guofenglinux@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Peter Geoghegan @ 2026-07-16 01:26 UTC (permalink / raw)
  To: Richard Guo <guofenglinux@gmail.com>; +Cc: Konstantin Knizhnik <knizhnik@garret.ru>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Wed, Jul 15, 2026 at 8:29 PM Richard Guo <guofenglinux@gmail.com> wrote:
> On Wed, Jul 15, 2026 at 10:37 PM Konstantin Knizhnik <knizhnik@garret.ru> wrote:
> > So it checks `offnum` and uses `nextoffnum`.
>
> Nice catch.  Seems like a copy/pasted typo.

Yeah, this is a bug. Will push a fix soon.

-- 
Peter Geoghegan






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Bug in heap_get_root_tuples
@ 2026-07-16 22:57  Peter Geoghegan <pg@bowt.ie>
  parent: Peter Geoghegan <pg@bowt.ie>
  0 siblings, 0 replies; 4+ messages in thread

From: Peter Geoghegan @ 2026-07-16 22:57 UTC (permalink / raw)
  To: Richard Guo <guofenglinux@gmail.com>; +Cc: Konstantin Knizhnik <knizhnik@garret.ru>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>

On Wed, Jul 15, 2026 at 9:26 PM Peter Geoghegan <pg@bowt.ie> wrote:
> Yeah, this is a bug. Will push a fix soon.

Pushed a fix for this just now, all the way back to 15.

Thanks for the report, Konstantin!

-- 
Peter Geoghegan






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-07-16 22:57 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 13:37 Bug in heap_get_root_tuples Konstantin Knizhnik <knizhnik@garret.ru>
2026-07-16 00:29 ` Richard Guo <guofenglinux@gmail.com>
2026-07-16 01:26   ` Peter Geoghegan <pg@bowt.ie>
2026-07-16 22:57     ` Peter Geoghegan <pg@bowt.ie>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox