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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
SET default_storage_engine=InnoDB;
#
# TABLESPACE related tests for the partition engine and InnoDB.
#
# The partition engine can send DATA DIRECTORY to InnoDB.
# In strict mode, it is an error if innodb_file_per_table = OFF
# or INDEX DIRECTORY is used.
SET SESSION innodb_strict_mode = ON;
SET GLOBAL innodb_file_per_table = OFF;
CREATE TABLE t1 (a int KEY, b text) ENGINE = InnoDB PARTITION BY HASH (a)
(PARTITION p0 engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data' INDEX DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
PARTITION p1 engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data' INDEX DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data');
ERROR HY000: Table storage engine for 't1' doesn't have this option
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: DATA DIRECTORY requires innodb_file_per_table.
Warning 1478 InnoDB: INDEX DIRECTORY is not supported
Error 1031 Table storage engine for 't1' doesn't have this option
Error 6 Error on delete of './test/t1.par' (Errcode: 2 - No such file or directory)
# Try again with innodb_file_per_table = ON and no INDEX DIRECTORY.
SET GLOBAL innodb_file_per_table = ON;
CREATE TABLE t1 (a int KEY, b text) ENGINE = InnoDB PARTITION BY HASH (a)
(PARTITION p0 engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
PARTITION p1 engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2');
SHOW WARNINGS;
Level Code Message
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
(PARTITION p0 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
PARTITION p1 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB) */
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
name n_cols file_format row_format
test/t1#p#p0 5 Antelope Compact
test/t1#p#p1 5 Antelope Compact
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
name file_format row_format
test/t1#p#p0 Antelope Compact or Redundant
test/t1#p#p1 Antelope Compact or Redundant
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p0.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p1.ibd
# Verifying .frm, .par, .isl & .ibd files
# Verifying that there are no MyISAM files
# 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;
a b
2 green
1 red
3 blue
TRUNCATE TABLE t1;
SELECT * FROM t1;
a b
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
(PARTITION p0 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
PARTITION p1 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB) */
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
name n_cols file_format row_format
test/t1#p#p0 5 Antelope Compact
test/t1#p#p1 5 Antelope Compact
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
name file_format row_format
test/t1#p#p0 Antelope Compact or Redundant
test/t1#p#p1 Antelope Compact or Redundant
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p0.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p1.ibd
# Verifying .frm, .par and MyISAM files (.MYD, MYI)
# Test RENAME TABLE with partitioned InnoDB tables
RENAME TABLE t1 TO t11;
SHOW CREATE TABLE t11;
Table Create Table
t11 CREATE TABLE `t11` (
`a` int(11) NOT NULL,
`b` text,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
(PARTITION p0 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
PARTITION p1 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB) */
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
name n_cols file_format row_format
test/t11#p#p0 5 Antelope Compact
test/t11#p#p1 5 Antelope Compact
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
name file_format row_format
test/t11#p#p0 Antelope Compact or Redundant
test/t11#p#p1 Antelope Compact or Redundant
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alternate_dir/data/test/t11#p#p0.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t11#p#p1.ibd
# Verifying .frm, .par and MyISAM files (.MYD, MYI)
DROP TABLE t11;
# Test the previous DDL as a prepared statement.
SET GLOBAL innodb_file_per_table = ON;
PREPARE stmt1 FROM "CREATE TABLE t1 (a int KEY, b text)
ENGINE = InnoDB PARTITION BY HASH (a)
(PARTITION p0 engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
PARTITION p1 engine=InnoDB DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2')";
EXECUTE stmt1;
SHOW WARNINGS;
Level Code Message
DEALLOCATE PREPARE stmt1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (a)
(PARTITION p0 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
PARTITION p1 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB) */
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
name n_cols file_format row_format
test/t1#p#p0 5 Antelope Compact
test/t1#p#p1 5 Antelope Compact
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
name file_format row_format
test/t1#p#p0 Antelope Compact or Redundant
test/t1#p#p1 Antelope Compact or Redundant
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p0.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p1.ibd
DROP TABLE t1;
# Test DATA DIRECTORY with Sub-partitions.
SET GLOBAL innodb_file_per_table = ON;
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='MYSQL_TMP_DIR/alternate_dir/data',
SUBPARTITION s1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2'
),
PARTITION p1 VALUES LESS THAN (2000) (
SUBPARTITION s2 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
SUBPARTITION s3 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2'
),
PARTITION p2 VALUES LESS THAN MAXVALUE (
SUBPARTITION s4 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
SUBPARTITION s5 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2'
)
);
SHOW WARNINGS;
Level Code Message
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;
id purchased
4 1970-05-31
1 1980-05-31
5 1985-05-31
2 2090-05-31
3 2012-05-31
6 2006-05-31
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`purchased` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE ( YEAR(purchased))
SUBPARTITION BY HASH ( TO_DAYS(purchased))
(PARTITION p0 VALUES LESS THAN (1990)
(SUBPARTITION s0 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
SUBPARTITION s1 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB),
PARTITION p1 VALUES LESS THAN (2000)
(SUBPARTITION s2 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
SUBPARTITION s3 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB),
PARTITION p2 VALUES LESS THAN MAXVALUE
(SUBPARTITION s4 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
SUBPARTITION s5 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB)) */
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
name n_cols file_format row_format
test/t1#p#p0#sp#s0 5 Antelope Compact
test/t1#p#p0#sp#s1 5 Antelope Compact
test/t1#p#p1#sp#s2 5 Antelope Compact
test/t1#p#p1#sp#s3 5 Antelope Compact
test/t1#p#p2#sp#s4 5 Antelope Compact
test/t1#p#p2#sp#s5 5 Antelope Compact
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
name file_format row_format
test/t1#p#p0#sp#s0 Antelope Compact or Redundant
test/t1#p#p0#sp#s1 Antelope Compact or Redundant
test/t1#p#p1#sp#s2 Antelope Compact or Redundant
test/t1#p#p1#sp#s3 Antelope Compact or Redundant
test/t1#p#p2#sp#s4 Antelope Compact or Redundant
test/t1#p#p2#sp#s5 Antelope Compact or Redundant
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p0#sp#s0.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p0#sp#s1.ibd
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p1#sp#s2.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p1#sp#s3.ibd
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p2#sp#s4.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p2#sp#s5.ibd
# Verifying .frm, .par, .isl & .ibd files
DROP TABLE t1;
# Same as above except with ROW_FORMAT=Dyamic.
SET GLOBAL innodb_file_format = Barracuda;
SET GLOBAL innodb_file_per_table = ON;
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='MYSQL_TMP_DIR/alternate_dir/data',
SUBPARTITION s1 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2'
),
PARTITION p1 VALUES LESS THAN (2000) (
SUBPARTITION s2 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
SUBPARTITION s3 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2'
),
PARTITION p2 VALUES LESS THAN MAXVALUE (
SUBPARTITION s4 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data',
SUBPARTITION s5 DATA DIRECTORY='MYSQL_TMP_DIR/alternate_dir/data2'
)
);
SHOW WARNINGS;
Level Code Message
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;
id purchased
4 1970-05-31
1 1980-05-31
5 1985-05-31
2 2090-05-31
3 2012-05-31
6 2006-05-31
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`purchased` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
/*!50100 PARTITION BY RANGE ( YEAR(purchased))
SUBPARTITION BY HASH ( TO_DAYS(purchased))
(PARTITION p0 VALUES LESS THAN (1990)
(SUBPARTITION s0 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
SUBPARTITION s1 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB),
PARTITION p1 VALUES LESS THAN (2000)
(SUBPARTITION s2 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
SUBPARTITION s3 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB),
PARTITION p2 VALUES LESS THAN MAXVALUE
(SUBPARTITION s4 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data' ENGINE = InnoDB,
SUBPARTITION s5 DATA DIRECTORY = 'MYSQL_TMP_DIR/alternate_dir/data2' ENGINE = InnoDB)) */
SELECT name,n_cols,file_format,row_format
FROM information_schema.innodb_sys_tables WHERE name LIKE 'test%';
name n_cols file_format row_format
test/t1#p#p0#sp#s0 5 Barracuda Dynamic
test/t1#p#p0#sp#s1 5 Barracuda Dynamic
test/t1#p#p1#sp#s2 5 Barracuda Dynamic
test/t1#p#p1#sp#s3 5 Barracuda Dynamic
test/t1#p#p2#sp#s4 5 Barracuda Dynamic
test/t1#p#p2#sp#s5 5 Barracuda Dynamic
SELECT name,file_format,row_format
FROM information_schema.innodb_sys_tablespaces WHERE name LIKE 'test%';
name file_format row_format
test/t1#p#p0#sp#s0 Barracuda Dynamic
test/t1#p#p0#sp#s1 Barracuda Dynamic
test/t1#p#p1#sp#s2 Barracuda Dynamic
test/t1#p#p1#sp#s3 Barracuda Dynamic
test/t1#p#p2#sp#s4 Barracuda Dynamic
test/t1#p#p2#sp#s5 Barracuda Dynamic
SELECT path FROM information_schema.innodb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
path
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p0#sp#s0.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p0#sp#s1.ibd
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p1#sp#s2.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p1#sp#s3.ibd
MYSQL_TMP_DIR/alternate_dir/data/test/t1#p#p2#sp#s4.ibd
MYSQL_TMP_DIR/alternate_dir/data2/test/t1#p#p2#sp#s5.ibd
# Verifying .frm, .par, .isl & .ibd files
#
# Cleanup
#
DROP TABLE t1;
|