Re: Cleaning up array_in()

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Nikhil Benesch <nikhil(dot)benesch(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Cleaning up array_in()
Date: 2023-09-11 05:26:16
Message-ID: CACJufxEv1GQ600VvTesx-E3Xvy87ZguqAjjstcNu8nPvVSmeHQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Sep 10, 2023 at 6:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
> 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

hi.
Thanks for reviewing it.

> DETAIL: Unexpected end of input.
In many cases, ending errors will happen, so I consolidate it.

SELECT '{{},}'::text[];
solved by tracking current token type and previous token type.

select '{\{}'::text[];
solved by update dstendptr.

attached.

Attachment Content-Type Size
v6-0001-Simplify-and-speed-up-ReadArrayStr.patch application/x-patch 8.1 KB
v6-0002-Rewrite-ArrayCount-to-make-dimensionality-checks-.patch application/x-patch 20.5 KB
v6-0004-Extract-loop-to-read-array-dimensions-to-subrouti.patch application/x-patch 8.2 KB
v6-0003-Re-indent-ArrayCount.patch application/x-patch 10.7 KB
v6-0005-Determine-array-dimensions-and-parse-the-elements.patch application/x-patch 38.0 KB
v6-0006-refactor-ReadDimensionInt.patch application/x-patch 5.5 KB
v6-0007-refactor-ReadArrayStr.patch application/x-patch 5.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message bt23nguyent 2023-09-11 05:42:16 Re: pg_logical_emit_message() misses a XLogFlush()
Previous Message Dilip Kumar 2023-09-11 05:09:03 Re: [PoC] pg_upgrade: allow to upgrade publisher node