mariadb/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test
Alexey Botchkov b88542681b MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work properly when used with DATA DIRECTORY.
When table is renamed, the InnoDB's dictionary cache didn't
        change the ib_table->data_dir_path accordingly.
        Now it's set to NULL.
2018-02-10 22:17:49 +04:00

303 lines
11 KiB
Text

################################################################################
# t/partition_basic_innodb.test #
# #
# Purpose: #
# Tests around Create Partitioned table using DATA/INDEX DIR #
# InnoDB branch #
# #
#------------------------------------------------------------------------------#
# Original Author: mleich #
# Original Date: 2006-03-05 #
# Change Author: mattiasj #
# Change Date: 2008-02-05 #
# Change: copied it from partition_basic_innodb.test and kept DATA DIR #
# Change Author: mattiasj #
# Change Date: 2008-03-16 #
# Change: Replaced all test with alter -> myisam, since innodb does not support#
# Change Author: Kevin lewis #
# Change Date: 2012-03-02 #
# Change: WL5980 activates DATA DIRECTORY for InnoDB #
################################################################################
# NOTE: As of WL5980, InnoDB supports DATA DIRECTORY, but not INDEX DIRECTORY.
# See innodb.innodb-tablespace for tests using partition engine, innodb
# and DATADIRECTORY. The purpose of this test is to show that a
# partitioned table remembers the DATA/INDEX DIR and it is used if
# altered to MyISAM
#
--echo #
--echo # Verify that the DATA/INDEX DIR is stored and used if ALTER to MyISAM.
--echo #
--source include/have_innodb.inc
# The server must support partitioning.
--source include/have_partition.inc
# The server must support symlink for DATA/INDEX DIRECTORY.
--source include/have_symlink.inc
# windows does not support symlink for DATA/INDEX DIRECTORY.
--source include/not_windows.inc
# Does not work with --embedded
--source include/not_embedded.inc
--disable_query_log
let $MYSQLD_DATADIR= `select @@datadir`;
# These values can change during the test
LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`;
LET $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`;
--enable_query_log
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--mkdir $MYSQLTEST_VARDIR/mysql-test-data-dir
--mkdir $MYSQLTEST_VARDIR/mysql-test-idx-dir
SET SESSION innodb_strict_mode = ON;
--echo #
--echo # InnoDB only supports DATA DIRECTORY with innodb_file_per_table=ON
--echo #
SET GLOBAL innodb_file_per_table = OFF;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error ER_CANT_CREATE_TABLE
eval CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
PARTITION BY HASH (c1) (
PARTITION p0
DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir',
PARTITION p1
DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir'
);
--replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR
SHOW WARNINGS;
--echo #
--echo # InnoDB is different from MyISAM in that it uses a text file
--echo # with an '.isl' extension instead of a symbolic link so that
--echo # the tablespace can be re-located on any OS. Also, instead of
--echo # putting the file directly into the DATA DIRECTORY,
--echo # it adds a folder under it with the name of the database.
--echo # Since strict mode is off, InnoDB ignores the INDEX DIRECTORY
--echo # and it is no longer part of the definition.
--echo #
SET SESSION innodb_strict_mode = OFF;
SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1 (c1 INT) ENGINE = InnoDB
PARTITION BY HASH (c1)
(PARTITION p0
DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir',
PARTITION p1
DATA DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-data-dir'
INDEX DIRECTORY = '$MYSQLTEST_VARDIR/mysql-test-idx-dir'
);
SHOW WARNINGS;
--echo # Verifying .frm, .par, .isl & .ibd files
--echo ---- MYSQLD_DATADIR/test
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir/test
--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir/test
--echo # The ibd tablespaces should not be directly under the DATA DIRECTORY
--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir
--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir
--echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir
--list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir
FLUSH TABLES;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
--echo #
--echo # Verify that the DATA/INDEX DIRECTORY is stored and used if we
--echo # ALTER TABLE to MyISAM.
--echo #
ALTER TABLE t1 engine=MyISAM;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
--echo # Verifying .frm, .par and MyISAM files (.MYD, MYI)
--echo ---- MYSQLD_DATADIR/test
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir
--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir
--echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir
--list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir
--echo #
--echo # Now verify that the DATA DIRECTORY is used again if we
--echo # ALTER TABLE back to InnoDB.
--echo #
SET SESSION innodb_strict_mode = ON;
ALTER TABLE t1 engine=InnoDB;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
--echo # Verifying .frm, .par, .isl and InnoDB .ibd files
--echo ---- MYSQLD_DATADIR/test
--list_files $MYSQLD_DATADIR/test
--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir
--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir
--echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir
--list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir
--echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir/test
--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir/test
DROP TABLE t1;
--echo #
--echo # MDEV-14611 ALTER TABLE EXCHANGE PARTITION does not work
--echo # properly when used with DATA DIRECTORY
--echo #
let $data_dir_path= $MYSQLTEST_VARDIR/mysql-test-data-dir;
let $alt_data_dir_path= $MYSQLTEST_VARDIR/mysql-test-idx-dir;
SET GLOBAL innodb_file_per_table = ON;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB PARTITION BY KEY (myid)
(
PARTITION p0001 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0002 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0003 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0004 DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB
);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t2
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB DATA DIRECTORY = '$data_dir_path';
ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
DROP TABLE t1, t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB PARTITION BY RANGE (myid)
(
PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB
);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t2
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB DATA DIRECTORY = '$alt_data_dir_path';
insert into t1 values (1, 'one');
insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four');
select * from t1;
ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t2;
select * from t1;
select * from t2;
DROP TABLE t1, t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB PARTITION BY RANGE (myid)
(
PARTITION p0001 VALUES LESS THAN (50) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0002 VALUES LESS THAN (150) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0003 VALUES LESS THAN (1050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB,
PARTITION p0004 VALUES LESS THAN (10050) DATA DIRECTORY = '$data_dir_path' ENGINE = INNODB
);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t2
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB;
insert into t1 values (1, 'one');
insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four');
select * from t1;
ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t2;
select * from t1;
select * from t2;
DROP TABLE t1, t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB PARTITION BY RANGE (myid)
(
PARTITION p0001 VALUES LESS THAN (50) ENGINE = INNODB,
PARTITION p0002 VALUES LESS THAN (150) ENGINE = INNODB,
PARTITION p0003 VALUES LESS THAN (1050) ENGINE = INNODB,
PARTITION p0004 VALUES LESS THAN (10050) ENGINE = INNODB
);
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t2
(
myid INT(11) NOT NULL,
myval VARCHAR(10),
PRIMARY KEY (myid)
) ENGINE=INNODB DATA DIRECTORY = '$alt_data_dir_path';
insert into t1 values (1, 'one');
insert into t2 values (2, 'two'), (3, 'threee'), (4, 'four');
select * from t1;
ALTER TABLE t1 EXCHANGE PARTITION p0001 WITH TABLE t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
SHOW CREATE TABLE t2;
select * from t1;
select * from t2;
DROP TABLE t1, t2;
--echo #
--echo # Cleanup
--echo #
--rmdir $MYSQLTEST_VARDIR/mysql-test-data-dir/test
--rmdir $MYSQLTEST_VARDIR/mysql-test-data-dir
--rmdir $MYSQLTEST_VARDIR/mysql-test-idx-dir
--disable_query_log
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