Re: BUG #17128: minimum numeric 'integer' is -2147483647 not -2147483648 as documented

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: kjs(at)teews(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17128: minimum numeric 'integer' is -2147483647 not -2147483648 as documented
Date: 2021-07-30 17:56:30
Message-ID: CAFBsxsFZvq=z75Y+bMZQdZ5HbMxdjQ2fhSs=Y+nNb5tt9taPdw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Jul 30, 2021 at 11:14 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> John Naylor <john(dot)naylor(at)enterprisedb(dot)com> writes:
> > On Fri, Jul 30, 2021 at 7:53 AM PG Bug reporting form <
> > noreply(at)postgresql(dot)org> wrote:
> >> - if (l < -INT_MAX || l > INT_MAX)
> >> + if (l < (-INT_MAX - 1) || l > INT_MAX)
>
> > Yeah, that looks like it should be INT_MIN instead. I'll see about
making
> > that happen. Thanks for the report!
>
> The whole stanza perhaps ought to be within
>
> #if SIZEOF_LONG > SIZEOF_INT
>
> otherwise some compilers will bleat about useless tests.

Here's a draft fix for master, with regression tests. It will need a bit of
massaging for the back branches -- the problem goes back at least to 9.6.

--
John Naylor
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
v1-0001-Fix-range-check-in-ECPG-numeric-to-int-conversion.patch application/x-patch 5.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Noah Misch 2021-07-30 18:41:26 Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Previous Message Tom Lane 2021-07-30 15:14:32 Re: BUG #17128: minimum numeric 'integer' is -2147483647 not -2147483648 as documented