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-12 08:45:29
Message-ID: CACJufxGU80rKcFw0-4QfHiNTr2h8Aqpvw3WyYfHuertLMUq_-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 11, 2023 at 8:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
>
> I can confirm that all those anomalies are fixed now.
> But new version brings a warning when compiled with gcc:
> arrayfuncs.c:659:9: warning: variable 'prev_tok' is uninitialized when used here [-Wuninitialized]
> if (prev_tok == ATOK_DELIM || nest_level == 0)
> ^~~~~~~~
> arrayfuncs.c:628:3: note: variable 'prev_tok' is declared here
> ArrayToken prev_tok;
> ^
> 1 warning generated.
>
> Also it looks like an updated comment needs fixing/improving:
> /* No array dimensions, so first literal character should be oepn curl-braces */
> (should be an opening brace?)
>

fixed these 2 issues.
--query
SELECT ('{ ' || string_agg(chr((ascii('B') + round(random() * 25)) ::
integer),', ') || ' }')::text[]
FROM generate_series(1,1e6) \watch i=0.1 c=1

After applying the patch, the above query runs slightly faster.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-09-12 08:55:50 RE: pg_upgrade and logical replication
Previous Message Tatsuo Ishii 2023-09-12 08:44:57 Re: Row pattern recognition