Skip to content

Commit 7db6809

Browse files
committed
Avoid requiring Spanish locale to test NLS infrastructure.
I had supposed that the majority of machines with gettext installed would have most language locales installed, but at least in the buildfarm it turns out less than half have es_ES installed. So depending on that to run the test now seems like a bad idea. But it turns out that gettext can be persuaded to "translate" even in the C locale, as long as you fake out its short-circuit logic by spelling the locale name like "C.UTF-8" or similar. (Many thanks to Bryan Green for correcting my misconceptions about that.) Quick testing suggests that that spelling is accepted by most platforms, though again the buildfarm may show that "most" isn't "all". Hence, remove the es_ES dependency and instead create a "C" message catalog. I've made the test unconditionally set lc_messages to 'C.UTF-8'. That approach might need adjustment depending on what the buildfarm shows, but let's keep it simple until proven wrong. While at it, tweak the test so that we run the various ereport's even when !ENABLE_NLS. This is useful to verify that the macros provided by <inttypes.h> are compatible with snprintf.c, as we now know is worth questioning. Discussion: https://postgr.es/m/1991599.1765818338@sss.pgh.pa.us
1 parent 95a19fe commit 7db6809

File tree

8 files changed

+237
-314
lines changed

8 files changed

+237
-314
lines changed

src/test/regress/expected/nls.out

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,29 @@ CREATE FUNCTION test_translation()
66
RETURNS void
77
AS :'regresslib'
88
LANGUAGE C;
9-
-- There's less standardization in locale name spellings than one could wish.
10-
-- While some platforms insist on having a codeset name in lc_messages,
11-
-- fortunately it seems that it need not match the actual database encoding.
12-
-- However, if no es_ES locale is installed at all, this'll fail.
13-
SET lc_messages = 'C';
14-
do $$
15-
declare locale text; ok bool;
16-
begin
17-
for locale in values('es_ES'), ('es_ES.UTF-8'), ('es_ES.utf8')
18-
loop
19-
ok = true;
20-
begin
21-
execute format('set lc_messages = %L', locale);
22-
exception when invalid_parameter_value then
23-
ok = false;
24-
end;
25-
exit when ok;
26-
end loop;
27-
-- Don't clutter the expected results with this info, just log it
28-
raise log 'NLS regression test: lc_messages = %',
29-
current_setting('lc_messages');
30-
end $$;
31-
SELECT current_setting('lc_messages') = 'C' AS failed \gset
32-
\if :failed
33-
\echo Could not find an acceptable spelling of es_ES locale
34-
\quit
35-
\endif
9+
-- We don't want to assume that the platform has any particular language
10+
-- installed, so we use a "translation" for the C locale. However, gettext
11+
-- will short-circuit translation if lc_messages is just 'C'. Fake it out
12+
-- by appending a codeset name. Fortunately it seems that that need not
13+
-- match the actual database encoding.
14+
SET lc_messages = 'C.UTF-8';
3615
SELECT test_translation();
37-
NOTICE: traducido PRId64 = 424242424242
38-
NOTICE: traducido PRId32 = -1234
39-
NOTICE: traducido PRIdMAX = -5678
40-
NOTICE: traducido PRIdPTR = 9999
41-
NOTICE: traducido PRIu64 = 424242424242
42-
NOTICE: traducido PRIu32 = 1234
43-
NOTICE: traducido PRIuMAX = 5678
44-
NOTICE: traducido PRIuPTR = 9999
45-
NOTICE: traducido PRIx64 = 62c6d1a9b2
46-
NOTICE: traducido PRIx32 = 4d2
47-
NOTICE: traducido PRIxMAX = 162e
48-
NOTICE: traducido PRIxPTR = 270f
49-
NOTICE: traducido PRIX64 = 62C6D1A9B2
50-
NOTICE: traducido PRIX32 = 4D2
51-
NOTICE: traducido PRIXMAX = 162E
52-
NOTICE: traducido PRIXPTR = 270F
16+
NOTICE: translated PRId64 = 424242424242
17+
NOTICE: translated PRId32 = -1234
18+
NOTICE: translated PRIdMAX = -123456789012
19+
NOTICE: translated PRIdPTR = -9999
20+
NOTICE: translated PRIu64 = 424242424242
21+
NOTICE: translated PRIu32 = 4294966062
22+
NOTICE: translated PRIuMAX = 123456789012
23+
NOTICE: translated PRIuPTR = 9999
24+
NOTICE: translated PRIx64 = 62c6d1a9b2
25+
NOTICE: translated PRIx32 = fffffb2e
26+
NOTICE: translated PRIxMAX = 1cbe991a14
27+
NOTICE: translated PRIxPTR = 270f
28+
NOTICE: translated PRIX64 = 62C6D1A9B2
29+
NOTICE: translated PRIX32 = FFFFFB2E
30+
NOTICE: translated PRIXMAX = 1CBE991A14
31+
NOTICE: translated PRIXPTR = 270F
5332
test_translation
5433
------------------
5534

