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@gmail.com>
Subject: [tarantool-patches] [PATCH v1 1/1] box: remove migration from alpha 1.8.2 and 1.8.4
Date: Fri,  8 Jun 2018 16:04:45 +0300	[thread overview]
Message-ID: <53552ee2d5b52f38024e42cfd3eacbee5586accf.1528463042.git.kshcherbatov@gmail.com> (raw)

From: Kirill Shcherbatov <kshcherbatov@gmail.com>

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                         |  48 +++------
 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, 189 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..5f2f400 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -465,60 +465,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 +519,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 +544,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/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

                 reply	other threads:[~2018-06-08 13:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=53552ee2d5b52f38024e42cfd3eacbee5586accf.1528463042.git.kshcherbatov@gmail.com \
    --to=kshcherbatov@tarantool.org \
    --cc=kshcherbatov@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v1 1/1] 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