Debian Codegraph @

mysql-test/suite/storage_engine/parts/alter_table.test

raw
1 #
2 # Basic ALTER TABLE statements related to partitioning
3 #
4
5 --source include/have_partition.inc
6 --source ../have_engine.inc
7
8 --disable_warnings
9 DROP TABLE IF EXISTS t1;
10 --enable_warnings
11
12 --let $create_definition = a $int_col
13 --let $partition_options = PARTITION BY HASH(a) PARTITIONS 2
14 --source ../create_table.inc
15 if ($mysql_errname)
16 {
17 --let $my_last_stmt = $create_statement
18 --let $functionality = Partitions
19 --source ../unexpected_result.inc
20 }
21 if (!$mysql_errname)
22 {
23 INSERT INTO t1 (a) VALUES (1),(2),(2),(3),(4);
24
25 --let $alter_definition = ADD PARTITION PARTITIONS 2
26 --source ../alter_table.inc
27 if ($mysql_errname)
28 {
29 --let $my_last_stmt = $alter_statement
30 --let $functionality = ALTER TABLE
31 --source ../unexpected_result.inc
32 }
33 --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
34 EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 3;
35
36 --let $alter_definition = COALESCE PARTITION 1
37 --source ../alter_table.inc
38 --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
39 EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 3;
40
41 --let $alter_definition = REORGANIZE PARTITION
42 --source ../alter_table.inc
43 --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
44 EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 2;
45
46 --let $alter_definition = REBUILD PARTITION p0
47 --source ../alter_table.inc
48 --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
49 EXPLAIN PARTiTIONS SELECT a FROM t1;
50
51 --let $alter_definition = REMOVE PARTITIONING
52 --source ../alter_table.inc
53 --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
54 EXPLAIN PARTiTIONS SELECT a FROM t1;
55
56 --let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
57 --let $alter_definition = PARTITION BY LIST(a) ( PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (101,102) )
58 --source ../alter_table.inc
59 if ($mysql_errname != ER_NO_PARTITION_FOR_GIVEN_VALUE)
60 {
61 --let $my_last_stmt = $alter_statement
62 --let $my_functionality = ALTER TABLE or INSERT
63 --source ../unexpected_result.inc
64 }
65
66 --let $alter_definition = PARTITION BY LIST(a) ( PARTITION p0 VALUES IN (1,2,3,4), PARTITION p1 VALUES IN (101,102) )
67 --source ../alter_table.inc
68
69 --let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
70 INSERT INTO t1 (a) VALUES (50);
71 --source ../check_errors.inc
72 --let $alter_definition = ADD PARTITION ( PARTITION p2 VALUES IN (50,51) )
73 --source ../alter_table.inc
74 INSERT INTO t1 (a) VALUES (50);
75
76 --let $alter_definition = DROP PARTITION p1
77 --source ../alter_table.inc
78 --let $alter_definition = REORGANIZE PARTITION p0, p2 INTO ( PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (4), PARTITION p2 VALUES IN (50,51), PARTITION p3 VALUES IN (101,102) )
79 --source ../alter_table.inc
80 --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
81 EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 2;
82 DROP TABLE t1;
83 }
84
85
86 --let $create_definition = a $int_col, b $int_col
87 let $partition_options = PARTITION BY LIST(a) SUBPARTITION by HASH(b) (
88 PARTITION abc VALUES IN (1,2,3),
89 PARTITION def VALUES IN (100,101,102)
90 );
91 --source ../create_table.inc
92 if ($mysql_errname)
93 {
94 --let $my_last_stmt = $create_statement
95 --let $functionality = Partitions or subpartitions
96 --source ../unexpected_result.inc
97 }
98 if (!$mysql_errname)
99 {
100 --let $alter_definition = DROP PARTITION abc
101 --source ../alter_table.inc
102
103 DROP TABLE t1;
104 }
105
106 --source ../cleanup_engine.inc
107