1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Use ICU by default at initdb time.

If the ICU locale is not specified, initialize the default collator
and retrieve the locale name from that.

Discussion: https://postgr.es/m/510d284759f6e943ce15096167760b2edcb2e700.camel@j-davis.com
Reviewed-by: Peter Eisentraut
This commit is contained in:
Jeff Davis
2023-03-09 10:52:41 -08:00
parent a7e584a7d6
commit 27b62377b4
18 changed files with 147 additions and 42 deletions

View File

@ -89,10 +89,28 @@ PostgreSQL documentation
and character set encoding. These can also be set separately for each
database when it is created. <command>initdb</command> determines those
settings for the template databases, which will serve as the default for
all other databases. By default, <command>initdb</command> uses the
locale provider <literal>libc</literal>, takes the locale settings from
the environment, and determines the encoding from the locale settings.
This is almost always sufficient, unless there are special requirements.
all other databases.
</para>
<para>
By default, <command>initdb</command> uses the ICU library to provide
locale services if the server was built with ICU support; otherwise it uses
the <literal>libc</literal> locale provider (see <xref
linkend="locale-providers"/>). To choose the specific ICU locale ID to
apply, use the option <option>--icu-locale</option>. Note that for
implementation reasons and to support legacy code,
<command>initdb</command> will still select and initialize libc locale
settings when the ICU locale provider is used.
</para>
<para>
Alternatively, <command>initdb</command> can use the locale provider
<literal>libc</literal>. To select this option, specify
<literal>--locale-provider=libc</literal>, or build the server without ICU
support. The <literal>libc</literal> locale provider takes the locale
settings from the environment, and determines the encoding from the locale
settings. This is almost always sufficient, unless there are special
requirements.
</para>
<para>
@ -103,17 +121,6 @@ PostgreSQL documentation
categories can give nonsensical results, so this should be used with care.
</para>
<para>
Alternatively, the ICU library can be used to provide locale services.
(Again, this only sets the default for subsequently created databases.) To
select this option, specify <literal>--locale-provider=icu</literal>.
To choose the specific ICU locale ID to apply, use the option
<option>--icu-locale</option>. Note that
for implementation reasons and to support legacy code,
<command>initdb</command> will still select and initialize libc locale
settings when the ICU locale provider is used.
</para>
<para>
When <command>initdb</command> runs, it will print out the locale settings
it has chosen. If you have complex requirements or specified multiple
@ -234,7 +241,13 @@ PostgreSQL documentation
<term><option>--icu-locale=<replaceable>locale</replaceable></option></term>
<listitem>
<para>
Specifies the ICU locale ID, if the ICU locale provider is used.
Specifies the ICU locale when the ICU provider is used. Locale support
is described in <xref linkend="locale"/>.
</para>
<para>
If this option is not specified, the locale is inherited from the
environment in which <command>initdb</command> runs. The environment's
locale is matched to a similar ICU locale name, if possible.
</para>
</listitem>
</varlistentry>
@ -307,10 +320,12 @@ PostgreSQL documentation
<term><option>--locale-provider={<literal>libc</literal>|<literal>icu</literal>}</option></term>
<listitem>
<para>
This option sets the locale provider for databases created in the
new cluster. It can be overridden in the <command>CREATE
This option sets the locale provider for databases created in the new
cluster. It can be overridden in the <command>CREATE
DATABASE</command> command when new databases are subsequently
created. The default is <literal>libc</literal>.
created. The default is <literal>icu</literal> if the server was
built with ICU support; otherwise the default is
<literal>libc</literal> (see <xref linkend="locale-providers"/>).
</para>
</listitem>
</varlistentry>