Try a few different locale name spellings in nls.sql.
authorTom Lane <[email protected]>
Sun, 14 Dec 2025 17:54:57 +0000 (12:54 -0500)
committerTom Lane <[email protected]>
Sun, 14 Dec 2025 17:54:57 +0000 (12:54 -0500)
While CI testing in advance of commit 8c498479d suggested that all
Unix-ish platforms would accept 'es_ES.UTF-8', the buildfarm has
a different opinion.  Let's dynamically select something that works,
if possible.

Discussion: https://postgr.es/m/[email protected]

src/test/regress/expected/nls.out
src/test/regress/expected/nls_1.out
src/test/regress/sql/nls.sql

index 5a650294eaf300695c876a93bc60dd31fb6f13b0..45c6fc2aaac7a97ab2d647d174f538b130f33c12 100644 (file)
@@ -6,10 +6,23 @@ CREATE FUNCTION test_translation()
     RETURNS void
     AS :'regresslib'
     LANGUAGE C;
--- Some BSDen are sticky about wanting a codeset name in lc_messages,
--- but it seems that at least on common platforms it doesn't have
--- to match the actual database encoding.
-SET lc_messages = 'es_ES.UTF-8';
+-- There's less standardization in locale name spellings than one could wish.
+-- While some platforms insist on having a codeset name in lc_messages,
+-- fortunately it seems that it need not match the actual database encoding.
+do $$
+declare locale text; ok bool;
+begin
+  for locale in values('es_ES'), ('es_ES.UTF-8'), ('es_ES.utf8')
+  loop
+    ok = true;
+    begin
+      execute format('set lc_messages = %L', locale);
+    exception when invalid_parameter_value then
+      ok = false;
+    end;
+    exit when ok;
+  end loop;
+end $$;
 SELECT test_translation();
 NOTICE:  traducido PRId64 = 424242424242
 NOTICE:  traducido PRId32 = -1234
index 9f1a2776e500b9a3ac09be70b1ffc2d11651d527..554d7204bf17ea03a5e2fa316bfe3761c0daea39 100644 (file)
@@ -6,10 +6,23 @@ CREATE FUNCTION test_translation()
     RETURNS void
     AS :'regresslib'
     LANGUAGE C;
--- Some BSDen are sticky about wanting a codeset name in lc_messages,
--- but it seems that at least on common platforms it doesn't have
--- to match the actual database encoding.
-SET lc_messages = 'es_ES.UTF-8';
+-- There's less standardization in locale name spellings than one could wish.
+-- While some platforms insist on having a codeset name in lc_messages,
+-- fortunately it seems that it need not match the actual database encoding.
+do $$
+declare locale text; ok bool;
+begin
+  for locale in values('es_ES'), ('es_ES.UTF-8'), ('es_ES.utf8')
+  loop
+    ok = true;
+    begin
+      execute format('set lc_messages = %L', locale);
+    exception when invalid_parameter_value then
+      ok = false;
+    end;
+    exit when ok;
+  end loop;
+end $$;
 SELECT test_translation();
 NOTICE:  NLS is not enabled
  test_translation 
index efeda8c5841c5a3db8ed9ce5db8adb9ef309232b..9d5b0fd7d4514e9e984ce94fdeab28167e075a2d 100644 (file)
@@ -9,10 +9,23 @@ CREATE FUNCTION test_translation()
     AS :'regresslib'
     LANGUAGE C;
 
--- Some BSDen are sticky about wanting a codeset name in lc_messages,
--- but it seems that at least on common platforms it doesn't have
--- to match the actual database encoding.
-SET lc_messages = 'es_ES.UTF-8';
+-- There's less standardization in locale name spellings than one could wish.
+-- While some platforms insist on having a codeset name in lc_messages,
+-- fortunately it seems that it need not match the actual database encoding.
+do $$
+declare locale text; ok bool;
+begin
+  for locale in values('es_ES'), ('es_ES.UTF-8'), ('es_ES.utf8')
+  loop
+    ok = true;
+    begin
+      execute format('set lc_messages = %L', locale);
+    exception when invalid_parameter_value then
+      ok = false;
+    end;
+    exit when ok;
+  end loop;
+end $$;
 
 SELECT test_translation();