Re: Cleaning up array_in()
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, Tom Lane <tgl@sss.pgh.pa.us>, Nikhil Benesch <nikhil.benesch@gmail.com>,
Nathan Bossart <nathandbossart@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2023-09-12T08:45:29Z
Lists: pgsql-hackers
Attachments
- v7-0003-Re-indent-ArrayCount.patch (text/x-patch) patch v7-0003
- v7-0005-Determine-array-dimensions-and-parse-the-elements.patch (text/x-patch) patch v7-0005
- v7-0001-Simplify-and-speed-up-ReadArrayStr.patch (text/x-patch) patch v7-0001
- v7-0004-Extract-loop-to-read-array-dimensions-to-subrouti.patch (text/x-patch) patch v7-0004
- v7-0002-Rewrite-ArrayCount-to-make-dimensionality-checks-.patch (text/x-patch) patch v7-0002
- v7-0006-refactor-ReadDimensionInt.patch (text/x-patch) patch v7-0006
- v7-0007-refactor-ReadArrayStr.patch (text/x-patch) patch v7-0007
On Mon, Sep 11, 2023 at 8:00 PM Alexander Lakhin <exclusion@gmail.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.
Commits
-
Don't specify number of dimensions in cases where we don't know it.
- 8d5573b92e66 17.0 landed
-
Improve readability and error detection of array_in().
- 83472de606db 17.0 landed
-
Add trailing commas to enum definitions
- 611806cd726f 17.0 cited