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
|
#
# Basic CREATE TABLE .. PARTITION statements
#
--source include/have_partition.inc
--source ../have_engine.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
let $create_definition = a $int_col;
let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
--source ../create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Partitions
--source ../unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES (1),(2),(3),(2);
# We are only interested in partition information
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a=2;
DROP TABLE t1;
}
let $create_definition = a $char_col;
let $partition_options = PARTITION BY KEY(a) PARTITIONS 2;
--source ../create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Partitions or CHAR types
--source ../unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES ('a'),('b'),('c');
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 'b';
DROP TABLE t1;
}
--let $continue = 1
--source ../have_default_index.inc
if ($have_default_index)
{
let $create_definition = a $int_indexed_col, $default_index (a);
let $partition_options = PARTITION BY KEY(a) PARTITIONS 2;
--source ../create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Partitions or indexes
--source ../unexpected_result.inc
}
if (!$mysql_errname)
{
--source ../mask_engine.inc
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
INSERT INTO t1 (a) VALUES (1),(2),(3),(5);
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a IN (1,3);
DROP TABLE t1;
}
}
let $create_definition = a $int_indexed_col PRIMARY KEY;
let $partition_options = PARTITION BY KEY() PARTITIONS 2;
--source ../create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = PK
--source ../unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
INSERT INTO t1 (a) VALUES (1),(200),(3),(2);
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a=2;
DROP TABLE t1;
}
let $create_definition = a $int_col;
let $partition_options = PARTITION BY RANGE(a) (
PARTITION p0 VALUES LESS THAN (10),
PARTITION p1 VALUES LESS THAN (1000)
);
--source ../create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Partitions
--source ../unexpected_result.inc
}
if (!$mysql_errname)
{
INSERT INTO t1 (a) VALUES (1),(2),(400);
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 2;
--let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
INSERT INTO t1 (a) VALUES (10000);
--source ../check_errors.inc
DROP TABLE t1;
let $create_definition = a $int_col;
let $partition_options = PARTITION BY LIST(a) (
PARTITION abc VALUES IN (1,2,3),
PARTITION def VALUES IN (100,101,102)
);
--source ../create_table.inc
INSERT INTO t1 (a) VALUES (1),(101),(1);
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100;
--let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
INSERT INTO t1 (a) VALUES (50);
--source ../check_errors.inc
DROP TABLE t1;
}
let $create_definition = a $int_col, b $int_col;
let partition_options = PARTITION BY LIST(a) SUBPARTITION by HASH(b) (
PARTITION abc VALUES IN (1,2,3),
PARTITION def VALUES IN (100,101,102)
);
--source ../create_table.inc
if ($mysql_errname)
{
--let $my_last_stmt = $create_statement
--let $functionality = Partitions or subpartitions
--source ../unexpected_result.inc
}
if (!$mysql_errname)
{
--replace_column 6 # 7 # 10 # 11 #
SHOW INDEX IN t1;
INSERT INTO t1 (a,b) VALUES (1,1),(101,2),(1,3);
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1;
--replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100;
--sorted_result
SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, SUBPARTITION_NAME, PARTITION_METHOD, SUBPARTITION_METHOD
FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1';
# This is just to hit some more handler functions while we are here
--disable_result_log
SELECT * FROM INFORMATION_SCHEMA.PARTITIONS;
--enable_result_log
DROP TABLE t1;
}
--source ../cleanup_engine.inc
|