Re: general purpose array_sort
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Junwang Zhao <zhjwpku@gmail.com>
Cc: jian he <jian.universality@gmail.com>,
Michael Paquier <michael@paquier.xyz>,
Aleksander Alekseev <aleksander@timescale.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
"David G. Johnston" <david.g.johnston@gmail.com>,
Amit Langote <amitlangote09@gmail.com>,
"andreas@proxel.se" <andreas@proxel.se>,
Robert Haas <robertmhaas@gmail.com>
Date: 2025-03-31T17:11:58Z
Lists: pgsql-hackers
Attachments
- v19-0001-Introduce-a-SQL-callable-function-array_sort-any.patch (text/x-diff) patch v19-0001
- v19-0002-Add-pg_type.typarray-to-the-typcache-s-collectio.patch (text/x-diff) patch v19-0002
Junwang Zhao <zhjwpku@gmail.com> writes: > On Mon, Mar 31, 2025 at 5:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> In v18, it's somewhat annoying that the typcache doesn't cache >> the typarray field; we would not need a separate get_array_type() >> lookup if it did. I doubt there is any real reason for that except >> that pg_type.typarray didn't exist when the typcache was invented. >> So I'm tempted to add it. But I looked at existing callers of >> get_array_type() and none of them are adjacent to typcache lookups, >> so only array_sort would be helped immediately. I left it alone >> for the moment; wonder if anyone else has an opinion? > The need for `elmtyp` and `array_type` here because a column can > have arrays with varying dimensions. Maybe other callers don't share > this behavior? Maybe. I think some of what's going on here is that because for a long time we only had pg_type.typelem and not pg_type.typarray, code was written to not need to look up the array type if at all possible. So there are simply not that many users. Anyway it seems really cheap to add this field to the typcache now. Attached 0001 is the same as v18, and then 0002 is the proposed addition to typcache. regards, tom lane
Commits
-
Introduce a SQL-callable function array_sort(anyarray).
- 6c12ae09f5a5 18.0 landed
-
Fix ARRAY_SUBLINK and ARRAY[] for int2vector and oidvector input.
- 4618045bee4a 18.0 cited
-
Re-implement the ereport() macro using __VA_ARGS__.
- e3a87b4991cc 13.0 cited