summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2023-06-07 14:57:06 +0000
committerPeter Eisentraut2023-06-07 14:57:06 +0000
commitb0f6c437160db640d4ea3e49398ebc3ba39d1982 (patch)
tree7f20cb41b997c06a0f5748415e3185c349941937
parentd64e6468f489effec356ce3501c0f226ac1cfcc0 (diff)
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 <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected]
-rw-r--r--contrib/citext/expected/citext_utf8.out4
-rw-r--r--contrib/citext/expected/citext_utf8_1.out4
-rw-r--r--contrib/citext/sql/citext_utf8.sql4
-rw-r--r--doc/src/sgml/config.sgml32
-rw-r--r--src/backend/utils/init/postinit.c4
-rw-r--r--src/backend/utils/misc/guc_tables.c26
-rw-r--r--src/test/regress/expected/collate.icu.utf8.out4
-rw-r--r--src/test/regress/expected/collate.linux.utf8.out6
-rw-r--r--src/test/regress/expected/collate.windows.win1252.out6
-rw-r--r--src/test/regress/sql/collate.icu.utf8.sql4
-rw-r--r--src/test/regress/sql/collate.linux.utf8.sql6
-rw-r--r--src/test/regress/sql/collate.windows.win1252.sql6
12 files changed, 22 insertions, 84 deletions
diff --git a/contrib/citext/expected/citext_utf8.out b/contrib/citext/expected/citext_utf8.out
index 77b4586d8fa..6630e09a4de 100644
--- a/contrib/citext/expected/citext_utf8.out
+++ b/contrib/citext/expected/citext_utf8.out
@@ -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
diff --git a/contrib/citext/expected/citext_utf8_1.out b/contrib/citext/expected/citext_utf8_1.out
index d1e1fe1a9d8..3caa7a00d42 100644
--- a/contrib/citext/expected/citext_utf8_1.out
+++ b/contrib/citext/expected/citext_utf8_1.out
@@ -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
diff --git a/contrib/citext/sql/citext_utf8.sql b/contrib/citext/sql/citext_utf8.sql
index 8530c68dd7e..1f51df134bf 100644
--- a/contrib/citext/sql/citext_utf8.sql
+++ b/contrib/citext/sql/citext_utf8.sql
@@ -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
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 5da74b3c406..19c133b02d0 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -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>
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 6856ed99e7d..561bd13ed24 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -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);
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 68aecad66f4..4665b0a35c3 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -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."),
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index c658ee1404d..00dee24549a 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -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;
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index 6d34667cebc..01664f7c1b5 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -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
diff --git a/src/test/regress/expected/collate.windows.win1252.out b/src/test/regress/expected/collate.windows.win1252.out
index 61b421161fa..b7b93959de9 100644
--- a/src/test/regress/expected/collate.windows.win1252.out
+++ b/src/test/regress/expected/collate.windows.win1252.out
@@ -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
diff --git a/src/test/regress/sql/collate.icu.utf8.sql b/src/test/regress/sql/collate.icu.utf8.sql
index 7bd09012810..a8001b4b8e9 100644
--- a/src/test/regress/sql/collate.icu.utf8.sql
+++ b/src/test/regress/sql/collate.icu.utf8.sql
@@ -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
$$;
diff --git a/src/test/regress/sql/collate.linux.utf8.sql b/src/test/regress/sql/collate.linux.utf8.sql
index 2b787507c55..132d13af0a8 100644
--- a/src/test/regress/sql/collate.linux.utf8.sql
+++ b/src/test/regress/sql/collate.linux.utf8.sql
@@ -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
diff --git a/src/test/regress/sql/collate.windows.win1252.sql b/src/test/regress/sql/collate.windows.win1252.sql
index b5c45e18103..353d769a5bd 100644
--- a/src/test/regress/sql/collate.windows.win1252.sql
+++ b/src/test/regress/sql/collate.windows.win1252.sql
@@ -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