Skip to content

Commit 1944bff

Browse files
committed
Make initdb print a message about which locale it is about to use.
Re-add warning if the locale prevents LIKE-optimization. Done within initdb now.
1 parent 16e22de commit 1944bff

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 5 additions & 6 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.114 2002/04/26 01:24:08 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.115 2002/05/09 13:30:24 petere Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -145,11 +145,10 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput>
145145
linkend="locale">. One surprise you might encounter while running
146146
<command>initdb</command> is a notice similar to this:
147147
<screen>
148-
WARNING: Initializing database with en_US collation order.
149-
This locale setting will prevent use of index optimization for
150-
LIKE and regexp searches. If you are concerned about speed of
151-
such queries, you may wish to set LC_COLLATE to "C" and
152-
re-initdb. For more information see the Administrator's Guide.
148+
The database cluster will be initialized with locale de_DE.
149+
This locale setting will prevent the use of indexes for pattern matching
150+
operations. If that is a concern, rerun initdb with the collation order
151+
set to "C". For more information see the Administrator's Guide.
153152
</screen>
154153
This is intended to warn you that the currently selected locale
155154
will cause indexes to be sorted in an order that prevents them from

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.93 2002/04/24 01:54:43 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.94 2002/05/09 13:30:24 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -39,7 +39,6 @@
3939
#include "storage/spin.h"
4040
#include "utils/builtins.h"
4141
#include "utils/relcache.h"
42-
#include "utils/selfuncs.h"
4342
#include "miscadmin.h"
4443

4544

@@ -2108,19 +2107,6 @@ WriteControlFile(void)
21082107
elog(PANIC, "invalid LC_CTYPE setting");
21092108
StrNCpy(ControlFile->lc_ctype, localeptr, LOCALE_NAME_BUFLEN);
21102109

2111-
/*
2112-
* Issue warning WARNING if initdb'ing in a locale that will not permit
2113-
* LIKE index optimization. This is not a clean place to do it, but I
2114-
* don't see a better place either...
2115-
*/
2116-
if (!locale_is_like_safe())
2117-
elog(WARNING, "Initializing database with %s collation order."
2118-
"\n\tThis locale setting will prevent use of index optimization for"
2119-
"\n\tLIKE and regexp searches. If you are concerned about speed of"
2120-
"\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and"
2121-
"\n\tre-initdb. For more information see the Administrator's Guide.",
2122-
ControlFile->lc_collate);
2123-
21242110
/* Contents are protected with a CRC */
21252111
INIT_CRC64(ControlFile->crc);
21262112
COMP_CRC64(ControlFile->crc,

src/backend/utils/adt/selfuncs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.110 2002/04/25 02:56:55 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.111 2002/05/09 13:30:24 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -3189,6 +3189,8 @@ pattern_selectivity(char *patt, Pattern_Type ptype)
31893189
* could be different from lc_collate_is_c(), but in a different
31903190
* theory, non-C locales are completely unpredicable so it's unlikely
31913191
* to happen.)
3192+
*
3193+
* Be sure to maintain the correspondence with the code in initdb.
31923194
*/
31933195
bool
31943196
locale_is_like_safe(void)

src/bin/initdb/initdb.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
2828
# Portions Copyright (c) 1994, Regents of the University of California
2929
#
30-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.152 2002/04/27 21:24:34 tgl Exp $
30+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.153 2002/05/09 13:30:24 petere Exp $
3131
#
3232
#-------------------------------------------------------------------------
3333

@@ -464,6 +464,30 @@ echo "The files belonging to this database system will be owned by user \"$Effec
464464
echo "This user must also own the server process."
465465
echo
466466

467+
TAB=' '
468+
469+
if test `pg_getlocale CTYPE` = `pg_getlocale COLLATE` \
470+
&& test `pg_getlocale CTYPE` = `pg_getlocale TIME` \
471+
&& test `pg_getlocale CTYPE` = `pg_getlocale NUMERIC` \
472+
&& test `pg_getlocale CTYPE` = `pg_getlocale MONETARY` \
473+
&& test `pg_getlocale CTYPE` = `pg_getlocale MESSAGES`
474+
then
475+
echo "The database cluster will be initialized with locale `pg_getlocale CTYPE`."
476+
else
477+
echo "The database cluster will be initialized with locales:"
478+
echo " COLLATE: `pg_getlocale COLLATE`${TAB}CTYPE: `pg_getlocale CTYPE`${TAB}MESSAGES: `pg_getlocale MESSAGES`"
479+
echo " MONETARY: `pg_getlocale MONETARY`${TAB}NUMERIC: `pg_getlocale NUMERIC`${TAB}TIME: `pg_getlocale TIME`"
480+
fi
481+
482+
# (Be sure to maintain the correspondence with locale_is_like_safe() in selfuncs.c.)
483+
if test `pg_getlocale COLLATE` != C && test `pg_getlocale COLLATE` != POSIX; then
484+
echo "This locale setting will prevent the use of indexes for pattern matching"
485+
echo "operations. If that is a concern, rerun $CMDNAME with the collation order"
486+
echo "set to \"C\". For more information see the Administrator's Guide."
487+
fi
488+
echo
489+
490+
467491
##########################################################################
468492
#
469493
# CREATE DATABASE DIRECTORY

0 commit comments

Comments
 (0)