Skip to content

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

@tkeinz

Description

@tkeinz

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions