mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-04 04:46:15 +01:00 
			
		
		
		
	Tests with checking metadata or that cannot be run with the view-protocol are excluded from --view-protocol. For tests that do not allow the use of an additional connection, the util connection is disabled with "--disable_service_connection". Also cases with bugs for --view-protocol are disabled.
		
			
				
	
	
		
			348 lines
		
	
	
	
		
			10 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			348 lines
		
	
	
	
		
			10 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
--source include/have_symlink.inc
 | 
						|
--source include/not_windows.inc
 | 
						|
 | 
						|
--disable_warnings
 | 
						|
drop table if exists t1,t2,t7,t8,t9;
 | 
						|
drop database if exists mysqltest;
 | 
						|
--enable_warnings
 | 
						|
 | 
						|
#
 | 
						|
# First create little data to play with
 | 
						|
#
 | 
						|
 | 
						|
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a));
 | 
						|
create table t2 (a int not null auto_increment, b char(16) not null, primary key (a));
 | 
						|
insert into t1 (b) values ("test"),("test1"),("test2"),("test3");
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
insert into t2 (b) select b from t1;
 | 
						|
insert into t1 (b) select b from t2;
 | 
						|
drop table t2;
 | 
						|
 | 
						|
#
 | 
						|
# Start the test
 | 
						|
# We use t9 here to not crash with tables generated by the backup test
 | 
						|
# 
 | 
						|
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) 
 | 
						|
engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" index directory="$MYSQLTEST_VARDIR/run";
 | 
						|
 | 
						|
insert into t9 select * from t1;
 | 
						|
check table t9;
 | 
						|
optimize table t9;
 | 
						|
repair table t9;
 | 
						|
alter table t9 add column c int not null;
 | 
						|
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table t9;
 | 
						|
 | 
						|
# Test renames
 | 
						|
alter table t9 rename t8, add column d int not null;
 | 
						|
alter table t8 rename t7;
 | 
						|
rename table t7 to t9;
 | 
						|
# Drop old t1 table, keep t9
 | 
						|
drop table t1;
 | 
						|
 | 
						|
#
 | 
						|
# Test error handling
 | 
						|
# Note that we are using the above table t9 here!
 | 
						|
#
 | 
						|
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
SHOW CREATE TABLE t9;
 | 
						|
 | 
						|
 | 
						|
# Check that we cannot link over a table from another database.
 | 
						|
 | 
						|
create database mysqltest;
 | 
						|
 | 
						|
--error 1,1
 | 
						|
create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) 
 | 
						|
engine=myisam index directory="/this-dir-does-not-exist";
 | 
						|
 | 
						|
# temporarily disabled as it returns different result in the embedded server
 | 
						|
--error ER_WRONG_TABLE_NAME
 | 
						|
create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) 
 | 
						|
engine=myisam index directory="not-hard-path";
 | 
						|
 | 
						|
# Should fail becasue the file t9.MYI already exist in 'run'
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
--error 1,156
 | 
						|
eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) 
 | 
						|
engine=myisam index directory="$MYSQLTEST_VARDIR/run";
 | 
						|
 | 
						|
# Should fail becasue the file t9.MYD already exist in 'tmp'
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
--error 1,1
 | 
						|
eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) 
 | 
						|
engine=myisam data directory="$MYSQLTEST_VARDIR/tmp";
 | 
						|
 | 
						|
# Check moving table t9 from default database to mysqltest;
 | 
						|
# In this case the symlinks should be removed.
 | 
						|
 | 
						|
alter table t9 rename mysqltest.t9;
 | 
						|
select count(*) from mysqltest.t9;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table mysqltest.t9;
 | 
						|
drop database mysqltest;
 | 
						|
 | 
						|
#
 | 
						|
# Test changing data dir (Bug #1662)
 | 
						|
#
 | 
						|
 | 
						|
create table t1 (a int not null) engine=myisam;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table t1;
 | 
						|
alter table t1 add b int;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval alter table t1 data directory="$MYSQLTEST_VARDIR/log";
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table t1;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval alter table t1 index directory="$MYSQLTEST_VARDIR/log";
 | 
						|
show create table t1;
 | 
						|
drop table t1;
 | 
						|
 | 
						|
#
 | 
						|
# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE
 | 
						|
#
 | 
						|
--write_file $MYSQLTEST_VARDIR/tmp/t1.MYI
 | 
						|
EOF
 | 
						|
 | 
						|
--replace_result $MYSQLTEST_VARDIR TEST_DIR $MYSQLTEST_VARDIR TEST_DIR
 | 
						|
--error 1,1
 | 
						|
eval CREATE TABLE t1(a INT)
 | 
						|
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
 | 
						|
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
 | 
						|
--replace_result $MYSQLTEST_VARDIR TEST_DIR
 | 
						|
eval CREATE TABLE t2(a INT)
 | 
						|
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
 | 
						|
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
 | 
						|
