Re: Remove dependence on integer wrapping

From: Joseph Koshakow <koshy44(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Remove dependence on integer wrapping
Date: 2024-07-23 21:41:18
Message-ID: CAAvxfHeOdkaQXoca3W54=RZ6opCWLzqgmDM6s8GrUxKG1Tk+_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 22, 2024 at 6:07 PM Matthew Kim <matthewkmkim(at)gmail(dot)com> wrote:
>
> On Mon, Jul 22, 2024 at 5:52 PM Alexander Lakhin <exclusion(at)gmail(dot)com>
wrote:
>
>> Also there are several trap-producing cases with date types:
>> SELECT to_date('100000000', 'CC');
>
> Hi, I’ve attached a patch that fixes the to_date() overflow. Patches 1
through 3 remain unchanged.

Thanks for the contribution Mattew!

On Tue, Jul 23, 2024 at 2:14 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Tue, Jul 23, 2024 at 6:56 AM Joseph Koshakow <koshy44(at)gmail(dot)com> wrote:
>>
>> 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.
>>
> I agree with you.

I've updated the patch to add this test back in.

> also v13-0003-Remove-dependence-on-integer-wrapping-for-jsonb.patch
> in setPathArray we change to can
>
> if (idx == PG_INT32_MIN || -idx > nelems)
> {
> /*
> * If asked to keep elements position consistent, it's not
allowed
> * to prepend the array.
> */
> if (op_type & JB_PATH_CONSISTENT_POSITION)
> ereport(ERROR,
> (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
> errmsg("path element at position %d is out of
> range: %d",
> level + 1, idx)));
> idx = PG_INT32_MIN;
> }

Done in the attached patch.

Attachment Content-Type Size
v15-0001-Remove-dependence-on-integer-wrapping.patch text/x-patch 13.5 KB
v15-0003-Remove-dependence-on-integer-wrapping-for-jsonb.patch text/x-patch 2.7 KB
v15-0004-Handle-overflows-in-do_to_timestamp.patch text/x-patch 3.1 KB
v15-0002-Remove-overflow-from-array_set_slice.patch text/x-patch 2.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2024-07-23 21:41:28 Re: proposal: schema variables
Previous Message Tom Lane 2024-07-23 21:11:25 Re: [18] Policy on IMMUTABLE functions and Unicode updates