Re: Cleaning up array_in() - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: Cleaning up array_in()
Date
Msg-id 81c6363b-e0d0-c65a-8c91-bb9bfb007672@gmail.com
Whole thread Raw
In response to Re: Cleaning up array_in()  (jian he <jian.universality@gmail.com>)
Responses Re: Cleaning up array_in()
List pgsql-hackers
Hello Jian,

05.09.2023 02:53, jian he wrote:
> On Mon, Sep 4, 2023 at 8:00 AM jian he <jian.universality@gmail.com> wrote:
>> hi.
>> attached v4.
>> v4, 0001 to 0005 is the same as v3 in
>> https://www.postgresql.org/message-id/5859ce4e-2be4-92b0-c85c-e1e24eab57c6%40iki.fi
>>
>> v4-0006 doing some modifications to address the corner case mentioned
>> in the previous thread (like select '{{1,},{1},}'::text[]).
>> also fixed all these FIXME, Heikki mentioned in the code.
>>
>> v4-0007 refactor ReadDimensionInt. to make the array dimension bound
>> variables within the INT_MIN and INT_MAX. so it will make select
>> '[21474836488:21474836489]={1,2}'::int[]; fail.
>
> attached, same as v4, but delete unused variable {nitems_according_to_dims}.

Please look at the differences, I've observed with the latest patches
applied, old vs new behavior:

Case 1:
SELECT '{1,'::integer[];
ERROR:  malformed array literal: "{1,"
LINE 1: SELECT '{1,'::integer[];
                ^
DETAIL:  Unexpected end of input.

vs

ERROR:  malformed array literal: "{1,"
LINE 1: SELECT '{1,'::integer[];
                ^

(no DETAIL)

Case 2:
SELECT '{{},}'::text[];
ERROR:  malformed array literal: "{{},}"
LINE 1: SELECT '{{},}'::text[];
                ^
DETAIL:  Unexpected "}" character

vs
  text
------
  {}
(1 row)

Case 3:
select '{\{}'::text[];
  text
-------
  {"{"}
(1 row)

vs
  text
------
  {""}

Best regards,
Alexander



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Surely this code in setrefs.c is wrong?
Next
From: Tom Lane
Date:
Subject: Re: Inefficiency in parallel pg_restore with many tables