Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to create ICU-based collation with locale keywords #6903

Closed
tkeinz opened this issue Jul 18, 2021 · 2 comments · Fixed by #6914
Closed

Unable to create ICU-based collation with locale keywords #6903

tkeinz opened this issue Jul 18, 2021 · 2 comments · Fixed by #6914

Comments

@tkeinz
Copy link
Contributor

tkeinz commented Jul 18, 2021

Firebird does not seem to allow the creation of ICU-based collations whose locales contain keywords, such as de@collation=phonebook or de-u-co-phonebk.

For example, executing the following statement:

CREATE COLLATION UNICODE_TEST FOR UTF8 FROM UNICODE
  PAD SPACE
  CASE SENSITIVE
  ACCENT SENSITIVE
  'LOCALE=de-u-co-phonebk-ka-shifted';

fails with:

Message: isc_dsql_execute2 failed

SQL Message : -607
This operation is not defined for system tables.

Engine Code    : 335544351
Engine Message :
unsuccessful metadata update
CREATE COLLATION UNICODE_TEST failed
Invalid collation attributes

The failure originates from UnicodeUtil::Utf16Collation::loadICU() (file src/common/unicode_util.cpp). When checking the incoming locale, it is compared against the locale names obtained from ICU's enumeration. This however does not include keywords or collation subtypes, so anything other than locale base names will fail this test.

I'm attaching a patch with a suggested fix (against v4.0-release, but should work on FB3 also). The fix adds a fallback check which tries to create a collator with the locale in question. This check is only performed if the previous check failed. With this modification, locales with keywords are accepted when creating a collation, and the collation works as expected when applied to a table column.

allow_keyword_locales.zip

asfernandes pushed a commit that referenced this issue Aug 2, 2021
…6903) (#6914)

* Allow keywords in locales when creating ICU collations

* Change ICU locale creation check to fail for any warning.

Co-authored-by: Thomas Keinz <thomas.keinz@hescom.de>
@pavel-zotov
Copy link

Currently fix presents only in v4.0-release. What about master ?

@asfernandes
Copy link
Member

Currently fix presents only in v4.0-release. What about master ?

I will do it.

asfernandes pushed a commit that referenced this issue Aug 4, 2021
…6903) (#6914)

* Allow keywords in locales when creating ICU collations

* Change ICU locale creation check to fail for any warning.

Co-authored-by: Thomas Keinz <thomas.keinz@hescom.de>
# for free to join this conversation on GitHub. Already have an account? # to comment