--replace_result $MYSQLTEST_VARDIR TEST_DIR
 | 
						|
--error 1
 | 
						|
RENAME TABLE t2 TO t1;
 | 
						|
DROP TABLE t2;
 | 
						|
--remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI
 | 
						|
 | 
						|
#
 | 
						|
# Bug#8706 - temporary table with data directory option fails
 | 
						|
#
 | 
						|
#view cannot has temporary table in definition
 | 
						|
--disable_view_protocol
 | 
						|
 | 
						|
connect (session1,localhost,root,,);
 | 
						|
connect (session2,localhost,root,,);
 | 
						|
 | 
						|
connection session1;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a;
 | 
						|
# If running test suite with a non standard tmp dir, the "show create table"
 | 
						|
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table t1;
 | 
						|
 | 
						|
connection session2;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a;
 | 
						|
# If running test suite with a non standard tmp dir, the "show create table"
 | 
						|
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table t1;
 | 
						|
 | 
						|
connection default;
 | 
						|
create table t1 (a int) engine=myisam select 42 a;
 | 
						|
 | 
						|
connection session1;
 | 
						|
select * from t1;
 | 
						|
disconnect session1;
 | 
						|
connection session2;
 | 
						|
select * from t1;
 | 
						|
disconnect session2;
 | 
						|
connection default;
 | 
						|
select * from t1;
 | 
						|
drop table t1;
 | 
						|
 | 
						|
--enable_view_protocol
 | 
						|
 | 
						|
--echo End of 4.1 tests
 | 
						|
 | 
						|
#
 | 
						|
# Bug #29325: create table overwrites .MYD file of other table (datadir)
 | 
						|
#
 | 
						|
let $MYSQLD_DATADIR= `select @@datadir`;
 | 
						|
SET SESSION keep_files_on_create = TRUE;
 | 
						|
--write_file $MYSQLD_DATADIR/test/t1.MYD
 | 
						|
EOF
 | 
						|
--disable_abort_on_error
 | 
						|
--error 1,1,ER_TABLE_EXISTS_ERROR
 | 
						|
CREATE TABLE t1 (a INT) ENGINE MYISAM;
 | 
						|
--error 0,1
 | 
						|
--remove_file $MYSQLD_DATADIR/test/t1.MYD;
 | 
						|
--enable_abort_on_error
 | 
						|
SET SESSION keep_files_on_create = FALSE;
 | 
						|
CREATE TABLE t1 (a INT) ENGINE MYISAM;
 | 
						|
DROP TABLE t1;
 | 
						|
 | 
						|
--echo End of 5.0 tests
 | 
						|
 | 
						|
#
 | 
						|
# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY
 | 
						|
#
 | 
						|
# With Bug#41002 (symlink.test fails on symlinked datadir) it was
 | 
						|
# decided that the below statements may also succeed if the data
 | 
						|
# home directory is symlinked, e.g. mysql-test-run --mem.
 | 
						|
# This will be fixed in 6.0 only.
 | 
						|
#
 | 
						|
let $MYSQLD_DATADIR= `select @@datadir`;
 | 
						|
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
 | 
						|
--error 0,ER_WRONG_ARGUMENTS
 | 
						|
eval CREATE TABLE t1(a INT)
 | 
						|
INDEX DIRECTORY='$MYSQLD_DATADIR/mysql';
 | 
						|
--disable_warnings
 | 
						|
DROP TABLE IF EXISTS t1;
 | 
						|
--enable_warnings
 | 
						|
#
 | 
						|
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
 | 
						|
--error 0,ER_WRONG_ARGUMENTS
 | 
						|
eval CREATE TABLE t1(a INT)
 | 
						|
DATA DIRECTORY='$MYSQLD_DATADIR/test';
 | 
						|
--disable_warnings
 | 
						|
DROP TABLE IF EXISTS t1;
 | 
						|
--enable_warnings
 | 
						|
#
 | 
						|
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
 | 
						|
--error 0,ER_WRONG_ARGUMENTS
 | 
						|
eval CREATE TABLE t1(a INT)
 | 
						|
DATA DIRECTORY='$MYSQLD_DATADIR/';
 | 
						|
--disable_warnings
 | 
						|
DROP TABLE IF EXISTS t1;
 | 
						|
--enable_warnings
 | 
						|
#
 | 
						|
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
 | 
						|
--error 0,ER_WRONG_ARGUMENTS
 | 
						|
eval CREATE TABLE t1(a INT)
 | 
						|
INDEX DIRECTORY='$MYSQLD_DATADIR';
 | 
						|
--disable_warnings
 | 
						|
DROP TABLE IF EXISTS t1;
 | 
						|
--enable_warnings
 | 
						|
#
 | 
						|
--replace_result $MYSQLTEST_VARDIR TEST_DIR
 | 
						|
--error 1
 | 
						|
