1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Pin two ctype-dependent test_regex_utf8 cases to pg_c_utf8

test_regex_utf8 decides whether to run by looking at the database
encoding alone, but two of its cases, [[:graph:]] and [[:print:]] over
E'xᔀሷ', depend on the ctype as well.  In a database with encoding
UTF8 and locale C they match just the x, because isgraph() and isprint()
are false for anything outside ASCII, and the file fails.

No buildfarm animal builds such a cluster, which is why this went
unnoticed, and why the to_date() crash in 18.5 went undetected for want
of exactly this coverage.  A pending buildfarm client change will let an
animal be configured that way.

Fix by giving the two cases an explicit collation, so that they exercise
a fixed Unicode ctype instead of whatever the database happened to be
initialized with.  test_regex() already passes its input collation down
to the regex compiler.  The expected results are unchanged; only the
echoed queries differ.

Backpatch-through: 17 (15 and 16 get a different fix)

Reviewed-by: Jonathan Gonzalez V. <jonathan@abdiel.eu>
This commit is contained in:
Andrew Dunstan
2026-08-22 17:47:24 -04:00
parent ef89c839cd
commit 073bd83277
2 changed files with 8 additions and 4 deletions

View File

@@ -147,7 +147,9 @@ select * from test_regex('[[:digit:]]+', E'x9\u1500\u1237', 'L');
{9}
(2 rows)
select * from test_regex('[[:graph:]]+', E'x\u1500\u1237', 'L');
-- graph and print depend on the ctype and not just the encoding, so pin them
-- to a Unicode-aware collation rather than the database's
select * from test_regex('[[:graph:]]+', E'x\u1500\u1237' COLLATE pg_c_utf8, 'L');
test_regex
-----------------
{0,REG_ULOCALE}
@@ -161,7 +163,7 @@ select * from test_regex('[[:lower:]]+', E'x\u1500\u1237', 'L');
{x}
(2 rows)
select * from test_regex('[[:print:]]+', E'x\u1500\u1237', 'L');
select * from test_regex('[[:print:]]+', E'x\u1500\u1237' COLLATE pg_c_utf8, 'L');
test_regex
-----------------
{0,REG_ULOCALE}

View File

@@ -66,9 +66,11 @@ select * from test_regex('[[:ascii:]]+', E'x\u1500\u1237', 'L');
select * from test_regex('[[:blank:]]+', E'x \t\u1500\u1237', 'L');
select * from test_regex('[[:cntrl:]]+', E'x\u1500\u1237', 'L');
select * from test_regex('[[:digit:]]+', E'x9\u1500\u1237', 'L');
select * from test_regex('[[:graph:]]+', E'x\u1500\u1237', 'L');
-- graph and print depend on the ctype and not just the encoding, so pin them
-- to a Unicode-aware collation rather than the database's
select * from test_regex('[[:graph:]]+', E'x\u1500\u1237' COLLATE pg_c_utf8, 'L');
select * from test_regex('[[:lower:]]+', E'x\u1500\u1237', 'L');
select * from test_regex('[[:print:]]+', E'x\u1500\u1237', 'L');
select * from test_regex('[[:print:]]+', E'x\u1500\u1237' COLLATE pg_c_utf8, 'L');
select * from test_regex('[[:punct:]]+', E'x.\u1500\u1237', 'L');
select * from test_regex('[[:space:]]+', E'x \t\u1500\u1237', 'L');
select * from test_regex('[[:upper:]]+', E'xX\u1500\u1237', 'L');