mirror of
https://github.com/postgres/postgres.git
synced 2025-12-18 05:01:01 +03:00
Test PRI* macros even when we can't test NLS translation.
Further research shows that the reason commit7db6809cefailed is that recent glibc versions short-circuit translation attempts when LC_MESSAGES is 'C.<encoding>', not only when it's 'C'. There seems no way around that, so we'll have to live with only testing NLS when a suitable real locale is installed. However, something can still be salvaged: it still seems like a good idea to verify that the PRI* macros work as-expected even when we can't check their translations (seef8715ec86for motivation). Hence, adjust the test to always run the ereport calls, and tweak the parameter values in hopes of detecting any cases where there's confusion about the actual widths of the parameters. Discussion: https://postgr.es/m/1991599.1765818338@sss.pgh.pa.us
This commit is contained in:
@@ -28,27 +28,22 @@ begin
|
|||||||
raise log 'NLS regression test: lc_messages = %',
|
raise log 'NLS regression test: lc_messages = %',
|
||||||
current_setting('lc_messages');
|
current_setting('lc_messages');
|
||||||
end $$;
|
end $$;
|
||||||
SELECT current_setting('lc_messages') = 'C' AS failed \gset
|
|
||||||
\if :failed
|
|
||||||
\echo Could not find an acceptable spelling of es_ES locale
|
|
||||||
\quit
|
|
||||||
\endif
|
|
||||||
SELECT test_translation();
|
SELECT test_translation();
|
||||||
NOTICE: traducido PRId64 = 424242424242
|
NOTICE: traducido PRId64 = 424242424242
|
||||||
NOTICE: traducido PRId32 = -1234
|
NOTICE: traducido PRId32 = -1234
|
||||||
NOTICE: traducido PRIdMAX = -5678
|
NOTICE: traducido PRIdMAX = -123456789012
|
||||||
NOTICE: traducido PRIdPTR = 9999
|
NOTICE: traducido PRIdPTR = -9999
|
||||||
NOTICE: traducido PRIu64 = 424242424242
|
NOTICE: traducido PRIu64 = 424242424242
|
||||||
NOTICE: traducido PRIu32 = 1234
|
NOTICE: traducido PRIu32 = 4294966062
|
||||||
NOTICE: traducido PRIuMAX = 5678
|
NOTICE: traducido PRIuMAX = 123456789012
|
||||||
NOTICE: traducido PRIuPTR = 9999
|
NOTICE: traducido PRIuPTR = 9999
|
||||||
NOTICE: traducido PRIx64 = 62c6d1a9b2
|
NOTICE: traducido PRIx64 = 62c6d1a9b2
|
||||||
NOTICE: traducido PRIx32 = 4d2
|
NOTICE: traducido PRIx32 = fffffb2e
|
||||||
NOTICE: traducido PRIxMAX = 162e
|
NOTICE: traducido PRIxMAX = 1cbe991a14
|
||||||
NOTICE: traducido PRIxPTR = 270f
|
NOTICE: traducido PRIxPTR = 270f
|
||||||
NOTICE: traducido PRIX64 = 62C6D1A9B2
|
NOTICE: traducido PRIX64 = 62C6D1A9B2
|
||||||
NOTICE: traducido PRIX32 = 4D2
|
NOTICE: traducido PRIX32 = FFFFFB2E
|
||||||
NOTICE: traducido PRIXMAX = 162E
|
NOTICE: traducido PRIXMAX = 1CBE991A14
|
||||||
NOTICE: traducido PRIXPTR = 270F
|
NOTICE: traducido PRIXPTR = 270F
|
||||||
test_translation
|
test_translation
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
@@ -28,13 +28,24 @@ begin
|
|||||||
raise log 'NLS regression test: lc_messages = %',
|
raise log 'NLS regression test: lc_messages = %',
|
||||||
current_setting('lc_messages');
|
current_setting('lc_messages');
|
||||||
end $$;
|
end $$;
|
||||||
SELECT current_setting('lc_messages') = 'C' AS failed \gset
|
|
||||||
\if :failed
|
|
||||||
\echo Could not find an acceptable spelling of es_ES locale
|
|
||||||
\quit
|
|
||||||
\endif
|
|
||||||
SELECT test_translation();
|
SELECT test_translation();
|
||||||
NOTICE: NLS is not enabled
|
NOTICE: NLS is not enabled
|
||||||
|
NOTICE: translated PRId64 = 424242424242
|
||||||
|
NOTICE: translated PRId32 = -1234
|
||||||
|
NOTICE: translated PRIdMAX = -123456789012
|
||||||
|
NOTICE: translated PRIdPTR = -9999
|
||||||
|
NOTICE: translated PRIu64 = 424242424242
|
||||||
|
NOTICE: translated PRIu32 = 4294966062
|
||||||
|
NOTICE: translated PRIuMAX = 123456789012
|
||||||
|
NOTICE: translated PRIuPTR = 9999
|
||||||
|
NOTICE: translated PRIx64 = 62c6d1a9b2
|
||||||
|
NOTICE: translated PRIx32 = fffffb2e
|
||||||
|
NOTICE: translated PRIxMAX = 1cbe991a14
|
||||||
|
NOTICE: translated PRIxPTR = 270f
|
||||||
|
NOTICE: translated PRIX64 = 62C6D1A9B2
|
||||||
|
NOTICE: translated PRIX32 = FFFFFB2E
|
||||||
|
NOTICE: translated PRIXMAX = 1CBE991A14
|
||||||
|
NOTICE: translated PRIXPTR = 270F
|
||||||
test_translation
|
test_translation
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,27 @@ begin
|
|||||||
raise log 'NLS regression test: lc_messages = %',
|
raise log 'NLS regression test: lc_messages = %',
|
||||||
current_setting('lc_messages');
|
current_setting('lc_messages');
|
||||||
end $$;
|
end $$;
|
||||||
SELECT current_setting('lc_messages') = 'C' AS failed \gset
|
SELECT test_translation();
|
||||||
\if :failed
|
NOTICE: lc_messages is 'C'
|
||||||
\echo Could not find an acceptable spelling of es_ES locale
|
NOTICE: translated PRId64 = 424242424242
|
||||||
Could not find an acceptable spelling of es_ES locale
|
NOTICE: translated PRId32 = -1234
|
||||||
\quit
|
NOTICE: translated PRIdMAX = -123456789012
|
||||||
|
NOTICE: translated PRIdPTR = -9999
|
||||||
|
NOTICE: translated PRIu64 = 424242424242
|
||||||
|
NOTICE: translated PRIu32 = 4294966062
|
||||||
|
NOTICE: translated PRIuMAX = 123456789012
|
||||||
|
NOTICE: translated PRIuPTR = 9999
|
||||||
|
NOTICE: translated PRIx64 = 62c6d1a9b2
|
||||||
|
NOTICE: translated PRIx32 = fffffb2e
|
||||||
|
NOTICE: translated PRIxMAX = 1cbe991a14
|
||||||
|
NOTICE: translated PRIxPTR = 270f
|
||||||
|
NOTICE: translated PRIX64 = 62C6D1A9B2
|
||||||
|
NOTICE: translated PRIX32 = FFFFFB2E
|
||||||
|
NOTICE: translated PRIXMAX = 1CBE991A14
|
||||||
|
NOTICE: translated PRIXPTR = 270F
|
||||||
|
test_translation
|
||||||
|
------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
RESET lc_messages;
|
||||||
|
|||||||
@@ -1156,6 +1156,10 @@ test_relpath(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple test to verify NLS support, particularly that the PRI* macros work.
|
* Simple test to verify NLS support, particularly that the PRI* macros work.
|
||||||
|
*
|
||||||
|
* A secondary objective is to verify that <inttypes.h>'s values for the
|
||||||
|
* PRI* macros match what our snprintf.c code will do. Therefore, we run
|
||||||
|
* the ereport() calls even when we know that translation will not happen.
|
||||||
*/
|
*/
|
||||||
PG_FUNCTION_INFO_V1(test_translation);
|
PG_FUNCTION_INFO_V1(test_translation);
|
||||||
Datum
|
Datum
|
||||||
@@ -1185,44 +1189,52 @@ test_translation(PG_FUNCTION_ARGS)
|
|||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If nls.sql failed to select a non-C locale, no translation will happen.
|
||||||
|
* Report that so that we can distinguish this outcome from brokenness.
|
||||||
|
* (We do this here, not in nls.sql, so as to need only 3 expected files.)
|
||||||
|
*/
|
||||||
|
if (strcmp(GetConfigOption("lc_messages", false, false), "C") == 0)
|
||||||
|
elog(NOTICE, "lc_messages is 'C'");
|
||||||
|
#else
|
||||||
|
elog(NOTICE, "NLS is not enabled");
|
||||||
|
#endif
|
||||||
|
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRId64 = %" PRId64, (int64) 424242424242));
|
errmsg("translated PRId64 = %" PRId64, (int64) 424242424242));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRId32 = %" PRId32, (int32) -1234));
|
errmsg("translated PRId32 = %" PRId32, (int32) -1234));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIdMAX = %" PRIdMAX, (intmax_t) -5678));
|
errmsg("translated PRIdMAX = %" PRIdMAX, (intmax_t) -123456789012));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIdPTR = %" PRIdPTR, (intptr_t) 9999));
|
errmsg("translated PRIdPTR = %" PRIdPTR, (intptr_t) -9999));
|
||||||
|
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIu64 = %" PRIu64, (uint64) 424242424242));
|
errmsg("translated PRIu64 = %" PRIu64, (uint64) 424242424242));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIu32 = %" PRIu32, (uint32) 1234));
|
errmsg("translated PRIu32 = %" PRIu32, (uint32) -1234));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIuMAX = %" PRIuMAX, (uintmax_t) 5678));
|
errmsg("translated PRIuMAX = %" PRIuMAX, (uintmax_t) 123456789012));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIuPTR = %" PRIuPTR, (uintptr_t) 9999));
|
errmsg("translated PRIuPTR = %" PRIuPTR, (uintptr_t) 9999));
|
||||||
|
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIx64 = %" PRIx64, (uint64) 424242424242));
|
errmsg("translated PRIx64 = %" PRIx64, (uint64) 424242424242));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIx32 = %" PRIx32, (uint32) 1234));
|
errmsg("translated PRIx32 = %" PRIx32, (uint32) -1234));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIxMAX = %" PRIxMAX, (uintmax_t) 5678));
|
errmsg("translated PRIxMAX = %" PRIxMAX, (uintmax_t) 123456789012));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIxPTR = %" PRIxPTR, (uintptr_t) 9999));
|
errmsg("translated PRIxPTR = %" PRIxPTR, (uintptr_t) 9999));
|
||||||
|
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIX64 = %" PRIX64, (uint64) 424242424242));
|
errmsg("translated PRIX64 = %" PRIX64, (uint64) 424242424242));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIX32 = %" PRIX32, (uint32) 1234));
|
errmsg("translated PRIX32 = %" PRIX32, (uint32) -1234));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIXMAX = %" PRIXMAX, (uintmax_t) 5678));
|
errmsg("translated PRIXMAX = %" PRIXMAX, (uintmax_t) 123456789012));
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
errmsg("translated PRIXPTR = %" PRIXPTR, (uintptr_t) 9999));
|
errmsg("translated PRIXPTR = %" PRIXPTR, (uintptr_t) 9999));
|
||||||
#else
|
|
||||||
elog(NOTICE, "NLS is not enabled");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,6 @@ begin
|
|||||||
current_setting('lc_messages');
|
current_setting('lc_messages');
|
||||||
end $$;
|
end $$;
|
||||||
|
|
||||||
SELECT current_setting('lc_messages') = 'C' AS failed \gset
|
|
||||||
\if :failed
|
|
||||||
\echo Could not find an acceptable spelling of es_ES locale
|
|
||||||
\quit
|
|
||||||
\endif
|
|
||||||
|
|
||||||
SELECT test_translation();
|
SELECT test_translation();
|
||||||
|
|
||||||
RESET lc_messages;
|
RESET lc_messages;
|
||||||
|
|||||||
Reference in New Issue
Block a user