eval CREATE TABLE t1(a INT)
 | 
						|
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data_var';
 | 
						|
 | 
						|
#
 | 
						|
# BUG#25677 - With --skip-symbolic-links option on, DATA DIRECTORY clause is
 | 
						|
#             silently ignored
 | 
						|
#
 | 
						|
 | 
						|
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE';
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
 | 
						|
DROP TABLE t1;
 | 
						|
SET @@SQL_MODE=@OLD_SQL_MODE;
 | 
						|
 | 
						|
--echo #
 | 
						|
--echo # BUG#40980 - Drop table can remove another MyISAM table's
 | 
						|
--echo #             data and index files
 | 
						|
--echo #
 | 
						|
--mkdir $MYSQL_TMP_DIR/mysql 
 | 
						|
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
 | 
						|
eval CREATE TABLE user(a INT) DATA DIRECTORY='$MYSQL_TMP_DIR/mysql'
 | 
						|
                             INDEX DIRECTORY='$MYSQL_TMP_DIR/mysql';
 | 
						|
FLUSH TABLE user;
 | 
						|
--echo # Symlinking mysql database to tmpdir
 | 
						|
--remove_file $MYSQL_TMP_DIR/mysql/user.MYD
 | 
						|
--remove_file $MYSQL_TMP_DIR/mysql/user.MYI
 | 
						|
--rmdir $MYSQL_TMP_DIR/mysql
 | 
						|
--exec ln -s $MYSQLD_DATADIR/mysql $MYSQL_TMP_DIR/mysql
 | 
						|
FLUSH TABLE mysql.user;
 | 
						|
DROP TABLE user;
 | 
						|
FLUSH TABLE mysql.user;
 | 
						|
--disable_result_log
 | 
						|
SELECT * FROM mysql.user;
 | 
						|
--enable_result_log
 | 
						|
--remove_file $MYSQL_TMP_DIR/mysql
 | 
						|
 | 
						|
--echo End of 5.1 tests
 | 
						|
 | 
						|
 | 
						|
--echo #
 | 
						|
--echo # Test for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... '
 | 
						|
--echo #                           STATEMENTS FAIL".
 | 
						|
--echo #
 | 
						|
--disable_warnings
 | 
						|
drop table if exists t1, t2;
 | 
						|
--enable_warnings
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval create table t1 (a int primary key) engine=myisam
 | 
						|
      data directory="$MYSQLTEST_VARDIR/tmp"
 | 
						|
      index directory="$MYSQLTEST_VARDIR/run";
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
show create table t1;
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
select create_options from information_schema.tables where table_name='t1';
 | 
						|
--echo # CREATE TABLE LIKE statement on table with INDEX/DATA DIRECTORY
 | 
						|
--echo # options should not fail. Per documentation newly created table
 | 
						|
--echo # should not inherit value of these options from the original table.
 | 
						|
create table t2 like t1;
 | 
						|
show create table t2;
 | 
						|
drop tables t1, t2;
 | 
						|
 | 
						|
--echo #
 | 
						|
--echo # Test for bug #25514146 DB_NAME IS IGNORED WHEN CREATING TABLE
 | 
						|
--echo # WITH DATA DIRECTORY
 | 
						|
--echo #
 | 
						|
 | 
						|
--echo # Make sure we have no current database
 | 
						|
CREATE DATABASE x;
 | 
						|
USE x;
 | 
						|
DROP DATABASE x;
 | 
						|
 | 
						|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 | 
						|
eval CREATE TABLE test.t1(id INT(11)) ENGINE MYISAM
 | 
						|
DATA DIRECTORY "$MYSQLTEST_VARDIR/tmp";
 | 
						|
 | 
						|
DROP TABLE test.t1;
 | 
						|
use test;
 | 
						|
 | 
						|
#
 | 
						|
# End of 5.5 tests
 | 
						|
#
 | 
						|
 | 
						|
#
 | 
						|
# End of 10.0 tests
 | 
						|
#
 | 
						|
 | 
						|
#
 | 
						|
# MDEV-13636 ALTER TABLE ... DELAY_KEY_WRITE=1 creates table copy for MyISAM table with DATA DIRECTORY/INDEX DIRECTORY options
 | 
						|
#
 | 
						|
replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR;
 | 
						|
eval
 | 
						|
create table t1(c1 int, c2 int, c3 varchar(100)) engine=MyISAM data directory='$MYSQL_TMP_DIR' index directory = '$MYSQL_TMP_DIR';
 | 
						|
insert t1 values (1,2,3), (2,3,4), (3,4,5), (4,5,6), (5,6,7), (6,7,8), (7,8,9);
 | 
						|
alter online table t1 delay_key_write=1;
 | 
						|
replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR;
 | 
						|
show create table t1;
 | 
						|
drop table t1;
 | 
						|
 | 
						|
#
 | 
						|
# End of 10.1 tests
 | 
						|
#
 |