Re: BUG #18247: Integer overflow leads to negative width

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: rekgrpth@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-12-14T10:34:44Z
Lists: pgsql-bugs
On Thu, Dec 14, 2023 at 5:29 PM PG Bug reporting form <
noreply@postgresql.org> wrote:

> EXPLAIN SELECT * FROM t;
>                          QUERY PLAN
> ------------------------------------------------------------
>  Seq Scan on t  (cost=0.00..10.00 rows=1 width=-2113929008)
> (1 row)


Interesting.  In an Assert-enabled build this query will cause the
Assert failure in set_rel_width().

    Assert(tuple_width >= 0);

Can we just error out when an overflow occurs?

Thanks
Richard

Commits

  1. Prevent integer overflow when forming tuple width estimates.

  2. compute_bitmap_pages' loop_count parameter should be double not int.