From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Possible to create a hidden collation |
Date: | 2023-05-11 20:45:38 |
Message-ID: | 051c9395cf880307865ee8b17acdbf7f838c1e39.camel@j-davis.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Repro:
create collation test(provider=icu,
deterministic=false, locale='@colStrength=primary');
create collation "en_US"(provider=icu,
deterministic=false, locale='@colStrength=primary');
select 'a' = 'A' collate test; -- true
select 'a' = 'A' collate "en_US"; -- false
drop collation "en_US"; -- drops built-in collation
select 'a' = 'A' collate "en_US"; -- true
Explanation:
The second collation named "en_US" is hidden behind the built-in
collation "en_US" because the former is created with collencoding=-1
(as all icu collations are), and the latter is a libc collation with
collencoding equal to the current database encoding (which takes
precedence).
It's a minor bug, but could be surprising behavior.
Solution:
There's no reason to create user defined collations with collencoding=-
1. As far as I can tell, collencoding is only there to hide built-in
collations (inherited from template0) that aren't compatible with the
current database encoding. So we can just always create user-defined
collations with collencoding=GetDatabaseEncoding().
Patch attached (extracted from series posted elsewhere because this is
a bug in old versions). I don't intend to backport because the bug is
minor and it will affect catalog contents. If others agree with the
fix, then I'll also bump the catversion, though I'm not sure that it's
strictly necessary.
Regards,
Jeff Davis
Attachment | Content-Type | Size |
---|---|---|
v5-0001-For-user-defined-collations-never-set-collencodin.patch | text/x-patch | 4.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-05-12 00:02:14 | Re: Possible to create a hidden collation |
Previous Message | Robert Haas | 2023-05-11 18:21:04 | Re: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware) |