src/test/regress/expected/nls_1.out

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,30 @@ CREATE FUNCTION test_translation()
66
RETURNS void
77
AS :'regresslib'
88
LANGUAGE C;
9-
-- There's less standardization in locale name spellings than one could wish.
10-
-- While some platforms insist on having a codeset name in lc_messages,
11-
-- fortunately it seems that it need not match the actual database encoding.
12-
-- However, if no es_ES locale is installed at all, this'll fail.
13-
SET lc_messages = 'C';
14-
do $$
15-
declare locale text; ok bool;
16-
begin
17-
for locale in values('es_ES'), ('es_ES.UTF-8'), ('es_ES.utf8')
18-
loop
19-
ok = true;
20-
begin
21-
execute format('set lc_messages = %L', locale);
22-
exception when invalid_parameter_value then
23-
ok = false;
24-
end;
25-
exit when ok;
26-
end loop;
27-
-- Don't clutter the expected results with this info, just log it
28-
raise log 'NLS regression test: lc_messages = %',
29-
current_setting('lc_messages');
30-
end $$;
31-
SELECT current_setting('lc_messages') = 'C' AS failed \gset
32-
\if :failed
33-
\echo Could not find an acceptable spelling of es_ES locale
34-
\quit
35-
\endif
9+
-- We don't want to assume that the platform has any particular language
10+
-- installed, so we use a "translation" for the C locale. However, gettext
11+
-- will short-circuit translation if lc_messages is just 'C'. Fake it out
12+
-- by appending a codeset name. Fortunately it seems that that need not
13+
-- match the actual database encoding.
14+
SET lc_messages = 'C.UTF-8';
3615
SELECT test_translation();
3716
NOTICE: NLS is not enabled
17+
NOTICE: untranslated PRId64 = 424242424242
18+
NOTICE: untranslated PRId32 = -1234
19+
NOTICE: untranslated PRIdMAX = -123456789012
20+
NOTICE: untranslated PRIdPTR = -9999
21+
NOTICE: untranslated PRIu64 = 424242424242
22+
NOTICE: untranslated PRIu32 = 4294966062
23+
NOTICE: untranslated PRIuMAX = 123456789012
24+
NOTICE: untranslated PRIuPTR = 9999
25+
NOTICE: untranslated PRIx64 = 62c6d1a9b2
26+
NOTICE: untranslated PRIx32 = fffffb2e
27+
NOTICE: untranslated PRIxMAX = 1cbe991a14
28+
NOTICE: untranslated PRIxPTR = 270f
29+
NOTICE: untranslated PRIX64 = 62C6D1A9B2
30+
NOTICE: untranslated PRIX32 = FFFFFB2E
31+
NOTICE: untranslated PRIXMAX = 1CBE991A14
32+
NOTICE: untranslated PRIXPTR = 270F
3833
test_translation
3934
------------------
4035

src/test/regress/expected/nls_2.out

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/test/regress/po/C.po

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# C message translation file for regress test library
2+
#
3+
# Note that we don't need translation of this library into non-English.
4+
#
5+
# Copyright (C) 2025 PostgreSQL Global Development Group
6+
# This file is distributed under the same license as the regress (PostgreSQL) package.
7+
#
8+
# Tom Lane <tgl@sss.pgh.pa.us>, 2025.
9+
#
10+
msgid ""
11+
msgstr ""
12+
"Project-Id-Version: regress (PostgreSQL) 19\n"
13+
"Report-Msgid-Bugs-To: pgsql-bugs@lists.postgresql.org\n"
14+
"POT-Creation-Date: 2025-12-15 14:28-0500\n"
15+
"PO-Revision-Date: 2025-12-15 14:28-0500\n"
16+
"Last-Translator: Tom Lane <tgl@sss.pgh.pa.us>\n"
17+
"Language-Team: PG Hackers <pgsql-hackers@lists.postgresql.org>\n"
18+
"Language: C\n"
19+
"MIME-Version: 1.0\n"
20+
"Content-Type: text/plain; charset=UTF-8\n"
21+
"Content-Transfer-Encoding: 8bit\n"
22+
23+
#: regress.c:202
24+
#, c-format
25+
msgid "invalid input syntax for type %s: \"%s\""
26+
msgstr ""
27+
28+
#: regress.c:839
29+
#, c-format
30+
msgid "test_inline_in_from_support_func called with %d args but expected 3"
31+
msgstr ""
32+
33+
#: regress.c:847 regress.c:863
34+
#, c-format
35+
msgid "test_inline_in_from_support_func called with non-Const parameters"
36+
msgstr ""
37+
38+
#: regress.c:854 regress.c:870
39+
#, c-format
40+
msgid "test_inline_in_from_support_func called with non-TEXT parameters"
41+
msgstr ""
42+
43+
#: regress.c:903
44+
#, c-format
45+
msgid "test_inline_in_from_support_func parsed to more than one node"
46+
msgstr ""
47+
48+
#: regress.c:914
49+
#, c-format
50+
msgid "test_inline_in_from_support_func rewrote to more than one node"
51+
msgstr ""
52+
53+
#: regress.c:921
54+
#, c-format
55+
msgid "test_inline_in_from_support_func didn't parse to a Query"
56+
msgstr ""
57+
58+
#: regress.c:1028
59+
#, c-format
60+
msgid "invalid source encoding name \"%s\""
61+
msgstr ""
62+
63+
#: regress.c:1033
64+
#, c-format
65+
msgid "invalid destination encoding name \"%s\""
66+
msgstr ""
67+
68+
#: regress.c:1078
69+
#, c-format
70+
msgid "default conversion function for encoding \"%s\" to \"%s\" does not exist"
71+
msgstr ""
72+
73+
#: regress.c:1085
74+
#, c-format
75+
msgid "out of memory"
76+
msgstr ""
77+
78+
#: regress.c:1086
79+
#, c-format
80+
msgid "String of %d bytes is too long for encoding conversion."
81+
msgstr ""
82+
83+
#: regress.c:1197
84+
#, c-format
85+
msgid "untranslated PRId64 = %<PRId64>"
86+
msgstr "translated PRId64 = %<PRId64>"
87+
88+
#: regress.c:1199
89+
#, c-format
90+
msgid "untranslated PRId32 = %<PRId32>"
91+
msgstr "translated PRId32 = %<PRId32>"
92+
93+
#: regress.c:1201
94+
#, c-format
95+
msgid "untranslated PRIdMAX = %<PRIdMAX>"
96+
msgstr "translated PRIdMAX = %<PRIdMAX>"
97+
98+
#: regress.c:1203
99+
#, c-format
100+
msgid "untranslated PRIdPTR = %<PRIdPTR>"
101+
msgstr "translated PRIdPTR = %<PRIdPTR>"
102+
103+
#: regress.c:1206
104+
#, c-format
105+
msgid "untranslated PRIu64 = %<PRIu64>"
106+
msgstr "translated PRIu64 = %<PRIu64>"
107+
108+
#: regress.c:1208
109+
#, c-format
110+
msgid "untranslated PRIu32 = %<PRIu32>"
111+
msgstr "translated PRIu32 = %<PRIu32>"
112+
113+
#: regress.c:1210
114+
#, c-format
115+
msgid "untranslated PRIuMAX = %<PRIuMAX>"
116+
msgstr "translated PRIuMAX = %<PRIuMAX>"
117+
118+
#: regress.c:1212
119+
#, c-format
120+
msgid "untranslated PRIuPTR = %<PRIuPTR>"
121+
msgstr "translated PRIuPTR = %<PRIuPTR>"
122+
123+
#: regress.c:1215
124+
#, c-format
125+
msgid "untranslated PRIx64 = %<PRIx64>"
126+
msgstr "translated PRIx64 = %<PRIx64>"
127+
128+
#: regress.c:1217
129+
#, c-format
130+
msgid "untranslated PRIx32 = %<PRIx32>"
131+
msgstr "translated PRIx32 = %<PRIx32>"
132+
133+
#: regress.c:1219
134+
#, c-format
135+
msgid "untranslated PRIxMAX = %<PRIxMAX>"
136+
msgstr "translated PRIxMAX = %<PRIxMAX>"
137+
138+
#: regress.c:1221
139+
#, c-format
140+
msgid "untranslated PRIxPTR = %<PRIxPTR>"
141+
msgstr "translated PRIxPTR = %<PRIxPTR>"
142+
143+
#: regress.c:1224
144+
#, c-format
145+
msgid "untranslated PRIX64 = %<PRIX64>"
146+
msgstr "translated PRIX64 = %<PRIX64>"
147+
148+
#: regress.c:1226
149+
#, c-format
150+
msgid "untranslated PRIX32 = %<PRIX32>"
151+
msgstr "translated PRIX32 = %<PRIX32>"
152+
153+
#: regress.c:1228
154+
#, c-format
155+
msgid "untranslated PRIXMAX = %<PRIXMAX>"
156+
msgstr "translated PRIXMAX = %<PRIXMAX>"
157+
158+
#: regress.c:1230
159+
#, c-format
160+
msgid "untranslated PRIXPTR = %<PRIXPTR>"
161+
msgstr "translated PRIXPTR = %<PRIXPTR>"

src/test/regress/po/LINGUAS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
es
1+
C

0 commit comments

Comments
 (0)