1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
test_run = require('test_run').new()
---
...
engine = test_run:get_cfg('engine')
---
...
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})
---
...
work_dir = 'sql/upgrade/1.10/'
---
...
test_run:cmd('create server upgrade with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
---
- true
...
test_run:cmd('start server upgrade')
---
- true
...
test_run:switch('upgrade')
---
- true
...
-- test system tables
box.space._space.index['name']:get('_trigger')
---
- [328, 1, '_trigger', 'memtx', 0, {}, [{'name': 'name', 'type': 'string'}, {'name': 'space_id',
'type': 'unsigned'}, {'name': 'opts', 'type': 'map'}]]
...
box.space._index:get({box.space._space.index['name']:get('_trigger').id, 0})
---
- [328, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
...
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.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);")
---
- row_count: 1
...
box.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);")
---
- row_count: 1
...
box.execute("CREATE TRIGGER t1t AFTER INSERT ON t FOR EACH ROW BEGIN INSERT INTO t_out VALUES(1); END;")
---
- row_count: 1
...
box.execute("CREATE TRIGGER t2t AFTER INSERT ON t FOR EACH ROW BEGIN INSERT INTO t_out VALUES(2); END;")
---
- row_count: 1
...
box.space._space.index['name']:get('T')
---
- [513, 1, 'T', 'memtx', 1, {}, [{'type': 'integer', 'nullable_action': 'abort', 'name': 'X',
'is_nullable': false}]]
...
box.space._space.index['name']:get('T_OUT')
---
- [514, 1, 'T_OUT', 'memtx', 1, {}, [{'type': 'integer', 'nullable_action': 'abort',
'name': 'X', 'is_nullable': false}]]
...
t1t = box.space._trigger:get('T1T')
---
...
t2t = box.space._trigger:get('T2T')
---
...
t1t.name
---
- T1T
...
t1t.opts
---
- {'sql': 'CREATE TRIGGER t1t AFTER INSERT ON t FOR EACH ROW BEGIN INSERT INTO t_out
VALUES(1); END;'}
...
t2t.name
---
- T2T
...
t2t.opts
---
- {'sql': 'CREATE TRIGGER t2t AFTER INSERT ON t FOR EACH ROW BEGIN INSERT INTO t_out
VALUES(2); END;'}
...
assert(t1t.space_id == t2t.space_id)
---
- true
...
assert(t1t.space_id == box.space.T.id)
---
- true
...
box.execute("INSERT INTO T VALUES(1);")
---
- row_count: 1
...
box.space.T:select()
---
- - [1]
...
box.space.T_OUT:select()
---
- - [1]
- [2]
...
box.execute("SELECT * FROM T")
---
- metadata:
- name: X
type: integer
rows:
- [1]
...
box.execute("SELECT * FROM T")
---
- metadata:
- name: X
type: integer
rows:
- [1]
...
box.execute("DROP TABLE T;")
---
- row_count: 1
...
box.execute("DROP TABLE T_OUT;")
---
- row_count: 1
...
test_run:switch('default')
---
- true
...
test_run:cmd('stop server upgrade')
---
- true
...
test_run:cmd('cleanup server upgrade')
---
- true
...
-- Test Tarantool 2.1.0 to 2.1.1 migration.
work_dir = 'sql/upgrade/2.1.0/'
---
...
test_run:cmd('create server upgrade210 with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
---
- true
...
test_run:cmd('start server upgrade210')
---
- true
...
test_run:switch('upgrade210')
---
- true
...
s = box.space.T5
---
...
s ~= nil
---
- true
...
i = box.space._index:select(s.id)
---
...
i ~= nil
---
- true
...
i[1].opts.sql == nil
---
- true
...
box.space._space:get(s.id).flags.checks == nil
---
- true
...
check = box.space._ck_constraint:select()[1]
---
...
check ~= nil
---
- true
...
check.name
---
- CK_CONSTRAINT_1_T5
...
check.code
---
- x < 2
...
s:drop()
---
...
test_run:switch('default')
---
- true
...
test_run:cmd('stop server upgrade210')
---
- true
...
test_run:cmd('cleanup server upgrade210')
---
- true
...
|