Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
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	[thread overview]
Message-ID: <61d8c4bb7d76a728789a4c6f62a872fbe36865d7.1528535873.git.kshcherbatov@tarantool.org> (raw)
In-Reply-To: <cover.1528535873.git.kshcherbatov@tarantool.org>
In-Reply-To: <cover.1528535873.git.kshcherbatov@tarantool.org>

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

  parent reply	other threads:[~2018-06-09 10:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-09  9:58 [tarantool-patches] [PATCH v2 00/11] sql: remove Triggers to server Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 10/11] sql: move " Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-28  7:18   ` Konstantin Osipov
2018-06-28  7:33     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 11/11] sql: VDBE tests for trigger existence Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 02/11] box: move db->pShchema init to sql_init Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 04/11] sql: fix sql len in tarantoolSqlite3RenameTrigger Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 06/11] sql: refactor sql_expr_compile to return AST Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 07/11] sql: move sqlite3DeleteTrigger to sql.h Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 08/11] box: sort error codes in misc.test Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 09/11] sql: new _trigger space format with space_id Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:58 ` Kirill Shcherbatov [this message]
2018-06-09  9:58 ` [tarantool-patches] [PATCH v2 03/11] sql: fix leak on CREATE TABLE and resolve self ref Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:58 ` [tarantool-patches] [PATCH v2 05/11] box: port schema_find_id to C Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61d8c4bb7d76a728789a4c6f62a872fbe36865d7.1528535873.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v2 01/11] box: remove migration from alpha 1.8.2 and 1.8.4' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox