0001-Add-standard-collation-UNICODE.patch
text/plain
Filename: 0001-Add-standard-collation-UNICODE.patch
Type: text/plain
Part: 0
Message:
Add standard collation UNICODE
Patch
Format: format-patch
Series: patch 0001
Subject: Add standard collation UNICODE
| File | + | − |
|---|---|---|
| doc/src/sgml/charset.sgml | 27 | 3 |
| src/bin/initdb/initdb.c | 7 | 3 |
From 98fce30e4997253e5b010b6ac72d66255bc77bf6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
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 @@ <title>Standard Collations</title>
</para>
<para>
- Additionally, the SQL standard collation name <literal>ucs_basic</literal>
- is available for encoding <literal>UTF8</literal>. It is equivalent
- to <literal>C</literal> and sorts by Unicode code point.
+ Additionally, two SQL standard collation names are available for encoding
+ <literal>UTF8</literal>:
+
+ <variablelist>
+ <varlistentry>
+ <term><literal>unicode</literal></term>
+ <listitem>
+ <para>
+ 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 <xref
+ linkend="collation-managing-predefined-icu-und-x-icu"/>.) This
+ collation is only available when ICU support is configured.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>ucs_basic</literal></term>
+ <listitem>
+ <para>
+ This collation sorts by Unicode code point. (This is the same
+ behavior as the libc locale specification <literal>C</literal>.)
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</para>
</sect3>
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