Skip to content

Commit bbea364

Browse files
committed
Store current LC_COLLATE and LC_CTYPE settings in pg_control during initdb;
re-adopt these settings at every postmaster or standalone-backend startup. This should fix problems with indexes becoming corrupt due to failure to provide consistent locale environment for postmaster at all times. Also, refuse to start up a non-locale-enabled compilation in a database originally initdb'd with a non-C locale. Suppress LIKE index optimization if locale is not "C" or "POSIX" (are there any other locales where it's safe?). Issue NOTICE during initdb if selected locale disables LIKE optimization.
1 parent 0432ce9 commit bbea364

File tree

11 files changed

+341
-127
lines changed

11 files changed

+341
-127
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.38 2000/11/22 01:41:12 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.39 2000/11/25 20:33:47 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -79,9 +79,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.38 2000/11/22 01:41:12 mom
7979
<command>initdb</command> will attempt to create the directory you
8080
specify if it does not already exist. It is likely that it won't
8181
have the permission to do so (if you followed our advice and
82-
created an unprivileged account). In that case you can create the
83-
directory yourself (as root) and transfer ownership of it or grant
84-
write access to it. Here is how this might work:
82+
created an unprivileged account). In that case you should create the
83+
directory yourself (as root) and transfer ownership of it to the
84+
Postgres user account. Here is how this might work:
8585
<screen>
8686
root# <userinput>mkdir /usr/local/pgsql/data</userinput>
8787
root# <userinput>chown postgres /usr/local/pgsql/data</userinput>
@@ -101,6 +101,28 @@ postgres&gt; <userinput>initdb -D /usr/local/pgsql/data</userinput>
101101
access. <command>initdb</command> therefore revokes access
102102
permissions from everyone but the Postgres user account.
103103
</para>
104+
105+
<para>
106+
One surprise you might encounter while running <command>initdb</command> is
107+
a notice similar to this one:
108+
<screen>
109+
NOTICE: Initializing database with en_US collation order.
110+
This locale setting will prevent use of index optimization for
111+
LIKE and regexp searches. If you are concerned about speed of
112+
such queries, you may wish to set LC_COLLATE to "C" and
113+
re-initdb. For more information see the Administrator's Guide.
114+
</screen>
115+
This notice is intended to warn you that the currently selected locale
116+
will cause indexes to be sorted in an order that prevents them from
117+
being used for LIKE and regular-expression searches. If you need
118+
good performance of such searches, you should set your current locale
119+
to "C" and re-run <command>initdb</command>. On most systems, setting the
120+
current locale is done by changing the value of the environment variable
121+
<literal>LC_ALL</literal> or <literal>LANG</literal>. The sort order used
122+
within a particular database cluster is set by <command>initdb</command>
123+
and cannot be changed later, short of dumping all data, re-initdb,
124+
reload data. So it's important to make this choice correctly now.
125+
</para>
104126
</sect1>
105127

106128
<sect1 id="postmaster-start">

0 commit comments

Comments
 (0)