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
This commit is contained in:
Peter Eisentraut 2023-06-07 16:57:06 +02:00
parent d64e6468f4
commit b0f6c43716
12 changed files with 22 additions and 84 deletions

View File

@ -8,8 +8,8 @@
* to the "tr-TR-x-icu" collation where it will succeed.
*/
SELECT getdatabaseencoding() <> 'UTF8' OR
current_setting('lc_ctype') = 'C' OR
(SELECT datlocprovider='i' FROM pg_database
(SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
FROM pg_database
WHERE datname=current_database())
AS skip_test \gset
\if :skip_test

View File

@ -8,8 +8,8 @@
* to the "tr-TR-x-icu" collation where it will succeed.
*/
SELECT getdatabaseencoding() <> 'UTF8' OR
current_setting('lc_ctype') = 'C' OR
(SELECT datlocprovider='i' FROM pg_database
(SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
FROM pg_database
WHERE datname=current_database())
AS skip_test \gset
\if :skip_test

View File

@ -9,8 +9,8 @@
*/
SELECT getdatabaseencoding() <> 'UTF8' OR
current_setting('lc_ctype') = 'C' OR
(SELECT datlocprovider='i' FROM pg_database
(SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
FROM pg_database
WHERE datname=current_database())
AS skip_test \gset
\if :skip_test

View File

@ -10788,38 +10788,6 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</listitem>
</varlistentry>
<varlistentry id="guc-lc-collate" xreflabel="lc_collate">
<term><varname>lc_collate</varname> (<type>string</type>)
<indexterm>
<primary><varname>lc_collate</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Reports the locale in which sorting of textual data is done.
See <xref linkend="locale"/> for more information.
This value is determined when a database is created.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-lc-ctype" xreflabel="lc_ctype">
<term><varname>lc_ctype</varname> (<type>string</type>)
<indexterm>
<primary><varname>lc_ctype</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Reports the locale that determines character classifications.
See <xref linkend="locale"/> for more information.
This value is determined when a database is created.
Ordinarily this will be the same as <varname>lc_collate</varname>,
but for special applications it might be set differently.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-max-function-args" xreflabel="max_function_args">
<term><varname>max_function_args</varname> (<type>integer</type>)
<indexterm>

View File

@ -483,10 +483,6 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
quote_identifier(name))));
}
/* Make the locale settings visible as GUC variables, too */
SetConfigOption("lc_collate", collate, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT);
SetConfigOption("lc_ctype", ctype, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT);
ReleaseSysCache(tup);
}

View File

@ -563,8 +563,6 @@ static char *syslog_ident_str;
static double phony_random_seed;
static char *client_encoding_string;
static char *datestyle_string;
static char *locale_collate;
static char *locale_ctype;
static char *server_encoding_string;
static char *server_version_string;
static int server_version_num;
@ -4050,30 +4048,6 @@ struct config_string ConfigureNamesString[] =
NULL, NULL, NULL
},
/* See main.c about why defaults for LC_foo are not all alike */
{
{"lc_collate", PGC_INTERNAL, PRESET_OPTIONS,
gettext_noop("Shows the collation order locale."),
NULL,
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
},
&locale_collate,
"C",
NULL, NULL, NULL
},
{
{"lc_ctype", PGC_INTERNAL, PRESET_OPTIONS,
gettext_noop("Shows the character classification and case conversion locale."),
NULL,
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
},
&locale_ctype,
"C",
NULL, NULL, NULL
},
{
{"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,
gettext_noop("Sets the language in which messages are displayed."),

View File

@ -1023,7 +1023,7 @@ SET client_min_messages TO WARNING;
do $$
BEGIN
EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@ -1031,7 +1031,7 @@ ERROR: collation "test0" already exists
do $$
BEGIN
EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
RESET client_min_messages;

View File

@ -1027,7 +1027,7 @@ CREATE SCHEMA test_schema;
do $$
BEGIN
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@ -1039,9 +1039,9 @@ NOTICE: collation "test0" for encoding "UTF8" already exists, skipping
do $$
BEGIN
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
quote_literal(current_setting('lc_collate')) ||
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
', lc_ctype = ' ||
quote_literal(current_setting('lc_ctype')) || ');';
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

View File

@ -863,7 +863,7 @@ CREATE SCHEMA test_schema;
do $$
BEGIN
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@ -875,9 +875,9 @@ NOTICE: collation "test0" for encoding "WIN1252" already exists, skipping
do $$
BEGIN
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
quote_literal(current_setting('lc_collate')) ||
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
', lc_ctype = ' ||
quote_literal(current_setting('lc_ctype')) || ');';
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

View File

@ -362,14 +362,14 @@ SET client_min_messages TO WARNING;
do $$
BEGIN
EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
do $$
BEGIN
EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT daticulocale FROM pg_database WHERE datname = current_database())) || ');';
END
$$;

View File

@ -359,7 +359,7 @@ CREATE SCHEMA test_schema;
do $$
BEGIN
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@ -368,9 +368,9 @@ CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo'); -- ok, skipped
do $$
BEGIN
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
quote_literal(current_setting('lc_collate')) ||
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
', lc_ctype = ' ||
quote_literal(current_setting('lc_ctype')) || ');';
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype

View File

@ -310,7 +310,7 @@ CREATE SCHEMA test_schema;
do $$
BEGIN
EXECUTE 'CREATE COLLATION test0 (locale = ' ||
quote_literal(current_setting('lc_collate')) || ');';
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test0 FROM "C"; -- fail, duplicate name
@ -319,9 +319,9 @@ CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo'); -- ok, skipped
do $$
BEGIN
EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||
quote_literal(current_setting('lc_collate')) ||
quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) ||
', lc_ctype = ' ||
quote_literal(current_setting('lc_ctype')) || ');';
quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');';
END
$$;
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail, need lc_ctype