Re: Remove dependence on integer wrapping - Mailing list pgsql-hackers

From Joseph Koshakow
Subject Re: Remove dependence on integer wrapping
Date
Msg-id CAAvxfHeg0En5VV_9pjoHgd0kerK7REL84XEiS6=PUDOSKwx9rg@mail.gmail.com
Whole thread Raw
In response to Re: Remove dependence on integer wrapping  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Remove dependence on integer wrapping
List pgsql-hackers
On Mon, Jul 22, 2024 at 6:27 PM Nathan Bossart <nathandbossart@gmail.com> wrote:
>
> Actually, I think my concerns about prohibiting more than necessary go away
> if we do the subtraction first.  If "upperIndx[i] - lowerIndx[i]"
> overflows, we know the array size is too big.  Similarly, if adding one to
> that result overflows, we again know the the array size is too big.  This
> appears to be how the surrounding code handles this problem (e.g.,
> ReadArrayDimensions()).  Thoughts?

I like that approach! It won't reject any valid bounds and is
consistent with the surrounding code. Also statements of the following
format will maintain the same error messages they had previously:

    # INSERT INTO arroverflowtest(i[2147483646:2147483647]) VALUES ('{1,2}');
    ERROR:  array lower bound is too large: 2147483646

The specific bug that this patch fixes is preventing the following
statement:

    # INSERT INTO arroverflowtest(i[-2147483648:2147483647]) VALUES ('{1}');

So we may want to add that test back in.

Thanks,
Joseph Koshakow

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] GROUP BY ALL
Next
From: Michael Paquier
Date:
Subject: Re: pg_upgrade and logical replication