summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-11-04 09:40:36 +0200
committerunknown <monty@narttu.mysql.fi>2003-11-04 09:40:36 +0200
commitf97f48acaf26aebc3f79de34b21607e11e1b91fa (patch)
treed387df22d5d3ffed50ecd8620f1eb18bc61ead7e /mysql-test
parent1eebd1174e87836f4c5bcb58143b11a9dfb8e18f (diff)
parent56ebe77bd1639ee85958ff958bdad05819997043 (diff)
downloadmariadb-git-f97f48acaf26aebc3f79de34b21607e11e1b91fa.tar.gz
Merge with 4.0
BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-apply-patch: Delete: netware/BUILD/apply-patch BitKeeper/deleted/.del-save-patch: Delete: netware/BUILD/save-patch BitKeeper/deleted/.del-mini_client.cc~8677895ec8169183: Auto merged BitKeeper/triggers/post-commit: Auto merged VC++Files/mysys/mysys.dsp: Auto merged client/mysqlbinlog.cc: Auto merged extra/resolveip.c: Auto merged include/config-win.h: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql_com.h: Auto merged innobase/include/os0thread.h: Auto merged innobase/os/os0file.c: Auto merged innobase/srv/srv0start.c: Auto merged innobase/thr/thr0loc.c: Auto merged libmysql/manager.c: Auto merged libmysqld/Makefile.am: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/ft_boolean_search.c: Auto merged myisam/mi_extra.c: Auto merged myisam/mi_locking.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/myisam.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/t/fulltext.test: Auto merged mysql-test/t/myisam.test: Auto merged mysql-test/t/rpl_reset_slave.test: Auto merged mysql-test/t/rpl_trunc_binlog.test: Auto merged mysys/Makefile.am: Auto merged mysys/errors.c: Auto merged mysys/my_symlink.c: Auto merged mysys/my_thr_init.c: Auto merged scripts/mysql_install_db.sh: Auto merged sql/item_func.cc: Auto merged sql/log_event.h: Auto merged sql/mysqld.cc: Auto merged sql/slave.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_repl.cc: Auto merged sql/sql_test.cc: Auto merged sql/unireg.h: Auto merged client/mysqldump.c: merge with 4.0 (quoted names) configure.in: use local file include/my_pthread.h: Use local file innobase/include/srv0srv.h: Use local file innobase/row/row0sel.c: Use local file innobase/srv/srv0srv.c: Use local file libmysql/libmysql.c: Use local file myisam/myisamchk.c: merge fixes mysql-test/r/func_crypt.result: update results mysql-test/r/order_by.result: update results mysql-test/r/query_cache.result: update results mysql-test/r/range.result: update results mysql-test/r/rpl_reset_slave.result: update results mysql-test/r/rpl_trunc_binlog.result: update results mysql-test/t/func_crypt.test: Added disable_warnings/enable warnings mysql-test/t/query_cache.test: merge tests mysql-test/t/range.test: merge tests mysys/charset.c: use local file (will merge patch separately) sql/ha_innodb.cc: use local file sql/log_event.cc: new slave_proxy_id handling sql/slave.h: merge sql/sql_base.cc: merge sql/sql_parse.cc: Fixes for counting user connect resourses Added function comments for involved functions sql/sql_select.cc: Fix for not doing sort with LIMIT when OPTION_FOUND_ROWS is used sql/unireg.cc: merge fixes support-files/mysql.server.sh: merge fixes
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/mysql-test-run.sh13
-rw-r--r--mysql-test/r/fulltext.result2
-rw-r--r--mysql-test/r/func_crypt.result10
-rw-r--r--mysql-test/r/order_by.result6
-rw-r--r--mysql-test/r/query_cache.result43
-rw-r--r--mysql-test/r/range.result17
-rw-r--r--mysql-test/r/rpl_chain_temp_table.result30
-rw-r--r--mysql-test/r/rpl_reset_slave.result10
-rw-r--r--mysql-test/r/rpl_trunc_binlog.result5
-rw-r--r--mysql-test/r/select.result4
-rw-r--r--mysql-test/t/fulltext.test6
-rw-r--r--mysql-test/t/func_crypt.test12
-rw-r--r--mysql-test/t/query_cache-master.opt1
-rw-r--r--mysql-test/t/query_cache.test53
-rw-r--r--mysql-test/t/range.test25
-rw-r--r--mysql-test/t/rpl_chain_temp_table.test99
-rw-r--r--mysql-test/t/rpl_reset_slave.test18
-rw-r--r--mysql-test/t/rpl_trunc_binlog.test2
18 files changed, 342 insertions, 14 deletions
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index eda2f3b2a34..8af3a3ac3ec 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -338,7 +338,13 @@ while test $# -gt 0; do
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
;;
--valgrind)
- VALGRIND="valgrind --alignment=8 --leak-check=yes --num-callers=16"
+ VALGRIND=`which valgrind` # this will print an error if not found
+ # Give good warning to the user and stop
+ if [ -z "$VALGRIND" ] ; then
+ $ECHO "You need to have the 'valgrind' program in your PATH to run mysql-test-run with option --valgrind. Valgrind's home page is http://developer.kde.org/~sewardj ."
+ exit 1
+ fi
+ VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16"
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
SLEEP_TIME_AFTER_RESTART=10
@@ -349,6 +355,9 @@ while test $# -gt 0; do
TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"`
VALGRIND="$VALGRIND $TMP"
;;
+ --valgrind-all)
+ VALGRIND="$VALGRIND -v --show-reachable=yes"
+ ;;
--skip-*)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $1"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $1"
@@ -1163,7 +1172,7 @@ run_testcase ()
echo $tname > $CURRENT_TEST
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ $USE_MANAGER = 1 ] ; then
- many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
+ many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)`
fi
if [ -n "$SKIP_TEST" ] ; then
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index da3b3d0b8da..56f95ff0c90 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -297,6 +297,8 @@ insert into t2 values (3, 1, 'xxbuz');
select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('xxfoo' in boolean mode);
t1_id name t2_id t1_id name
1 data1 1 1 xxfoo
+select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode);
+t2_id t1_id name
drop table t1,t2;
SET NAMES latin1;
CREATE TABLE t1 (t text character set utf8 not null, fulltext(t));
diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result
index 5ee0f0f3e93..6b63002fd39 100644
--- a/mysql-test/r/func_crypt.result
+++ b/mysql-test/r/func_crypt.result
@@ -1,6 +1,16 @@
+drop table if exists t1;
select length(encrypt('foo', 'ff')) <> 0;
length(encrypt('foo', 'ff')) <> 0
1
+create table t1 (name varchar(50), pw varchar(16));
+insert into t1 values ('tom', password('my_pass'));
+set @pass='my_pass';
+select name from t1 where name='tom' and pw=password(@pass);
+name
+tom
+select name from t1 where name='tom' and pw=password(@undefined);
+name
+drop table t1;
select password('abc');
password('abc')
*0D3CED9BEC10A777AEC23CCC353A8C08A633045E
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index db747e3a7eb..f4878664076 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -306,17 +306,17 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 9 NULL 8 Using where; Using index
explain select * from t1 where a = 2 and b >0 order by a desc,b desc;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
+1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
explain select * from t1 where a = 2 and b is null order by a desc,b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 9 const,const 1 Using where; Using index; Using filesort
explain select * from t1 where a = 2 and (b is null or b > 0) order by a
desc,b desc;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 9 NULL 6 Using where; Using index
+1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
+1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index b446d30c83f..45e195e89f7 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -1,8 +1,9 @@
+set GLOBAL query_cache_size=1355776;
flush query cache;
flush query cache;
reset query cache;
flush status;
-drop table if exists t1,t2,t3;
+drop table if exists t1,t2,t3,t4,t11,t21;
drop database if exists mysqltest;
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
@@ -722,6 +723,46 @@ Variable_name Value
Qcache_queries_in_cache 2
SET OPTION SQL_SELECT_LIMIT=DEFAULT;
drop table t1;
+flush query cache;
+reset query cache;
+flush status;
+set GLOBAL query_cache_size=1048576;
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a text not null);
+create table t3 (a text not null);
+insert into t3 values("1111111111111111111111111111111111111111111111111111");
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+drop table t2;
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+create table t4 (a int not null);
+insert into t4 values (1),(2),(3);
+select * from t4;
+select * from t2;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+delete from t2 where a=1;
+flush query cache;
+select * from t3;
+delete from t4 where a=1;
+flush query cache;
+drop table t1,t2,t3,t4;
+set GLOBAL query_cache_size=0;
SET NAMES koi8r;
CREATE TABLE t1 (a char(1) character set koi8r);
INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á');
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 38d3d9b2b7d..324eb37b334 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -262,6 +262,23 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref j1 j1 4 const 1 Using where; Using index
1 SIMPLE t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 0x2)
DROP TABLE t1,t2;
+CREATE TABLE t1 (
+a int(11) default NULL,
+b int(11) default NULL,
+KEY a (a),
+KEY b (b)
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES
+(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2),
+(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3),
+(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5),
+(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
+EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
+table type possible_keys key key_len ref rows Extra
+t1 range a,b a 5 NULL 2 Using where
+SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
+a b
+DROP TABLE t1;
create table t1 (id int(10) primary key);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
select id from t1 where id in (2,5,9) ;
diff --git a/mysql-test/r/rpl_chain_temp_table.result b/mysql-test/r/rpl_chain_temp_table.result
new file mode 100644
index 00000000000..5ece80565c7
--- /dev/null
+++ b/mysql-test/r/rpl_chain_temp_table.result
@@ -0,0 +1,30 @@
+slave stop;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+slave start;
+reset master;
+change master to master_host='127.0.0.1',master_port=9307, master_user='root';
+start slave;
+create temporary table t1 (a int);
+create temporary table t1 (a int);
+show status like 'slave_open_temp_tables';
+Variable_name Value
+Slave_open_temp_tables 2
+create temporary table t1 (a int);
+create temporary table t1 (a int);
+show status like 'slave_open_temp_tables';
+Variable_name Value
+Slave_open_temp_tables 4
+stop slave;
+insert into t1 values(1);
+create table t2 as select * from t1;
+start slave;
+show status like 'slave_open_temp_tables';
+Variable_name Value
+Slave_open_temp_tables 4
+select * from t2;
+a
+1
+drop table t2;
diff --git a/mysql-test/r/rpl_reset_slave.result b/mysql-test/r/rpl_reset_slave.result
index 8887462389d..e1fbf12786d 100644
--- a/mysql-test/r/rpl_reset_slave.result
+++ b/mysql-test/r/rpl_reset_slave.result
@@ -20,3 +20,13 @@ start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No #
+stop slave;
+reset slave;
+start slave;
+create temporary table t1 (a int);
+stop slave;
+reset slave;
+start slave;
+show status like 'slave_open_temp_tables';
+Variable_name Value
+Slave_open_temp_tables 1
diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result
index 1cd9cdf08a0..bc5e401287d 100644
--- a/mysql-test/r/rpl_trunc_binlog.result
+++ b/mysql-test/r/rpl_trunc_binlog.result
@@ -8,7 +8,8 @@ stop slave;
flush logs;
reset slave;
start slave;
-show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No #
-reset master;
+show slave status;
+Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
+127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 161 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 317
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index b9218942a5e..8edd0182dec 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2150,10 +2150,10 @@ a a a
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;
a a a
1 1 2
-2 2 2
-3 3 2
1 1 3
+2 2 2
2 2 3
+3 3 2
3 3 3
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a a
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 9c48f84161a..467d1aa6f07 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -228,6 +228,12 @@ insert into t2 values (1, 1, 'xxfoo');
insert into t2 values (2, 1, 'xxbar');
insert into t2 values (3, 1, 'xxbuz');
select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('xxfoo' in boolean mode);
+
+#
+# bug with many short (< ft_min_word_len) words in boolean search
+#
+select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode);
+
drop table t1,t2;
#
diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test
index c1c7090cab3..3cf1e15e3ef 100644
--- a/mysql-test/t/func_crypt.test
+++ b/mysql-test/t/func_crypt.test
@@ -1,9 +1,21 @@
-- source include/have_crypt.inc
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
select length(encrypt('foo', 'ff')) <> 0;
--replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l.
+create table t1 (name varchar(50), pw varchar(16));
+insert into t1 values ('tom', password('my_pass'));
+set @pass='my_pass';
+select name from t1 where name='tom' and pw=password(@pass);
+select name from t1 where name='tom' and pw=password(@undefined);
+drop table t1;
+
# Test new and old password handling functions
+
select password('abc');
select password('');
select old_password('abc');
diff --git a/mysql-test/t/query_cache-master.opt b/mysql-test/t/query_cache-master.opt
deleted file mode 100644
index cfdce628e74..00000000000
--- a/mysql-test/t/query_cache-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---set-variable=query_cache_size=1355776
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 0ec6e5ecb73..14cbf4c906d 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -3,6 +3,7 @@
#
# Tests with query cache
#
+set GLOBAL query_cache_size=1355776;
# Reset query cache variables.
@@ -11,7 +12,7 @@ flush query cache; # This crashed in some versions
reset query cache;
flush status;
--disable_warnings
-drop table if exists t1,t2,t3;
+drop table if exists t1,t2,t3,t4,t11,t21;
drop database if exists mysqltest;
--enable_warnings
@@ -490,6 +491,55 @@ SET OPTION SQL_SELECT_LIMIT=DEFAULT;
drop table t1;
#
+# query cache crash on using same table twice in one query test
+#
+flush query cache;
+reset query cache;
+flush status;
+set GLOBAL query_cache_size=1048576;
+
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a text not null);
+create table t3 (a text not null);
+insert into t3 values("1111111111111111111111111111111111111111111111111111");
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+drop table t2;
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+create table t4 (a int not null);
+insert into t4 values (1),(2),(3);
+
+disable_result_log;
+select * from t4;
+select * from t2;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+
+delete from t2 where a=1;
+flush query cache;
+select * from t3;
+enable_result_log;
+delete from t4 where a=1;
+flush query cache;
+
+drop table t1,t2,t3,t4;
+
+#
# Test character set related variables:
# character_set_result
# character_set_client
@@ -535,3 +585,4 @@ show status like "Qcache_queries_in_cache";
# Keep things tidy
#
DROP TABLE t1;
+SET GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index 40ae49f8005..0b39f20e346 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -306,3 +306,28 @@ select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
drop table t1,t2;
+
+#
+# bug #1724: use RANGE on more selective column instead of REF on less
+# selective
+
+CREATE TABLE t1 (
+ a int(11) default NULL,
+ b int(11) default NULL,
+ KEY a (a),
+ KEY b (b)
+) TYPE=MyISAM;
+
+
+INSERT INTO t1 VALUES
+(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(10,2),
+(13,2),(14,2),(15,2),(16,2),(17,3),(17,3),(16,3),(17,3),(19,3),(20,3),
+(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5),
+(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
+
+EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
+SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
+
+DROP TABLE t1;
+
+# we expect that optimizer will choose key on A
diff --git a/mysql-test/t/rpl_chain_temp_table.test b/mysql-test/t/rpl_chain_temp_table.test
new file mode 100644
index 00000000000..007b018e9d8
--- /dev/null
+++ b/mysql-test/t/rpl_chain_temp_table.test
@@ -0,0 +1,99 @@
+ # This test makes some assumptions about values of thread ids, which should be
+# true if the servers have been restarted for this test. So we want to
+# stop/restart servers. Note that if assumptions are wrong, the test will not
+# fail; it will just fail to test the error-prone scenario.
+# Using the manager is the only way to have more than one slave server.
+# So you must run this test with --manager.
+
+require_manager;
+server_stop master;
+server_start master;
+server_stop slave;
+server_start slave;
+# no need for slave_sec (no assumptions on thread ids for this server).
+
+source include/master-slave.inc;
+connect (slave_sec,localhost,root,,test,0,slave.sock-1);
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+save_master_pos;
+connection slave_sec;
+eval change master to master_host='127.0.0.1',master_port=$SLAVE_MYPORT, master_user='root';
+start slave;
+sync_with_master;
+
+# :P now we have a chain ready-to-test.
+
+connection master;
+create temporary table t1 (a int);
+save_master_pos;
+connection slave;
+sync_with_master;
+connection master1;
+create temporary table t1 (a int);
+save_master_pos;
+connection slave;
+sync_with_master;
+save_master_pos;
+
+# First test:
+
+connection slave_sec;
+# Before BUG#1686 ("If 2 master threads with same-name temp table, slave makes
+# bad binlog") was fixed, sync_with_master failed
+sync_with_master;
+show status like 'slave_open_temp_tables';
+
+# 'master' and 'master1' usually have thread id 2-3 or 3-4.
+# 'slave' and 'slave1' usually have thread id 2-3.
+connection slave;
+create temporary table t1 (a int);
+connection slave1;
+create temporary table t1 (a int);
+# So it's likely that in the binlog of slave we get
+# server_id=of_master thread_id=3 create temp...
+# server_id=of_slave thread_id=3 create temp...
+# which would confuse slave-sec unless slave-sec uses server id to distinguish
+# between temp tables (here thread id is obviously not enough to distinguish).
+
+save_master_pos;
+
+# Second test:
+
+connection slave_sec;
+# If we did not use the server id to distinguish between temp tables,
+# sync_with_master would fail
+sync_with_master;
+show status like 'slave_open_temp_tables';
+
+# Third test (BUG#1240 "slave of slave breaks when STOP SLAVE was issud on
+# parent slave and temp tables").
+stop slave;
+connection slave;
+insert into t1 values(1);
+create table t2 as select * from t1;
+save_master_pos;
+connection slave_sec;
+start slave;
+sync_with_master;
+show status like 'slave_open_temp_tables';
+select * from t2;
+
+# clean up
+connection slave;
+drop table t2;
+save_master_pos;
+connection slave_sec;
+sync_with_master;
+
+# On purpose, we don't delete the temporary tables explicitely.
+# So temp tables remain on slave (remember they are not deleted when the slave
+# SQL thread terminates). If you run this test with
+# --valgrind --valgrind-options=--show-reachable=yes
+# you will see if they get cleaned up at slave's shutdown (that is, if the
+# memory they use is freed (it should) by mysqld before it terminates).
+# If they wouldn't be cleaned up, you would see some "still reachable" blocks in
+# Valgrind.
diff --git a/mysql-test/t/rpl_reset_slave.test b/mysql-test/t/rpl_reset_slave.test
index e03916ec73a..d58e9c711d1 100644
--- a/mysql-test/t/rpl_reset_slave.test
+++ b/mysql-test/t/rpl_reset_slave.test
@@ -2,6 +2,8 @@
# --master-* options from mysqld, as this is what is going to be used next time
# slave threads will be started). In bug 985, it displayed old values (of before
# RESET SLAVE).
+# See if slave crashes when doing a CREATE TEMPORARY TABLE twice, separated by
+# RESET SLAVE.
source include/master-slave.inc;
connection master;
@@ -28,3 +30,19 @@ sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 33 #
show slave status;
+
+# test of crash with temp tables & RESET SLAVE
+# (test to see if RESET SLAVE clears temp tables in memory and disk)
+stop slave;
+reset slave;
+start slave;
+connection master;
+create temporary table t1 (a int);
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+reset slave;
+start slave;
+sync_with_master;
+show status like 'slave_open_temp_tables';
diff --git a/mysql-test/t/rpl_trunc_binlog.test b/mysql-test/t/rpl_trunc_binlog.test
index 4c14ec72b5c..32052af9184 100644
--- a/mysql-test/t/rpl_trunc_binlog.test
+++ b/mysql-test/t/rpl_trunc_binlog.test
@@ -23,5 +23,3 @@ sleep 3;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 33 #
show slave status;
-connection master;
-reset master;