There was a bug that if you created an ICU collation with tailoring
rules, any strength specification inside the rules was ignored. This
was because we called ucol_openRules() with UCOL_DEFAULT_STRENGTH for
the strength argument, which overrides the strength. This was because
of faulty guidance in the ICU documentation, which has since been
fixed. The correct invocation is to use UCOL_DEFAULT for the strength
argument.
This fixes bug #18771 and bug #19425.
Author: Daniel Verite <daniel@manitou-mail.org>
Reported-by: Ruben Ruiz <ruben.ruizcuadrado@gmail.com>
Reported-by: dorian.752@live.fr
Reported-by: Todd Lang <Todd.Lang@D2L.com>
Discussion: https://www.postgresql.org/message-id/flat/YT2PPF959236618377A072745A280E278F4BE1DA@YT2PPF959236618.CANPRD01.PROD.OUTLOOK.COM
Discussion: https://www.postgresql.org/message-id/flat/18771-
98bb23e455b0f367@postgresql.org
Discussion: https://www.postgresql.org/message-id/flat/19425-
58915e19dacd4f40%40postgresql.org
status = U_ZERO_ERROR;
collator_all_rules = ucol_openRules(all_rules, u_strlen(all_rules),
- UCOL_DEFAULT, UCOL_DEFAULT_STRENGTH,
+ UCOL_DEFAULT, UCOL_DEFAULT,
NULL, &status);
if (U_FAILURE(status))
{
CREATE COLLATION testcoll_rulesx (provider = icu, locale = '', rules = '!!wrong!!');
NOTICE: using standard form "und" for ICU locale ""
ERROR: could not open collator for locale "und" with rules "!!wrong!!": U_INVALID_FORMAT_ERROR
+-- strength specified in the rules
+CREATE COLLATION strength_in_rule (provider = icu, locale = 'und', deterministic = false, rules = '[strength 1]');
+SELECT 'a' = 'à' COLLATE strength_in_rule; -- true because of the rule
+ ?column?
+----------
+ t
+(1 row)
+
-- nondeterministic collations
CREATE COLLATION ctest_det (provider = icu, locale = '', deterministic = true);
NOTICE: using standard form "und" for ICU locale ""
CREATE COLLATION testcoll_rulesx (provider = icu, locale = '', rules = '!!wrong!!');
+-- strength specified in the rules
+CREATE COLLATION strength_in_rule (provider = icu, locale = 'und', deterministic = false, rules = '[strength 1]');
+SELECT 'a' = 'à' COLLATE strength_in_rule; -- true because of the rule
+
-- nondeterministic collations