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
|
#
# A series of tests to show the correct behavior when using
# ALTER TABLE ... REORGANIZE PARTITION with TokuDB
# See also; parts.partition_basic_symlink_tokudb.test for
# partition related tests with remote tablespaces.
# See tokudb.tokudb-restart for tablespace migration tests.
#
--source include/have_tokudb.inc
--source include/have_partition.inc
SET default_storage_engine=TokuDB;
LET $MYSQLD_DATADIR = `select @@datadir`;
# These values can change during the test
LET $tokudb_file_format_orig=`select @@tokudb_file_format`;
LET $tokudb_file_per_table_orig=`select @@tokudb_file_per_table`;
LET $tokudb_strict_mode_orig=`select @@session.tokudb_strict_mode`;
SET SESSION tokudb_strict_mode = ON;
SET GLOBAL tokudb_file_per_table=ON;
SET GLOBAL tokudb_file_format=barracuda;
# Unlike MyISAM, TokuDB creates the subdirectories given to it in the
# DATA DIRECTORY clauses. Another difference is that TokuDB uses an extra
# directory under DATA DIRECTORY with the name of the database.
--echo #
--echo # CREATE a table with SUBPARTITIONS
--echo #
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE emp (
id INT NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id INT
) engine TokuDB
PARTITION BY RANGE(store_id) SUBPARTITION BY HASH(store_id)
(
PARTITION northeast VALUES LESS THAN (50)
DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir_northeast'
(SUBPARTITION ne0, SUBPARTITION ne1),
PARTITION southwest VALUES LESS THAN (100)
DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir_southwest'
(SUBPARTITION sw2, SUBPARTITION sw3)
);
INSERT INTO emp values(1,'Oracle','NUT',10);
INSERT INTO emp values(2,'SAP','BOLT',40);
INSERT INTO emp values(3,'IBM','NAIL',60);
INSERT INTO emp values(4,'SUN','SCREW',90);
SELECT * FROM emp;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE emp;
--replace_regex /#P#/#p#/ /#SP#/#sp#/
SELECT name,n_cols,file_format,row_format
FROM information_schema.tokudb_sys_tables
WHERE name LIKE 'test%' ORDER BY name;
--replace_regex /#P#/#p#/ /#SP#/#sp#/
SELECT name,file_format,row_format
FROM information_schema.tokudb_sys_tablespaces
WHERE name LIKE 'test%' ORDER BY name;
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.tokudb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo ---- MYSQLD_DATADIR/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir_northeast/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_northeast/test
--echo ---- MYSQL_TMP_DIR/alt_dir_southwest/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_southwest/test
--echo #
--echo # REORGANIZE the PARTITIONS and SUBPARTITIONS
--echo #
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval ALTER TABLE emp REORGANIZE PARTITION northeast INTO
(
PARTITION east VALUES LESS THAN (25)
DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir_east'
(SUBPARTITION e0, SUBPARTITION e1),
PARTITION north VALUES LESS THAN (50)
DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir_north'
(SUBPARTITION n0, SUBPARTITION n1)
);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval ALTER TABLE emp REORGANIZE PARTITION southwest INTO
(
PARTITION west VALUES LESS THAN (75)
DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir_west'
(SUBPARTITION w0, SUBPARTITION w1),
PARTITION south VALUES LESS THAN (100)
DATA DIRECTORY = '$MYSQL_TMP_DIR/alt_dir_south'
(SUBPARTITION s0, SUBPARTITION s1)
);
SELECT * FROM emp;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE emp;
--replace_regex /#P#/#p#/ /#SP#/#sp#/
SELECT name,n_cols,file_format,row_format
FROM information_schema.tokudb_sys_tables
WHERE name LIKE 'test%' ORDER BY name;
--replace_regex /#P#/#p#/ /#SP#/#sp#/
SELECT name,file_format,row_format
FROM information_schema.tokudb_sys_tablespaces
WHERE name LIKE 'test%' ORDER BY name;
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT path FROM information_schema.tokudb_sys_datafiles
WHERE path LIKE '%test%' ORDER BY space;
--echo ---- MYSQLD_DATADIR/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQL_TMP_DIR/alt_dir_northeast/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_northeast/test
--echo ---- MYSQL_TMP_DIR/alt_dir_southwest/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_southwest/test
--echo ---- MYSQL_TMP_DIR/alt_dir_east/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_east/test
--echo ---- MYSQL_TMP_DIR/alt_dir_north/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_north/test
--echo ---- MYSQL_TMP_DIR/alt_dir_west/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_west/test
--echo ---- MYSQL_TMP_DIR/alt_dir_south/test
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--list_files $MYSQL_TMP_DIR/alt_dir_south/test
DROP TABLE emp;
--echo #
--echo # Cleanup
--echo #
--rmdir $MYSQL_TMP_DIR/alt_dir_northeast/test
--rmdir $MYSQL_TMP_DIR/alt_dir_northeast
--rmdir $MYSQL_TMP_DIR/alt_dir_southwest/test
--rmdir $MYSQL_TMP_DIR/alt_dir_southwest
--rmdir $MYSQL_TMP_DIR/alt_dir_east/test
--rmdir $MYSQL_TMP_DIR/alt_dir_east
--rmdir $MYSQL_TMP_DIR/alt_dir_north/test
--rmdir $MYSQL_TMP_DIR/alt_dir_north
--rmdir $MYSQL_TMP_DIR/alt_dir_west/test
--rmdir $MYSQL_TMP_DIR/alt_dir_west
--rmdir $MYSQL_TMP_DIR/alt_dir_south/test
--rmdir $MYSQL_TMP_DIR/alt_dir_south
--disable_query_log
EVAL SET GLOBAL tokudb_file_format=$tokudb_file_format_orig;
EVAL SET GLOBAL tokudb_file_per_table=$tokudb_file_per_table_orig;
EVAL SET SESSION tokudb_strict_mode=$tokudb_strict_mode_orig;
--enable_query_log
|