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/
696054d1-bc88-b6ab-129a-
18b8bce6a6f0@enterprisedb.com
* 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
* 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
*/
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
</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>
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);
}
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;
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."),
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
$$;
RESET client_min_messages;
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
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
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
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
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
$$;
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
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
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
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