[PATCH 12/12] vinyl: allow to modify key definition if it does not require rebuild

Konstantin Osipov kostja at tarantool.org
Thu Apr 5 17:45:03 MSK 2018


* Vladimir Davydov <vdavydov.dev at gmail.com> [18/04/02 11:49]:

> +--
> +-- Modify key definition without index rebuild.
> +--

One more thing, please, we need more functional tests.

Let's create a test plan which we will then reuse for non-empty
spaces as well:

Modify:
 - unique -> non unique, non-unique -> unique, or no change
 - nullable -> not-nullable, not-nullable -> nullable, or no
   change
 - a wider type is altered to a more narrow type, or vice versa,
   or the type types are incompatible, or no change,
 - key part added, removed, or all key parts changed, or no key
   parts changed.

Each line above creates a testing dimension, so in the end we
should have at least 3*4*4*4  = 192 different test cases.
Let's construct a test case in a way allowing us to add different
dimensions to it in the future.

> +s = box.schema.create_space('test', {engine = engine})
> +---
> +...
> +i1 = s:create_index('i1', {unique = true,  parts = {1, 'unsigned'}})
> +---
> +...
> +i2 = s:create_index('i2', {unique = false, parts = {2, 'unsigned'}})
> +---
> +...
> +i3 = s:create_index('i3', {unique = true,  parts = {3, 'unsigned'}})
> +---
> +...
> +_ = s:insert{1, 2, 3}
> +---
> +...
> +box.snapshot()
> +---
> +- ok
> +...
> +_ = s:insert{3, 2, 1}
> +---
> +...
> +i1:alter{parts = {1, 'integer'}}
> +---
> +...
> +_ = s:insert{-1, 2, 2}
> +---
> +...
> +i1:select()
> +---
> +- - [-1, 2, 2]
> +  - [1, 2, 3]
> +  - [3, 2, 1]
> +...
> +i2:select()
> +---
> +- - [-1, 2, 2]
> +  - [1, 2, 3]
> +  - [3, 2, 1]
> +...
> +i3:select()
> +---
> +- - [3, 2, 1]
> +  - [-1, 2, 2]
> +  - [1, 2, 3]
> +...
> +i2:alter{parts = {2, 'integer'}}
> +---
> +...
> +i3:alter{parts = {3, 'integer'}}
> +---
> +...
> +_ = s:replace{-1, -1, -1}
> +---
> +...
> +i1:select()
> +---
> +- - [-1, -1, -1]
> +  - [1, 2, 3]
> +  - [3, 2, 1]
> +...
> +i2:select()
> +---
> +- - [-1, -1, -1]
> +  - [1, 2, 3]
> +  - [3, 2, 1]
> +...
> +i3:select()
> +---
> +- - [-1, -1, -1]
> +  - [3, 2, 1]
> +  - [1, 2, 3]
> +...
> +box.snapshot()
> +---
> +- ok
> +...
> +_ = s:replace{-1, -2, -3}
> +---
> +...
> +_ = s:replace{-3, -2, -1}
> +---
> +...
> +i1:select()
> +---
> +- - [-3, -2, -1]
> +  - [-1, -2, -3]
> +  - [1, 2, 3]
> +  - [3, 2, 1]
> +...
> +i2:select()
> +---
> +- - [-3, -2, -1]
> +  - [-1, -2, -3]
> +  - [1, 2, 3]
> +  - [3, 2, 1]
> +...
> +i3:select()
> +---
> +- - [-1, -2, -3]
> +  - [-3, -2, -1]
> +  - [3, 2, 1]
> +  - [1, 2, 3]
> +...
> +s:drop()
> +---
> +...

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov



More information about the Tarantool-patches mailing list