Jeremie Courreges-Anglas - Thu, 12 December 2019 at 11:35:51
> Can you actually use ICU as the default collation algorithm used by
> a database?

it's not totally straightforward but yes, on the schema level it's
possible to override collation:

macos=# CREATE TABLE t (n text COLLATE "fr-FR-x-icu");
CREATE TABLE

macos=# INSERT INTO t (values ('bernard'),('bérénice'),('béatrice'),('boris'));
INSERT 0 4

macos=# SELECT * FROM t ORDER BY n;
    n
----------
 béatrice
 bérénice
 bernard
 boris
(4 rows)

macos=# show lc_collate;
 lc_collate
------------
 C
(1 row)

macos=# \d t
                 Table "public.t"
 Column | Type |  Collation  | Nullable | Default
--------+------+-------------+----------+---------
 n      | text | fr-FR-x-icu |          |


however `CREATE DATABASE` and `initdb` does not support this.  it's WIP:
https://www.postgresql-archive.org/ICU-for-global-collation-td6099973.html


it is far from ideal but at least having the option to override the
collation on both schema and/or individual query level means a working
sorting.

this is a good article when ICU was introduced:
https://www.2ndquadrant.com/en/blog/icu-support-postgresql-10/

(...i wonder what's the actual situation with mariadb...)

-f
-- 
tower: "say position."  pilot: "position."

Reply via email to