-
Notifications
You must be signed in to change notification settings - Fork 410
/
Copy pathalter_exchange_partition.test
92 lines (81 loc) · 3.62 KB
/
alter_exchange_partition.test
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
# Copyright 2022 PingCAP, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# enable this test after https://github.com/pingcap/tiflash/issues/7941 is fixed
#RETURN
>> DBGInvoke __enable_schema_sync_service('true')
mysql> drop table if exists test.e;
mysql> drop table if exists test.e2;
mysql> drop table if exists test_new.e2;
mysql> drop database if exists test_new;
mysql> create table test.e(id INT NOT NULL,fname VARCHAR(30),lname VARCHAR(30)) PARTITION BY RANGE (id) ( PARTITION p0 VALUES LESS THAN (50),PARTITION p1 VALUES LESS THAN (150));
mysql> alter table test.e set tiflash replica 1;
mysql> create table test.e2(id int not null, fname varchar(30), lname varchar(30));
mysql> alter table test.e2 set tiflash replica 1;
mysql> create database test_new;
mysql> create table test_new.e2(id int not null, fname varchar(30), lname varchar(30));
mysql> alter table test_new.e2 set tiflash replica 1;
mysql> insert into test.e values (1, 'a', 'b'),(108, 'a', 'b');
mysql> insert into test.e2 values (2, 'a', 'b');
mysql> insert into test_new.e2 values (3, 'a', 'b');
func> wait_table test e
func> wait_table test e2
func> wait_table test_new e2
# disable schema sync service
>> DBGInvoke __enable_schema_sync_service('false')
>> DBGInvoke __refresh_schemas()
# case 1, exchange partition in the same database, no error happens
mysql> set @@tidb_enable_exchange_partition=1; alter table test.e exchange partition p0 with table test.e2
>> DBGInvoke __refresh_schemas()
mysql> alter table test.e add column c1 int;
>> DBGInvoke __refresh_table_schema(test, e)
mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.e order by id;
+-----+-------+-------+------+
| id | fname | lname | c1 |
+-----+-------+-------+------+
| 2 | a | b | NULL |
| 108 | a | b | NULL |
+-----+-------+-------+------+
mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.e2;
+----+-------+-------+
| id | fname | lname |
+----+-------+-------+
| 1 | a | b |
+----+-------+-------+
mysql> alter table test.e drop column c1;
>> DBGInvoke __refresh_table_schema(test, e)
# case 2, exchange partition across databases, no error happens
mysql> set @@tidb_enable_exchange_partition=1; alter table test.e exchange partition p0 with table test_new.e2
>> DBGInvoke __refresh_schemas()
mysql> alter table test.e add column c1 int;
>> DBGInvoke __refresh_table_schema(test, e)
mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.e order by id;
+-----+-------+-------+------+
| id | fname | lname | c1 |
+-----+-------+-------+------+
| 3 | a | b | NULL |
| 108 | a | b | NULL |
+-----+-------+-------+------+
mysql> set session tidb_isolation_read_engines='tiflash'; select * from test_new.e2;
+----+-------+-------+
| id | fname | lname |
+----+-------+-------+
| 2 | a | b |
+----+-------+-------+
mysql> alter table test.e drop column c1;
>> DBGInvoke __refresh_table_schema(test, e)
mysql> drop table if exists test.e;
mysql> drop table if exists test.e2;
mysql> drop table if exists test_new.e2;
mysql> drop database if exists test_new;
>> DBGInvoke __enable_schema_sync_service('true')