Re: Non-decimal integer literals

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Non-decimal integer literals
Date: 2022-11-23 16:25:50
Message-ID: CAEZATCU0E8sRPf=P-vqYNoMEn7d-_wsy4jUKVOuoPqjOaoGNhA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 22 Nov 2022 at 13:37, Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2022-11-23 16:58:41 Re: pgsql: Prevent instability in contrib/pageinspect's regression test.
Previous Message Bruce Momjian 2022-11-23 16:14:51 Re: Prefetch the next tuple's memory during seqscans