[tarantool-patches] [PATCH] Feature request for a new collation

Vladimir Davydov vdavydov.dev at gmail.com
Mon Feb 25 14:59:12 MSK 2019


On Fri, Feb 22, 2019 at 02:49:39PM +0300, Stanislav Zudin wrote:
> Adds a new default collation 'unicode_s2' to support the difference 
> between Cyrillic letters 'Е' and 'Ё'. The standard case insensitive 
> collation ('unicode_ci') doesn't distinguish these letters.
> 
> Closes #4007
> ---
> Branch: https://github.com/tarantool/tarantool/tree/stanztt/gh-4007-new-default-collation
> Issue: https://github.com/tarantool/tarantool/issues/4007
> 
>  src/box/bootstrap.snap      | Bin 1527 -> 1561 bytes
>  src/box/lua/upgrade.lua     |   6 ++
>  test/box/collation.result   | 160 ++++++++++++++++++++++++++++++++++++
>  test/box/collation.test.lua |  49 +++++++++++
>  4 files changed, 215 insertions(+)
>  create mode 100644 test/box/collation.result
>  create mode 100644 test/box/collation.test.lua

Tests don't pass on Travis CI, please fix.

> diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
> index ab705e978..a28b93ada 100644
> --- a/src/box/lua/upgrade.lua
> +++ b/src/box/lua/upgrade.lua
> @@ -998,9 +998,15 @@ local function create_vinyl_deferred_delete_space()
>                    'blackhole', 0, {group_id = 1}, format}
>  end
>  
> +local function create_default_collation_s2()
> +    log.info("create predefined collation")
> +    box.space._collation:replace{3, "unicode_s2", ADMIN, "ICU", "ru_RU", {strength='secondary'}}
> +end
> +
>  local function upgrade_to_1_10_2()
>      upgrade_priv_to_1_10_2()
>      create_vinyl_deferred_delete_space()
> +    create_default_collation_s2()

We push only to branch 2.1 and then backport to 1.10. Please implement
this patch for 2.1 first. The committer will try to backport it to 1.10
by himself. If he fails, he'll ask you for assistance.

Anyway, 1.10.2, as well as 2.1.1, has already been released. You must
use version 1.10.3 / 2.1.2.

>  end
>  
>  local function get_version()
> diff --git a/test/box/collation.result b/test/box/collation.result
> new file mode 100644
> index 000000000..2dbb43c31
> --- /dev/null
> +++ b/test/box/collation.result
> @@ -0,0 +1,160 @@
> +env = require('test_run')
> +---
> +...
> +test_run = env.new()
> +---
> +...
> +--
> +-- gh-4007 Feature request for a new collation
> +--
> +-- Ensure all default collations exist
> +box.space._collation.index.name:get{'unicode'};

Please don't use semicolon (;) in Lua - it's not required.

> +---
> +- [1, 'unicode', 1, 'ICU', '', {}]
> +...
> +box.space._collation.index.name:get{'unicode_ci'};
> +---
> +- [2, 'unicode_ci', 1, 'ICU', '', {'strength': 'primary'}]
> +...
> +box.space._collation.index.name:get{'unicode_s2'};
> +---
> +- [3, 'unicode_s2', 1, 'ICU', 'ru_RU', {'strength': 'secondary'}]
> +...
> +-- Default unicode collation deals with russian letters
> +s = box.schema.space.create('t1');
> +---
> +...
> +s:format({{name='s1', type='string', collation = 'unicode'}});
> +---
> +...
> +s:create_index('pk', {unique = true, type='tree', parts={{'s1', collation = 'unicode'}}});
> +---
> +- unique: true
> +  parts:
> +  - type: string
> +    is_nullable: false
> +    collation: unicode
> +    fieldno: 1
> +  id: 0
> +  space_id: 512

Please don't print space_id in tests - it can change if you run the test
in a different order.



More information about the Tarantool-patches mailing list