Skip to content

Commit b0f6c43

Browse files
committed
Remove read-only server settings lc_collate and lc_ctype
The GUC settings lc_collate and lc_ctype are from a time when those locale settings were cluster-global. When those locale settings were made per-database (PG 8.4), the settings were kept as read-only. As of PG 15, you can use ICU as the per-database locale provider, so examining these settings is already less meaningful and possibly confusing, since you need to look into pg_database to find out what is really happening, and they would likely become fully obsolete in the future anyway. Reviewed-by: Jeff Davis <pgsql@j-davis.com> Discussion: https://www.postgresql.org/message-id/696054d1-bc88-b6ab-129a-18b8bce6a6f0@enterprisedb.com
1 parent d64e646 commit b0f6c43

File tree

12 files changed

+22
-84
lines changed

12 files changed

+22
-84
lines changed

contrib/citext/expected/citext_utf8.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* to the "tr-TR-x-icu" collation where it will succeed.
99
*/
1010
SELECT getdatabaseencoding() <> 'UTF8' OR
11-
current_setting('lc_ctype') = 'C' OR
12-
(SELECT datlocprovider='i' FROM pg_database
11+
(SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
12+
FROM pg_database
1313
WHERE datname=current_database())
1414
AS skip_test \gset
1515
\if :skip_test

contrib/citext/expected/citext_utf8_1.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* to the "tr-TR-x-icu" collation where it will succeed.
99
*/
1010
SELECT getdatabaseencoding() <> 'UTF8' OR
11-
current_setting('lc_ctype') = 'C' OR
12-
(SELECT datlocprovider='i' FROM pg_database
11+
(SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
12+
FROM pg_database
1313
WHERE datname=current_database())
1414
AS skip_test \gset
1515
\if :skip_test

contrib/citext/sql/citext_utf8.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*/
1010

1111
SELECT getdatabaseencoding() <> 'UTF8' OR
12-
current_setting('lc_ctype') = 'C' OR
13-
(SELECT datlocprovider='i' FROM pg_database
12+
(SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
13+
FROM pg_database
1414
WHERE datname=current_database())
1515
AS skip_test \gset
1616
\if :skip_test

doc/src/sgml/config.sgml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10788,38 +10788,6 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
1078810788
</listitem>
1078910789
</varlistentry>
1079010790

10791-
<varlistentry id="guc-lc-collate" xreflabel="lc_collate">
10792-
<term><varname>lc_collate</varname> (<type>string</type>)
10793-
<indexterm>
10794-
<primary><varname>lc_collate</varname> configuration parameter</primary>
10795-
</indexterm>
10796-
</term>
10797-
<listitem>
10798-
<para>
10799-
Reports the locale in which sorting of textual data is done.
10800-
See <xref linkend="locale"/> for more information.
10801-
This value is determined when a database is created.
10802-
</para>
10803-
</listitem>
10804-
</varlistentry>
10805-
10806-
<varlistentry id="guc-lc-ctype" xreflabel="lc_ctype">
10807-
<term><varname>lc_ctype</varname> (<type>string</type>)
10808-
<indexterm>
10809-
<primary><varname>lc_ctype</varname> configuration parameter</primary>
10810-
</indexterm>
10811-
</term>
10812-
<listitem>
10813-
<para>
10814-
Reports the locale that determines character classifications.
10815-
See <xref linkend="locale"/> for more information.
10816-
This value is determined when a database is created.
10817-
Ordinarily this will be the same as <varname>lc_collate</varname>,
10818-
but for special applications it might be set differently.
10819-
</para>
10820-
</listitem>
10821-
</varlistentry>
10822-
1082310791
<varlistentry id="guc-max-function-args" xreflabel="max_function_args">
1082410792
<term><varname>max_function_args</varname> (<type>integer</type>)
1082510793
<indexterm>

src/backend/utils/init/postinit.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,6 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
483483
quote_identifier(name))));
484484
}
485485

486-
/* Make the locale settings visible as GUC variables, too */
487-
SetConfigOption("lc_collate", collate, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT);
488-
SetConfigOption("lc_ctype", ctype, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT);
489-
490486
ReleaseSysCache(tup);
491487
}
492488

src/backend/utils/misc/guc_tables.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,6 @@ static char *syslog_ident_str;
563563
static double phony_random_seed;
564564
static char *client_encoding_string;
565565
static char *datestyle_string;
566-
static char *locale_collate;
567-
static char *locale_ctype;
568566
static char *server_encoding_string;
569567
static char *server_version_string;
570568
static int server_version_num;
@@ -4050,30 +4048,6 @@ struct config_string ConfigureNamesString[] =
40504048
NULL, NULL, NULL
40514049
},
40524050

4053-
/* See main.c about why defaults for LC_foo are not all alike */
4054-
4055-
{
4056-
{"lc_collate", PGC_INTERNAL, PRESET_OPTIONS,
4057-
gettext_noop("Shows the collation order locale."),
4058-
NULL,
4059-
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
4060-
},
4061-
&locale_collate,
4062-
"C",
4063-
NULL, NULL, NULL
4064-
},
4065-
4066-
{
4067-
{"lc_ctype", PGC_INTERNAL, PRESET_OPTIONS,
4068-
gettext_noop("Shows the character classification and case conversion locale."),
4069-
NULL,
4070-
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
4071-
},
4072-
&locale_ctype,
4073-
"C",
4074-
NULL, NULL, NULL
4075-
},
4076-
40774051
{
40784052
{"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
40794053
gettext_noop("Sets the language in which messages are displayed."),

src/test/regress/expected/collate.icu.utf8.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,15 +1023,15 @@ SET client_min_messages TO WARNING;
10231023
do $$
10241024
BEGIN
10251025
EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
1026-
quote_literal(current_setting('lc_collate')) || ');';
1026+
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
10271027
END
10281028
$$;
10291029
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
10301030
ERROR: collation "test0" already exists
10311031
do $$
10321032
BEGIN
10331033
EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||
1034-
quote_literal(current_setting('lc_collate')) || ');';
1034+
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
10351035
END
10361036
$$;
10371037
RESET client_min_messages;

src/test/regress/expected/collate.linux.utf8.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ CREATE SCHEMA test_schema;
10271027
do $$
10281028
BEGIN
10291029
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
1030-
quote_literal(current_setting('lc_collate')) || ');';
1030+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
10311031
END
10321032
$$;
10331033
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@@ -1039,9 +1039,9 @@ NOTICE: collation "test0" for encoding "UTF8" already exists, skipping
10391039
do $$
10401040
BEGIN
10411041
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
1042-
quote_literal(current_setting('lc_collate')) ||
1042+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
10431043
', lc_ctype = ' ||
1044-
quote_literal(current_setting('lc_ctype')) || ');';
1044+
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
10451045
END
10461046
$$;
10471047
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

src/test/regress/expected/collate.windows.win1252.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ CREATE SCHEMA test_schema;
863863
do $$
864864
BEGIN
865865
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
866-
quote_literal(current_setting('lc_collate')) || ');';
866+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
867867
END
868868
$$;
869869
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@@ -875,9 +875,9 @@ NOTICE: collation "test0" for encoding "WIN1252" already exists, skipping
875875
do $$
876876
BEGIN
877877
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
878-
quote_literal(current_setting('lc_collate')) ||
878+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
879879
', lc_ctype = ' ||
880-
quote_literal(current_setting('lc_ctype')) || ');';
880+
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
881881
END
882882
$$;
883883
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

src/test/regress/sql/collate.icu.utf8.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,14 @@ SET client_min_messages TO WARNING;
362362
do $$
363363
BEGIN
364364
EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
365-
quote_literal(current_setting('lc_collate')) || ');';
365+
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
366366
END
367367
$$;
368368
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
369369
do $$
370370
BEGIN
371371
EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||
372-
quote_literal(current_setting('lc_collate')) || ');';
372+
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
373373
END
374374
$$;
375375

src/test/regress/sql/collate.linux.utf8.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ CREATE SCHEMA test_schema;
359359
do $$
360360
BEGIN
361361
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
362-
quote_literal(current_setting('lc_collate')) || ');';
362+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
363363
END
364364
$$;
365365
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@@ -368,9 +368,9 @@ CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo'); -- ok, skipped
368368
do $$
369369
BEGIN
370370
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
371-
quote_literal(current_setting('lc_collate')) ||
371+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
372372
', lc_ctype = ' ||
373-
quote_literal(current_setting('lc_ctype')) || ');';
373+
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
374374
END
375375
$$;
376376
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

src/test/regress/sql/collate.windows.win1252.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ CREATE SCHEMA test_schema;
310310
do $$
311311
BEGIN
312312
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
313-
quote_literal(current_setting('lc_collate')) || ');';
313+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
314314
END
315315
$$;
316316
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@@ -319,9 +319,9 @@ CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo'); -- ok, skipped
319319
do $$
320320
BEGIN
321321
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
322-
quote_literal(current_setting('lc_collate')) ||
322+
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
323323
', lc_ctype = ' ||
324-
quote_literal(current_setting('lc_ctype')) || ');';
324+
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
325325
END
326326
$$;
327327
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy