Introduce a SQL-callable function array_sort(anyarray).
Tom Lane <tgl@sss.pgh.pa.us>
Introduce a SQL-callable function array_sort(anyarray). Create a function that will sort the elements of an array according to the element type's sort order. If the array has more than one dimension, the sub-arrays of the first dimension are sorted per normal array-comparison rules, leaving their contents alone. In support of this, add pg_type.typarray to the set of fields cached by the typcache. Author: Junwang Zhao <zhjwpku@gmail.com> Co-authored-by: Jian He <jian.universality@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://postgr.es/m/CAEG8a3J41a4dpw_-F94fF-JPRXYxw-GfsgoGotKcjs9LVfEEvw@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +36 −0 |
| src/backend/utils/adt/array_userfuncs.c | modified | +178 −0 |
| src/backend/utils/cache/typcache.c | modified | +2 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.dat | modified | +12 −0 |
| src/include/utils/typcache.h | modified | +1 −0 |
| src/test/regress/expected/arrays.out | modified | +142 −0 |
| src/test/regress/expected/collate.icu.utf8.out | modified | +13 −0 |
| src/test/regress/sql/arrays.sql | modified | +36 −0 |
| src/test/regress/sql/collate.icu.utf8.sql | modified | +4 −0 |
| src/tools/pgindent/typedefs.list | modified | +1 −0 |
Documentation touched
Discussion
- general purpose array_sort 63 messages · 2024-09-27 → 2025-04-01