From 98fce30e4997253e5b010b6ac72d66255bc77bf6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 1 Mar 2023 10:38:19 +0100 Subject: [PATCH] Add standard collation UNICODE --- doc/src/sgml/charset.sgml | 30 +++++++++++++++++++++++++++--- src/bin/initdb/initdb.c | 10 +++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml index 3032392b80..13ec238a81 100644 --- a/doc/src/sgml/charset.sgml +++ b/doc/src/sgml/charset.sgml @@ -659,9 +659,33 @@ Standard Collations - Additionally, the SQL standard collation name ucs_basic - is available for encoding UTF8. It is equivalent - to C and sorts by Unicode code point. + Additionally, two SQL standard collation names are available for encoding + UTF8: + + + + unicode + + + This collation sorts using the Unicode Collation Algorithm with the + Default Unicode Collation Element Table. (This is the same behavior + as the ICU root locale; see .) This + collation is only available when ICU support is configured. + + + + + + ucs_basic + + + This collation sorts by Unicode code point. (This is the same + behavior as the libc locale specification C.) + + + + diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 7a58c33ace..525bec4b44 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1482,10 +1482,14 @@ static void setup_collation(FILE *cmdfd) { /* - * Add an SQL-standard name. We don't want to pin this, so it doesn't go - * in pg_collation.h. But add it before reading system collations, so - * that it wins if libc defines a locale named ucs_basic. + * Add SQL-standard names. We don't want to pin these, so they don't go + * in pg_collation.h. But add them before reading system collations, so + * that they win if libc defines a locale with the same name. */ + PG_CMD_PRINTF("INSERT INTO pg_collation (oid, collname, collnamespace, collowner, collprovider, collisdeterministic, collencoding, colliculocale)" + "VALUES (pg_nextoid('pg_catalog.pg_collation', 'oid', 'pg_catalog.pg_collation_oid_index'), 'unicode', 'pg_catalog'::regnamespace, %u, '%c', true, %d, 'und');\n\n", + BOOTSTRAP_SUPERUSERID, COLLPROVIDER_ICU, PG_UTF8); + PG_CMD_PRINTF("INSERT INTO pg_collation (oid, collname, collnamespace, collowner, collprovider, collisdeterministic, collencoding, collcollate, collctype)" "VALUES (pg_nextoid('pg_catalog.pg_collation', 'oid', 'pg_catalog.pg_collation_oid_index'), 'ucs_basic', 'pg_catalog'::regnamespace, %u, '%c', true, %d, 'C', 'C');\n\n", BOOTSTRAP_SUPERUSERID, COLLPROVIDER_LIBC, PG_UTF8); -- 2.39.2