From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 374F22169A for ; Sat, 9 Jun 2018 06:36:14 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7oqaSuTad_rj for ; Sat, 9 Jun 2018 06:36:14 -0400 (EDT) Received: from fallback.mail.ru (fallback7.mail.ru [94.100.181.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 33C40215F7 for ; Sat, 9 Jun 2018 06:36:13 -0400 (EDT) Received: from [10.161.17.67] (port=54756 helo=smtpng2.m.smailru.net) by fallback7.mail.ru with esmtp (envelope-from ) id 1fRae7-0004pC-MM for tarantool-patches@freelists.org; Sat, 09 Jun 2018 12:58:55 +0300 From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 01/11] box: remove migration from alpha 1.8.2 and 1.8.4 Date: Sat, 9 Jun 2018 12:58:41 +0300 Message-Id: <61d8c4bb7d76a728789a4c6f62a872fbe36865d7.1528535873.git.kshcherbatov@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov As 1.10 released before 1.8.2 and 1.8.4 we have had some binary incompatibility between 2.0 and 1.8.2, 1.8.4. This alphas were dropped. --- src/box/lua/upgrade.lua | 49 +++------- test/box/migrate.result | 123 ++++++++++++++++++++++++ test/box/migrate.test.lua | 45 +++++++++ test/box/migrate/1.10/00000000000000000003.snap | Bin 0 -> 1568 bytes test/box/migrate/migrate.lua | 7 ++ 5 files changed, 190 insertions(+), 34 deletions(-) create mode 100644 test/box/migrate.result create mode 100644 test/box/migrate.test.lua create mode 100644 test/box/migrate/1.10/00000000000000000003.snap create mode 100644 test/box/migrate/migrate.lua diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua index 8302f4b..18bfaa9 100644 --- a/src/box/lua/upgrade.lua +++ b/src/box/lua/upgrade.lua @@ -74,6 +74,7 @@ end local function set_system_triggers(val) box.space._space:run_triggers(val) box.space._index:run_triggers(val) + box.space._trigger:run_triggers(val) box.space._user:run_triggers(val) box.space._func:run_triggers(val) box.space._priv:run_triggers(val) @@ -465,60 +466,49 @@ local function upgrade_to_1_10_0() end -------------------------------------------------------------------------------- --- Tarantool 1.8.2 +-- Tarantool 2.1.0 -------------------------------------------------------------------------------- -local function upgrade_to_1_8_2() +local function upgrade_to_2_1_0() local _space = box.space[box.schema.SPACE_ID] local _index = box.space[box.schema.INDEX_ID] local _trigger = box.space[box.schema.TRIGGER_ID] + local MAP = setmap({}) + + log.info("create space _trigger") local format = {{name='name', type='string'}, {name='opts', type='map'}} + _space:insert{_trigger.id, ADMIN, '_trigger', 'memtx', 0, MAP, format} - log.info("create space _trigger") - _space:insert{_trigger.id, ADMIN, '_trigger', 'memtx', 0, setmap({}), {}} log.info("create index primary on _trigger") _index:insert{_trigger.id, 0, 'primary', 'tree', { unique = true }, - {{0, 'string'}}} - - log.info("alter space _trigger set format") - _trigger:format(format) -end - --------------------------------------------------------------------------------- --- Tarantool 1.8.4 --------------------------------------------------------------------------------- + {{0, 'string'}}} -local function upgrade_to_1_8_4() - local _space = box.space[box.schema.SPACE_ID] - local _index = box.space[box.schema.INDEX_ID] local stat1_ft = {{name='tbl', type='string'}, {name='idx', type='string'}, - {name='stat', type='string'}} + {name='stat', type='string'}} local stat4_ft = {{name='tbl', type='string'}, {name='idx', type='string'}, {name='neq', type='string'}, {name='nlt', type='string'}, {name='ndlt', type='string'}, {name='sample', type='scalar'}} - local MAP = setmap({}) log.info("create space _sql_stat1") - _space:insert{box.schema.SQL_STAT1_ID, ADMIN, '_sql_stat1', 'memtx', 0, - MAP, stat1_ft} + _space:insert{box.schema.SQL_STAT1_ID, ADMIN, '_sql_stat1', 'memtx', 0, MAP, + stat1_ft} log.info("create index primary on _sql_stat1") _index:insert{box.schema.SQL_STAT1_ID, 0, 'primary', 'tree', {unique = true}, {{0, 'string'}, {1, 'string'}}} log.info("create space _sql_stat4") - _space:insert{box.schema.SQL_STAT4_ID, ADMIN, '_sql_stat4', 'memtx', 0, - MAP, stat4_ft} + _space:insert{box.schema.SQL_STAT4_ID, ADMIN, '_sql_stat4', 'memtx', 0, MAP, + stat4_ft} log.info("create index primary on _sql_stat4") _index:insert{box.schema.SQL_STAT4_ID, 0, 'primary', 'tree', - {unique = true}, {{0, 'string'}, {1, 'string'}, - {5, 'scalar'}}} + {unique = true}, {{0, 'string'}, {1, 'string'}, {5, 'scalar'}}} -- Nullability wasn't skipable. This was fixed in 1-7. -- Now, abscent field means NULL, so we can safely set second @@ -530,14 +520,6 @@ local function upgrade_to_1_8_4() box.space._schema:format(format) end --------------------------------------------------------------------------------- --- Tarantool 2.1.0 --------------------------------------------------------------------------------- - -local function upgrade_to_2_1_0() - upgrade_to_1_10_0() -end - local function get_version() local version = box.space._schema:get{'version'} if version == nil then @@ -563,8 +545,7 @@ local function upgrade(options) local handlers = { {version = mkversion(1, 7, 6), func = upgrade_to_1_7_6, auto = true}, {version = mkversion(1, 7, 7), func = upgrade_to_1_7_7, auto = true}, - {version = mkversion(1, 8, 2), func = upgrade_to_1_8_2, auto = true}, - {version = mkversion(1, 8, 4), func = upgrade_to_1_8_4, auto = true}, + {version = mkversion(1, 10, 0), func = upgrade_to_1_10_0, auto = true}, {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0, auto = true} } diff --git a/test/box/migrate.result b/test/box/migrate.result new file mode 100644 index 0000000..91209b8 --- /dev/null +++ b/test/box/migrate.result @@ -0,0 +1,123 @@ +test_run = require('test_run').new() +--- +... +work_dir = 'box/migrate/1.10/' +--- +... +test_run:cmd('create server migrate with script="box/migrate/migrate.lua", workdir="' .. work_dir .. '"') +--- +- true +... +test_run:cmd('start server migrate') +--- +- true +... +test_run:switch('migrate') +--- +- true +... +-- test system tables +box.space._space.index['name']:get('_trigger') +--- +- [328, 1, '_trigger', 'memtx', 0, {}, [{'name': 'name', 'type': 'string'}, {'name': 'opts', + 'type': 'map'}]] +... +box.space._space.index['name']:get('_sql_stat1') +--- +- [348, 1, '_sql_stat1', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx', + 'type': 'string'}, {'name': 'stat', 'type': 'string'}]] +... +box.space._space.index['name']:get('_sql_stat4') +--- +- [349, 1, '_sql_stat4', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx', + 'type': 'string'}, {'name': 'neq', 'type': 'string'}, {'name': 'nlt', 'type': 'string'}, + {'name': 'ndlt', 'type': 'string'}, {'name': 'sample', 'type': 'scalar'}]] +... +box.space._index:get({box.space._space.index['name']:get('_trigger').id, 0}) +--- +- [328, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]] +... +box.space._index:get({box.space._space.index['name']:get('_sql_stat1').id, 0}) +--- +- [348, 0, 'primary', 'tree', {'unique': true}, [[0, 'string'], [1, 'string']]] +... +box.space._index:get({box.space._space.index['name']:get('_sql_stat4').id, 0}) +--- +- [349, 0, 'primary', 'tree', {'unique': true}, [[0, 'string'], [1, 'string'], [5, + 'scalar']]] +... +box.space._schema:format() +--- +- [{'type': 'string', 'name': 'key'}, {'type': 'any', 'name': 'value', 'is_nullable': true}] +... +-- test data migration +box.space._space.index['name']:get('T1') +--- +- [512, 1, 'T1', 'memtx', 0, {}, [{'name': 'x', 'type': 'unsigned'}]] +... +box.space._index:get({box.space._space.index['name']:get('T1').id, 0}) +--- +- [512, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]] +... +-- test system tables functionality +box.sql.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);") +--- +... +box.sql.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);") +--- +... +box.sql.execute("CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1); END;") +--- +... +box.space._space.index['name']:get('T') +--- +- [513, 1, 'T', 'memtx', 1, {'sql': 'CREATE TABLE t(x INTEGER PRIMARY KEY)'}, [{'type': 'integer', + 'nullable_action': 'abort', 'name': 'X', 'is_nullable': false}]] +... +box.space._space.index['name']:get('T_OUT') +--- +- [514, 1, 'T_OUT', 'memtx', 1, {'sql': 'CREATE TABLE t_out(x INTEGER PRIMARY KEY)'}, + [{'type': 'integer', 'nullable_action': 'abort', 'name': 'X', 'is_nullable': false}]] +... +box.space._trigger:get('T1T') +--- +- ['T1T', {'sql': 'CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1); + END;'}] +... +box.sql.execute("INSERT INTO T VALUES(1);") +--- +... +box.space.T:select() +--- +- - [1] +... +box.space.T_OUT:select() +--- +- - [1] +... +box.sql.execute("SELECT * FROM T") +--- +- - [1] +... +box.sql.execute("SELECT * FROM T") +--- +- - [1] +... +box.sql.execute("DROP TABLE T;") +--- +... +box.sql.execute("DROP TABLE T_OUT;") +--- +... +test_run:switch('default') +--- +- true +... +test_run:cmd('stop server migrate') +--- +- true +... +test_run:cmd('cleanup server migrate') +--- +- true +... diff --git a/test/box/migrate.test.lua b/test/box/migrate.test.lua new file mode 100644 index 0000000..40f5ce8 --- /dev/null +++ b/test/box/migrate.test.lua @@ -0,0 +1,45 @@ +test_run = require('test_run').new() + +work_dir = 'box/migrate/1.10/' +test_run:cmd('create server migrate with script="box/migrate/migrate.lua", workdir="' .. work_dir .. '"') +test_run:cmd('start server migrate') + +test_run:switch('migrate') + +-- test system tables +box.space._space.index['name']:get('_trigger') +box.space._space.index['name']:get('_sql_stat1') +box.space._space.index['name']:get('_sql_stat4') + +box.space._index:get({box.space._space.index['name']:get('_trigger').id, 0}) +box.space._index:get({box.space._space.index['name']:get('_sql_stat1').id, 0}) +box.space._index:get({box.space._space.index['name']:get('_sql_stat4').id, 0}) + +box.space._schema:format() + +-- test data migration +box.space._space.index['name']:get('T1') +box.space._index:get({box.space._space.index['name']:get('T1').id, 0}) + +-- test system tables functionality +box.sql.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);") +box.sql.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);") +box.sql.execute("CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1); END;") +box.space._space.index['name']:get('T') +box.space._space.index['name']:get('T_OUT') +box.space._trigger:get('T1T') + +box.sql.execute("INSERT INTO T VALUES(1);") +box.space.T:select() +box.space.T_OUT:select() +box.sql.execute("SELECT * FROM T") +box.sql.execute("SELECT * FROM T") + + +box.sql.execute("DROP TABLE T;") +box.sql.execute("DROP TABLE T_OUT;") + + +test_run:switch('default') +test_run:cmd('stop server migrate') +test_run:cmd('cleanup server migrate') diff --git a/test/box/migrate/1.10/00000000000000000003.snap b/test/box/migrate/1.10/00000000000000000003.snap new file mode 100644 index 0000000000000000000000000000000000000000..728d12c9157092b3cc31b2f7ed32c5219bc48d0b diff --git a/test/box/migrate/migrate.lua b/test/box/migrate/migrate.lua new file mode 100644 index 0000000..2853492 --- /dev/null +++ b/test/box/migrate/migrate.lua @@ -0,0 +1,7 @@ +#!/usr/bin/env tarantool + +box.cfg{ + listen = os.getenv("LISTEN"), +} + +require('console').listen(os.getenv('ADMIN')) -- 2.7.4