diff options
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/drop_temp_table.test | 19 | ||||
-rw-r--r-- | mysql-test/t/ins000001.test | 12 | ||||
-rw-r--r-- | mysql-test/t/insert.test | 13 | ||||
-rw-r--r-- | mysql-test/t/mysqlbinlog-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/t/mysqlbinlog.test | 103 | ||||
-rw-r--r-- | mysql-test/t/rpl000009.test | 57 | ||||
-rw-r--r-- | mysql-test/t/rpl_loaddata.test | 15 | ||||
-rw-r--r-- | mysql-test/t/rpl_trunc_binlog.test | 22 | ||||
-rw-r--r-- | mysql-test/t/select.test | 6 | ||||
-rw-r--r-- | mysql-test/t/user_var.test | 30 |
10 files changed, 263 insertions, 15 deletions
diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test new file mode 100644 index 00000000000..1a7d8796bb3 --- /dev/null +++ b/mysql-test/t/drop_temp_table.test @@ -0,0 +1,19 @@ +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connection con1; +reset master; +create database `drop-temp+table-test`; +use `drop-temp+table-test`; +create temporary table `table:name` (a int); +select get_lock("a",10); +disconnect con1; + +connection con2; +# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no +# guarantee that logging of the terminated con1 has been done yet. +# To be sure that logging has been done, we use a user lock. +select get_lock("a",10); +let $VERSION=`select version()`; +--replace_result $VERSION VERSION +show binlog events; +drop database `drop-temp+table-test`; diff --git a/mysql-test/t/ins000001.test b/mysql-test/t/ins000001.test deleted file mode 100644 index afcd27ebfca..00000000000 --- a/mysql-test/t/ins000001.test +++ /dev/null @@ -1,12 +0,0 @@ -use test; ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -create table t1 (email varchar(50)); -insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'), -('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com'); -create table t2(id int not null auto_increment primary key, - t2 varchar(50), unique(t2)); -insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1; -select * from t2; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 9cc0bf8c46c..ae0a87895e1 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1; +drop table if exists t1,t2; --enable_warnings create table t1 (a int not null); @@ -65,6 +65,17 @@ select * from t1; drop table t1; # +# Test if insert ... select distinct +# + +create table t1 (email varchar(50)); +insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com'); +create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2)); +insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1; +select * from t2; +drop table t1,t2; + +# # Test of mysqld crash with fully qualified column names # diff --git a/mysql-test/t/mysqlbinlog-master.opt b/mysql-test/t/mysqlbinlog-master.opt new file mode 100644 index 00000000000..ac1a87c73b3 --- /dev/null +++ b/mysql-test/t/mysqlbinlog-master.opt @@ -0,0 +1 @@ +--max-binlog-size=4096 diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test new file mode 100644 index 00000000000..22b63146652 --- /dev/null +++ b/mysql-test/t/mysqlbinlog.test @@ -0,0 +1,103 @@ +# We are using .opt file since we need small binlog size +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +# we need this for getting fixed timestamps inside of this test +set timestamp=1000000000; + +create table t1 (word varchar(20)); +create table t2 (id int auto_increment not null primary key); + +# simple test for simple statement and various events +insert into t1 values ("abirvalg"); +insert into t2 values (); +# Should be uncommented in 4.1 +# set @a:=1 +# insert into t2 values (@a); + +# test for load data and load data distributed among the several +# files (we need to fill up first binlog) +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1; +# simple query to show more in second binlog +insert into t1 values ("Alas"); +flush logs; + +# delimiters are for easier debugging in future +--disable_query_log +select "--- Local --" as ""; +--enable_query_log + +# +# We should use --short-form everywhere because in other case output will +# be time dependend. Better than nothing. +# + +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.001 + +# this should not fail but shouldn't produce any working statements +--disable_query_log +select "--- Broken LOAD DATA --" as ""; +--enable_query_log +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.002 + +# this should show almost nothing +--disable_query_log +select "--- --database --" as ""; +--enable_query_log +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.001 + +# this test for position option +--disable_query_log +select "--- --position --" as ""; +--enable_query_log +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form --position=27 $MYSQL_TEST_DIR/var/log/master-bin.002 + +# These are tests for remote binlog. +# They should return the same as previous test. +# But now they are not. V. Vagin should fix this. +# We test all the same options second time since code for remote case is +# essentially different. If code for both cases will be unified we'll be +# able to throw out most of this. + +--disable_query_log +select "--- Remote --" as ""; +--enable_query_log + +# This is broken now +# By the way it seems that remote version fetches all events with name >= master-bin.001 +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.001 + +# This is broken too +--disable_query_log +select "--- Broken LOAD DATA --" as ""; +--enable_query_log +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002 + +# And this too ! (altough it is documented) +--disable_query_log +select "--- --database --" as ""; +--enable_query_log +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.001 + +# Strangely but this works +--disable_query_log +select "--- --position --" as ""; +--enable_query_log +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002 + +# clean up +drop table t1; diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test index ffec20c793e..4db62540e7b 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl000009.test @@ -60,16 +60,45 @@ sync_with_master; # This should show that the slave is empty at this point show databases; +# Create foo and foo2 on slave; we expect that LOAD DATA FROM MASTER will +# neither touch database foo nor foo2. +create database foo; +create table foo.t1(n int, s char(20)); +insert into foo.t1 values (1, 'original foo.t1'); +create table foo.t3(n int, s char(20)); +insert into foo.t3 values (1, 'original foo.t3'); +create database foo2; +create table foo2.t1(n int, s char(20)); +insert into foo2.t1 values (1, 'original foo2.t1'); +# Create bar, and bar.t1, to check that it gets replaced, +# and bar.t3 to check that it is not touched (there is no bar.t3 on master) +create database bar; +create table bar.t1(n int, s char(20)); +insert into bar.t1 values (1, 'original bar.t1'); +create table bar.t3(n int, s char(20)); +insert into bar.t3 values (1, 'original bar.t3'); + load data from master; # Now let's check if we have the right tables and the right data in them show databases; use mysqltest2; -show tables; +# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which databases +# have to be copied. So it thinks "foo" has to be copied. Before 4.0.16 it would +# first drop "foo", then create "foo". This "drop" is a bug; in that case t3 +# would disappear. +# So here the effect of this bug (BUG#1248) would be to leave an empty "foo" on +# the slave. +show tables; # should be t1 & t3 +select * from t1; # should be slave's original +use foo2; +show tables; # should be t1 +select * from t1; # should be slave's original use mysqltest; -show tables; +show tables; # should contain master's copied t1&t2, slave's original t3 select * from mysqltest.t1; select * from mysqltest.t2; +select * from mysqltest.t3; # Now let's see if replication works connection master; @@ -79,6 +108,28 @@ connection slave; sync_with_master; select * from mysqltest.t1; +# Check that LOAD DATA FROM MASTER reports the error if it can't drop a +# table to be overwritten. +# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX +# insert into bar.t1 values(10, 'should be there'); +# flush tables; +# system chmod 500 var/slave-data/bar/; +# --error 6 +# load data from master; # should fail (errno 13) +# system chmod 700 var/slave-data/bar/; +# select * from bar.t1; # should contain the row (10, ...) + + +# Check that LOAD TABLE FROM MASTER fails if the table exists on slave +--error 1050 +load table bar.t1 from master; +drop table bar.t1; +load table bar.t1 from master; + +# as LOAD DATA FROM MASTER failed it did not restart slave threads +# DISABLED FOR NOW +# start slave; + # Now time for cleanup connection master; drop database mysqltest; @@ -86,3 +137,5 @@ drop database mysqltest2; save_master_pos; connection slave; sync_with_master; +drop database mysqltest; +drop database mysqltest2; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index 478d4b75a36..88d9a7ee03f 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -113,3 +113,18 @@ stop slave; reset slave; --replace_result $MASTER_MYPORT MASTER_PORT show slave status; + +# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE + +connection master; +reset master; +create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), +unique(day)); +--error 1062; +load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by +'\n##\n' starting by '>' ignore 1 lines; +# To test that there is Create_file & Delete_file, we test if the binlog is as +# long as expected (can't do SHOW BINLOG EVENTS because of varying file_id). +show master status; +drop table t2; diff --git a/mysql-test/t/rpl_trunc_binlog.test b/mysql-test/t/rpl_trunc_binlog.test new file mode 100644 index 00000000000..efdc3012471 --- /dev/null +++ b/mysql-test/t/rpl_trunc_binlog.test @@ -0,0 +1,22 @@ +# We are testing if a binlog which contains BEGIN but not COMMIT (the master did +# while writing the transaction to the binlog) triggers an error on slave. +# So we use such a truncated binlog and simulate that the master restarted after +# this. + +source include/master-slave.inc; + +connection slave; +stop slave; +connection master; +flush logs; +system mv -f var/log/master-bin.001 var/log/master-bin.002; +system cp std_data/trunc_binlog.001 var/log/master-bin.001; +connection slave; +reset slave; +start slave; +# can't sync_with_master so we must sleep +sleep 3; +--replace_result $MASTER_MYPORT MASTER_PORT +show slave status; +connection master; +reset master; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 4593eeb0691..d727befe661 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -42,6 +42,7 @@ CREATE TABLE t2 ( # Populate table # +--disable_query_log INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat',''); INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); @@ -1241,6 +1242,7 @@ INSERT INTO t2 VALUES (1190,123304,00,'bruises','Medicare','backer',''); INSERT INTO t2 VALUES (1191,068504,00,'bonfire','corresponds','positively',''); INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky',''); INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly',''); +--enable_query_log # # Search with a key @@ -1366,6 +1368,7 @@ create table t3 ( key (name) ); +--disable_query_log INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724); INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648); INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872); @@ -1376,6 +1379,7 @@ INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,9835 INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892); INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392); INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234); +--enable_query_log create temporary table tmp type = myisam select * from t3; @@ -1496,6 +1500,7 @@ create table t4 ( UNIQUE KEY companyname(companyname) ) TYPE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; +--disable_query_log INSERT INTO t4 (companynr, companyname) VALUES (29,'company 1'); INSERT INTO t4 (companynr, companyname) VALUES (34,'company 2'); INSERT INTO t4 (companynr, companyname) VALUES (36,'company 3'); @@ -1508,6 +1513,7 @@ INSERT INTO t4 (companynr, companyname) VALUES (65,'company 9'); INSERT INTO t4 (companynr, companyname) VALUES (68,'company 10'); INSERT INTO t4 (companynr, companyname) VALUES (50,'company 11'); INSERT INTO t4 (companynr, companyname) VALUES (00,'Unknown'); +--enable_query_log # # Test of stright join to force a full join. diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 947c944c79e..8fe48641fed 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -26,7 +26,37 @@ explain select * from t1 where i=@vv1; drop table t1,t2; # Check types of variables +set @a=0,@b=0; select @a:=10, @b:=1, @a > @b, @a < @b; +# Note that here a and b will be avaluated as number select @a:="10", @b:="1", @a > @b, @a < @b; +# Note that here a and b will be avaluated as strings select @a:=10, @b:=2, @a > @b, @a < @b; select @a:="10", @b:="2", @a > @b, @a < @b; + +# Fixed bug #1194 +select @a:=1; +select @a, @a:=1; + +create table t1 (id int, d double, c char(10)); +insert into t1 values (1,2.0, "test"); +select @c:=0; +update t1 SET id=(@c:=@c+1); +select @c; +select @c:=0; +update t1 set id=(@c:=@c+1); +select @c; +select @c:=0; +select @c:=@c+1; +select @d,(@d:=id),@d from t1; +select @e,(@e:=d),@e from t1; +select @f,(@f:=c),@f from t1; +set @g=1; +select @g,(@g:=c),@g from t1; +select @c, @d, @e, @f; +select @d:=id, @e:=id, @f:=id, @g:=@id from t1; +select @c, @d, @e, @f, @g; +drop table t1; + +# just for fun :) +select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; |