Re: Non-decimal integer literals

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, 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-29 20:22:25
Message-ID: CAApHDvqPHHxbXmqpvzCbQeSmhxYEgbnNTfXt=kA=aK4A3TtTQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 29 Nov 2022 at 03:00, Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> Fixed in new patch.

There seems to be a small bug in the pg_strtointXX functions in the
code that checks that there's at least 1 digit. This causes 0x to be
a valid representation of zero. That does not seem to be allowed by
the parser, so I think we should likely reject it in COPY too.

-- Does not work.
postgres=# select 0x + 1;
ERROR: invalid hexadecimal integer at or near "0x"
LINE 1: select 0x + 1;

postgres=# create table a (a int);
CREATE TABLE

-- probably shouldn't work
postgres=# copy a from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 0x
>> \.
COPY 1

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2022-11-29 20:32:34 Re: User functions for building SCRAM secrets
Previous Message Jeff Davis 2022-11-29 20:21:07 Re: Collation version tracking for macOS