Debian Codegraph @

mysql-test/suite/versioning/t/online.test

raw
1 --source suite/versioning/innodb.inc
2 --source suite/versioning/common.inc
3 --source include/maybe_debug.inc
4
5 set system_versioning_alter_history=keep;
6
7 create or replace table t (a int);
8 alter table t add system versioning, lock=none;
9 alter table t drop system versioning;
10 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
11 alter table t add system versioning, algorithm=inplace;
12 alter table t add system versioning, lock=shared;
13
14 alter table t add column b int, change column a a int without system versioning, lock=none;
15 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
16 alter table t drop system versioning, lock=none;
17 alter table t drop system versioning, algorithm=inplace;
18
19 --replace_result $sys_datatype_expl SYS_DATATYPE
20 eval create or replace table t (
21 a int, b int,
22 row_start $sys_datatype_expl as row start invisible,
23 row_end $sys_datatype_expl as row end invisible,
24 period for system_time (row_start, row_end)
25 ) with system versioning;
26 insert into t values (1, 0);
27 insert into t values (2, 0);
28 delete from t where a = 2;
29 alter table t drop column b, lock=none;
30 alter table t add index idx(a), lock=none;
31
32 select a, check_row(row_start, row_end) from t for system_time all order by a;
33
34 --echo # MDEV-17038 ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL -
35 --echo # generates error if table uses SYSTEM VERSIONING [tempesta-tech/mariadb#540]
36 create or replace table t1 (a int, key(a)) with system versioning;
37 create or replace table t2 like t;
38 alter table t2 add foreign key(a) references t1(a);
39 alter table t2 modify column a int not null, lock=none;
40
41 drop table t2;
42 drop table t1;
43
44 --echo # MDEV-16330 Allow instant change of WITH SYSTEM VERSIONING column attribute
45 --replace_result $sys_datatype_expl SYS_DATATYPE
46 eval create or replace table t1 (
47 a int,
48 b int,
49 row_start $sys_datatype_expl as row start invisible,
50 row_end $sys_datatype_expl as row end invisible,
51 period for system_time(row_start, row_end)
52 ) with system versioning;
53
54 --replace_result $sys_datatype_expl SYS_DATATYPE
55 eval create or replace table t2 (
56 a int without system versioning,
57 b int,
58 row_start $sys_datatype_expl as row start invisible,
59 row_end $sys_datatype_expl as row end invisible,
60 period for system_time(row_start, row_end)
61 ) with system versioning;
62
63 insert into t1 values (1,1);
64 insert into t2 values (1,1);
65
66 set @@system_versioning_alter_history=keep;
67
68 --enable_info
69 --echo # without rebuild
70 alter table t1
71 change a a int without system versioning,
72 algorithm=instant;
73
74 --error ER_ALTER_OPERATION_NOT_SUPPORTED
75 alter table t2
76 change a a int with system versioning,
77 add primary key pk (a),
78 algorithm=instant;
79
80 --echo # with rebuild
81 alter table t2
82 change a a int with system versioning,
83 add primary key pk (a);
84 --disable_info
85
86 --source include/restart_mysqld.inc
87
88 update t1 set a=2;
89 select count(*) from t1 for system_time all;
90
91 update t2 set a=2;
92 select count(*) from t2 for system_time all;
93
94 drop table t1, t2;
95
96 --echo # rollback ALTER TABLE: nothing should change
97 --replace_result $sys_datatype_expl SYS_DATATYPE
98 eval create or replace table t (
99 a int,
100 b int,
101 row_start $sys_datatype_expl as row start invisible,
102 row_end $sys_datatype_expl as row end invisible,
103 period for system_time(row_start, row_end)
104 ) with system versioning;
105
106 insert into t values (1, 1);
107
108 select c.prtype from information_schema.innodb_sys_columns as c
109 join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
110 where t.name='test/t' and c.name='b';
111
112 set @@system_versioning_alter_history=keep;
113
114 if ($have_debug) {
115 --disable_query_log
116 --disable_result_log
117 set debug_dbug='+d,ib_commit_inplace_fail_1';
118 --error ER_INTERNAL_ERROR
119 alter table t
120 change b b int without system versioning;
121 set debug_dbug= default;
122 --enable_query_log
123 --enable_result_log
124 }
125
126 select c.prtype from information_schema.innodb_sys_columns as c
127 join information_schema.innodb_sys_tables as t on c.table_id=t.table_id
128 where t.name='test/t' and c.name='b';
129
130 --replace_result $sys_datatype_expl SYS_DATATYPE
131 show create table t;
132
133 select count(*) from t for system_time all;
134 update t set b=11;
135 select count(*) from t for system_time all;
136 drop table t;
137
138 --echo # Start of 10.4 tests
139
140 create or replace table t (a int, b int) engine=innodb;
141 alter table t
142 add s bigint unsigned as row start,
143 add e bigint unsigned as row end,
144 add period for system_time(s, e),
145 add system versioning;
146 alter table t drop column b, algorithm=instant;
147 alter table t add index idx(a), lock=none;
148 alter table t drop column s, drop column e;
149 --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
150 alter table t drop system versioning, lock=none;
151
152 --echo #
153 --echo # MDEV-17697 Broken versioning info after instant drop column
154 --echo #
155 set @@system_versioning_alter_history= keep;
156 create or replace table t1 (a int, b int) with system versioning;
157 insert into t1 values (1, 1);
158 alter table t1 drop column b, algorithm=instant;
159 alter table t1 drop system versioning;
160
161 create or replace table t1 (a int, b int) with system versioning;
162 insert into t1 values (1, 1);
163
164 if ($have_debug) {
165 --disable_query_log
166 --disable_result_log
167 set debug_dbug='+d,ib_commit_inplace_fail_1';
168 --error ER_INTERNAL_ERROR
169 alter table t1 drop column b, algorithm=instant;
170 set debug_dbug= default;
171 --enable_query_log
172 --enable_result_log
173 }
174 alter table t1 drop system versioning;
175
176 --echo #
177 --echo # MDEV-18173 Assertion `o->ind == vers_end' or `o->ind == vers_start' failed in dict_table_t::instant_column
178 --echo #
179 set @@system_versioning_alter_history= keep;
180 create or replace table t1 (pk integer primary key, a int, b int, v int as (a))
181 with system versioning;
182
183 alter table t1 force;
184 alter table t1 drop column b;
185
186 --echo #
187 --echo # MDEV-18122 Assertion `table->versioned() == m_prebuilt->table->versioned()' failed in ha_innobase::open
188 --echo #
189 create or replace table t1 (
190 x int,
191 v int as (x) virtual,
192 y int
193 ) with system versioning;
194 alter table t1 drop system versioning;
195
196 drop tables t, t1;
197
198 --source suite/versioning/common_finish.inc