Debian Codegraph @

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

raw
1 #
2 # TRUNCATE TABLE with partitions and TRUNCATE PARTITION
3 #
4
5 --source include/have_partition.inc
6 --source ../have_engine.inc
7
8 # A part of the standard TRUNCATE test
9
10 --disable_warnings
11 DROP TABLE IF EXISTS t1;
12 --enable_warnings
13
14
15 # Truncate partitioned table
16
17 let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
18 --source ../create_table.inc
19 if ($mysql_errname)
20 {
21 --let $my_last_stmt = $create_statement
22 --let $functionality = Partitions
23 --source ../unexpected_result.inc
24 }
25 if (!$mysql_errname)
26 {
27 TRUNCATE TABLE t1;
28 if ($mysql_errname)
29 {
30 --let $functionality = TRUNCATE TABLE
31 --source ../unexpected_result.inc
32 }
33
34 INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
35 TRUNCATE TABLE t1;
36 SELECT a,b FROM t1;
37
38 DROP TABLE t1;
39 }
40
41
42 # Truncate resets auto-increment value on the table
43
44 let $create_definition = a $int_indexed_col KEY AUTO_INCREMENT, c $char_col;
45 let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
46 --source ../create_table.inc
47
48 if ($mysql_errname)
49 {
50 --let $my_last_stmt = $create_statement
51 --let $functionality = Partitions or PK or auto-increment
52 --source ../unexpected_result.inc
53 }
54 if (!$mysql_errname)
55 {
56 --source ../mask_engine.inc
57 SHOW CREATE TABLE t1;
58 INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
59 --source ../mask_engine.inc
60 SHOW CREATE TABLE t1;
61 TRUNCATE TABLE t1;
62 --source ../mask_engine.inc
63 SHOW CREATE TABLE t1;
64 INSERT INTO t1 (c) VALUES ('d');
65 --source ../mask_engine.inc
66 SHOW CREATE TABLE t1;
67 SELECT a,c FROM t1;
68 DROP TABLE t1;
69 }
70
71
72 # Truncate partitions
73
74 let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
75 --source ../create_table.inc
76 if ($mysql_errname)
77 {
78 --let $my_last_stmt = $create_statement
79 --let $functionality = Partitions
80 --source ../unexpected_result.inc
81 }
82 if (!$mysql_errname)
83 {
84 INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
85
86 let $alter_definition = TRUNCATE PARTITION p0;
87 --source ../alter_table.inc
88 if ($mysql_errname)
89 {
90 --let $my_last_stmt = $alter_statement
91 --let $functionality = ALTER TABLE
92 --source ../unexpected_result.inc
93 }
94
95 --sorted_result
96 SELECT a,b FROM t1;
97 --replace_column 5 # 6 # 7 # 8 # 9 # 10 #
98 EXPLAIN PARTITIONS SELECT a,b FROM t1;
99
100 INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
101
102 let $alter_definition = TRUNCATE PARTITION ALL;
103 --source ../alter_table.inc
104
105 SELECT a,b FROM t1;
106
107 DROP TABLE t1;
108 }
109
110 --source ../cleanup_engine.inc
111