Greetings, everyone!

When you try to run installcheck using a cluster that was initialized with ICU (./initdb -D ../data --locale-provider=icu --icu-locale='en_US_POSIX') and NO_LOCALE=1 you get a warning:

        # +++ regress install-check in src/test/regress +++
        # using postmaster on Unix socket, default port
WARNING: could not convert locale name "C" to language tag: U_ILLEGAL_ARGUMENT_ERROR
        WARNING:  ICU locale "C" has unknown language "c"
HINT: To disable ICU locale validation, set the parameter "icu_validation_level" to "disabled".

This happens with PostgreSQL 16, 17 and master

While this case is somewhat superficial (you need ICU and NO_LOCALE), when you try to run installcheck of test_extensions test module (using a cluster initialized with ICU) you will get the same warnings due to NO_LOCALE=1 in Makefile

There could be an argument "if you are using ICU and don't want warnings just set icu_validation_level=disabled in postgresql.conf", but then installcheck fails because of collate.icu.utf8 like this:

CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes'); DROP COLLATION testx; -WARNING: could not convert locale name "@colStrength=primary;nonsense=yes" to language tag: U_ILLEGAL_ARGUMENT_ERROR CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere'); DROP COLLATION testx; -WARNING: ICU locale "nonsense-nowhere" has unknown language "nonsense" -HINT: To disable ICU locale validation, set the parameter "icu_validation_level" to "disabled".
        CREATE COLLATION test4 FROM nonsense;

And we definitely want to check warnings there

So for now I propose adding icu_validation_level=disabled to pg_regress when we were passed NO_LOCALE=1 (patch is attached)

Also since locale 'C' isn't converted to anything with ICU since f3a01af, maybe we want to somehow handle NO_LOCALE with ICU in a special way? Maybe only during tests?

On another none, test test_extensions from src/test/modules/test_extensions fails during installcheck when the cluster was initialized with ICU locale. It was already reported at [1]. This test fails on current REL_17_STABLE (2530367) and master (2a5e709)

One way to fix it is to just skip the test if we find ICU locale provider (patch attached bellow), but I'm not sure this is the optimal way. In [1] there was an attempt to replace \dx+ with function with collation-independent output

[1] https://www.postgresql.org/message-id/a2fd691f8d9f1325cec1283b161d6...@postgrespro.ru
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 53435c47420..390a10b8239 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -1957,6 +1957,14 @@ create_database(const char *dbname)
 	StringInfo	buf = psql_start_command();
 	_stringlist *sl;
 
+	/*
+	 * Disable warning that ICU locale "C" has unknown language "c". This can
+	 * happen if the cluster was initialized with the icu locale and the new
+	 * database uses the C locale.
+	 */
+	if (nolocale)
+		psql_add_command(buf, "SET icu_validation_level=disabled");
+
 	/*
 	 * We use template0 so that any installation-local cruft in template1 will
 	 * not mess up the tests.
diff --git a/src/test/modules/test_extensions/expected/test_extensions.out b/src/test/modules/test_extensions/expected/test_extensions.out
index f357cc21aaa..a74da86a1fb 100644
--- a/src/test/modules/test_extensions/expected/test_extensions.out
+++ b/src/test/modules/test_extensions/expected/test_extensions.out
@@ -1,3 +1,7 @@
+SELECT (SELECT datlocprovider='i' FROM pg_database WHERE datname=current_database()) as skip_test \gset
+\if :skip_test
+\quit
+\endif
 CREATE SCHEMA has$dollar;
 -- test some errors
 CREATE EXTENSION test_ext1;
diff --git a/src/test/modules/test_extensions/expected/test_extensions_0.out b/src/test/modules/test_extensions/expected/test_extensions_0.out
new file mode 100644
index 00000000000..aeb23e2ff38
--- /dev/null
+++ b/src/test/modules/test_extensions/expected/test_extensions_0.out
@@ -0,0 +1,3 @@
+SELECT (SELECT datlocprovider='i' FROM pg_database WHERE datname=current_database()) as skip_test \gset
+\if :skip_test
+\quit
diff --git a/src/test/modules/test_extensions/sql/test_extensions.sql b/src/test/modules/test_extensions/sql/test_extensions.sql
index 642c82ff5d3..eb5868d4c8c 100644
--- a/src/test/modules/test_extensions/sql/test_extensions.sql
+++ b/src/test/modules/test_extensions/sql/test_extensions.sql
@@ -1,3 +1,8 @@
+SELECT (SELECT datlocprovider='i' FROM pg_database WHERE datname=current_database()) as skip_test \gset
+\if :skip_test
+\quit
+\endif
+
 CREATE SCHEMA has$dollar;
 
 -- test some errors

Reply via email to