Re: Non-decimal integer literals - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Non-decimal integer literals
Date
Msg-id CAEZATCU0E8sRPf=P-vqYNoMEn7d-_wsy4jUKVOuoPqjOaoGNhA@mail.gmail.com
Whole thread Raw
In response to Re: Non-decimal integer literals  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: Non-decimal integer literals
List pgsql-hackers
On Tue, 22 Nov 2022 at 13:37, Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:
>
> On 15.11.22 11:31, Peter Eisentraut wrote:
> > On 14.11.22 08:25, John Naylor wrote:
> >> Regarding the patch, it looks good overall. My only suggestion would
> >> be to add a regression test for just below and just above overflow, at
> >> least for int2.
> >
> This was a valuable suggestion, because this found some breakage.  In
> particular, the handling of grammar-level literals that overflow to
> "Float" was not correct.  (The radix prefix was simply stripped and
> forgotten.)  So I added a bunch more tests for this.  Here is a new patch.

Taking a quick look, I noticed that there are no tests for negative
values handled in the parser.

Giving that a spin shows that make_const() fails to correctly identify
the base of negative non-decimal integers in the T_Float case, causing
it to fall through to numeric_in() and fail:

SELECT -0x80000000;

ERROR:  invalid input syntax for type numeric: "-0x80000000"
               ^
Regards,
Dean



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Prefetch the next tuple's memory during seqscans
Next
From: Greg Stark
Date:
Subject: Re: pgsql: Prevent instability in contrib/pageinspect's regression test.