Re: BUG #17170: Invalid collation created with provider icu and initdb' locale C
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: andrewbille@gmail.com
Cc: pgsql-bugs@lists.postgresql.org,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Date: 2021-08-31T16:34:05Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes: > When using postgres built "--with-icu" I get an invalid collation with the > following script: > initdb -D db --locale=C > createdb testdb > psql testdb -c "CREATE COLLATION test (provider=icu, > locale='en_US.utf8');" > psql testdb -c "SELECT 'a' < 'b' COLLATE test;" > ERROR: collation "test" for encoding "SQL_ASCII" does not exist > LINE 1: SELECT 'a' < 'b' COLLATE test; > ^ That error doesn't seem inappropriate; ICU collations don't work in SQL_ASCII encoding. > psql testdb -c "DROP COLLATION test;" > ERROR: collation "test" for encoding "SQL_ASCII" does not exist That, however, is a bit annoying. If you can create the collation you should be able to drop it. The immediate issue is that DROP COLLATION uses the same lookup rule as other code paths, so it fails to see inapplicable pg_collation entries at all. So one approach to a fix is to relax its lookup rule. But I wonder if we should have prevented the CREATE in the first place, instead. Unfortunately, either approach is likely to still have some edge-case odd behaviors :-(. This whole business of having the database encoding be implicitly part of the lookup rule is just prone to that. regards, tom lane
Commits
-
Disallow creating an ICU collation if the DB encoding won't support it.
- 2cc018ba8f80 14.0 landed
- db2760a84191 15.0 landed
- 9ebe2852e543 11.14 landed
- 9046a05368de 12.9 landed
- 5d7c6b6c8b4a 10.19 landed
- 132be60006b3 13.5 landed