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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
#
# A series of tests to show the correct tablespace behavior when the
# partition engine uses InnoDB.
#
--source include/not_embedded.inc
--source include/have_partition.inc
--source include/have_innodb.inc
SET default_storage_engine=InnoDB;
--echo #
--echo # TABLESPACE related tests for the partition engine and InnoDB.
--echo #
# Set up some variables
LET $MYSQLD_DATADIR = `select @@datadir`;
LET $data_directory = DATA DIRECTORY='$MYSQL_TMP_DIR/alternate_dir/data';
LET $data_directory2 = DATA DIRECTORY='$MYSQL_TMP_DIR/alternate_dir/data2';
LET $index_directory = INDEX DIRECTORY='$MYSQL_TMP_DIR/alternate_dir/data';
# These values can change during the test
LET $innodb_file_format_orig=`select @@innodb_file_format`;
LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`;
LET $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`;
--echo # The partition engine can send DATA DIRECTORY to InnoDB.
--echo # In strict mode, it is an error if innodb_file_per_table = OFF
--echo # or INDEX DIRECTORY is used.
SET SESSION innodb_strict_mode = ON;
SET GLOBAL innodb_file_per_table = OFF;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--error ER_ILLEGAL_HA
eval CREATE TABLE t1 (a int KEY, b text) ENGINE = InnoDB PARTITION BY HASH (a)
(PARTITION p0 engine=InnoDB $data_directory $index_directory,
PARTITION p1 engine=InnoDB $data_directory $index_directory);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW WARNINGS;
--echo # Try again with innodb_file_per_table = ON and no INDEX DIRECTORY.
SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1 (a int KEY, b text) ENGINE = InnoDB PARTITION BY HASH (a)
(PARTITION p0 engine=InnoDB $data_directory,
PARTITION p1 engine=InnoDB $data_directory2);
SHOW WARNINGS;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
# replace_result 't1#P' with 't1#p' because on Linux, InnoDB is always
# case sensitive with table names and on Windows, it is always lower case.
# This is independent of the value of lower_case_table_names. This cannot
# be changes without breaking backward compatibility.
--replace_result t1#P t1#p
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
--replace_result t1#P t1#p
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
--replace_result t1#P t1#p $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo # Verifying .frm, .par, .isl & .ibd files
--file_exists $MYSQLD_DATADIR/test/t1.frm
--file_exists $MYSQLD_DATADIR/test/t1.par
--file_exists $MYSQLD_DATADIR/test/t1#P#p0.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p1.isl
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p0.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p1.ibd
--echo # Verifying that there are no MyISAM files
--error 1
--file_exists $MYSQLD_DATADIR/test/t1#P#p0.myd
--error 1
--file_exists $MYSQLD_DATADIR/test/t1#P#p0.myi
--error 1
--file_exists $MYSQLD_DATADIR/test/t1#P#p1.myd
--error 1
--file_exists $MYSQLD_DATADIR/test/t1#P#p1.myi
--error 1
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/t1#P#p0.myd
--error 1
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/t1#P#p0.myi
--error 1
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/t1#P#p1.myd
--error 1
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/t1#P#p1.myi
# The ibd tablespaces should not be directly under the DATA DIRECTORY
--error 1
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/t1#P#p0.ibd
--error 1
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/t1#P#p1.ibd
--echo # Test TRUNCATE TABLE with partitioned InnoDB tables
INSERT INTO t1 VALUES (1, "red");
INSERT INTO t1 VALUES (2, "green");
INSERT INTO t1 VALUES (3, "blue");
SELECT * FROM t1;
TRUNCATE TABLE t1;
SELECT * FROM t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
--replace_result t1#P t1#p
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
--replace_result t1#P t1#p
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
--replace_result t1#P t1#p $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo # Verifying .frm, .par and MyISAM files (.MYD, MYI)
--file_exists $MYSQLD_DATADIR/test/t1.frm
--file_exists $MYSQLD_DATADIR/test/t1.par
--file_exists $MYSQLD_DATADIR/test/t1#P#p0.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p1.isl
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p0.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p1.ibd
--echo # Test RENAME TABLE with partitioned InnoDB tables
RENAME TABLE t1 TO t11;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t11;
--replace_result t11#P t11#p
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
--replace_result t11#P t11#p
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
--replace_result t11#P t11#p $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo # Verifying .frm, .par and MyISAM files (.MYD, MYI)
--file_exists $MYSQLD_DATADIR/test/t11.frm
--file_exists $MYSQLD_DATADIR/test/t11.par
--file_exists $MYSQLD_DATADIR/test/t11#P#p0.isl
--file_exists $MYSQLD_DATADIR/test/t11#P#p1.isl
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t11#P#p0.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t11#P#p1.ibd
DROP TABLE t11;
--echo # Test the previous DDL as a prepared statement.
SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval PREPARE stmt1 FROM "CREATE TABLE t1 (a int KEY, b text)
ENGINE = InnoDB PARTITION BY HASH (a)
(PARTITION p0 engine=InnoDB $data_directory,
PARTITION p1 engine=InnoDB $data_directory2)";
EXECUTE stmt1;
SHOW WARNINGS;
DEALLOCATE PREPARE stmt1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
--replace_result t1#P t1#p
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
--replace_result t1#P t1#p
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
--replace_result t1#P t1#p $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
DROP TABLE t1;
--echo # Test DATA DIRECTORY with Sub-partitions.
SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1 (id INT, purchased DATE) engine=InnoDB
PARTITION BY RANGE( YEAR(purchased) )
SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
PARTITION p0 VALUES LESS THAN (1990) (
SUBPARTITION s0 $data_directory,
SUBPARTITION s1 $data_directory2
),
PARTITION p1 VALUES LESS THAN (2000) (
SUBPARTITION s2 $data_directory,
SUBPARTITION s3 $data_directory2
),
PARTITION p2 VALUES LESS THAN MAXVALUE (
SUBPARTITION s4 $data_directory,
SUBPARTITION s5 $data_directory2
)
);
SHOW WARNINGS;
INSERT INTO t1 VALUES(1,'1980-05-31');
INSERT INTO t1 VALUES(2,'2090-05-31');
INSERT INTO t1 VALUES(3,'2012-05-31');
INSERT INTO t1 VALUES(4,'1970-05-31');
INSERT INTO t1 VALUES(5,'1985-05-31');
INSERT INTO t1 VALUES(6,'2006-05-31');
SELECT * FROM t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
--replace_result #P# #p# #SP# #sp#
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
--replace_result #P# #p# #SP# #sp#
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
--replace_result #P# #p# #SP# #sp# $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo # Verifying .frm, .par, .isl & .ibd files
--file_exists $MYSQLD_DATADIR/test/t1.frm
--file_exists $MYSQLD_DATADIR/test/t1.par
--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#s0.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#s1.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#s2.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#s3.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#s4.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#s5.isl
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p0#SP#s0.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p0#SP#s1.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p1#SP#s2.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p1#SP#s3.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p2#SP#s4.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p2#SP#s5.ibd
DROP TABLE t1;
--echo # Same as above except with ROW_FORMAT=Dyamic.
SET GLOBAL innodb_file_format = Barracuda;
SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1 (id INT, purchased DATE)
engine = innodb row_format = dynamic
PARTITION BY RANGE( YEAR(purchased) )
SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
PARTITION p0 VALUES LESS THAN (1990) (
SUBPARTITION s0 $data_directory,
SUBPARTITION s1 $data_directory2
),
PARTITION p1 VALUES LESS THAN (2000) (
SUBPARTITION s2 $data_directory,
SUBPARTITION s3 $data_directory2
),
PARTITION p2 VALUES LESS THAN MAXVALUE (
SUBPARTITION s4 $data_directory,
SUBPARTITION s5 $data_directory2
)
);
SHOW WARNINGS;
INSERT INTO t1 VALUES(1,'1980-05-31');
INSERT INTO t1 VALUES(2,'2090-05-31');
INSERT INTO t1 VALUES(3,'2012-05-31');
INSERT INTO t1 VALUES(4,'1970-05-31');
INSERT INTO t1 VALUES(5,'1985-05-31');
INSERT INTO t1 VALUES(6,'2006-05-31');
SELECT * FROM t1;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t1;
--replace_result #P# #p# #SP# #sp#
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
--replace_result #P# #p# #SP# #sp#
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
--replace_result #P# #p# #SP# #sp# $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo # Verifying .frm, .par, .isl & .ibd files
--file_exists $MYSQLD_DATADIR/test/t1.frm
--file_exists $MYSQLD_DATADIR/test/t1.par
--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#s0.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p0#SP#s1.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#s2.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p1#SP#s3.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#s4.isl
--file_exists $MYSQLD_DATADIR/test/t1#P#p2#SP#s5.isl
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p0#SP#s0.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p0#SP#s1.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p1#SP#s2.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p1#SP#s3.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data/test/t1#P#p2#SP#s4.ibd
--file_exists $MYSQL_TMP_DIR/alternate_dir/data2/test/t1#P#p2#SP#s5.ibd
--echo #
--echo # Cleanup
--echo #
DROP TABLE t1;
--rmdir $MYSQL_TMP_DIR/alternate_dir/data/test
--rmdir $MYSQL_TMP_DIR/alternate_dir/data
--rmdir $MYSQL_TMP_DIR/alternate_dir/data2/test
--rmdir $MYSQL_TMP_DIR/alternate_dir/data2
--rmdir $MYSQL_TMP_DIR/alternate_dir
--disable_query_log
EVAL SET GLOBAL innodb_file_format=$innodb_file_format_orig;
EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig;
EVAL SET SESSION innodb_strict_mode=$innodb_strict_mode_orig;
--enable_query_log
|