summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/README0
-rw-r--r--mysql-test/t/alias.test3
-rw-r--r--mysql-test/t/alter_table.test31
-rw-r--r--mysql-test/t/analyse.test4
-rw-r--r--mysql-test/t/ansi.test7
-rw-r--r--mysql-test/t/auto_increment.test72
-rw-r--r--mysql-test/t/backup.test3
-rw-r--r--mysql-test/t/bdb-alter-table-1.test3
-rw-r--r--mysql-test/t/bdb-crash.test2
-rw-r--r--mysql-test/t/bdb-deadlock.test13
-rw-r--r--mysql-test/t/bdb.test11
-rw-r--r--mysql-test/t/bdb_cache.test5
-rw-r--r--mysql-test/t/bench_count_distinct.test6
-rw-r--r--mysql-test/t/bigint.test10
-rw-r--r--mysql-test/t/binary.test20
-rw-r--r--mysql-test/t/bool.test14
-rw-r--r--mysql-test/t/bulk_replace.test5
-rw-r--r--mysql-test/t/case.test61
-rw-r--r--mysql-test/t/cast.test53
-rw-r--r--mysql-test/t/check.test5
-rw-r--r--mysql-test/t/compare.test3
-rw-r--r--mysql-test/t/connect.test69
-rw-r--r--mysql-test/t/constraints.test2
-rw-r--r--mysql-test/t/convert.test11
-rw-r--r--mysql-test/t/count_distinct.test3
-rw-r--r--mysql-test/t/count_distinct2.test2
-rw-r--r--mysql-test/t/count_distinct3.test55
-rw-r--r--mysql-test/t/create.test142
-rw-r--r--mysql-test/t/ctype_collate.test157
-rw-r--r--mysql-test/t/ctype_latin1_de-master.opt3
-rw-r--r--mysql-test/t/ctype_latin1_de.test30
-rw-r--r--mysql-test/t/ctype_many.test210
-rw-r--r--mysql-test/t/ctype_mb.test8
-rw-r--r--mysql-test/t/ctype_recoding.test47
-rw-r--r--mysql-test/t/ctype_ujis-master.opt1
-rw-r--r--mysql-test/t/ctype_ujis.test6
-rw-r--r--mysql-test/t/delayed.test2
-rw-r--r--mysql-test/t/delete.test12
-rw-r--r--mysql-test/t/derived.test96
-rw-r--r--mysql-test/t/dirty_close.test4
-rw-r--r--mysql-test/t/distinct.test7
-rw-r--r--mysql-test/t/drop.test6
-rw-r--r--mysql-test/t/empty_table.test3
-rw-r--r--mysql-test/t/errors.test7
-rw-r--r--mysql-test/t/explain.test2
-rw-r--r--mysql-test/t/flush.test6
-rw-r--r--mysql-test/t/foreign_key.test3
-rw-r--r--mysql-test/t/fulltext.test13
-rw-r--r--mysql-test/t/fulltext2.test98
-rw-r--r--mysql-test/t/fulltext_cache.test3
-rw-r--r--mysql-test/t/fulltext_distinct.test3
-rw-r--r--mysql-test/t/fulltext_left_join.test3
-rw-r--r--mysql-test/t/fulltext_multi.test4
-rw-r--r--mysql-test/t/fulltext_order_by.test4
-rw-r--r--mysql-test/t/fulltext_update.test2
-rw-r--r--mysql-test/t/func_compress.test25
-rw-r--r--mysql-test/t/func_concat.test3
-rw-r--r--mysql-test/t/func_crypt.test8
-rw-r--r--mysql-test/t/func_date_add.test3
-rw-r--r--mysql-test/t/func_encrypt.test3
-rw-r--r--mysql-test/t/func_equal.test6
-rw-r--r--mysql-test/t/func_gconcat.test101
-rw-r--r--mysql-test/t/func_group.test227
-rw-r--r--mysql-test/t/func_if.test2
-rw-r--r--mysql-test/t/func_in.test65
-rw-r--r--mysql-test/t/func_isnull.test3
-rw-r--r--mysql-test/t/func_like.test23
-rw-r--r--mysql-test/t/func_regexp.test3
-rw-r--r--mysql-test/t/func_sapdb.test99
-rw-r--r--mysql-test/t/func_set.test18
-rw-r--r--mysql-test/t/func_str.test201
-rw-r--r--mysql-test/t/func_system.test21
-rw-r--r--mysql-test/t/func_test.test43
-rw-r--r--mysql-test/t/func_time.test42
-rw-r--r--mysql-test/t/func_timestamp.test3
-rw-r--r--mysql-test/t/gcc296.test19
-rw-r--r--mysql-test/t/gis-rtree.test69
-rw-r--r--mysql-test/t/gis.test144
-rw-r--r--mysql-test/t/grant.test36
-rw-r--r--mysql-test/t/grant2.test30
-rw-r--r--mysql-test/t/grant_cache.test9
-rw-r--r--mysql-test/t/group_by.test17
-rw-r--r--mysql-test/t/handler.test11
-rw-r--r--mysql-test/t/having.test8
-rw-r--r--mysql-test/t/heap.test7
-rw-r--r--mysql-test/t/heap_auto_increment.test33
-rw-r--r--mysql-test/t/heap_btree.test158
-rw-r--r--mysql-test/t/heap_hash.test143
-rw-r--r--mysql-test/t/help.test115
-rw-r--r--mysql-test/t/innodb-deadlock.test77
-rw-r--r--mysql-test/t/innodb.test101
-rw-r--r--mysql-test/t/innodb_cache.test6
-rw-r--r--mysql-test/t/innodb_handler.test5
-rw-r--r--mysql-test/t/ins000001.test3
-rw-r--r--mysql-test/t/insert.test16
-rw-r--r--mysql-test/t/insert_select.test4
-rw-r--r--mysql-test/t/insert_update.test26
-rw-r--r--mysql-test/t/isam.test32
-rw-r--r--mysql-test/t/join.test5
-rw-r--r--mysql-test/t/join_crash.test3
-rw-r--r--mysql-test/t/join_outer.test5
-rw-r--r--mysql-test/t/key.test7
-rw-r--r--mysql-test/t/key_cache-master.opt1
-rw-r--r--mysql-test/t/key_cache.test42
-rw-r--r--mysql-test/t/key_diff.test3
-rw-r--r--mysql-test/t/key_primary.test3
-rw-r--r--mysql-test/t/keywords.test3
-rw-r--r--mysql-test/t/kill.test3
-rw-r--r--mysql-test/t/limit.test3
-rw-r--r--mysql-test/t/loaddata.test2
-rw-r--r--mysql-test/t/lock.test2
-rw-r--r--mysql-test/t/lock_multi.test4
-rw-r--r--mysql-test/t/lock_tables_lost_commit.test2
-rw-r--r--mysql-test/t/lowercase_table.test6
-rw-r--r--mysql-test/t/merge.test43
-rw-r--r--mysql-test/t/multi_update.test18
-rw-r--r--mysql-test/t/myisam.test22
-rw-r--r--mysql-test/t/null.test6
-rw-r--r--mysql-test/t/null_key.test41
-rw-r--r--mysql-test/t/odbc.test6
-rw-r--r--mysql-test/t/olap.test111
-rw-r--r--mysql-test/t/openssl_1.test2
-rw-r--r--mysql-test/t/order_by.test22
-rw-r--r--mysql-test/t/order_fill_sortbuf.test3
-rw-r--r--mysql-test/t/outfile.test5
-rw-r--r--mysql-test/t/preload.test100
-rw-r--r--mysql-test/t/query_cache.test43
-rw-r--r--mysql-test/t/raid.test14
-rw-r--r--mysql-test/t/range.test3
-rw-r--r--mysql-test/t/rename.test5
-rw-r--r--mysql-test/t/repair_part1.test (renamed from mysql-test/t/repair.test)3
-rw-r--r--mysql-test/t/replace.test7
-rw-r--r--mysql-test/t/rollback.test11
-rw-r--r--mysql-test/t/row.test83
-rw-r--r--mysql-test/t/rpl000001.test12
-rw-r--r--mysql-test/t/rpl000002.test19
-rw-r--r--mysql-test/t/rpl000003.test14
-rw-r--r--mysql-test/t/rpl000004.test6
-rw-r--r--mysql-test/t/rpl000005.test2
-rw-r--r--mysql-test/t/rpl000006.test2
-rw-r--r--mysql-test/t/rpl000008-slave.opt2
-rw-r--r--mysql-test/t/rpl000008.test41
-rw-r--r--mysql-test/t/rpl000009-slave.opt2
-rw-r--r--mysql-test/t/rpl000009.test81
-rw-r--r--mysql-test/t/rpl000010.test10
-rw-r--r--mysql-test/t/rpl000011.test18
-rw-r--r--mysql-test/t/rpl000012.test8
-rw-r--r--mysql-test/t/rpl000013.test6
-rw-r--r--mysql-test/t/rpl000015.test12
-rw-r--r--mysql-test/t/rpl000016-slave.opt1
-rwxr-xr-xmysql-test/t/rpl000017-slave.sh4
-rw-r--r--mysql-test/t/rpl000017.test12
-rw-r--r--mysql-test/t/rpl000018.test14
-rw-r--r--mysql-test/t/rpl_alter.test3
-rw-r--r--mysql-test/t/rpl_empty_master_crash.test3
-rw-r--r--mysql-test/t/rpl_failsafe.test8
-rw-r--r--mysql-test/t/rpl_flush_log_loop.test6
-rw-r--r--mysql-test/t/rpl_flush_tables.test35
-rw-r--r--mysql-test/t/rpl_insert_id-slave.opt1
-rw-r--r--mysql-test/t/rpl_insert_id.test1
-rw-r--r--mysql-test/t/rpl_loaddata.test5
-rw-r--r--mysql-test/t/rpl_log.test42
-rw-r--r--mysql-test/t/rpl_log_pos.test25
-rwxr-xr-xmysql-test/t/rpl_misc_functions-slave.sh1
-rw-r--r--mysql-test/t/rpl_misc_functions.test30
-rw-r--r--mysql-test/t/rpl_mystery22.test14
-rw-r--r--mysql-test/t/rpl_redirect.test1
-rw-r--r--mysql-test/t/rpl_relayrotate-slave.opt4
-rw-r--r--mysql-test/t/rpl_relayrotate.test71
-rw-r--r--mysql-test/t/rpl_replicate_do.test9
-rw-r--r--mysql-test/t/rpl_rotate_logs.test62
-rw-r--r--mysql-test/t/rpl_skip_error.test1
-rw-r--r--mysql-test/t/rpl_sporadic_master.test16
-rw-r--r--mysql-test/t/rpl_temporary.test107
-rw-r--r--mysql-test/t/rpl_user_variables.test49
-rw-r--r--mysql-test/t/sel000001.test31
-rw-r--r--mysql-test/t/sel000002.test17
-rw-r--r--mysql-test/t/sel000003.test18
-rw-r--r--mysql-test/t/sel000031.test20
-rw-r--r--mysql-test/t/sel000032.test20
-rw-r--r--mysql-test/t/sel000033.test2
-rw-r--r--mysql-test/t/sel000100.test2
-rw-r--r--mysql-test/t/select.test13
-rw-r--r--mysql-test/t/select_found.test12
-rw-r--r--mysql-test/t/select_safe.test3
-rw-r--r--mysql-test/t/show_check.test8
-rw-r--r--mysql-test/t/sql_mode.test30
-rw-r--r--mysql-test/t/status.test5
-rw-r--r--mysql-test/t/subselect.test924
-rw-r--r--mysql-test/t/subselect2.test149
-rw-r--r--mysql-test/t/symlink.test3
-rw-r--r--mysql-test/t/tablelock.test3
-rw-r--r--mysql-test/t/temp_table.test6
-rw-r--r--mysql-test/t/truncate.test3
-rw-r--r--mysql-test/t/type_blob.test43
-rw-r--r--mysql-test/t/type_date.test5
-rw-r--r--mysql-test/t/type_datetime.test5
-rw-r--r--mysql-test/t/type_decimal.test10
-rw-r--r--mysql-test/t/type_enum.test3
-rw-r--r--mysql-test/t/type_float.test11
-rw-r--r--mysql-test/t/type_ranges.test5
-rw-r--r--mysql-test/t/type_set.test5
-rw-r--r--mysql-test/t/type_time.test4
-rw-r--r--mysql-test/t/type_timestamp.test5
-rw-r--r--mysql-test/t/type_uint.test4
-rw-r--r--mysql-test/t/type_year.test3
-rw-r--r--mysql-test/t/union.test70
-rw-r--r--mysql-test/t/update.test10
-rw-r--r--mysql-test/t/user_var.test8
-rw-r--r--mysql-test/t/varbinary.test6
-rw-r--r--mysql-test/t/variables-master.opt2
-rw-r--r--mysql-test/t/variables.test25
-rw-r--r--mysql-test/t/warnings-master.opt1
-rw-r--r--mysql-test/t/warnings.test74
214 files changed, 5680 insertions, 613 deletions
diff --git a/mysql-test/t/README b/mysql-test/t/README
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/mysql-test/t/README
+++ /dev/null
diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test
index 57b46181fa1..e0fa10d56d5 100644
--- a/mysql-test/t/alias.test
+++ b/mysql-test/t/alias.test
@@ -1,4 +1,7 @@
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 (
cont_nr int(11) NOT NULL auto_increment,
ver_nr int(11) NOT NULL default '0',
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index d438f2d5825..06a5db13ea3 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -1,8 +1,10 @@
#
# Test of alter table
#
-
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (
col1 int not null auto_increment primary key,
col2 varchar(30) not null,
@@ -144,6 +146,33 @@ ALTER TABLE t1 ENABLE KEYS;
drop table t1;
#
+# Test that data get converted when character set is changed
+# Test that data doesn't get converted when src or dst is BINARY/BLOB
+#
+set names koi8r;
+create table t1 (a char(10) character set koi8r);
+insert into t1 values ('ÔÅÓÔ');
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) binary;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+alter table t1 change a a varchar(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+alter table t1 change a a text character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+
+drop table t1;
+
+#
# Test ALTER TABLE ENABLE/DISABLE keys when things are locked
#
diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test
index 9bf737c9515..6aca345b282 100644
--- a/mysql-test/t/analyse.test
+++ b/mysql-test/t/analyse.test
@@ -2,12 +2,16 @@
# Test of procedure analyse
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
+select count(*) from t1 procedure analyse();
select * from t1 procedure analyse();
select * from t1 procedure analyse(2);
create table t2 select * from t1 procedure analyse();
select * from t2;
drop table t1,t2;
+EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
diff --git a/mysql-test/t/ansi.test b/mysql-test/t/ansi.test
index e1ac8ffd4f9..f4aef5c3f8e 100644
--- a/mysql-test/t/ansi.test
+++ b/mysql-test/t/ansi.test
@@ -2,7 +2,9 @@
# Test of ansi mode
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
# Test some functions that works different in ansi mode
@@ -15,3 +17,8 @@ SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
--error 1055
SELECT id FROM t1 GROUP BY id2;
drop table t1;
+
+set sql_mode="MySQL40";
+select @@sql_mode;
+set sql_mode="ANSI";
+select @@sql_mode;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 5fba4bb9234..a036121f297 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -1,8 +1,11 @@
#
# Test of auto_increment; The test for BDB tables is in bdb.test
#
-
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
insert into t1 values (1,1),(NULL,3),(NULL,4);
delete from t1 where a=4;
@@ -70,3 +73,70 @@ select * from t1;
check table t1;
drop table t1;
+#
+# last_insert_id() madness
+#
+create table t1 (i tinyint unsigned not null auto_increment primary key);
+insert into t1 set i = 254;
+insert into t1 set i = null;
+select last_insert_id();
+--error 1062
+insert into t1 set i = 254;
+select last_insert_id();
+--error 1062
+insert into t1 set i = null;
+select last_insert_id();
+drop table t1;
+
+create table t1 (i tinyint unsigned not null auto_increment, key (i));
+insert into t1 set i = 254;
+insert into t1 set i = null;
+select last_insert_id();
+insert into t1 set i = null;
+select last_insert_id();
+drop table t1;
+
+create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
+insert into t1 values (NULL, 10);
+select last_insert_id();
+insert into t1 values (NULL, 15);
+select last_insert_id();
+--error 1062
+insert into t1 values (NULL, 10);
+select last_insert_id();
+
+drop table t1;
+
+create table t1(a int auto_increment,b int null,primary key(a));
+SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
+insert into t1(a,b)values(NULL,1);
+insert into t1(a,b)values(200,2);
+insert into t1(a,b)values(0,3);
+insert into t1(b)values(4);
+insert into t1(b)values(5);
+insert into t1(b)values(6);
+insert into t1(b)values(7);
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=0 where b=5;
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=NULL where b=6;
+update t1 set a=300 where b=7;
+SET SQL_MODE='';
+insert into t1(a,b)values(NULL,8);
+insert into t1(a,b)values(400,9);
+insert into t1(a,b)values(0,10);
+insert into t1(b)values(11);
+insert into t1(b)values(12);
+insert into t1(b)values(13);
+insert into t1(b)values(14);
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=0 where b=12;
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=NULL where b=13;
+update t1 set a=500 where b=14;
+select * from t1 order by b;
+drop table t1;
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index 650b85477f5..ed24161bef5 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -6,6 +6,9 @@ connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
set SQL_LOG_BIN=0;
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
create table t4(n int);
--replace_result "errno: 1" "errno: X" "errno: 2" "errno: X" "errno: 22" "errno: X" "errno: 23" "errno: X"
backup table t4 to '../bogus';
diff --git a/mysql-test/t/bdb-alter-table-1.test b/mysql-test/t/bdb-alter-table-1.test
index 5861c2fe0bf..7537cc358e8 100644
--- a/mysql-test/t/bdb-alter-table-1.test
+++ b/mysql-test/t/bdb-alter-table-1.test
@@ -2,7 +2,10 @@
# Test of problem when shutting down mysqld at once after ALTER TABLE
#
-- source include/have_bdb.inc
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1(objid BIGINT not null, tablename varchar(64), oid BIGINT not null, test BIGINT, PRIMARY KEY (objid), UNIQUE(tablename)) type=BDB;
insert into t1 values(1, 't1',4,9);
insert into t1 values(2, 'metatable',1,9);
diff --git a/mysql-test/t/bdb-crash.test b/mysql-test/t/bdb-crash.test
index 4575a612728..d77de901a30 100644
--- a/mysql-test/t/bdb-crash.test
+++ b/mysql-test/t/bdb-crash.test
@@ -2,7 +2,9 @@
# test for bug reported by Mark Steele
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (
ChargeID int(10) unsigned NOT NULL auto_increment,
ServiceID int(10) unsigned DEFAULT '0' NOT NULL,
diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test
index b32b50c715b..2453c42e49a 100644
--- a/mysql-test/t/bdb-deadlock.test
+++ b/mysql-test/t/bdb-deadlock.test
@@ -11,7 +11,9 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
connection con1;
create table t1 (id integer, x integer) type=BDB;
create table t2 (id integer, x integer) type=BDB;
@@ -30,13 +32,19 @@ select x from t1 where id = 0;
connection con1;
# This should generate a deadlock as we are trying to access a locked row
---error 1213
+--send
select x from t2 where id = 0;
-commit;
connection con2;
+--error 1213
reap;
commit;
+
+connection con1;
+reap;
+commit;
+
+connection con2;
select * from t1;
select * from t2;
commit;
@@ -45,4 +53,5 @@ connection con1;
select * from t1;
select * from t2;
commit;
+
drop table t1,t2;
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index 608d4bf5042..27755e51b7f 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -4,7 +4,9 @@
# Small basic test with ignore
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
+--enable_warnings
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=bdb;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
@@ -441,7 +443,6 @@ drop table t1;
# This gave a wrong result because the row information was freed too early
#
-drop table if exists t1, t2, t3, t4, t5, t6, t7;
create table t1
(
branch_id int auto_increment primary key,
@@ -451,7 +452,6 @@ create table t1
unique branch_name(branch_name),
index branch_active(branch_active)
) type=bdb;
-drop table if exists t2 ;
create table t2
(
target_id int auto_increment primary key,
@@ -461,7 +461,6 @@ create table t2
unique target_name(target_name),
index target_active(target_active)
) type=bdb;
-drop table if exists t3 ;
create table t3
(
platform_id int auto_increment primary key,
@@ -471,7 +470,6 @@ create table t3
unique platform_name(platform_name),
index platform_active(platform_active)
) type=bdb;
-drop table if exists t4 ;
create table t4
(
product_id int auto_increment primary key,
@@ -482,7 +480,6 @@ create table t4
unique product_name(product_name),
index product_active(product_active)
) type=bdb;
-drop table if exists t5 ;
create table t5
(
product_file_id int auto_increment primary key,
@@ -496,7 +493,6 @@ create table t5
unique product_file(product_id,file_name),
index file_included(file_included)
) type=bdb;
-drop table if exists t6 ;
create table t6
(
file_platform_id int auto_increment primary key,
@@ -510,7 +506,6 @@ create table t6
unique file_platform(product_file_id,platform_id,branch_id)
) type=bdb;
-drop table if exists t8 ;
create table t8
(
archive_id int auto_increment primary key,
@@ -523,7 +518,6 @@ create table t8
unique archive(branch_id,target_id,platform_id,product_id),
index status_id(status_id)
) type=bdb;
-drop table if exists t7 ;
create table t7
(
build_id int auto_increment primary key,
@@ -727,7 +721,6 @@ DROP TABLE t1,t2;
# Test problem with joining table to itself on a multi-part unique key
#
-drop table if exists t1;
create table t1 (a int(11) not null, b int(11) not null, unique (a,b)) type=bdb;
insert into t1 values (1,1), (1,2);
select * from t1 where a = 1;
diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test
index aa5572886c5..0d7de75ccf6 100644
--- a/mysql-test/t/bdb_cache.test
+++ b/mysql-test/t/bdb_cache.test
@@ -4,7 +4,9 @@
#
# Without auto_commit.
#
+--disable_warnings
drop table if exists t1, t2, t3;
+--enable_warnings
flush status;
set autocommit=0;
create table t1 (a int not null) type=bdb;
@@ -47,4 +49,5 @@ select * from t3;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
commit;
-show status like "Qcache_queries_in_cache"; \ No newline at end of file
+show status like "Qcache_queries_in_cache";
+drop table if exists t1, t2, t3;
diff --git a/mysql-test/t/bench_count_distinct.test b/mysql-test/t/bench_count_distinct.test
index 9059428bea4..c1adeab2c44 100644
--- a/mysql-test/t/bench_count_distinct.test
+++ b/mysql-test/t/bench_count_distinct.test
@@ -1,4 +1,10 @@
+#
+# Test of count(distinct ..)
+#
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n int not null, key(n)) delay_key_write = 1;
let $1=100;
disable_query_log;
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index c5691a760c7..9ac44c8ba0a 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -1,4 +1,11 @@
#
+# Initialize
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
# Test of reading of bigint values
#
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
@@ -6,13 +13,14 @@ select 9223372036854775807,-009223372036854775808;
select +9999999999999999999,-9999999999999999999;
select cast(9223372036854775808 as unsigned)+1;
select 9223372036854775808+1;
+select -(0-3),round(-(0-3)), round(9999999999999999999);
+
#
# In 3.23 we have to disable the test of column to bigint as
# this fails on AIX powerpc (the resolution for double is not good enough)
# This will work on 4.0 as we then have internal handling of bigint variables.
#
-drop table if exists t1;
create table t1 (a bigint unsigned not null, primary key(a));
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE);
select * from t1;
diff --git a/mysql-test/t/binary.test b/mysql-test/t/binary.test
index 95815cda60f..48912a390ed 100644
--- a/mysql-test/t/binary.test
+++ b/mysql-test/t/binary.test
@@ -1,8 +1,10 @@
#
# test sort,min and max on binary fields
#
-
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (name char(20) not null, primary key (name));
create table t2 (name char(20) binary not null, primary key (name));
insert into t1 values ("å");
@@ -28,16 +30,16 @@ drop table t1,t2;
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
-select * from t1 where a="hello";
-select * from t1 where a="hello ";
-select * from t1 ignore index (a) where a="hello ";
-select * from t1 where b="hello";
-select * from t1 where b="hello ";
-select * from t1 ignore index (b) where b="hello ";
+select concat("-",a,"-",b,"-") from t1 where a="hello";
+select concat("-",a,"-",b,"-") from t1 where a="hello ";
+select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
+select concat("-",a,"-",b,"-") from t1 where b="hello";
+select concat("-",a,"-",b,"-") from t1 where b="hello ";
+select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
# blob test
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
-select * from t1 where b="hello ";
-select * from t1 ignore index (b) where b="hello ";
+select concat("-",a,"-",b,"-") from t1 where b="hello ";
+select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
drop table t1;
#
diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test
index 10f97fefb73..c001973baeb 100644
--- a/mysql-test/t/bool.test
+++ b/mysql-test/t/bool.test
@@ -2,7 +2,9 @@
# Test of boolean operations with NULL
#
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
@@ -33,19 +35,17 @@ DROP TABLE t1;
# Read nA as !A, AB as A && B, AoB as A || B
# Result table makes ANSI happy
-drop table if exists t;
-create table t(a int, b int);
-insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
+create table t1 (a int, b int);
+insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
# Below test is valid untill we have True/False implemented as 1/0
# To comply to all rules it must show that: n(AB) = nAonB, n(AoB) = nAnB
-select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t;
+select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
# This should work with any internal representation of True/False
# Result must be same as above
-select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t;
+select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
-
-drop table t;
+drop table t1;
diff --git a/mysql-test/t/bulk_replace.test b/mysql-test/t/bulk_replace.test
index d366004c16f..755d34083f8 100644
--- a/mysql-test/t/bulk_replace.test
+++ b/mysql-test/t/bulk_replace.test
@@ -1,11 +1,10 @@
#
# this is a test of bulk-insert code
-# as used by REPLACE
-#
-# by Monty
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, index(c));
replace into t1 values (1,1,1),(2,2,2),(3,1,3);
select * from t1;
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 3ba3a292c77..4d4ceb062e4 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -2,7 +2,9 @@
# Testing of CASE
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
select CASE "b" when "a" then 1 when "b" then 2 END;
select CASE "c" when "a" then 1 when "b" then 2 END;
@@ -39,3 +41,62 @@ create table t1 (row int not null, col int not null, val varchar(255) not null);
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
select max(case col when 1 then val else null end) as color from t1 group by row;
drop table t1;
+
+SET NAMES latin1;
+
+#
+# CASE and argument types/collations aggregation into result
+#
+CREATE TABLE t1 SELECT
+ CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
+ CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
+ CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
+ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
+ CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
+ CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
+ CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
+ CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8
+;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error 1266
+SELECT CASE
+ WHEN 1
+ THEN _latin1'a' COLLATE latin1_danish_ci
+ ELSE _latin1'a' COLLATE latin1_swedish_ci
+ END;
+
+--error 1269
+SELECT CASE _latin1'a' COLLATE latin1_general_ci
+ WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
+ WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
+ END;
+
+SELECT
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
+;
+
+#
+# COALESCE is a CASE abbrevation:
+#
+# COALESCE(v1,v2) == CASE WHEN v1 IS NOT NULL THEN v1 ELSE v2 END
+#
+# COALESCE(V1, V2, . . . ,Vn ) =
+# CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2, . . . ,Vn) END
+#
+# Check COALESCE argument types aggregation
+
+--error 1266
+CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
+--error 1266
+CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
+CREATE TABLE t1 SELECT
+ COALESCE(1), COALESCE(1.0),COALESCE('a'),
+ COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
+ COALESCE('a' COLLATE latin1_bin,'b');
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 7a120ef5005..b3ae8981671 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -14,9 +14,62 @@ select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
select cast("1:2:3" as TIME);
#
+# Character set convertion
+#
+set names binary;
+select cast(_latin1'test' as char character set latin2);
+select cast(_koi8r'ÔÅÓÔ' as char character set cp1251);
+create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t;
+show create table t1;
+drop table t1;
+
+#
+# CAST to CHAR with/without length
+#
+select
+ cast(_latin1'ab' AS char) as c1,
+ cast(_latin1'a ' AS char) as c2,
+ cast(_latin1'abc' AS char(2)) as c3,
+ cast(_latin1'a ' AS char(2)) as c4,
+ cast(_latin1'a' AS char(2)) as c5;
+
+create table t1 select
+ cast(_latin1'ab' AS char) as c1,
+ cast(_latin1'a ' AS char) as c2,
+ cast(_latin1'abc' AS char(2)) as c3,
+ cast(_latin1'a ' AS char(2)) as c4,
+ cast(_latin1'a' AS char(2)) as c5;
+select * from t1;
+show create table t1;
+drop table t1;
+
+#
+# CAST to NCHAR with/without length
+#
+select
+ cast(_koi8r'ÆÇ' AS nchar) as c1,
+ cast(_koi8r'Æ ' AS nchar) as c2,
+ cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
+ cast(_koi8r'Æ ' AS nchar(2)) as c4,
+ cast(_koi8r'Æ' AS nchar(2)) as c5;
+
+create table t1 select
+ cast(_koi8r'ÆÇ' AS nchar) as c1,
+ cast(_koi8r'Æ ' AS nchar) as c2,
+ cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
+ cast(_koi8r'Æ ' AS nchar(2)) as c4,
+ cast(_koi8r'Æ' AS nchar(2)) as c5;
+select * from t1;
+show create table t1;
+drop table t1;
+
+
+#
# The following should be fixed in 4.1
#
select cast("2001-1-1" as date) = "2001-01-01";
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
select cast("1:2:3" as TIME) = "1:02:03";
+select cast(NULL as DATE);
+select cast(NULL as BINARY);
diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test
index 947566e725b..bc61aea2d66 100644
--- a/mysql-test/t/check.test
+++ b/mysql-test/t/check.test
@@ -1,8 +1,11 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
+--disable_warnings
drop table if exists t1;
-#add a lot of keys to slow down check
+--enable_warnings
+
+# Add a lot of keys to slow down check
create table t1(n int not null, key(n), key(n), key(n), key(n));
let $1=10000;
disable_query_log;
diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test
index 450d9c0961c..e5a2e310866 100644
--- a/mysql-test/t/compare.test
+++ b/mysql-test/t/compare.test
@@ -2,7 +2,10 @@
# Bug when using comparions of strings and integers.
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001;
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
new file mode 100644
index 00000000000..e6ccc52f0d4
--- /dev/null
+++ b/mysql-test/t/connect.test
@@ -0,0 +1,69 @@
+# This test is to check various cases of connections
+# with right and wrong password, with and without database
+# Unfortunately the check is incomplete as we can't handle errors on connect
+# Also we can't connect without database
+
+#connect (con1,localhost,root,,"");
+#show tables;
+connect (con1,localhost,root,,mysql);
+show tables;
+connect (con1,localhost,root,,test);
+show tables;
+
+# Re enable this one day if error handling on connect will take place
+
+#connect (con1,localhost,root,z,test2);
+#--error 1045
+#connect (con1,localhost,root,z,);
+#--error 1045
+
+grant ALL on *.* to test@localhost identified by "gambling";
+grant ALL on *.* to test@127.0.0.1 identified by "gambling";
+
+# Now check this user with different databases
+
+#connect (con1,localhost,test,gambling,"");
+#show tables;
+connect (con1,localhost,test,gambling,mysql);
+show tables;
+connect (con1,localhost,test,gambling,test);
+show tables;
+
+# Re enable this one day if error handling on connect will take place
+
+#connect (con1,localhost,test,,test2);
+#--error 1045
+#connect (con1,localhost,test,,"");
+#--error 1045
+#connect (con1,localhost,test,zorro,test2);
+#--error 1045
+#connect (con1,localhost,test,zorro,);
+#--error 1045
+
+
+# check if old password version also works
+update mysql.user set password=old_password("gambling2") where user="test";
+flush privileges;
+
+#connect (con1,localhost,test,gambling2,"");
+#show tables;
+connect (con1,localhost,test,gambling2,mysql);
+show tables;
+connect (con1,localhost,test,gambling2,test);
+show tables;
+
+# Re enable this one day if error handling on connect will take place
+
+#connect (con1,localhost,test,,test2);
+#--error 1045
+#connect (con1,localhost,test,,);
+#--error 1045
+#connect (con1,localhost,test,zorro,test2);
+#--error 1045
+#connect (con1,localhost,test,zorro,);
+#--error 1045
+
+# remove user 'test' so that other tests which may use 'test'
+# do not depend on this test.
+delete from mysql.user where user="test";
+flush privileges;
diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test
index 8682cdc42a2..cc796e0abd2 100644
--- a/mysql-test/t/constraints.test
+++ b/mysql-test/t/constraints.test
@@ -2,7 +2,9 @@
# Testing of constraints
# Currently MySQL only ignores the syntax.
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a int check (a>0));
insert into t1 values (1);
diff --git a/mysql-test/t/convert.test b/mysql-test/t/convert.test
deleted file mode 100644
index f26ef3a8c72..00000000000
--- a/mysql-test/t/convert.test
+++ /dev/null
@@ -1,11 +0,0 @@
-# Test of character set conversions
-
-# Test that SET DEFAULT works
-
-select @@convert_character_set;
-select @@global.convert_character_set;
-show variables like "%convert_character_set%";
-SET CHARACTER SET cp1251_koi8;
-select @@convert_character_set;
-SET CHARACTER SET DEFAULT;
-select @@convert_character_set;
diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test
index cb84d0211d7..1f0404876cb 100644
--- a/mysql-test/t/count_distinct.test
+++ b/mysql-test/t/count_distinct.test
@@ -2,7 +2,10 @@
# Problem with count(distinct)
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1 (libname varchar(21) not null, city text, primary key (libname));
create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
diff --git a/mysql-test/t/count_distinct2.test b/mysql-test/t/count_distinct2.test
index d1bea7614c8..9100f622dec 100644
--- a/mysql-test/t/count_distinct2.test
+++ b/mysql-test/t/count_distinct2.test
@@ -1,4 +1,6 @@
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
insert into t1 values (1,11, 'one','eleven', 'eleven'),
diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test
new file mode 100644
index 00000000000..e6cc98d47df
--- /dev/null
+++ b/mysql-test/t/count_distinct3.test
@@ -0,0 +1,55 @@
+#
+# this is a test for error 1032 in count(distinct) + group by, introduced in
+# mysql-4.1
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
+
+--disable_query_log
+SET @rnd_max= 2147483647;
+let $1 = 1000;
+while ($1)
+{
+ SET @rnd= RAND();
+ SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
+ SET @id_rev= @rnd_max - @id;
+ SET @grp= CAST(128.0 * @rnd AS UNSIGNED);
+ INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev);
+ dec $1;
+}
+CREATE TABLE t2 SELECT * FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+DROP TABLE t2;
+--enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+# As t1 contains random numbers, results are different from test to test.
+# That's okay, because we test only that select doesn't yield an
+# error. Note, that --disable_result_log doesn't suppress error output.
+
+--disable_result_log
+SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
+--enable_result_log
+DROP TABLE t1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index d46807f1dca..2e21768dc0b 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -2,7 +2,10 @@
# Check some special create statements.
#
-drop table if exists t1,t2;
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1 (b char(0));
insert into t1 values (""),(null);
select * from t1;
@@ -12,7 +15,7 @@ create table t1 (b char(0) not null);
create table if not exists t1 (b char(0) not null);
insert into t1 values (""),(null);
select * from t1;
-drop table if exists t1;
+drop table t1;
#
# Test of some CREATE TABLE'S that should fail
@@ -22,11 +25,11 @@ drop table if exists t1;
!$1146 create table t2 select auto+1 from t1;
drop table if exists t1,t2;
!$1167 create table t1 (b char(0) not null, index(b));
-!$1164 create table t1 (a int not null auto_increment,primary key (a)) type=heap;
+create table t1 (a int not null auto_increment,primary key (a)) type=heap;
!$1163 create table t1 (a int not null,b text) type=heap;
drop table if exists t1;
-!$1164 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
+!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
-- error 1044,1
create table not_existing_database.test (a int);
@@ -89,6 +92,25 @@ describe t2;
drop table t1,t2;
#
+# Test of CREATE ... SELECT with duplicate fields
+#
+
+create table t1 (a tinyint);
+create table t2 (a int) select * from t1;
+describe t1;
+describe t2;
+drop table if exists t2;
+--error 1060
+create table t2 (a int, a float) select * from t1;
+drop table if exists t2;
+--error 1060
+create table t2 (a int) select a as b, a+1 as b from t1;
+drop table if exists t2;
+--error 1060
+create table t2 (b int) select a as b, a+1 as b from t1;
+drop table if exists t1,t2;
+
+#
# Test of primary key with 32 index
#
@@ -123,14 +145,118 @@ drop table t1;
#
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
insert into t1 values ("a", 1), ("b", 2);
-!$1048 insert into t1 values ("c", NULL);
-!$1048 insert into t1 values (NULL, 3);
-!$1048 insert into t1 values (NULL, NULL);
+--error 1048
+insert into t1 values ("c", NULL);
+--error 1048
+insert into t1 values (NULL, 3);
+--error 1048
+insert into t1 values (NULL, NULL);
drop table t1;
#
-# Bug # 801
+# Test create with foreign keys
+#
+
+create table t1 (a int, key(a));
+create table t2 (b int, foreign key(b) references t1(a), key(b));
+drop table if exists t1,t2;
+
+#
+# Test for CREATE TABLE .. LIKE ..
+#
+
+create table t1(id int not null, name char(20));
+insert into t1 values(10,'mysql'),(20,'monty- the creator');
+create table t2(id int not null);
+insert into t2 values(10),(20);
+create table t3 like t1;
+show create table t3;
+select * from t3;
+create table if not exists t3 like t1;
+select @@warning_count;
+create temporary table t3 like t2;
+show create table t3;
+select * from t3;
+drop table t3;
+show create table t3;
+select * from t3;
+drop table t2, t3;
+drop database if exists test_$1;
+create database test_$1;
+create table test_$1.t3 like t1;
+create temporary table t3 like test_$1.t3;
+show create table t3;
+create table t2 like t3;
+show create table t2;
+select * from t2;
+create table t3 like t1;
+!$1050 create table t3 like test_$1.t3;
+--error 1044,1
+create table non_existing_database.t1 like t1;
+!$1051 create table t3 like non_existing_table;
+!$1050 create temporary table t3 like t1;
+!$1103 create table t3 like `a/a`;
+drop table t1, t2, t3;
+drop table t3;
+drop database test_$1;
+
+#
+# Test default table type
#
+SET SESSION table_type="heap";
+SELECT @@table_type;
+CREATE TABLE t1 (a int not null);
+show create table t1;
+drop table t1;
+# Test what happens when using a non existing table type
+SET SESSION table_type="gemini";
+SELECT @@table_type;
+CREATE TABLE t1 (a int not null);
+show create table t1;
+SET SESSION table_type=default;
+drop table t1;
+#
+# Bug # 801
+#
create table t1 select x'4132';
drop table t1;
+
+#
+# Test types of data for create select with functions
+#
+
+create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
+insert into t1(a)values(1);
+insert into t1(a,b,c,d,e,f,g,h)
+values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
+select * from t1;
+select a,
+ ifnull(b,cast(-7 as signed)) as b,
+ ifnull(c,cast(7 as unsigned)) as c,
+ ifnull(d,cast('2000-01-01' as date)) as d,
+ ifnull(e,cast('b' as char)) as e,
+ ifnull(f,cast('2000-01-01' as datetime)) as f,
+ ifnull(g,cast('5:4:3' as time)) as g,
+ ifnull(h,cast('yet another binary data' as binary)) as h,
+ addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
+from t1;
+
+create table t2
+select
+ a,
+ ifnull(b,cast(-7 as signed)) as b,
+ ifnull(c,cast(7 as unsigned)) as c,
+ ifnull(d,cast('2000-01-01' as date)) as d,
+ ifnull(e,cast('b' as char)) as e,
+ ifnull(f,cast('2000-01-01' as datetime)) as f,
+ ifnull(g,cast('5:4:3' as time)) as g,
+ ifnull(h,cast('yet another binary data' as binary)) as h,
+ addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
+from t1;
+explain t2;
+
+select * from t2;
+
+drop table t1, t2;
+
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
new file mode 100644
index 00000000000..d42696e693b
--- /dev/null
+++ b/mysql-test/t/ctype_collate.test
@@ -0,0 +1,157 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (
+ latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
+);
+
+--error 1252
+CREATE TABLE t2 (
+ latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
+);
+
+--error 1272
+CREATE TABLE t2 (
+ latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL
+);
+
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'a');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AD');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ad');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AE');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ae');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AF');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'af');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ä');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Å');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'å');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'B');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'b');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'U');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'u');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'UE');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ue');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ü');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'SS');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ss');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ß');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Y');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'y');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Z');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'z');
+
+
+-- ORDER BY
+
+SELECT latin1_f FROM t1 ORDER BY latin1_f;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin;
+--error 1252
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
+
+--SELECT latin1_f COLLATE koi8r FROM t1 ;
+
+-- AS + ORDER BY
+SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+--error 1252
+SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+
+
+-- GROUP BY
+
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin;
+--error 1252
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
+
+
+-- DISTINCT
+
+SELECT DISTINCT latin1_f FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1;
+--error 1272
+SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
+
+
+-- Aggregates
+--SELECT MAX(k COLLATE latin1_german2_ci)
+--FROM t1
+
+
+-- WHERE
+--SELECT *
+--FROM t1
+--WHERE (_latin1'Mu"ller' COLLATE latin1_german2_ci) = k
+
+--HAVING
+--SELECT *
+--FROM t1
+--HAVING (_latin1'Mu"ller' COLLATE latin1_german2_ci) = k
+
+
+#
+# Check that SHOW displays COLLATE clause
+#
+
+SHOW CREATE TABLE t1;
+SHOW FIELDS FROM t1;
+ALTER TABLE t1 CHANGE latin1_f
+latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
+SHOW CREATE TABLE t1;
+SHOW FIELDS FROM t1;
+ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
+SHOW CREATE TABLE t1;
+SHOW FIELDS FROM t1;
+
+#
+# Check SET CHARACTER SET
+#
+
+SET CHARACTER SET 'latin1';
+SHOW VARIABLES LIKE 'character_set_client';
+SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+
+SET CHARACTER SET koi8r;
+SHOW VARIABLES LIKE 'collation_client';
+SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+
+--error 1115
+SET CHARACTER SET 'DEFAULT';
+
+DROP TABLE t1;
+
+CREATE TABLE t1
+(s1 CHAR(5) COLLATE latin1_german1_ci,
+ s2 CHAR(5) COLLATE latin1_swedish_ci);
+--error 1266
+SELECT * FROM t1 WHERE s1 = s2;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_latin1_de-master.opt b/mysql-test/t/ctype_latin1_de-master.opt
index 895a62364d6..79fdb1c63dc 100644
--- a/mysql-test/t/ctype_latin1_de-master.opt
+++ b/mysql-test/t/ctype_latin1_de-master.opt
@@ -1,2 +1 @@
---default-character-set=latin1_de --new
-
+--default-character-set=latin1 --default-collation=latin1_german2_ci
diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test
index 3a0f2658969..52ee227b011 100644
--- a/mysql-test/t/ctype_latin1_de.test
+++ b/mysql-test/t/ctype_latin1_de.test
@@ -1,7 +1,13 @@
#
# Test latin_de character set
#
+
+select @@collation_connection;
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a char (20) not null, b int not null auto_increment, index (a,b));
insert into t1 (a) values ('ä'),('ac'),('ae'),('ad'),('Äc'),('aeb');
insert into t1 (a) values ('üc'),('uc'),('ue'),('ud'),('Ü'),('ueb'),('uf');
@@ -54,21 +60,35 @@ drop table t1;
# Test bug report #152 (problem with index on latin1_de)
#
+#
+# The below checks both binary and character comparisons.
+#
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word));
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word;
-select word, word=0xdf as t from t1 having t > 0;
+select word, word=binary 0xdf as t from t1 having t > 0;
select word, word=cast(0xdf AS CHAR) as t from t1 having t > 0;
-select * from t1 where word=0xDF;
+select * from t1 where word=binary 0xDF;
select * from t1 where word=CAST(0xDF as CHAR);
-select * from t1 where word2=0xDF;
+select * from t1 where word2=binary 0xDF;
select * from t1 where word2=CAST(0xDF as CHAR);
select * from t1 where word='ae';
select * from t1 where word= 0xe4 or word=CAST(0xe4 as CHAR);
-select * from t1 where word between 0xDF and 0xDF;
+select * from t1 where word between binary 0xDF and binary 0xDF;
select * from t1 where word between CAST(0xDF AS CHAR) and CAST(0xDF AS CHAR);
select * from t1 where word like 'ae';
select * from t1 where word like 'AE';
-select * from t1 where word like 0xDF;
+select * from t1 where word like binary 0xDF;
select * from t1 where word like CAST(0xDF as CHAR);
drop table t1;
+
+CREATE TABLE t1 (
+s1 CHAR(5) CHARACTER SET latin1 COLLATE latin1_german2_ci
+);
+INSERT INTO t1 VALUES ('Ü');
+INSERT INTO t1 VALUES ('ue');
+SELECT DISTINCT s1 FROM t1;
+SELECT s1,COUNT(*) FROM t1 GROUP BY s1;
+SELECT COUNT(DISTINCT s1) FROM t1;
+SELECT FIELD('ue',s1), FIELD('Ü',s1), s1='ue', s1='Ü' FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test
new file mode 100644
index 00000000000..66732520f4d
--- /dev/null
+++ b/mysql-test/t/ctype_many.test
@@ -0,0 +1,210 @@
+-- source include/have_ucs2.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+SET CHARACTER SET latin1;
+
+CREATE TABLE t1 (
+ comment CHAR(32) ASCII NOT NULL,
+ koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL
+) CHARSET=latin5;
+
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 CHARSET=latin2;
+ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 DROP latin2_f, DROP latin5_f;
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('c','LAT SMALL C');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('d','LAT SMALL D');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('e','LAT SMALL E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('f','LAT SMALL F');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('g','LAT SMALL G');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('h','LAT SMALL H');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('i','LAT SMALL I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('j','LAT SMALL J');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('k','LAT SMALL K');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('l','LAT SMALL L');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('m','LAT SMALL M');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('n','LAT SMALL N');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('o','LAT SMALL O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('p','LAT SMALL P');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('q','LAT SMALL Q');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('r','LAT SMALL R');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('s','LAT SMALL S');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('t','LAT SMALL T');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('u','LAT SMALL U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('v','LAT SMALL V');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('w','LAT SMALL W');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('x','LAT SMALL X');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('y','LAT SMALL Y');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('z','LAT SMALL Z');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('A','LAT CAPIT A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('B','LAT CAPIT B');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('C','LAT CAPIT C');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('D','LAT CAPIT D');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('E','LAT CAPIT E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('F','LAT CAPIT F');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('G','LAT CAPIT G');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('H','LAT CAPIT H');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('I','LAT CAPIT I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('J','LAT CAPIT J');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('K','LAT CAPIT K');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('L','LAT CAPIT L');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('M','LAT CAPIT M');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('N','LAT CAPIT N');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('O','LAT CAPIT O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('P','LAT CAPIT P');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Q','LAT CAPIT Q');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('R','LAT CAPIT R');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('S','LAT CAPIT S');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('T','LAT CAPIT T');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('U','LAT CAPIT U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('V','LAT CAPIT V');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('W','LAT CAPIT W');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('X','LAT CAPIT X');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Y','LAT CAPIT Y');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Z','LAT CAPIT Z');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Á','CYR SMALL A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Â','CYR SMALL BE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'×','CYR SMALL VE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ç','CYR SMALL GE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ä','CYR SMALL DE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Å','CYR SMALL IE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'£','CYR SMALL IO');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ö','CYR SMALL ZHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ú','CYR SMALL ZE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'É','CYR SMALL I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ë','CYR SMALL KA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ì','CYR SMALL EL');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Í','CYR SMALL EM');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Î','CYR SMALL EN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ï','CYR SMALL O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ð','CYR SMALL PE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ò','CYR SMALL ER');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ó','CYR SMALL ES');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ô','CYR SMALL TE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Õ','CYR SMALL U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Æ','CYR SMALL EF');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'È','CYR SMALL HA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ã','CYR SMALL TSE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Þ','CYR SMALL CHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Û','CYR SMALL SHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ý','CYR SMALL SCHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ß','CYR SMALL HARD SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ù','CYR SMALL YERU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ø','CYR SMALL SOFT SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ü','CYR SMALL E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'À','CYR SMALL YU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ñ','CYR SMALL YA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'á','CYR CAPIT A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'â','CYR CAPIT BE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'÷','CYR CAPIT VE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ç','CYR CAPIT GE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ä','CYR CAPIT DE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'å','CYR CAPIT IE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'³','CYR CAPIT IO');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ö','CYR CAPIT ZHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ú','CYR CAPIT ZE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'é','CYR CAPIT I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ë','CYR CAPIT KA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ì','CYR CAPIT EL');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'í','CYR CAPIT EM');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'î','CYR CAPIT EN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ï','CYR CAPIT O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ð','CYR CAPIT PE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ò','CYR CAPIT ER');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ó','CYR CAPIT ES');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ô','CYR CAPIT TE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'õ','CYR CAPIT U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'æ','CYR CAPIT EF');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'è','CYR CAPIT HA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ã','CYR CAPIT TSE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'þ','CYR CAPIT CHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'û','CYR CAPIT SHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ý','CYR CAPIT SCHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ÿ','CYR CAPIT HARD SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ù','CYR CAPIT YERU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ø','CYR CAPIT SOFT SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA');
+
+SET CHARACTER SET utf8;
+SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1;
+
+ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL;
+UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
+SET CHARACTER SET koi8r;
+SELECT * FROM t1;
+
+ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
+UPDATE t1 SET bin_f=koi8_ru_f;
+SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1;
+
+SELECT koi8_ru_f,MIN(comment) FROM t1 GROUP BY 1;
+SELECT utf8_f,MIN(comment) FROM t1 GROUP BY 1;
+SELECT DISTINCT koi8_ru_f FROM t1;
+SELECT DISTINCT utf8_f FROM t1;
+SELECT lower(koi8_ru_f) FROM t1 ORDER BY 1 DESC;
+SELECT lower(utf8_f) FROM t1 ORDER BY 1 DESC;
+
+SELECT t11.comment,t12.comment
+FROM t1 t11,t1 t12 WHERE CONVERT(t11.koi8_ru_f USING utf8)=t12.utf8_f
+ORDER BY t11.koi8_ru_f,t11.comment,t12.comment;
+
+SELECT t11.comment,t12.comment
+FROM t1 t11,t1 t12
+WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r)
+ORDER BY t12.utf8_f,t11.comment,t12.comment;
+
+SET CHARACTER SET utf8;
+ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2;
+
+--disable_warnings
+ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL;
+--enable_warnings
+
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0394,'GREEK CAPIT DELTA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0395,'GREEK CAPIT EPSILON');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B1,'GREEK SMALL ALPHA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B2,'GREEK SMALL BETA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B3,'GREEK SMALL GAMMA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B4,'GREEK SMALL DELTA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B5,'GREEK SMALL EPSILON');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0531,'ARMENIAN CAPIT AYB');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0532,'ARMENIAN CAPIT BEN');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0533,'ARMENIAN CAPIT GIM');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0534,'ARMENIAN CAPIT DA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0535,'ARMENIAN CAPIT ECH');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0536,'ARMENIAN CAPIT ZA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0561,'ARMENIAN SMALL YAB');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0562,'ARMENIAN SMALL BEN');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0563,'ARMENIAN SMALL GIM');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0564,'ARMENIAN SMALL DA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0565,'ARMENIAN SMALL ECH');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA');
+
+ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL;
+ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL;
+UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE _latin2'GRE%';
+UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _latin2'ARM%';
+UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8'';
+UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2'';
+SELECT * FROM t1;
+SET CHARACTER SET 'binary';
+SELECT * FROM t1;
+SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_mb.test b/mysql-test/t/ctype_mb.test
new file mode 100644
index 00000000000..5c3e67eec01
--- /dev/null
+++ b/mysql-test/t/ctype_mb.test
@@ -0,0 +1,8 @@
+CREATE TABLE t1 SELECT _utf8'test' as c1, _utf8'тест' as c2;
+SHOW CREATE TABLE t1;
+DELETE FROM t1;
+ALTER TABLE t1 ADD c3 CHAR(4) CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('aaaabbbbccccdddd','aaaabbbbccccdddd','aaaabbbbccccdddd');
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test
new file mode 100644
index 00000000000..25df9c0a86b
--- /dev/null
+++ b/mysql-test/t/ctype_recoding.test
@@ -0,0 +1,47 @@
+SET CHARACTER SET koi8r;
+
+--disable_warnings
+DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ;
+--enable_warnings
+
+SET CHARACTER SET koi8r;
+CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp1251) SELECT _koi8r'ÐÒÏÂÁ' AS a;
+SHOW CREATE TABLE t1;
+SELECT a FROM t1;
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE ÔÁÂÌÉÃÁ
+(
+ ÐÏÌÅ CHAR(32) CHARACTER SET koi8r NOT NULL
+);
+
+SHOW TABLES;
+SHOW CREATE TABLE ÔÁÂÌÉÃÁ;
+SHOW FIELDS FROM ÔÁÂÌÉÃÁ;
+
+SET CHARACTER SET cp1251;
+SHOW TABLES;
+SHOW CREATE TABLE òàáëèöà;
+SHOW FIELDS FROM òàáëèöà;
+
+
+SET CHARACTER SET utf8;
+SHOW TABLES;
+SHOW CREATE TABLE таблОца;
+SHOW FIELDS FROM таблОца;
+
+SET CHARACTER SET koi8r;
+DROP TABLE ÔÁÂÌÉÃÁ;
+SET CHARACTER SET default;
+
+SET CHARACTER SET koi8r;
+CREATE DATABASE ÔÅÓÔ;
+USE ÔÅÓÔ;
+SHOW TABLES;
+SHOW TABLES IN ÔÅÓÔ;
+SET CHARACTER SET cp1251;
+SHOW TABLES;
+SHOW TABLES IN òåñò;
+SET CHARACTER SET koi8r;
+DROP DATABASE ÔÅÓÔ;
diff --git a/mysql-test/t/ctype_ujis-master.opt b/mysql-test/t/ctype_ujis-master.opt
deleted file mode 100644
index 1f4183d5027..00000000000
--- a/mysql-test/t/ctype_ujis-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---default-character-set=ujis
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index cd1dc965000..e41caf55948 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1,13 +1,17 @@
+-- source include/have_ujis.inc
+
#
# Tests with the ujis character set
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
#
# Test problem with LEFT()
#
-create table t1 (c text);
+create table t1 (c text character set ujis);
insert into t1 values (0xa4a2),(0xa4a3);
select hex(left(c,1)) from t1 group by c;
drop table t1;
diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
index 67111ea1734..4cf26b330c6 100644
--- a/mysql-test/t/delayed.test
+++ b/mysql-test/t/delayed.test
@@ -3,7 +3,9 @@
# (Can't be tested with purify :( )
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a char(10), tmsp timestamp);
insert into t1 set a = 1;
insert delayed into t1 set a = 2;
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index 904d959d148..f1f751d728b 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -2,7 +2,9 @@
# Check for problems with delete
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
@@ -36,6 +38,15 @@ insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(2
delete from t1 where a=27;
drop table t1;
+CREATE TABLE `t1` (
+ `i` int(10) NOT NULL default '0',
+ `i2` int(10) NOT NULL default '0',
+ PRIMARY KEY (`i`)
+);
+-- error 1054
+DELETE FROM t1 USING t1 WHERE post='1';
+drop table t1;
+
#
# CHAR(0) bug - not actually DELETE bug, but anyway...
#
@@ -60,4 +71,3 @@ delete from t1 where 3 > 2;
select count(*) from t1;
drop table t1;
-
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
new file mode 100644
index 00000000000..c3edbabcd53
--- /dev/null
+++ b/mysql-test/t/derived.test
@@ -0,0 +1,96 @@
+# Initialize
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+select * from (select 2 from DUAL) b;
+-- error 1054
+SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
+-- error 1054
+SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
+CREATE TABLE t1 (a int not null, b char (10) not null);
+insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
+CREATE TABLE t2 (a int not null, b char (10) not null);
+insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
+select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y;
+select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
+CREATE TABLE t3 (a int not null, b char (10) not null);
+insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
+select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
+--error 1054
+SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
+--error 1052
+SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
+SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
+SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
+--error 1054
+SELECT 1 FROM (SELECT 1) a WHERE a=2;
+--error 1054
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
+select * from t1 as x1, (select * from t1) as x2;
+explain select * from t1 as x1, (select * from t1) as x2;
+drop table if exists t2,t3;
+select * from (select 1) as a;
+select a from (select 1 as a) as b;
+select 1 from (select 1) as a;
+select * from (select * from t1 union select * from t1) a;
+select * from (select * from t1 union all select * from t1) a;
+explain select * from (select * from t1 union select * from t1) a;
+explain select * from (select * from t1 union all select * from t1) a;
+CREATE TABLE t2 (a int not null);
+insert into t2 values(1);
+select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
+select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
+explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
+drop table t1, t2;
+create table t1(a int not null, t char(8), index(a));
+disable_query_log;
+let $1 = 10000;
+while ($1)
+ {
+ eval insert into t1 values ($1,'$1');
+ dec $1;
+ }
+enable_query_log;
+SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
+explain select count(*) from t1 as tt1, (select * from t1) as tt2;
+drop table t1;
+SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
+select * from (select 1 as a) b left join (select 2 as a) c using(a);
+--error 1054
+SELECT * FROM (SELECT 1 UNION SELECT a) b;
+--error 1054
+SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
+--error 1054
+SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
+--error 1054
+select 1 from (select 2) a order by 0;
+
+#
+# Test of explain (bug #251)
+#
+
+create table t1 (id int);
+insert into t1 values (1),(2),(3);
+describe select * from (select * from t1 group by id) bar;
+drop table t1;
+
+#
+# test->used_keys test for derived tables
+#
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+
+SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+
+explain SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+explain SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+drop table t1,t2;
+
+#
+# derived table reference
+#
+SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
diff --git a/mysql-test/t/dirty_close.test b/mysql-test/t/dirty_close.test
index 3ed22f26d5b..f965df8cfea 100644
--- a/mysql-test/t/dirty_close.test
+++ b/mysql-test/t/dirty_close.test
@@ -3,7 +3,11 @@ connect (con2,localhost,root,,);
connection con1;
dirty_close con1;
connection con2;
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (n int);
insert into t1 values (1),(2),(3);
select * from t1;
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index 79770a17baa..0563b432873 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -3,7 +3,9 @@
# Bug with group by and not used fields
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
CREATE TABLE t1 (id int,facility char(20));
CREATE TABLE t2 (facility char(20));
@@ -198,7 +200,6 @@ drop table t1,t2,t3;
# This also test the case when one doesn't use all fields in GROUP BY.
#
-drop table if exists t1;
create table t1 (a int not null, b int not null, t time);
insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15");
select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
@@ -261,7 +262,7 @@ INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) NOT NULL default '0', homepage varchar(100) NOT NULL default '', icq varchar(20) NOT NULL default '', aim varchar(20) NOT NULL default '', yahoo varchar(20) NOT NULL default '', signature mediumtext NOT NULL, adminemail smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) TYPE=MyISAM;
INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1);
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
#
# test with const_item in ORDER BY
@@ -272,7 +273,7 @@ INSERT t1 VALUES (1,2,3);
CREATE TABLE t2 (a int primary key, b int, c int);
INSERT t2 VALUES (3,4,5);
SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c;
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
#
# Test of LEFT() with distinct
diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test
index 2f3fa99bac0..a55cbb45fd9 100644
--- a/mysql-test/t/drop.test
+++ b/mysql-test/t/drop.test
@@ -1,4 +1,9 @@
+# Initialise
+--disable_warnings
drop table if exists t1;
+drop database if exists mysqltest;
+--enable_warnings
+
--error 1051;
drop table t1;
create table t1(n int);
@@ -13,7 +18,6 @@ select * from t1;
# now test for a bug in drop database - it is important that the name
# of the table is the same as the name of the database - in the original
# code this triggered a bug
-drop database if exists mysqltest;
create database mysqltest;
drop database if exists mysqltest;
create database mysqltest;
diff --git a/mysql-test/t/empty_table.test b/mysql-test/t/empty_table.test
index 9ea79ee157f..db0a8e6a247 100644
--- a/mysql-test/t/empty_table.test
+++ b/mysql-test/t/empty_table.test
@@ -2,7 +2,10 @@
# Some special cases with empty tables
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
select count(*) from t1;
select * from t1;
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
index afb0cce9005..b558c90b0c6 100644
--- a/mysql-test/t/errors.test
+++ b/mysql-test/t/errors.test
@@ -2,23 +2,22 @@
# Test some error conditions
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
--error 1146
insert into t1 values(1);
--error 1146
delete from t1;
--error 1146
update t1 set a=1;
-
-#
-
create table t1 (a int);
--error 1054
select count(test.t1.b) from t1;
--error 1109
select count(not_existing_database.t1) from t1;
--error 1109
- select count(not_existing_database.t1.a) from t1;
+select count(not_existing_database.t1.a) from t1;
--error 1044,1146
select count(not_existing_database.t1.a) from not_existing_database.t1;
--error 1054
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index 045598e97df..ff1803368b9 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -1,7 +1,9 @@
#
# Test of different EXPLAIN's
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (id int not null, str char(10), unique(str));
explain select * from t1;
insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index 7754fc2e197..9ee6b5d76b8 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -9,11 +9,13 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
-drop table if exists t1;
+
+--disable_warnings
+drop table if exists t1,t2;
drop database if exists mysqltest;
+--enable_warnings
create temporary table t1(n int not null primary key);
-drop table if exists t2;
create table t2(n int);
insert into t2 values(3);
let $1=100;
diff --git a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test
index 1afcb546f6a..8c35fd65f74 100644
--- a/mysql-test/t/foreign_key.test
+++ b/mysql-test/t/foreign_key.test
@@ -2,7 +2,10 @@
# Test syntax of foreign keys
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (
a int not null references t2,
b int not null references t2 (c),
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 387a36f1f52..8c6bb97edf1 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -2,7 +2,9 @@
# Test of fulltext index
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
@@ -16,6 +18,10 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
select * from t1 where MATCH(a,b) AGAINST ("collections");
select * from t1 where MATCH(a,b) AGAINST ("indexes");
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
+select * from t1 where MATCH(a,b) AGAINST ("only");
+
+# UNION of fulltext's
+select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
# add_ft_keys() tests
@@ -147,10 +153,10 @@ CREATE TABLE t1 (
id int(11) auto_increment,
title varchar(100) default '',
PRIMARY KEY (id),
- KEY ind5 (title),
- FULLTEXT KEY FT1 (title)
+ KEY ind5 (title)
) TYPE=MyISAM;
+CREATE FULLTEXT INDEX ft1 ON t1(title);
insert into t1 (title) values ('this is a test');
select * from t1 where match title against ('test' in boolean mode);
update t1 set title='this is A test' where id=1;
@@ -181,7 +187,6 @@ drop table t1;
# ERROR 1030: Got error 127 from table handler
#
-drop table if exists t1;
create table t1 (a text, fulltext key (a));
insert into t1 values ('aaaa');
repair table t1;
@@ -193,7 +198,6 @@ drop table t1;
# FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore
#
-drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
@@ -214,4 +218,3 @@ 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);
drop table t1,t2;
-
diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test
new file mode 100644
index 00000000000..b739d60e3b3
--- /dev/null
+++ b/mysql-test/t/fulltext2.test
@@ -0,0 +1,98 @@
+#
+# test of new fulltext search features
+#
+
+#
+# two-level tree
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ i int(10) unsigned not null auto_increment primary key,
+ a varchar(255) not null,
+ FULLTEXT KEY (a)
+) TYPE=MyISAM;
+
+# two-level entry, second-level tree with depth 2
+--disable_query_log
+let $1=260;
+while ($1)
+{
+ eval insert t1 (a) values ('aaaxxx');
+ dec $1;
+}
+
+# two-level entry, second-level tree has only one page
+let $1=255;
+while ($1)
+{
+ eval insert t1 (a) values ('aaazzz');
+ dec $1;
+}
+
+# one-level entry (entries)
+let $1=250;
+while ($1)
+{
+ eval insert t1 (a) values ('aaayyy');
+ dec $1;
+}
+--enable_query_log
+
+# converting to two-level
+repair table t1 quick;
+
+select count(*) from t1 where match a against ('aaaxxx');
+select count(*) from t1 where match a against ('aaayyy');
+select count(*) from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
+
+select count(*) from t1 where match a against ('aaax*' in boolean mode);
+select count(*) from t1 where match a against ('aaay*' in boolean mode);
+select count(*) from t1 where match a against ('aaa*' in boolean mode);
+
+# mi_write:
+
+insert t1 (a) values ('aaaxxx'),('aaayyy');
+# call to enlarge_root() below
+insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx');
+select count(*) from t1 where match a against ('aaayyy');
+select count(*) from t1 where match a against ('aaazzz');
+
+# mi_delete
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+delete from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx');
+delete from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+# double-check without index
+select count(*) from t1 where a = 'aaaxxx';
+select count(*) from t1 where a = 'aaayyy';
+select count(*) from t1 where a = 'aaazzz';
+
+# update
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+update t1 set a='aaazzz' where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+update t1 set a='aaazzz' where a = 'aaaxxx';
+update t1 set a='aaaxxx' where a = 'aaayyy';
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+
+DROP TABLE IF EXISTS t1;
+
diff --git a/mysql-test/t/fulltext_cache.test b/mysql-test/t/fulltext_cache.test
index 0b15e57a97b..15f32fdb5a0 100644
--- a/mysql-test/t/fulltext_cache.test
+++ b/mysql-test/t/fulltext_cache.test
@@ -2,7 +2,10 @@
# Bugreport due to Roy Nasser <roy@vem.ca>
#
+--disable_warnings
drop table if exists t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
q varchar(255) default NULL,
diff --git a/mysql-test/t/fulltext_distinct.test b/mysql-test/t/fulltext_distinct.test
index 86e2f7ca1b4..2ccfb94c819 100644
--- a/mysql-test/t/fulltext_distinct.test
+++ b/mysql-test/t/fulltext_distinct.test
@@ -3,7 +3,10 @@
# bug reported by Tibor Simko <tibor.simko@cern.ch>
#
+--disable_warnings
DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
id mediumint unsigned NOT NULL auto_increment,
tag char(6) NOT NULL default '',
diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test
index da4df13bc0c..855649923c4 100644
--- a/mysql-test/t/fulltext_left_join.test
+++ b/mysql-test/t/fulltext_left_join.test
@@ -2,7 +2,10 @@
# Test for bug from Jean-Cédric COSTA <jean-cedric.costa@ensmp.fr>
#
+--disable_warnings
drop table if exists t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
id VARCHAR(255) NOT NULL PRIMARY KEY,
sujet VARCHAR(255),
diff --git a/mysql-test/t/fulltext_multi.test b/mysql-test/t/fulltext_multi.test
index 233c243146e..c312a5938b2 100644
--- a/mysql-test/t/fulltext_multi.test
+++ b/mysql-test/t/fulltext_multi.test
@@ -1,6 +1,8 @@
# several FULLTEXT indexes in one table test
-use test;
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 (
a int(11) NOT NULL auto_increment,
b text,
diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test
index 3b60ee77db2..f8afe49d95d 100644
--- a/mysql-test/t/fulltext_order_by.test
+++ b/mysql-test/t/fulltext_order_by.test
@@ -1,5 +1,7 @@
-use test;
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 (
a INT AUTO_INCREMENT PRIMARY KEY,
message CHAR(20),
diff --git a/mysql-test/t/fulltext_update.test b/mysql-test/t/fulltext_update.test
index 9e2ce3ccba5..a1d133ba3fe 100644
--- a/mysql-test/t/fulltext_update.test
+++ b/mysql-test/t/fulltext_update.test
@@ -2,7 +2,9 @@
# Test for bug by voi@ims.at
#
+--disable_warnings
drop table if exists test;
+--enable_warnings
CREATE TABLE test (
gnr INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
url VARCHAR(80) DEFAULT '' NOT NULL,
diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test
new file mode 100644
index 00000000000..826721a4053
--- /dev/null
+++ b/mysql-test/t/func_compress.test
@@ -0,0 +1,25 @@
+-- source include/have_compress.inc
+#
+# Test for compress and uncompress functions:
+#
+
+select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ';
+select length(@test_compress_string);
+
+select uncompress(compress(@test_compress_string));
+select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
+select uncompressed_length(compress(@test_compress_string));
+select length(compress(@test_compress_string))<length(@test_compress_string);
+
+create table t1 (a text, b char(255), c char(4)) type=myisam;
+insert into t1 (a,b,c) values (compress(@test_compress_string),compress(@test_compress_string),'d ');
+select uncompress(a) from t1;
+select uncompress(b) from t1;
+select concat('|',c,'|') from t1;
+drop table t1;
+
+select compress("");
+select uncompress("");
+select uncompress(compress(""));
+select uncompressed_length("");
+
diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test
index d6da1d6a603..147367a6d27 100644
--- a/mysql-test/t/func_concat.test
+++ b/mysql-test/t/func_concat.test
@@ -2,7 +2,10 @@
# Test of problem with CONCAT_WS() and long separators.
#
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 ( number INT NOT NULL, alpha CHAR(6) NOT NULL );
INSERT INTO t1 VALUES (1413006,'idlfmv'),
(1413065,'smpsfz'),(1413127,'sljrhx'),(1413304,'qerfnd');
diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test
index f403d96e885..c72356bda1a 100644
--- a/mysql-test/t/func_crypt.test
+++ b/mysql-test/t/func_crypt.test
@@ -2,5 +2,9 @@
select length(encrypt('foo', 'ff')) <> 0;
--replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l.
-select old_password('test'), password('test');
-select length(encrypt('test')), encrypt('test','aa');
+
+# Test new and old password handling functions
+select password("a",""), password("a",NULL), password("","a"), password(NULL,"a");
+select password("aaaaaaaaaaaaaaaa","a"), password("a","aaaaaaaaaaaaaaaa");
+select old_password('test'), length(password("1")), length(encrypt('test')), encrypt('test','aa');
+select old_password(""), old_password(NULL), password(""), password(NULL);
diff --git a/mysql-test/t/func_date_add.test b/mysql-test/t/func_date_add.test
index c0250c6ece4..35acfe84bee 100644
--- a/mysql-test/t/func_date_add.test
+++ b/mysql-test/t/func_date_add.test
@@ -2,7 +2,10 @@
# Test of DATE_ADD
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
visitor_id int(10) unsigned DEFAULT '0' NOT NULL,
group_id int(10) unsigned DEFAULT '0' NOT NULL,
diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test
index 3b6acc54ec9..fbb71f850e2 100644
--- a/mysql-test/t/func_encrypt.test
+++ b/mysql-test/t/func_encrypt.test
@@ -1,6 +1,9 @@
-- source include/have_openssl.inc
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (x blob);
insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','The quick red fox jumped over the lazy brown dog'));
insert into t1 values (des_encrypt('a','The quick red fox jumped over the lazy brown dog'));
diff --git a/mysql-test/t/func_equal.test b/mysql-test/t/func_equal.test
index 0d7a4ed9778..cbf589ffcc2 100644
--- a/mysql-test/t/func_equal.test
+++ b/mysql-test/t/func_equal.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
#
# Testing of the <=> operator
#
@@ -15,7 +20,6 @@ select "A"<=>"B","A"<=>NULL,NULL<=>"A";
# Test with tables
#
-drop table if exists t1,t2;
create table t1 (id int, value int);
create table t2 (id int, value int);
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
new file mode 100644
index 00000000000..f426f9ca4ee
--- /dev/null
+++ b/mysql-test/t/func_gconcat.test
@@ -0,0 +1,101 @@
+#
+# simple test of group_concat function
+#
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
+insert into t1 values (1,1,"a","a");
+insert into t1 values (2,2,"b","a");
+insert into t1 values (2,3,"c","b");
+insert into t1 values (3,4,"E","a");
+insert into t1 values (3,5,"C","b");
+insert into t1 values (3,6,"D","b");
+insert into t1 values (3,7,"d","d");
+insert into t1 values (3,8,"d","d");
+insert into t1 values (3,9,"D","c");
+
+# Test of MySQL simple request
+select grp,group_concat(c) from t1 group by grp;
+select grp,group_concat(a,c) from t1 group by grp;
+select grp,group_concat("(",a,":",c,")") from t1 group by grp;
+
+# Test of MySQL with options
+select grp,group_concat(c separator ",") from t1 group by grp;
+select grp,group_concat(c separator "---->") from t1 group by grp;
+select grp,group_concat(c order by c) from t1 group by grp;
+select grp,group_concat(c order by c desc) from t1 group by grp;
+select grp,group_concat(d order by a) from t1 group by grp;
+select grp,group_concat(d order by a desc) from t1 group by grp;
+select grp,group_concat(a order by a,d+c) from t1 group by grp;
+select grp,group_concat(c order by 1) from t1 group by grp;
+select grp,group_concat(c order by "c") from t1 group by grp;
+select grp,group_concat(distinct c order by c) from t1 group by grp;
+select grp,group_concat(distinct c order by c desc) from t1 group by grp;
+select grp,group_concat(c order by c separator ",") from t1 group by grp;
+select grp,group_concat(c order by c desc separator ",") from t1 group by grp;
+select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
+select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
+
+# Test of SQL_LIST objects
+select grp,group_concat(c order by grp desc) from t1 group by grp order by grp;
+
+
+# Test transfer to real values
+
+select grp, group_concat(a separator "")+0 from t1 group by grp;
+select grp, group_concat(a separator "")+0.0 from t1 group by grp;
+select grp, ROUND(group_concat(a separator "")) from t1 group by grp;
+
+# Test NULL values
+
+drop table t1;
+create table t1 (grp int, c char(10));
+insert into t1 values (1,NULL);
+insert into t1 values (2,"b");
+insert into t1 values (2,NULL);
+insert into t1 values (3,"E");
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (3,NULL);
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (4,"");
+insert into t1 values (5,NULL);
+select grp,group_concat(c order by c) from t1 group by grp;
+
+# Test warnings
+
+set group_concat_max_len = 5;
+select grp,group_concat(c) from t1 group by grp;
+show warnings;
+set group_concat_max_len = 1024;
+
+# Test errors
+
+--error 1111
+select group_concat(sum(a)) from t1 group by grp;
+--error 1054
+select grp,group_concat(c order by 2) from t1 group by grp;
+
+drop table t1;
+
+# Test variable length
+
+create table t1 ( URL_ID int(11), URL varchar(80));
+create table t2 ( REQ_ID int(11), URL_ID int(11));
+insert into t1 values (4,'www.host.com'), (5,'www.google.com'),(5,'www.help.com');
+insert into t2 values (1,4), (5,4), (5,5);
+# Make this order independent
+--replace_result www.help.com X www.host.com X www.google.com X
+select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
+t2.URL_ID = t1.URL_ID group by REQ_ID;
+drop table t1;
+drop table t2;
+
+create table t1 (id int, name varchar(16));
+insert into t1 values (1,'longername'),(1,'evenlongername');
+select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
+select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
+drop table t1;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 40d829d3e70..8a43716d854 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -2,7 +2,10 @@
# simple test of all group functions
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (grp int, a bigint unsigned, c char(10) not null);
insert into t1 values (1,1,"a");
insert into t1 values (2,2,"b");
@@ -21,9 +24,9 @@ select count(distinct a),count(distinct grp) from t1;
insert into t1 values (null,null,'');
select count(distinct a),count(distinct grp) from t1;
-select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
-select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
-select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
+select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
+select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
+select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
@@ -40,8 +43,8 @@ CREATE TABLE t1 (id int(11),value1 float(10,2));
INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00);
CREATE TABLE t2 (id int(11),name char(20));
INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two');
-select id, avg(value1), std(value1) from t1 group by id;
-select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id;
+select id, avg(value1), std(value1), variance(value1) from t1 group by id;
+select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id;
drop table t1,t2;
#
@@ -118,15 +121,213 @@ explain select min(a2) from t1;
explain select max(t1.a1), max(t2.a2) from t1, t2;
insert into t2 values('AAA', 10, 0.5);
+insert into t2 values('BBB', 20, 1.0);
+select t1.a1, t1.a2, t2.a1, t2.a2 from t1,t2;
+
select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9;
select max(t2.a1), max(t1.a1) from t1, t2 where t2.a2=9;
select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;
select max(t1.a2) from t1 left outer join t2 on t1.a1=10;
-select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20;
-select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10;
+select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=20;
+select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=10;
select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA';
+select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10;
drop table t1,t2;
+
+#
+# Tests to check MIN/MAX query optimization
+#
+
+# Create database schema
+create table t1(
+ a1 char(3) primary key,
+ a2 smallint,
+ a3 char(3),
+ a4 real,
+ a5 date,
+ key k1(a2,a3),
+ key k2(a4 desc,a1),
+ key k3(a5,a1)
+);
+create table t2(
+ a1 char(3) primary key,
+ a2 char(17),
+ a3 char(2),
+ a4 char(3),
+ key k1(a3, a2),
+ key k2(a4)
+);
+
+# Populate table t1
+insert into t1 values('AME',0,'SEA',0.100,date'1942-02-19');
+insert into t1 values('HBR',1,'SEA',0.085,date'1948-03-05');
+insert into t1 values('BOT',2,'SEA',0.085,date'1951-11-29');
+insert into t1 values('BMC',3,'SEA',0.085,date'1958-09-08');
+insert into t1 values('TWU',0,'LAX',0.080,date'1969-10-05');
+insert into t1 values('BDL',0,'DEN',0.080,date'1960-11-27');
+insert into t1 values('DTX',1,'NYC',0.080,date'1961-05-04');
+insert into t1 values('PLS',1,'WDC',0.075,date'1949-01-02');
+insert into t1 values('ZAJ',2,'CHI',0.075,date'1960-06-15');
+insert into t1 values('VVV',2,'MIN',0.075,date'1959-06-28');
+insert into t1 values('GTM',3,'DAL',0.070,date'1977-09-23');
+insert into t1 values('SSJ',null,'CHI',null,date'1974-03-19');
+insert into t1 values('KKK',3,'ATL',null,null);
+insert into t1 values('XXX',null,'MIN',null,null);
+
+# Populate table t2
+insert into t2 values('TKF','Seattle','WA','AME');
+insert into t2 values('LCC','Los Angeles','CA','TWU');
+insert into t2 values('DEN','Denver','CO','BDL');
+insert into t2 values('SDC','San Diego','CA','TWU');
+insert into t2 values('NOL','New Orleans','LA','GTM');
+insert into t2 values('LAK','Los Angeles','CA','TWU');
+
+# Show the table contents
+select * from t1;
+select * from t2;
+
+# Queries with min/max functions
+# which regular min/max optimization are applied to
+
+explain
+select min(a1) from t1;
+select min(a1) from t1;
+explain
+select max(a4) from t1;
+select max(a4) from t1;
+explain
+select min(a5), max(a5) from t1;
+select min(a5), max(a5) from t1;
+explain
+select min(a3) from t1 where a2 = 2;
+select min(a3) from t1 where a2 = 2;
+explain
+select min(a1), max(a1) from t1 where a4 = 0.080;
+select min(a1), max(a1) from t1 where a4 = 0.080;
+
+explain
+select min(t1.a5), max(t2.a3) from t1, t2;
+select min(t1.a5), max(t2.a3) from t1, t2;
+explain
+select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA';
+select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA';
+
+# Queries with min/max functions
+# which extended min/max optimization are applied to
+
+explain
+select min(a1) from t1 where a1 > 'KKK';
+select min(a1) from t1 where a1 > 'KKK';
+explain
+select min(a1) from t1 where a1 >= 'KKK';
+select min(a1) from t1 where a1 >= 'KKK';
+explain
+select max(a3) from t1 where a2 = 2 and a3 < 'SEA';
+select max(a3) from t1 where a2 = 2 and a3 < 'SEA';
+explain
+select max(a5) from t1 where a5 < date'1970-01-01';
+select max(a5) from t1 where a5 < date'1970-01-01';
+explain
+select max(a3) from t1 where a2 is null;
+select max(a3) from t1 where a2 is null;
+explain
+select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q';
+select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q';
+explain
+select min(a1), max(a1) from t1 where a1 between 'A' and 'P';
+select min(a1), max(a1) from t1 where a1 between 'A' and 'P';
+explain
+select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN';
+select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN';
+explain
+select max(a3) from t1 where a3 = 'MIN' and a2 = 2;
+select max(a3) from t1 where a3 = 'MIN' and a2 = 2;
+explain
+select max(a3) from t1 where a3 = 'DEN' and a2 = 2;
+select max(a3) from t1 where a3 = 'DEN' and a2 = 2;
+
+explain
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA';
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA';
+
+explain
+select max(a3) from t1 where a2 is null and a2 = 2;
+select max(a3) from t1 where a2 is null and a2 = 2;
+
+explain
+select max(a2) from t1 where a2 >= 1;
+select max(a2) from t1 where a2 >= 1;
+explain
+select min(a3) from t1 where a2 = 2 and a3 < 'SEA';
+select min(a3) from t1 where a2 = 2 and a3 < 'SEA';
+
+explain
+select min(a3) from t1 where a2 = 4;
+select min(a3) from t1 where a2 = 4;
+explain
+select min(a3) from t1 where a2 = 2 and a3 > 'SEA';
+select min(a3) from t1 where a2 = 2 and a3 > 'SEA';
+explain
+select (min(a4)+max(a4))/2 from t1;
+select (min(a4)+max(a4))/2 from t1;
+explain
+select min(a3) from t1 where 2 = a2;
+select min(a3) from t1 where 2 = a2;
+explain
+select max(a3) from t1 where a2 = 2 and 'SEA' > a3;
+select max(a3) from t1 where a2 = 2 and 'SEA' > a3;
+explain
+select max(a3) from t1 where a2 = 2 and 'SEA' < a3;
+select max(a3) from t1 where a2 = 2 and 'SEA' < a3;
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI';
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI';
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA';
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA';
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN';
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN';
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN';
+select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN';
+
+explain
+select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK';
+select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK';
+
+# Queries to which max/min optimization is not applied
+
+explain
+select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX';
+explain
+select min(a1) from t1 where a1 != 'KKK';
+explain
+select max(a3) from t1 where a2 < 2 and a3 < 'SEA';
+explain
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA';
+
+explain
+select min(a4 - 0.01) from t1;
+explain
+select max(a4 + 0.01) from t1;
+explain
+select min(a3) from t1 where (a2 +1 ) is null;
+explain
+select min(a3) from t1 where (a2 + 1) = 2;
+explain
+select min(a3) from t1 where 2 = (a2 + 1);
+explain
+select min(a2) from t1 where a2 < 2 * a2 - 8;
+explain
+select min(a1) from t1 where a1 between a3 and 'KKK';
+explain
+select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08;
+explain
+select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME';
+drop table t1, t2;
+
#
# Test of group function and NULL values
#
@@ -147,3 +348,15 @@ insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
drop table t1;
+--disable_warnings
+create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) type=InnoDB;
+--enable_warnings
+insert into t1 values (1, 3);
+select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
+select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
+drop table t1;
+
+create table t1 (a char(10));
+insert into t1 values ('a'),('b'),('c');
+select coercibility(max(a)) from t1;
+drop table t1;
diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test
index 85553d1a2fd..21e5836c781 100644
--- a/mysql-test/t/func_if.test
+++ b/mysql-test/t/func_if.test
@@ -1,7 +1,9 @@
#
# Init section
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
#
# Simple IF tests
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index e5d42ec25c4..689b061f88d 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -1,8 +1,44 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
#
# test of IN (NULL)
#
-drop table if exists t1;
+select 1 in (1,2,3);
+select 10 in (1,2,3);
+select NULL in (1,2,3);
+select 1 in (1,NULL,3);
+select 3 in (1,NULL,3);
+select 10 in (1,NULL,3);
+select 1.5 in (1.5,2.5,3.5);
+select 10.5 in (1.5,2.5,3.5);
+select NULL in (1.5,2.5,3.5);
+select 1.5 in (1.5,NULL,3.5);
+select 3.5 in (1.5,NULL,3.5);
+select 10.5 in (1.5,NULL,3.5);
+
+CREATE TABLE t1 (a int, b int, c int);
+insert into t1 values (1,2,3), (1,NULL,3);
+select 1 in (a,b,c) from t1;
+select 3 in (a,b,c) from t1;
+select 10 in (a,b,c) from t1;
+select NULL in (a,b,c) from t1;
+drop table t1;
+CREATE TABLE t1 (a float, b float, c float);
+insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
+select 1.5 in (a,b,c) from t1;
+select 3.5 in (a,b,c) from t1;
+select 10.5 in (a,b,c) from t1;
+drop table t1;
+CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
+insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
+select 'A' in (a,b,c) from t1;
+select 'EFD' in (a,b,c) from t1;
+select 'XSFGGHF' in (a,b,c) from t1;
+drop table t1;
+
CREATE TABLE t1 (field char(1));
INSERT INTO t1 VALUES ('A'),(NULL);
SELECT * from t1 WHERE field IN (NULL);
@@ -18,3 +54,30 @@ insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
select * from t1 where id in (2,5,9);
drop table t1;
+create table t1 (
+a char(1) character set latin1 collate latin1_general_ci,
+b char(1) character set latin1 collate latin1_swedish_ci,
+c char(1) character set latin1 collate latin1_danish_ci
+);
+insert into t1 values ('A','B','C');
+insert into t1 values ('a','c','c');
+--error 1266
+select * from t1 where a in (b);
+--error 1269
+select * from t1 where a in (b,c);
+--error 1270
+select * from t1 where 'a' in (a,b,c);
+select * from t1 where 'a' in (a);
+select * from t1 where a in ('a');
+select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
+select * from t1 where 'a' collate latin1_bin in (a,b,c);
+select * from t1 where 'a' in (a,b,c collate latin1_bin);
+drop table t1;
+
+select '1.0' in (1,2);
+select 1 in ('1.0',2);
+select 1 in (1,'2.0');
+select 1 in ('1.0',2.0);
+select 1 in (1.0,'2.0');
+select 1 in ('1.1',2);
+select 1 in ('1.1',2.0);
diff --git a/mysql-test/t/func_isnull.test b/mysql-test/t/func_isnull.test
index bd3bcd8d04c..506efada0eb 100644
--- a/mysql-test/t/func_isnull.test
+++ b/mysql-test/t/func_isnull.test
@@ -2,7 +2,10 @@
# test of ISNULL()
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (id int auto_increment primary key not null, mydate date not null);
insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01");
flush tables;
diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test
index a5d1193fd74..0cd85385df4 100644
--- a/mysql-test/t/func_like.test
+++ b/mysql-test/t/func_like.test
@@ -2,7 +2,10 @@
# Test of like
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a varchar(10), key(a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
explain select * from t1 where a like 'abc%';
@@ -21,3 +24,23 @@ select * from t1 where a like "%abcd%";
select * from t1 where a like "%abc\d%";
drop table t1;
+
+
+#
+# Test like with non-default character set
+#
+
+SET NAMES koi8r;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
+
+INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
+
+SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
+SELECT * FROM t1 WHERE a LIKE '%Æù×%';
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
+
+DROP TABLE t1;
diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test
index 7fbe4000cfc..6e5d601844e 100644
--- a/mysql-test/t/func_regexp.test
+++ b/mysql-test/t/func_regexp.test
@@ -2,7 +2,10 @@
# Some regexp tests
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (s1 char(64),s2 char(64));
insert into t1 values('aaa','aaa');
diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test
new file mode 100644
index 00000000000..afd84fe9630
--- /dev/null
+++ b/mysql-test/t/func_sapdb.test
@@ -0,0 +1,99 @@
+--disable_warnings
+drop table if exists t1, test;
+--enable_warnings
+
+
+#
+# time functions
+#
+select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select date_format("1997-12-31 23:59:59.000002", "%f");
+
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
+
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
+
+#Date functions
+select adddate("1997-12-31 23:59:59.000001", 10);
+select subdate("1997-12-31 23:59:59.000001", 10);
+
+select datediff("1997-12-31 23:59:59.000001","1997-12-30");
+select datediff("1997-11-31 23:59:59.000001","1997-12-31");
+select datediff("1997-11-31 23:59:59.000001",null);
+
+select weekofyear("1997-11-31 23:59:59.000001");
+
+select makedate(1997,1);
+select makedate(1997,0);
+
+#Time functions
+
+select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
+select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
+select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
+select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
+select subtime("01:00:00.999999", "02:00:00.999998");
+select subtime("02:01:01.999999", "01:01:01.999999");
+
+select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
+select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
+select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
+select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
+select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
+
+select maketime(10,11,12);
+select maketime(25,11,12);
+select maketime(-25,11,12);
+
+#Extraction functions
+select timestamp("2001-12-01", "01:01:01.999999");
+select timestamp("2001-13-01", "01:01:01.000001");
+select timestamp("2001-12-01", "25:01:01");
+select timestamp("2001-12-01 01:01:01.000100");
+select timestamp("2001-12-01");
+select day("1997-12-31 23:59:59.000001");
+select date("1997-12-31 23:59:59.000001");
+select date("1997-13-31 23:59:59.000001");
+select time("1997-12-31 23:59:59.000001");
+select time("1997-12-31 25:59:59.000001");
+select microsecond("1997-12-31 23:59:59.000001");
+
+create table t1
+select makedate(1997,1) as f1,
+ addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
+ addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
+ timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
+ timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
+ maketime(10,11,12) as f6,
+ timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
+ date("1997-12-31 23:59:59.000001") as f8,
+ time("1997-12-31 23:59:59.000001") as f9;
+describe t1;
+select * from t1;
+
+create table test(t1 datetime, t2 time, t3 time, t4 datetime);
+insert into test values
+('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
+('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
+('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
+('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
+('2001-01-01 01:01:01', null, '-1 01:01:01', null),
+(null, null, null, null),
+('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
+
+SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
+SELECT TIMEDIFF(t1,t4) As ttt, TIMEDIFF(t2, t3) As qqq from test;
+
+drop table t1, test;
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index 81f561989d5..b152c94096c 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -16,3 +16,21 @@ select elt(2,1),field(NULL,"a","b","c");
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
select interval(null, 1, 10, 100);
+
+#
+# test for a bug with elt()
+#
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1 (id int(10) not null unique);
+create table t2 (id int(10) not null primary key,
+val int(10) not null);
+insert into t1 values (1),(2),(4);
+insert into t2 values (1,1),(2,1),(3,1),(4,2);
+
+select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
+select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
+drop table t1,t2;
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 5ea3654134b..b421f47e5b8 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -4,7 +4,11 @@
# -----------
# Testing string functions
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
+set names latin1;
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
select 'hello' 'monty';
@@ -36,6 +40,11 @@ select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
select soundex(''),soundex('he'),soundex('hello all folks');
+select 'mood' sounds like 'mud';
+select 'Glazgo' sounds like 'Liverpool';
+select null sounds like 'null';
+select 'null' sounds like null;
+select null sounds like null;
select md5('hello');
select sha('abc');
select sha1('abc');
@@ -111,9 +120,9 @@ CREATE TABLE t1 (
) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
-SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') FROM t1;
+SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1;
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
-SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1;
+SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1;
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
drop table t1;
@@ -126,6 +135,187 @@ INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
DROP TABLE t1;
+#
+# Test collation and coercibility
+#
+
+select 1=_latin1'1';
+select _latin1'1'=1;
+select _latin2'1'=1;
+select 1=_latin2'1';
+--error 1266
+select _latin1'1'=_latin2'1';
+select row('a','b','c') = row('a','b','c');
+select row('A','b','c') = row('a','b','c');
+select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c');
+select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
+--error 1266
+select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
+
+--error 1266
+select concat(_latin1'a',_latin2'a');
+--error 1269
+select concat(_latin1'a',_latin2'a',_latin5'a');
+--error 1270
+select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
+
+
+#
+# Test FIELD() and collations
+#
+select FIELD('b','A','B');
+select FIELD('B','A','B');
+select FIELD('b' COLLATE latin1_bin,'A','B');
+select FIELD('b','A' COLLATE latin1_bin,'B');
+--error 1269
+select FIELD(_latin2'b','A','B');
+--error 1269
+select FIELD('b',_latin2'A','B');
+select FIELD('b',_latin2'A','B',1);
+
+
+select POSITION(_latin1'B' IN _latin1'abcd');
+select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
+select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd');
+--error 1266
+select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin);
+--error 1266
+select POSITION(_latin1'B' IN _latin2'abcd');
+
+select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d');
+--fix this:
+--select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d' COLLATE latin1_bin);
+--select FIND_IN_SET(_latin1'B' COLLATE latin1_bin,_latin1'a,b,c,d');
+--error 1266
+select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin);
+--error 1266
+select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d');
+
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2);
+--fix this:
+--select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_bin,_latin1'd',2);
+--select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd' COLLATE latin1_bin,2);
+--error 1266
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2);
+--error 1266
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2);
+
+select _latin1'B' between _latin1'a' and _latin1'c';
+select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c';
+select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c';
+select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin;
+--error 1269
+select _latin2'B' between _latin1'a' and _latin1'b';
+--error 1269
+select _latin1'B' between _latin2'a' and _latin1'b';
+--error 1269
+select _latin1'B' between _latin1'a' and _latin2'b';
+--error 1269
+select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b';
+
+select _latin1'B' in (_latin1'a',_latin1'b');
+select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
+select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
+select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
+--error 1269
+select _latin2'B' in (_latin1'a',_latin1'b');
+--error 1269
+select _latin1'B' in (_latin2'a',_latin1'b');
+--error 1269
+select _latin1'B' in (_latin1'a',_latin2'b');
+--error 1269
+select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
+--error 1269
+select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
+
+select collation(bin(130)), coercibility(bin(130));
+select collation(oct(130)), coercibility(oct(130));
+select collation(conv(130,16,10)), coercibility(conv(130,16,10));
+select collation(hex(130)), coercibility(hex(130));
+select collation(char(130)), coercibility(hex(130));
+select collation(format(130,10)), coercibility(format(130,10));
+select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
+select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a'));
+select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
+select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
+select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
+select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
+select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
+select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
+select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
+select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
+select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
+select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
+select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
+select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
+select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
+select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
+select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
+select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
+select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
+select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
+select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
+select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
+select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
+select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
+
+create table t1
+select
+ bin(130),
+ oct(130),
+ conv(130,16,10),
+ hex(130),
+ char(130),
+ format(130,10),
+ left(_latin2'a',1),
+ right(_latin2'a',1),
+ lcase(_latin2'a'),
+ ucase(_latin2'a'),
+ substring(_latin2'a',1,1),
+ concat(_latin2'a',_latin2'b'),
+ lpad(_latin2'a',4,_latin2'b'),
+ rpad(_latin2'a',4,_latin2'b'),
+ concat_ws(_latin2'a',_latin2'b'),
+ make_set(255,_latin2'a',_latin2'b',_latin2'c'),
+ export_set(255,_latin2'y',_latin2'n',_latin2' '),
+ trim(_latin2' a '),
+ ltrim(_latin2' a '),
+ rtrim(_latin2' a '),
+ trim(LEADING _latin2' ' FROM _latin2' a '),
+ trim(TRAILING _latin2' ' FROM _latin2' a '),
+ trim(BOTH _latin2' ' FROM _latin2' a '),
+ repeat(_latin2'a',10),
+ reverse(_latin2'ab'),
+ quote(_latin2'ab'),
+ soundex(_latin2'ab'),
+ substring(_latin2'ab',1),
+ insert(_latin2'abcd',2,3,_latin2'ef'),
+ replace(_latin2'abcd',_latin2'b',_latin2'B')
+;
+show create table t1;
+drop table t1;
+
+#
+# test for SUBSTR
+#
+select SUBSTR('abcdefg',3,2);
+select SUBSTRING('abcdefg',3,2);
+select SUBSTR('abcdefg',-3,2) FROM DUAL;
+select SUBSTR('abcdefg',-1,5) FROM DUAL;
+select SUBSTR('abcdefg',0,0) FROM DUAL;
+select SUBSTR('abcdefg',-1,-1) FROM DUAL;
+select SUBSTR('abcdefg',1,-1) FROM DUAL;
+
+#
+# Test that fix_fields doesn't follow to upper level (to comparison)
+# when an error on a lower level (in concat) has accured:
+#
+create table t7 (s1 char);
+--error 1266
+select * from t7
+where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA';
+drop table t7;
+
CREATE TABLE t1 (
wid int(10) unsigned NOT NULL auto_increment,
data_podp date default NULL,
@@ -141,13 +331,8 @@ DROP TABLE t1;
#
# test for #739
-CREATE TABLE t1 (
- title text
-) TYPE=MyISAM;
-
+CREATE TABLE t1 (title text) TYPE=MyISAM;
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
-
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
-
DROP TABLE t1;
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 052e0530cf6..998b2a5c3f4 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -2,5 +2,24 @@
# system functions
#
-select database(),user() like "%@%";
+select database();
+select charset(database());
+select database() = "test";
+select database() = _utf8"test";
+select database() = _latin1"test";
+
+select user() like "%@%";
+select user() like _utf8"%@%";
+select user() like _latin1"%@%";
+select charset(user());
+
select version()>="3.23.29";
+select version()>=_utf8"3.23.29";
+select version()>=_latin1"3.23.29";
+select charset(version());
+
+create table t1 (version char(40)) select database(), user(), version() as 'version';
+show create table t1;
+drop table t1;
+
+select TRUE,FALSE,NULL;
diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test
index e03d0dd0f0f..95b10c4ffb9 100644
--- a/mysql-test/t/func_test.test
+++ b/mysql-test/t/func_test.test
@@ -1,3 +1,6 @@
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
#
# Testing of comparison functions
#
@@ -17,6 +20,8 @@ select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,
select -1.49 or -1.49,0.6 or 0.6;
select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
+select 10 % 7, 10 mod 7, 10 div 3;
+select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
create table t1 (a int);
insert t1 values (1);
@@ -30,7 +35,43 @@ drop table t1;
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
select 1 and 0 or 2, 2 or 1 and 0;
-DROP TABLE IF EXISTS t1,t2;
+
+#
+# Coercibility
+#
+select _koi8r'a' = _koi8r'A';
+select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
+select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin;
+select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A';
+select _koi8r'a' COLLATE koi8r_bin = _koi8r'A';
+--error 1266
+select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci;
+--error 1266
+select _koi8r'a' = _latin1'A';
+
+select strcmp(_koi8r'a', _koi8r'A');
+select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci);
+select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin);
+select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A');
+select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A');
+--error 1266
+select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin);
+--error 1266
+select strcmp(_koi8r'a', _latin1'A');
+
+select _koi8r'a' LIKE _koi8r'A';
+select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci;
+select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin;
+select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A';
+select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A';
+--error 1266
+select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin;
+--error 1266
+select _koi8r'a' LIKE _latin1'A';
+
+#
+# Test for LEAST() BUG in LEFT JOIN
+#
CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) TYPE=MyISAM;
INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','<as-html>\r\n<table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n <td width=\"97%\">\r\n <h3><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000000\">How \r\n To</font><!-- #BeginEditable \"CS_troubleshoot_question\" --><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><font color=\"#000000\">: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected. </font></font><!-- #EndEditable --></h3>\r\n </td>\r\n </tr>\r\n</table>','<as-html>\r\n <table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n \r\n<td width=\"97%\"><!-- #BeginEditable \"CS_troubleshoot_answer\" --> \r\n \r\n<p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">1. Select \r\n the <i>On/Setup</i> button to access the DynaVox Setup Menu.<br>\r\n 2. Select <b>Button Features.</b><br>\r\n 3. Below the <b>OK</b> button is the <b>Usage Counts</b> button.<br>\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.<br>\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.<br>\r\n c. Select the <b>Usage Counts</b> Option Ring once and it will toggle \r\n to the alternative option.<br>\r\n 4. Once the correct setting has been chosen, select <b>OK</b> to leave the <i>Button \r\n Features</i> menu.<br>\r\n 5. Select <b>OK</b> out of the <i>Setup</i> menu and return to the communication \r\n page.</font></p>\r\n <p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">For \r\n further information on <i>Usage Counts,</i> see the <i>Button Features \r\n Menu Entry</i> in the DynaVox/DynaMyte Reference Manual.</font></p>\r\n<!-- #EndEditable --></td>\r\n </tr>\r\n</table>',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL);
CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index a51869e7d76..30d616915ab 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1,7 +1,9 @@
#
# time functions
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
select period_add("9602",-12),period_diff(199505,"9404") ;
@@ -189,3 +191,43 @@ select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
drop table t1,t2,t3;
+
+#
+# Test types from + INTERVAL
+#
+
+CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
+INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
+SELECT * from t1;
+select date_add("1997-12-31",INTERVAL 1 SECOND);
+select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
+
+select date_add(datetime, INTERVAL 1 SECOND) from t1;
+select date_add(datetime, INTERVAL 1 YEAR) from t1;
+
+select date_add(date,INTERVAL 1 SECOND) from t1;
+select date_add(date,INTERVAL 1 MINUTE) from t1;
+select date_add(date,INTERVAL 1 HOUR) from t1;
+select date_add(date,INTERVAL 1 DAY) from t1;
+select date_add(date,INTERVAL 1 MONTH) from t1;
+select date_add(date,INTERVAL 1 YEAR) from t1;
+select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
+select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
+select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
+select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
+select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
+select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
+select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
+
+# The following is not as one would expect...
+select date_add(time,INTERVAL 1 SECOND) from t1;
+drop table t1;
+
+# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
+# TZ variable set to GMT-3
+select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
+select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
+select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
+select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
+select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
+select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
diff --git a/mysql-test/t/func_timestamp.test b/mysql-test/t/func_timestamp.test
index 74e541f782d..8583c16073d 100644
--- a/mysql-test/t/func_timestamp.test
+++ b/mysql-test/t/func_timestamp.test
@@ -2,7 +2,10 @@
# Tests that depend on the timestamp and the TZ variable
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null,
Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998);
diff --git a/mysql-test/t/gcc296.test b/mysql-test/t/gcc296.test
index 7c72b57ca54..ebca4dbc897 100644
--- a/mysql-test/t/gcc296.test
+++ b/mysql-test/t/gcc296.test
@@ -1,6 +1,9 @@
#try to crash gcc 2.96
-drop table if exists obory;
-CREATE TABLE obory (
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1 (
kodoboru varchar(10) default NULL,
obor tinytext,
aobor tinytext,
@@ -8,10 +11,10 @@ CREATE TABLE obory (
FULLTEXT KEY obor (obor),
FULLTEXT KEY aobor (aobor)
);
-INSERT INTO obory VALUES ('0101000000','aaa','AAA');
-INSERT INTO obory VALUES ('0102000000','bbb','BBB');
-INSERT INTO obory VALUES ('0103000000','ccc','CCC');
-INSERT INTO obory VALUES ('0104000000','xxx','XXX');
+INSERT INTO t1 VALUES ('0101000000','aaa','AAA');
+INSERT INTO t1 VALUES ('0102000000','bbb','BBB');
+INSERT INTO t1 VALUES ('0103000000','ccc','CCC');
+INSERT INTO t1 VALUES ('0104000000','xxx','XXX');
-select * from obory;
-drop table obory;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
new file mode 100644
index 00000000000..0368ddb41cb
--- /dev/null
+++ b/mysql-test/t/gis-rtree.test
@@ -0,0 +1,69 @@
+#
+# test of rtree (using with spatial data)
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (
+ fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ g GEOMETRY NOT NULL,
+ SPATIAL KEY(g)
+) TYPE=MyISAM;
+
+SHOW CREATE TABLE t1;
+
+let $1=150;
+let $2=150;
+while ($1)
+{
+ eval INSERT INTO t1 (g) VALUES (GeomFromText('LineString($1 $1, $2 $2)'));
+ dec $1;
+ inc $2;
+}
+
+SELECT count(*) FROM t1;
+EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
+SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
+
+DROP TABLE t1;
+
+CREATE TABLE t2 (
+ fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ g GEOMETRY NOT NULL
+) TYPE=MyISAM;
+
+let $1=10;
+while ($1)
+{
+ let $2=10;
+ while ($2)
+ {
+ eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
+ dec $2;
+ }
+ dec $1;
+}
+
+ALTER TABLE t2 ADD SPATIAL KEY(g);
+SHOW CREATE TABLE t2;
+SELECT count(*) FROM t2;
+EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
+ GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+SELECT fid, AsText(g) FROM t2 WHERE Within(g,
+ GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+
+let $1=10;
+while ($1)
+{
+ let $2=10;
+ while ($2)
+ {
+ eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))));
+ SELECT count(*) FROM t2;
+ dec $2;
+ }
+ dec $1;
+}
+
+DROP TABLE t2;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
new file mode 100644
index 00000000000..b7c41135123
--- /dev/null
+++ b/mysql-test/t/gis.test
@@ -0,0 +1,144 @@
+#
+# Spatial objects
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS pt, ls, p, mpt, mls, mp, gc, geo;
+--enable_warnings
+
+CREATE TABLE pt (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
+CREATE TABLE ls (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
+CREATE TABLE p (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
+CREATE TABLE mpt (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
+CREATE TABLE mls (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
+CREATE TABLE mp (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
+CREATE TABLE gc (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
+CREATE TABLE geo (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
+
+SHOW FIELDS FROM pt;
+SHOW FIELDS FROM ls;
+SHOW FIELDS FROM p;
+SHOW FIELDS FROM mpt;
+SHOW FIELDS FROM mls;
+SHOW FIELDS FROM mp;
+SHOW FIELDS FROM gc;
+SHOW FIELDS FROM geo;
+
+
+INSERT INTO pt VALUES
+(101, PointFromText('POINT(10 10)')),
+(102, PointFromText('POINT(20 10)')),
+(103, PointFromText('POINT(20 20)')),
+(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+
+INSERT INTO ls VALUES
+(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
+(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
+(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
+
+INSERT INTO p VALUES
+(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
+(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
+(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+
+INSERT INTO mpt VALUES
+(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
+(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
+(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
+
+INSERT INTO mls VALUES
+(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
+(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
+(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+
+
+INSERT INTO mp VALUES
+(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+
+INSERT INTO gc VALUES
+(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+
+INSERT into geo SELECT * FROM pt;
+INSERT into geo SELECT * FROM ls;
+INSERT into geo SELECT * FROM p;
+INSERT into geo SELECT * FROM mpt;
+INSERT into geo SELECT * FROM mls;
+INSERT into geo SELECT * FROM mp;
+INSERT into geo SELECT * FROM gc;
+
+SELECT fid, AsText(g) FROM pt;
+SELECT fid, AsText(g) FROM ls;
+SELECT fid, AsText(g) FROM p;
+SELECT fid, AsText(g) FROM mpt;
+SELECT fid, AsText(g) FROM mls;
+SELECT fid, AsText(g) FROM mp;
+SELECT fid, AsText(g) FROM gc;
+SELECT fid, AsText(g) FROM geo;
+
+SELECT fid, Dimension(g) FROM geo;
+SELECT fid, GeometryType(g) FROM geo;
+SELECT fid, IsEmpty(g) FROM geo;
+SELECT fid, AsText(Envelope(g)) FROM geo;
+
+SELECT fid, X(g) FROM pt;
+SELECT fid, Y(g) FROM pt;
+
+SELECT fid, AsText(StartPoint(g)) FROM ls;
+SELECT fid, AsText(EndPoint(g)) FROM ls;
+SELECT fid, GLength(g) FROM ls;
+SELECT fid, NumPoints(g) FROM ls;
+SELECT fid, AsText(PointN(g, 2)) FROM ls;
+SELECT fid, IsClosed(g) FROM ls;
+
+SELECT fid, AsText(Centroid(g)) FROM p;
+SELECT fid, Area(g) FROM p;
+SELECT fid, AsText(ExteriorRing(g)) FROM p;
+SELECT fid, NumInteriorRings(g) FROM p;
+SELECT fid, AsText(InteriorRingN(g, 1)) FROM p;
+
+SELECT fid, IsClosed(g) FROM mls;
+
+SELECT fid, AsText(Centroid(g)) FROM mp;
+SELECT fid, Area(g) FROM mp;
+
+SELECT fid, NumGeometries(g) from mpt;
+SELECT fid, NumGeometries(g) from mls;
+SELECT fid, NumGeometries(g) from mp;
+SELECT fid, NumGeometries(g) from gc;
+
+SELECT fid, AsText(GeometryN(g, 2)) from mpt;
+SELECT fid, AsText(GeometryN(g, 2)) from mls;
+SELECT fid, AsText(GeometryN(g, 2)) from mp;
+SELECT fid, AsText(GeometryN(g, 2)) from gc;
+
+SELECT g1.fid as first, g2.fid as second,
+Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
+Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
+Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
+FROM gc g1, gc g2 ORDER BY first, second;
+
+DROP TABLE pt, ls, p, mpt, mls, mp, gc, geo;
+
+#
+# Check that ALTER TABLE doesn't loose geometry type
+#
+CREATE TABLE g1 (
+ pt point,
+ ln linestring,
+ pg polygon,
+ mpt multipoint,
+ mln multilinestring,
+ mpg multipolygon,
+ gc geometrycollection,
+ gm geometry
+);
+
+SHOW FIELDS FROM g1;
+ALTER TABLE g1 ADD fid INT NOT NULL;
+SHOW FIELDS FROM g1;
+DROP TABLE g1;
+
+SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 9b670b36f2c..55d2d9f3848 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -1,3 +1,6 @@
+# Test of GRANT commands
+
+# Cleanup
--disable_warnings
drop table if exists t1;
--enable_warnings
@@ -89,3 +92,36 @@ drop table t1;
--error 1221
GRANT FILE on mysqltest.* to mysqltest_1@localhost;
select 1; -- To test that the previous command didn't cause problems
+
+#
+# Test for 'drop user', 'revoke privileges, grant'
+#
+
+create table t1 (a int);
+grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION;
+show grants for drop_user2@localhost;
+revoke all privileges, grant from drop_user2@localhost;
+drop user drop_user2@localhost;
+
+grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION;
+grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION;
+grant select(a) on test.t1 to drop_user@localhost;
+show grants for drop_user@localhost;
+revoke all privileges, grant from drop_user@localhost;
+show grants for drop_user@localhost;
+drop user drop_user@localhost;
+--error 1268
+revoke all privileges, grant from drop_user@localhost;
+
+grant select(a) on test.t1 to drop_user1@localhost;
+grant select on test.t1 to drop_user2@localhost;
+grant select on test.* to drop_user3@localhost;
+grant select on *.* to drop_user4@localhost;
+--error 1267
+drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
+drop_user4@localhost;
+revoke all privileges, grant from drop_user1@localhost, drop_user2@localhost,
+drop_user3@localhost, drop_user4@localhost;
+drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
+drop_user4@localhost;
+drop table t1;
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
new file mode 100644
index 00000000000..148c4d3da21
--- /dev/null
+++ b/mysql-test/t/grant2.test
@@ -0,0 +1,30 @@
+#
+# GRANT tests that require several connections
+# (usually it's GRANT, reconnect as another user, try something)
+#
+
+
+#
+# wild_compare fun
+#
+
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+flush privileges;
+grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
+connect (user1,localhost,mysqltest_1,,);
+connection user1;
+select current_user();
+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
+--error 1044
+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
+disconnect user1;
+connection default;
+show grants for mysqltest_1@localhost;
+show grants for mysqltest_2@localhost;
+--error 1141
+show grants for mysqltest_3@localhost;
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+flush privileges;
+
diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test
index 95989d1ee99..9ba845d6baa 100644
--- a/mysql-test/t/grant_cache.test
+++ b/mysql-test/t/grant_cache.test
@@ -1,17 +1,20 @@
-- source include/have_query_cache.inc
-drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
-drop database if exists mysqltest;
-
#
# Test grants with query cache
#
+--disable_warnings
+drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
+drop database if exists mysqltest;
+--enable_warnings
reset query cache;
flush status;
connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock);
connection root;
+--disable_warnings
create database if not exists mysqltest;
+--enable_warnings
create table mysqltest.t1 (a int,b int,c int);
create table mysqltest.t2 (a int,b int,c int);
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index df99bc2a9dc..752896ce7b2 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1,8 +1,18 @@
+# Initialise
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+#
+# Simple test without tables
+
+-- error 1111
+SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
+
#
# Test of group (Failed for Lars Hoss <lh@pbm.de>)
#
-drop table if exists t1,t2,t3;
CREATE TABLE t1 (
spID int(10) unsigned,
userID int(10) unsigned,
@@ -43,7 +53,7 @@ SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spI
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
-drop table test.t1,test.t2;
+drop table t1,t2;
#
# Bug in GROUP BY, by Nikki Chumakov <nikki@saddam.cityline.ru>
@@ -122,7 +132,7 @@ CREATE TABLE t1 (
assigned_to mediumint(9) DEFAULT '0' NOT NULL,
bug_file_loc text,
bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
- bug_status enum('NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
+ bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
delta_ts timestamp(14),
short_desc mediumtext,
@@ -302,7 +312,6 @@ SELECT 1 FROM t1 GROUP BY CONCAT(a, b);
INSERT INTO t1 values ('hij','klm');
SELECT CONCAT(a, b),count(*) FROM t1 GROUP BY 1;
DROP TABLE t1;
-drop table if exists t1;
#
# Test problem with ORDER BY on a SUM() column
diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test
index 737b220c805..99ca858990c 100644
--- a/mysql-test/t/handler.test
+++ b/mysql-test/t/handler.test
@@ -2,13 +2,18 @@
# test of HANDLER ...
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int, b char(10), key a(a), key b(a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii");
handler t1 open as t2;
+-- error 1064
+handler t2 read a=(SELECT 1);
handler t2 read a first;
handler t2 read a next;
handler t2 read a next;
@@ -81,9 +86,8 @@ handler t2 read first;
drop table t1;
#
-# test case for the bug #787
+# Test case for the bug #787
#
-
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
@@ -96,7 +100,7 @@ handler t1 read first;
drop table t1;
#
-#test for #751
+# Test for #751
#
create table t1(a int, index(a));
insert into t1 values (1), (2), (3);
@@ -106,4 +110,3 @@ handler t1 read a=(W);
--error 1210
handler t1 read a=(a);
drop table t1;
-
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index cb6fa85ffde..7d5fbee011f 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -1,7 +1,10 @@
# test of problems with having (Reported by Mark Rogers)
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int);
select count(a) as b from t1 where a=0 having b > 0;
insert into t1 values (null);
@@ -59,7 +62,12 @@ select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null;
select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null;
select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null;
select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null;
+select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null;
drop table t1;
+
+#
+# Test problem with count(distinct) in having
+#
create table t1 (id int not null, qty int not null);
insert into t1 values (1,2),(1,3),(2,4),(2,5);
select id, sum(qty) as sqty from t1 group by id having sqty>2;
diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test
index b2de58ca083..797472e7769 100644
--- a/mysql-test/t/heap.test
+++ b/mysql-test/t/heap.test
@@ -2,7 +2,10 @@
# Test of heap tables.
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
insert into t1 values(1,1),(2,2),(3,3),(4,4);
delete from t1 where a=1 or a=0;
@@ -42,7 +45,7 @@ alter table t1 type=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
drop table t1;
-create table t1 (x int not null, y int not null, key x(x), unique y(y))
+create table t1 (x int not null, y int not null, key x (x), unique y (y))
type=heap;
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
select * from t1 where x=1;
@@ -102,7 +105,7 @@ insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("
explain select * from t1 where btn like "q%";
select * from t1 where btn like "q%";
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
-update t1 set new_col=btn;
+update t1 set new_col=left(btn,1);
explain select * from t1 where btn="a";
explain select * from t1 where btn="a" and new_col="a";
drop table t1;
diff --git a/mysql-test/t/heap_auto_increment.test b/mysql-test/t/heap_auto_increment.test
new file mode 100644
index 00000000000..6f392f6830d
--- /dev/null
+++ b/mysql-test/t/heap_auto_increment.test
@@ -0,0 +1,33 @@
+#
+# Test of auto_increment; The test for BDB tables is in bdb.test
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null auto_increment,b int, primary key (a)) type=heap auto_increment=3;
+insert into t1 values (1,1),(NULL,3),(NULL,4);
+delete from t1 where a=4;
+insert into t1 values (NULL,5),(NULL,6);
+select * from t1;
+delete from t1 where a=6;
+#show table status like "t1";
+replace t1 values (3,1);
+ALTER TABLE t1 add c int;
+replace t1 values (3,3,3);
+insert into t1 values (NULL,7,7);
+update t1 set a=8,b=b+1,c=c+1 where a=7;
+insert into t1 values (NULL,9,9);
+select * from t1;
+drop table t1;
+
+create table t1 (
+ skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
+ sval char(20)
+) type=heap;
+insert into t1 values (NULL, "hello");
+insert into t1 values (NULL, "hey");
+select * from t1;
+select _rowid,t1._rowid,skey,sval from t1;
+drop table t1;
diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test
new file mode 100644
index 00000000000..34aeeec0a11
--- /dev/null
+++ b/mysql-test/t/heap_btree.test
@@ -0,0 +1,158 @@
+#
+# Test of heap tables.
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a=1 or a=0;
+#show table status like "t1";
+show keys from t1;
+select * from t1;
+select * from t1 where a=4;
+update t1 set b=5 where a=4;
+update t1 set b=b+1 where a>=3;
+replace t1 values (3,3);
+select * from t1;
+alter table t1 add c int not null, add key using BTREE (c,a);
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps";
+insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a > -3;
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
+#show table status like "t1";
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null) type=heap;
+insert into t1 values (869751),(736494),(226312),(802616);
+select * from t1 where a > 736494;
+alter table t1 add unique uniq_id using BTREE (a);
+select * from t1 where a > 736494;
+select * from t1 where a = 736494;
+select * from t1 where a=869751 or a=736494;
+select * from t1 where a in (869751,736494,226312,802616);
+alter table t1 type=myisam;
+explain select * from t1 where a in (869751,736494,226312,802616);
+drop table t1;
+
+create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
+type=heap;
+insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
+explain select * from t1 where x=1;
+select * from t1 where x=1;
+select * from t1,t1 as t2 where t1.x=t2.y;
+explain select * from t1,t1 as t2 where t1.x=t2.y;
+drop table t1;
+
+create table t1 (a int) type=heap;
+insert into t1 values(1);
+select max(a) from t1;
+drop table t1;
+
+CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) TYPE=HEAP;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
+explain select * from t1 where a=1 order by a,b;
+--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
+explain select * from t1 where a=1 order by b;
+select * from t1 where b=1;
+--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
+explain select * from t1 where b=1;
+drop table t1;
+
+create table t1 (id int unsigned not null, primary key using BTREE (id)) type=HEAP;
+insert into t1 values(1);
+select max(id) from t1;
+insert into t1 values(2);
+select max(id) from t1;
+replace into t1 values(1);
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table if exists t1;
+
+# Test of non unique index
+
+CREATE table t1(f1 int not null,f2 char(20) not
+null,index(f2)) type=heap;
+INSERT into t1 set f1=12,f2="bill";
+INSERT into t1 set f1=13,f2="bill";
+INSERT into t1 set f1=14,f2="bill";
+INSERT into t1 set f1=15,f2="bill";
+INSERT into t1 set f1=16,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+delete from t1 where f2="bill";
+select * from t1;
+drop table t1;
+
+#
+# Test when using part key searches
+#
+
+create table t1 (btn char(10) not null, key using BTREE (btn)) type=heap;
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+explain select * from t1 where btn like "q%";
+select * from t1 where btn like "q%";
+alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
+update t1 set new_col=left(btn,1);
+explain select * from t1 where btn="a";
+explain select * from t1 where btn="a" and new_col="a";
+drop table t1;
+
+#
+# Test of NULL keys
+#
+
+CREATE TABLE t1 (
+ a int default NULL,
+ b int default NULL,
+ KEY a using BTREE (a),
+ UNIQUE b using BTREE (b)
+) type=heap;
+INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
+SELECT * FROM t1 WHERE a=NULL;
+explain SELECT * FROM t1 WHERE a IS NULL;
+SELECT * FROM t1 WHERE a<=>NULL;
+SELECT * FROM t1 WHERE b=NULL;
+explain SELECT * FROM t1 WHERE b IS NULL;
+SELECT * FROM t1 WHERE b<=>NULL;
+
+--error 1062
+INSERT INTO t1 VALUES (1,3);
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap;
+INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
+SELECT * FROM t1 WHERE a=1 and b IS NULL;
+SELECT * FROM t1 WHERE a=1 and c IS NULL;
+SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
+DROP TABLE t1;
+
+#
+# Test when deleting all rows
+#
+
+CREATE TABLE t1 (a int not null, primary key using BTREE (a)) type=heap;
+INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+DELETE from t1 where a < 100;
+SELECT * from t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test
new file mode 100644
index 00000000000..f339a10efc6
--- /dev/null
+++ b/mysql-test/t/heap_hash.test
@@ -0,0 +1,143 @@
+#
+# Test of heap tables.
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a=1 or a=0;
+#show table status like "t1";
+show keys from t1;
+select * from t1;
+select * from t1 where a=4;
+update t1 set b=5 where a=4;
+update t1 set b=b+1 where a>=3;
+replace t1 values (3,3);
+select * from t1;
+alter table t1 add c int not null, add key using HASH (c,a);
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a > 0;
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
+#show table status like "t1";
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null) type=heap;
+insert into t1 values (869751),(736494),(226312),(802616);
+select * from t1 where a > 736494;
+alter table t1 add unique uniq_id using HASH (a);
+select * from t1 where a > 736494;
+select * from t1 where a = 736494;
+select * from t1 where a=869751 or a=736494;
+select * from t1 where a in (869751,736494,226312,802616);
+alter table t1 type=myisam;
+explain select * from t1 where a in (869751,736494,226312,802616);
+drop table t1;
+
+create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
+type=heap;
+insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
+select * from t1 where x=1;
+select * from t1,t1 as t2 where t1.x=t2.y;
+explain select * from t1,t1 as t2 where t1.x=t2.y;
+drop table t1;
+
+create table t1 (a int) type=heap;
+insert into t1 values(1);
+select max(a) from t1;
+drop table t1;
+
+CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) TYPE=HEAP;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+drop table t1;
+
+create table t1 (id int unsigned not null, primary key using HASH (id)) type=HEAP;
+insert into t1 values(1);
+select max(id) from t1;
+insert into t1 values(2);
+select max(id) from t1;
+replace into t1 values(1);
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table if exists t1;
+
+# Test of non unique index
+
+CREATE table t1(f1 int not null,f2 char(20) not
+null,index(f2)) type=heap;
+INSERT into t1 set f1=12,f2="bill";
+INSERT into t1 set f1=13,f2="bill";
+INSERT into t1 set f1=14,f2="bill";
+INSERT into t1 set f1=15,f2="bill";
+INSERT into t1 set f1=16,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+delete from t1 where f2="bill";
+select * from t1;
+drop table t1;
+
+#
+# Test when using part key searches
+#
+
+create table t1 (btn char(10) not null, key using HASH (btn)) type=heap;
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+explain select * from t1 where btn like "q%";
+select * from t1 where btn like "q%";
+alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
+update t1 set new_col=left(btn,1);
+explain select * from t1 where btn="a";
+explain select * from t1 where btn="a" and new_col="a";
+drop table t1;
+
+#
+# Test of NULL keys
+#
+
+CREATE TABLE t1 (
+ a int default NULL,
+ b int default NULL,
+ KEY a using HASH (a),
+ UNIQUE b using HASH (b)
+) type=heap;
+INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
+SELECT * FROM t1 WHERE a=NULL;
+explain SELECT * FROM t1 WHERE a IS NULL;
+SELECT * FROM t1 WHERE a<=>NULL;
+SELECT * FROM t1 WHERE b=NULL;
+explain SELECT * FROM t1 WHERE b IS NULL;
+SELECT * FROM t1 WHERE b<=>NULL;
+
+--error 1062
+INSERT INTO t1 VALUES (1,3);
+DROP TABLE t1;
+
+#
+# Test when deleting all rows
+#
+
+CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap;
+INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+DELETE from t1 where a < 100;
+SELECT * from t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test
new file mode 100644
index 00000000000..82312340336
--- /dev/null
+++ b/mysql-test/t/help.test
@@ -0,0 +1,115 @@
+-- source include/have_innodb.inc
+
+# category: topic: keyword:
+#
+# impossible_category_1
+# impossible_function_1
+# impossible_function_5
+# impossible_function_2
+# impossible_function_1
+# impossible_category_2
+# impossible_function_3
+# impossible_function_6
+# impossible_function_4
+# impossible_function_6
+# impossible_category_3
+# impossible_function_7
+
+insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1');
+select @category1_id:= 1;
+insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2');
+select @category2_id:= 2;
+insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id);
+select @category3_id:= 3;
+
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
+select @topic1_id:= 1;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
+select @topic2_id:= 2;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
+select @topic3_id:= 3;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
+select @topic4_id:= 4;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
+select @topic5_id:= 5;
+
+insert into mysql.help_keyword(help_keyword_id,name)values(1,'impossible_function_1');
+select @keyword1_id:= 1;
+insert into mysql.help_keyword(help_keyword_id,name)values(2,'impossible_function_5');
+select @keyword2_id:= 2;
+insert into mysql.help_keyword(help_keyword_id,name)values(3,'impossible_function_6');
+select @keyword3_id:= 3;
+
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword1_id,@topic2_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword2_id,@topic1_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic3_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic4_id);
+
+##############
+help 'function_of_my_dream';
+help '%possible_f%';
+help 'impossible_func%';
+help 'impossible_category%';
+help 'impossible_%';
+
+help '%function_1';
+help '%function_2';
+help '%function_3';
+help '%function_4';
+help '%function_5';
+help '%function_6';
+help '%function_7';
+
+help '%category_2';
+help 'impossible_function_1';
+help 'impossible_category_1';
+##############
+
+alter table mysql.help_relation type=innodb;
+alter table mysql.help_keyword type=innodb;
+alter table mysql.help_topic type=innodb;
+alter table mysql.help_category type=innodb;
+
+##############
+help 'function_of_my_dream';
+help '%possible_f%';
+help 'impossible_func%';
+help 'impossible_category%';
+help 'impossible_%';
+
+help '%function_1';
+help '%function_2';
+help '%function_3';
+help '%function_4';
+help '%function_5';
+help '%function_6';
+help '%function_7';
+
+help '%category_2';
+help 'impossible_function_1';
+help 'impossible_category_1';
+##############
+
+alter table mysql.help_relation type=myisam;
+alter table mysql.help_keyword type=myisam;
+alter table mysql.help_topic type=myisam;
+alter table mysql.help_category type=myisam;
+
+delete from mysql.help_topic where help_topic_id=@topic1_id;
+delete from mysql.help_topic where help_topic_id=@topic2_id;
+delete from mysql.help_topic where help_topic_id=@topic3_id;
+delete from mysql.help_topic where help_topic_id=@topic4_id;
+delete from mysql.help_topic where help_topic_id=@topic5_id;
+
+delete from mysql.help_category where help_category_id=@category3_id;
+delete from mysql.help_category where help_category_id=@category2_id;
+delete from mysql.help_category where help_category_id=@category1_id;
+
+delete from mysql.help_keyword where help_keyword_id=@keyword1_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword2_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword3_id;
+
+delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topic_id=@topic2_id;
+delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id;
+delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
+delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test
index bc2839bfb3a..ba4ec4a9ae4 100644
--- a/mysql-test/t/innodb-deadlock.test
+++ b/mysql-test/t/innodb-deadlock.test
@@ -2,7 +2,10 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
-drop table if exists t1;
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
#
# Testing of FOR UPDATE
@@ -36,3 +39,75 @@ select * from t1;
commit;
drop table t1;
+#
+# Testing of FOR UPDATE
+#
+
+connection con1;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 10), (1, 20), (2, 30);
+commit;
+set autocommit=0;
+select * from t2;
+update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
+select * from t2;
+select * from t1;
+
+connection con2;
+set autocommit=0;
+
+# The following query should hang because con1 is locking the page
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1, t2;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 0), (1, 20), (2, 30);
+commit;
+
+connection con1;
+select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
+select * from t2;
+select * from t1;
+
+connection con2;
+
+# The following query should hang because con1 is locking the page
+update t2 set a=2 where b = 0;
+select * from t2;
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1, t2;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index e46f5801418..6e7eb0ea06f 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -4,8 +4,10 @@
# Small basic test with ignore
#
+--disable_warnings
drop table if exists t1,t2,t3;
drop database if exists mysqltest;
+--enable_warnings
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb;
@@ -21,6 +23,8 @@ drop table t1;
#
# A bit bigger test
+# The 'replace_column' statements are needed because the cardinality calculated
+# by innodb is not always the same between runs
#
CREATE TABLE t1 (
@@ -42,12 +46,17 @@ update ignore t1 set id=id+1; # This will change all rows
select * from t1;
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102;
-# explain select level from t1 where level=1;
-# explain select level,id from t1 where level=1;
-# explain select level,id,parent_id from t1 where level=1;
+--replace_column 9 #
+explain select level from t1 where level=1;
+--replace_column 9 #
+explain select level,id from t1 where level=1;
+--replace_column 9 #
+explain select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1;
optimize table t1;
+--replace_column 7 #
+show keys from t1;
drop table t1;
#
@@ -85,6 +94,8 @@ select * from t1;
create index skr on t1 (a);
insert into t1 values (3,""), (4,"testing");
analyze table t1;
+--replace_column 7 #
+show keys from t1;
drop table t1;
@@ -222,6 +233,8 @@ drop table t1;
CREATE TABLE t1 (a int not null, b int not null,c int not null,
key(a),primary key(a,b), unique(c),key(a),unique(b));
+--replace_column 7 #
+show index from t1;
drop table t1;
#
@@ -338,7 +351,8 @@ update ignore t1 set id=id+1; # This will change all rows
select * from t1;
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102;
-# explain select level from t1 where level=1;
+--replace_column 9 #
+explain select level from t1 where level=1;
select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1 order by id;
@@ -395,6 +409,8 @@ create table t1 (a varchar(100) not null, primary key(a), b int not null) type=i
insert into t1 values("hello",1),("world",2);
select * from t1 order by b desc;
optimize table t1;
+--replace_column 7 #
+show keys from t1;
drop table t1;
#
@@ -439,6 +455,8 @@ DROP TABLE t1;
create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb;
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
+--replace_column 9 #
+explain select * from t1 where a > 0 and a < 50;
drop table t1;
#
@@ -469,6 +487,15 @@ UNLOCK TABLES;
DROP TABLE t1;
#
+# Test prefix key
+#
+create table t1 (a char(20), unique (a(5))) type=innodb;
+drop table t1;
+create table t1 (a char(20), index (a(5))) type=innodb;
+show create table t1;
+drop table t1;
+
+#
# Test using temporary table and auto_increment
#
@@ -516,6 +543,8 @@ insert into mysqltest.t3 values(1);
commit;
drop database mysqltest;
# Don't check error message
+--error 12,12
+show tables from mysqltest;
#
# Test truncate table with and without auto_commit
@@ -553,6 +582,22 @@ drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb;
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
+--replace_column 9 #
+explain select * from t1 order by a;
+--replace_column 9 #
+explain select * from t1 order by b;
+--replace_column 9 #
+explain select * from t1 order by c;
+--replace_column 9 #
+explain select a from t1 order by a;
+--replace_column 9 #
+explain select b from t1 order by b;
+--replace_column 9 #
+explain select a,b from t1 order by b;
+--replace_column 9 #
+explain select a,b from t1;
+--replace_column 9 #
+explain select a,b,c from t1;
drop table t1;
#
@@ -642,7 +687,6 @@ DROP TABLE t1;
#
# Test of multi-table-update
#
-drop table if exists t1,t2;
create table t1 (n int(10), d int(10)) type=innodb;
create table t2 (n int(10), d int(10)) type=innodb;
insert into t1 values(1,1),(1,2);
@@ -780,7 +824,6 @@ CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) TYPE=InnoDB;
SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
--- error 1196
ROLLBACK;
SELECT * FROM t1;
drop table t1,t2;
@@ -792,7 +835,6 @@ drop table t1;
#
# Test that MySQL priorities clustered indexes
#
-
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) type=innodb;
create table t2 (a int not null auto_increment primary key, b int);
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
@@ -815,7 +857,11 @@ insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1;
+--replace_column 9 #
+explain select * from t1 where c between 1 and 10000;
update t1 set c=a;
+--replace_column 9 #
+explain select * from t1 where c between 1 and 10000;
drop table t1,t2;
#
@@ -838,3 +884,44 @@ update t1 set b=100 where a=1 order by b desc limit 2;
update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
drop table t1;
+
+
+CREATE TABLE t1 (col1 int(1))TYPE=InnoDB;
+CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
+(stamp))TYPE=InnoDB;
+insert into t1 values (1),(2),(3);
+insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 );
+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
+'20020204120000' GROUP BY col1;
+drop table t1,t2;
+
+#
+# Test by Francois MASUREL
+#
+
+CREATE TABLE t1 (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `id_object` int(10) unsigned default '0',
+ `id_version` int(10) unsigned NOT NULL default '1',
+ label varchar(100) NOT NULL default '',
+ `description` text,
+ PRIMARY KEY (`id`),
+ KEY `id_object` (`id_object`),
+ KEY `id_version` (`id_version`)
+) TYPE=InnoDB;
+
+INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
+
+CREATE TABLE t2 (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `id_version` int(10) unsigned NOT NULL default '1',
+ PRIMARY KEY (`id`),
+ KEY `id_version` (`id_version`)
+) TYPE=InnoDB;
+
+INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
+
+SELECT t2.id, t1.label FROM t2 INNER JOIN
+(SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl
+ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
+drop table t1,t2;
diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test
index 9066a5f19ba..8a08c19703d 100644
--- a/mysql-test/t/innodb_cache.test
+++ b/mysql-test/t/innodb_cache.test
@@ -1,10 +1,14 @@
-- source include/have_innodb.inc
-- source include/have_query_cache.inc
+# Initialise
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
#
# Without auto_commit.
#
-drop table if exists t1, t2, t3;
flush status;
set autocommit=0;
create table t1 (a int not null) type=innodb;
diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test
index 6777e4f49bd..cf6ac9870ce 100644
--- a/mysql-test/t/innodb_handler.test
+++ b/mysql-test/t/innodb_handler.test
@@ -4,7 +4,10 @@
# test of HANDLER ...
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int, b char(10), key a(a), key b(a,b)) type=innodb;
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
diff --git a/mysql-test/t/ins000001.test b/mysql-test/t/ins000001.test
index 4d75b4e7fe3..afcd27ebfca 100644
--- a/mysql-test/t/ins000001.test
+++ b/mysql-test/t/ins000001.test
@@ -1,5 +1,8 @@
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');
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index be585157e63..9cc0bf8c46c 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -2,7 +2,10 @@
# Test of refering to old values
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int not null);
insert into t1 values (1);
insert into t1 values (a+2);
@@ -65,10 +68,11 @@ drop table t1;
# Test of mysqld crash with fully qualified column names
#
-drop database if exists foo;
-create database foo;
-use foo;
+--disable_warnings
+drop database if exists test_$1;
+--enable_warnings
+create database test_$1;
+use test_$1;
create table t1 (c int);
-insert into foo.t1 set foo.t1.c = '1';
-drop database foo;
-
+insert into test_$1.t1 set test_$1.t1.c = '1';
+drop database test_$1;
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 5c63f3b3bb7..556b1ac9c8f 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -2,7 +2,10 @@
# Problem with INSERT ... SELECT
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
@@ -84,7 +87,6 @@ let $VERSION=`select version()`;
--replace_result $VERSION VERSION
show binlog events;
drop table t1, t2;
-drop table if exists t1, t2;
#
# Test of insert ... select from same table
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
new file mode 100644
index 00000000000..4f19aca8738
--- /dev/null
+++ b/mysql-test/t/insert_update.test
@@ -0,0 +1,26 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
+INSERT t1 VALUES (1,2,10), (3,4,20);
+INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
+SELECT * FROM t1;
+INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
+SELECT * FROM t1;
+-- error 1062
+INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+INSERT t1 VALUES (1,2,10), (3,4,20);
+INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
+SELECT * FROM t1;
+INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a);
+SELECT *, VALUES(a) FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/isam.test b/mysql-test/t/isam.test
index e807112dab4..f6c05d0f4bb 100644
--- a/mysql-test/t/isam.test
+++ b/mysql-test/t/isam.test
@@ -1,6 +1,8 @@
-- source include/have_isam.inc
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
#
# Test possible problem with rows that are about 65535 bytes long
@@ -41,10 +43,14 @@ drop table t1;
#
# Test of some CREATE TABLE's that should fail
#
-!$1121 create table t1 (a int,b text, index(a)) type=isam;
-!$1073 create table t1 (a int,b text, index(b)) type=isam;
-!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
-!$1121 create table t1 (ordid int(8), unique (ordid)) type=isam;
+--error 1121
+create table t1 (a int,b text, index(a)) type=isam;
+--error 1073
+create table t1 (a int,b text, index(b)) type=isam;
+--error 1075
+create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
+--error 1121
+create table t1 (ordid int(8), unique (ordid)) type=isam;
drop table if exists t1;
#
@@ -66,6 +72,24 @@ show index from t1;
drop table t1,t2;
#
+# Test of some show commands
+#
+
+create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
+insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
+create table t2 type=isam select * from t1;
+optimize table t1;
+check table t1,t2;
+repair table t1,t2;
+check table t2,t1;
+lock tables t1 write;
+check table t2,t1;
+show columns from t1;
+show full columns from t1;
+show index from t1;
+drop table t1,t2;
+
+#
# test of table with huge number of packed fields
#
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 19e04d2aa7e..e8977ae9b62 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -1,6 +1,8 @@
#
# Initialization
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
#
# Test different join syntaxes
@@ -25,7 +27,6 @@ drop table t1,t2;
# This failed for lia Perminov
#
-
create table t1 (id int primary key);
create table t2 (id int);
insert into t1 values (75);
@@ -111,7 +112,7 @@ drop table t1, t2;
create table t1 (a int primary key);
insert into t1 values(1),(2);
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
---replace_result "31 tables" "XX tables" "63 tables" "XX tables"
+--replace_result "31 tables" "XX tables" "62 tables" "XX tables"
--error 1116
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
drop table t1;
diff --git a/mysql-test/t/join_crash.test b/mysql-test/t/join_crash.test
index 4606b23f726..ada6e56e664 100644
--- a/mysql-test/t/join_crash.test
+++ b/mysql-test/t/join_crash.test
@@ -2,7 +2,10 @@
# This test gave a core dump
#
+--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4;
+--enable_warnings
+
CREATE TABLE t1 (
project_id int(11) NOT NULL auto_increment,
project_row_lock int(11) NOT NULL default '0',
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index ee7d55d2a4e..a63defff540 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -2,7 +2,9 @@
# test of left outer join
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5;
+--enable_warnings
CREATE TABLE t1 (
grp int(11) default NULL,
@@ -109,7 +111,6 @@ drop table t1,t2;
# Test of LEFT JOIN with const tables (failed for frankie@etsetb.upc.es)
#
-drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
cod_asig int(11) DEFAULT '0' NOT NULL,
desc_larga_cat varchar(80) DEFAULT '' NOT NULL,
@@ -416,7 +417,7 @@ explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30;
drop table t1,t2;
-drop table if exists t3;
+
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index cb80d88aee8..3b4cd7358cc 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -1,8 +1,12 @@
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
#
# This failed for Elizabeth Mattijsen
#
-drop table if exists t1,t2,t3;
CREATE TABLE t1 (
ID CHAR(32) NOT NULL,
name CHAR(32) NOT NULL,
@@ -173,7 +177,6 @@ drop table t1;
# Problem with UNIQUE() with NULL parts and auto increment
#
-DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
UNIQUE (c,i));
INSERT INTO t1 (c) VALUES (NULL),(NULL);
diff --git a/mysql-test/t/key_cache-master.opt b/mysql-test/t/key_cache-master.opt
new file mode 100644
index 00000000000..66e19c18a8a
--- /dev/null
+++ b/mysql-test/t/key_cache-master.opt
@@ -0,0 +1 @@
+--key_buffer_size=2M --small.key_buffer_size=256K --small.key_buffer_size=128K
diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test
new file mode 100644
index 00000000000..fb6b6b0027f
--- /dev/null
+++ b/mysql-test/t/key_cache.test
@@ -0,0 +1,42 @@
+#
+# Test of key cache
+#
+
+SET @save_key_buffer=@@key_buffer_size;
+
+SELECT @@key_buffer_size, @@small.key_buffer_size;
+
+# Change default key cache size
+SET @@global.key_buffer_size=16*1024*1024;
+SET @@global.default.key_buffer_size=16*1024*1024;
+SET @@global.default.key_buffer_size=16*1024*1024;
+
+SET @@global.small.key_buffer_size=1*1024*1024;
+SET @@global.medium.key_buffer_size=4*1024*1024;
+# Drop buffer
+SET @@global.medium.key_buffer_size=0;
+# Test double drop
+SET @@global.medium.key_buffer_size=0;
+
+# Print key buffer with different syntaxes
+SHOW VARIABLES like "key_buffer_size";
+SELECT @@key_buffer_size;
+SELECT @@global.key_buffer_size;
+SELECT @@global.default.key_buffer_size;
+SELECT @@global.default.`key_buffer_size`;
+SELECT @@global.`default`.`key_buffer_size`;
+SELECT @@`default`.key_buffer_size;
+
+SELECT @@small.key_buffer_size;
+SELECT @@medium.key_buffer_size;
+
+SET @@global.key_buffer_size=@save_key_buffer;
+
+#
+# Errors
+#
+
+--error 1064
+SELECT @@default.key_buffer_size;
+--error 1271
+SELECT @@skr.table_type="test";
diff --git a/mysql-test/t/key_diff.test b/mysql-test/t/key_diff.test
index 60afb5f81a4..b4e4339ae33 100644
--- a/mysql-test/t/key_diff.test
+++ b/mysql-test/t/key_diff.test
@@ -1,7 +1,10 @@
#
# Check on condition on different length keys.
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
a char(5) NOT NULL,
b char(4) NOT NULL,
diff --git a/mysql-test/t/key_primary.test b/mysql-test/t/key_primary.test
index 2cdb117128f..816365c517c 100644
--- a/mysql-test/t/key_primary.test
+++ b/mysql-test/t/key_primary.test
@@ -2,7 +2,10 @@
# test of primary key conversions
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (t1 char(3) primary key);
insert into t1 values("ABC");
insert into t1 values("ABA");
diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test
index 3bd757aa069..e7ec63afe54 100644
--- a/mysql-test/t/keywords.test
+++ b/mysql-test/t/keywords.test
@@ -2,7 +2,10 @@
# Test keywords as fields
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (time time, date date, timestamp timestamp);
insert into t1 values ("12:22:22","97:02:03","1997-01-02");
select * from t1;
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index 6bcc43ac916..65d4f27059f 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -11,7 +11,10 @@ connect (con2, localhost, root,,);
#remember id of con1
connection con1;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (kill_id int);
insert into t1 values(connection_id());
diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test
index d4f6ce186cf..88a9831aa68 100644
--- a/mysql-test/t/limit.test
+++ b/mysql-test/t/limit.test
@@ -2,7 +2,10 @@
# Test of update and delete with limit
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int primary key, b int not null);
insert into t1 () values (); -- Testing default values
insert into t1 values (1,1),(2,1),(3,1);
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 732ed248702..1720ae69bbb 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -2,7 +2,9 @@
# Some simple test of load data
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 385713174d2..0868cf2c4b1 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -2,7 +2,9 @@
# Testing of table locking
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
CREATE TABLE t1 ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) TYPE=MyISAM;
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
LOCK TABLE t1 WRITE;
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 0295fca29e7..fa095275182 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -6,9 +6,11 @@
#
-- source include/not_embedded.inc
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
-# test to see if select will get the lock ahead of low priority update
+# Test to see if select will get the lock ahead of low priority update
connect (locker,localhost,root,,);
connect (reader,localhost,root,,);
diff --git a/mysql-test/t/lock_tables_lost_commit.test b/mysql-test/t/lock_tables_lost_commit.test
index a12ee7369cb..a8a7a65bd76 100644
--- a/mysql-test/t/lock_tables_lost_commit.test
+++ b/mysql-test/t/lock_tables_lost_commit.test
@@ -4,7 +4,9 @@ connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(a int) type=innodb;
lock tables t1 write;
insert into t1 values(10);
diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test
index 86ea2918fd2..2e5cb5f89fc 100644
--- a/mysql-test/t/lowercase_table.test
+++ b/mysql-test/t/lowercase_table.test
@@ -2,7 +2,10 @@
# Test of --lower-case-table-names
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+
create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
SELECT * FROM t1;
@@ -15,15 +18,12 @@ ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
show tables like 't_';
drop table t3;
-
#
# Test alias
#
create table t1 (a int);
select count(*) from T1;
select count(*) from t1;
---error 1109
select count(T1.a) from t1;
---error 1109
select count(bags.a) from t1 as Bags;
drop table t1;
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index b625e780f1f..c3bffa4f2fb 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -2,7 +2,11 @@
# test of MERGE TABLES
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
+drop database if exists mysqltest;
+--enable_warnings
+
create table t1 (a int not null primary key auto_increment, message char(20));
create table t2 (a int not null primary key auto_increment, message char(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
@@ -45,12 +49,23 @@ show create table t3;
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
--error 1016
select * from t4;
---error 1212
-create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
+--error 1016
+alter table t4 add column c int;
-# Because of windows, it's important that we drop the merge tables first!
-drop table if exists t5,t4,t3,t1,t2;
+#
+# Test tables in different databases
+#
+create database mysqltest;
+create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
+create table t5 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,mysqltest.t6);
+show create table t5;
+alter table t5 type=myisam;
+drop table t5, mysqltest.t6;
+drop database mysqltest;
+# Because of windows, it's important that we drop the merge tables first!
+drop table t4,t3,t1,t2;
+
create table t1 (c char(10)) type=myisam;
create table t2 (c char(10)) type=myisam;
create table t3 (c char(10)) union=(t1,t2) type=merge;
@@ -110,10 +125,9 @@ select * from t1;
drop table t1;
#
-# Bug found by Monty.
+# Bug in flush tables combined with MERGE tables
#
-drop table if exists t3, t2, t1;
create table t1 (a int not null, b int not null, key(a,b));
create table t2 (a int not null, b int not null, key(a,b));
create table t3 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2);
@@ -127,7 +141,6 @@ drop table t3,t1,t2;
# [phi] testing INSERT_METHOD stuff
#
-drop table if exists t6, t5, t4, t3, t2, t1;
# first testing of common stuff with new parameters
create table t1 (a int not null, b int not null auto_increment, primary key(a,b));
create table t2 (a int not null, b int not null auto_increment, primary key(a,b));
@@ -175,21 +188,22 @@ select * from t1 order by a,b;
select * from t2 order by a,b;
select * from t5 order by a,b;
select * from t6 order by a,b;
-drop table if exists t6, t5, t4, t3, t2, t1;
+insert into t1 values (99,NULL);
+select * from t4 where a+0 > 90;
+drop table t6, t5, t4, t3, t2, t1;
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,1);
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,2), (2,2);
-CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
-select max(b) from t where a = 2;
+CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
+select max(b) from t3 where a = 2;
select max(b) from t1 where a = 2;
-drop table if exists t,t1,t2;
+drop table t3,t1,t2;
#
# temporary merge tables
#
-drop table if exists t1, t2, t3, t4, t5, t6;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
@@ -202,13 +216,12 @@ insert into t4 values (1);
insert into t5 values (2);
create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
select * from t6;
-drop table if exists t1, t2, t3, t4, t5, t6;
+drop table t6, t3, t1, t2, t4, t5;
#
# testing merge::records_in_range and optimizer
#
-DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
fileset_id tinyint(3) unsigned NOT NULL default '0',
file_code varchar(32) NOT NULL default '',
@@ -235,7 +248,7 @@ EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
AND file_code = '0000000115' LIMIT 1;
-DROP TABLE IF EXISTS t1, t2;
+DROP TABLE t2, t1;
#
# Test of ORDER BY DESC on key (Bug #515)
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 7aa4e74cec0..6b59778bbce 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -2,7 +2,10 @@
# Test of update statement that uses many tables.
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3));
@@ -99,7 +102,7 @@ INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'20
00:00:00'),(7,'2002-07-22 00:00:00');
delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id;
select * from t3;
-DROP TABLE IF EXISTS t1,t2,t3;
+DROP TABLE t1,t2,t3;
CREATE TABLE IF NOT EXISTS `t1` (
`id` int(11) NOT NULL auto_increment,
@@ -127,8 +130,7 @@ select * from t2;
UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id;
select * from t2;
-
-drop table if exists t1, t2 ;
+drop table t1, t2 ;
create table t1 (n numeric(10));
create table t2 (n numeric(10));
@@ -213,8 +215,14 @@ insert into t2 values(1,10),(1,20);
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
select * from t1;
select * from t2;
+UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n;
+select * from t1;
+select * from t2;
+DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n;
+select * from t1;
+select * from t2;
drop table t1,t2;
-drop table if exists t1,t2,t3;
+
CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,'');
CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM;
@@ -223,7 +231,7 @@ CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT
INSERT INTO t3 VALUES (1,'jedan'),(2,'dva');
update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj;
update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj;
-drop table if exists t1,t2,t3;
+drop table t1,t2,t3;
#
# Test multi update with different join methods
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 02c92109816..2918628e6f3 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -3,7 +3,10 @@
#
# Initialise
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+SET SQL_WARNINGS=1;
#
# Test problem with CHECK TABLE;
@@ -11,7 +14,7 @@ drop table if exists t1,t2;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
- KEY STRING_DATA (STRING_DATA)
+ KEY string_data (STRING_DATA)
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
@@ -31,11 +34,13 @@ create table t1 (a tinyint not null auto_increment, b blob not null, primary key
let $1=100;
disable_query_log;
+SET SQL_WARNINGS=0;
while ($1)
{
eval insert into t1 (b) values(repeat(char(65+$1),65550-$1));
dec $1;
}
+SET SQL_WARNINGS=1;
enable_query_log;
check table t1;
repair table t1;
@@ -88,7 +93,6 @@ DROP TABLE t1;
# in ha_myisam::repair, and index size is changed (decreased).
#
-drop table if exists t1;
create table t1 ( t1 char(255), key(t1(250)));
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
@@ -294,6 +298,9 @@ insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
update t1 set b=repeat('a',256);
update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
check table t1;
+delete from t1 where i8=1;
+select * from t1;
+check table t1;
drop table t1;
#
@@ -351,4 +358,15 @@ explain select * from t1,t2 where t1.b=t2.b;
explain select * from t1,t2 force index(c) where t1.a=t2.a;
explain select * from t1 where a=0 or a=2;
explain select * from t1 force index (a) where a=0 or a=2;
+explain select * from t1 where c=1;
+explain select * from t1 use index() where c=1;
drop table t1,t2;
+
+#
+# Test RTREE index
+#
+--error 1235
+CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
+# INSERT INTO t1 VALUES (1,1),(1,1);
+# DELETE FROM rt WHERE a<1;
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test
index 6fea7f0d10d..fa36249dce0 100644
--- a/mysql-test/t/null.test
+++ b/mysql-test/t/null.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
#
# Testing of NULL in a lot of different places
#
@@ -15,7 +20,6 @@ SELECT (NULL OR NULL) IS NULL;
select NULL AND 0, 0 and NULL;
select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
-drop table if exists t1;
create table t1 (x int);
insert into t1 values (null);
select * from t1 where x != 0;
diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test
index b1cbd5cdfb0..7d9500e90dd 100644
--- a/mysql-test/t/null_key.test
+++ b/mysql-test/t/null_key.test
@@ -1,7 +1,10 @@
#
# Check null keys
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
explain select * from t1 where a is null;
@@ -11,6 +14,7 @@ explain select * from t1 where a=2 and b = 2;
explain select * from t1 where a<=>b limit 2;
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
explain select * from t1 where (a is null or a = 7) and b=7;
+explain select * from t1 where (a is null or a = 7) and b=7 order by a;
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
explain select * from t1 where a > 1 and a < 3 limit 1;
@@ -22,6 +26,8 @@ select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
select * from t1 where (a is null or a = 7) and b=7;
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
+create table t2 like t1;
+insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
explain select * from t1 where a is null and b = 2;
explain select * from t1 where a is null and b = 2 and c=0;
@@ -44,14 +50,43 @@ select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
select * from t1 where (a is null or a = 7) and b=7 and c=0;
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
select * from t1 where b like "6%";
-drop table t1;
+#
+# Test ref_or_null optimization
+#
+drop table t1;
+rename table t2 to t1;
+alter table t1 modify b int null;
+insert into t1 values (7,null), (8,null), (8,7);
+explain select * from t1 where a = 7 and (b=7 or b is null);
+select * from t1 where a = 7 and (b=7 or b is null);
+explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
+select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
+explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
+select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
+create table t2 (a int);
+insert into t2 values (7),(8);
+explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
+drop index b on t1;
+explain select * from t2,t1 where t1.a=t2.a and b is null;
+select * from t2,t1 where t1.a=t2.a and b is null;
+explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
+select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
+explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
+select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
+explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
+select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
+insert into t2 values (null),(6);
+delete from t1 where a=8;
+explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
+explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
+select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
+drop table t1,t2;
#
# The following failed for Matt Loschert
#
-DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
uniq_id int(10) unsigned default NULL,
diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test
index 3e0fc214d3e..9aac5948359 100644
--- a/mysql-test/t/odbc.test
+++ b/mysql-test/t/odbc.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
#
# Test some ODBC compatibility
#
@@ -8,7 +13,6 @@ select {fn length("hello")}, { date "1997-10-20" };
# Test retreiving row with last insert_id value.
#
-drop table if exists t1;
create table t1 (a int not null auto_increment,b int not null,primary key (a,b));
insert into t1 SET A=NULL,B=1;
insert into t1 SET a=null,b=2;
diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test
index 8fe547db615..17bf6230f76 100644
--- a/mysql-test/t/olap.test
+++ b/mysql-test/t/olap.test
@@ -1,27 +1,90 @@
-drop table if exists sales;
-create table sales ( product varchar(32), country varchar(32), year int, profit int);
-insert into sales values ( 'Computer', 'India',2000, 1200),
-( 'TV', 'United States', 1999, 150),
-( 'Calculator', 'United States', 1999,50),
-( 'Computer', 'United States', 1999,1500),
-( 'Computer', 'United States', 2000,1500),
-( 'TV', 'United States', 2000, 150),
-( 'TV', 'India', 2000, 100),
-( 'TV', 'India', 2000, 100),
-( 'Calculator', 'United States', 2000,75),
-( 'Calculator', 'India', 2000,75),
-( 'TV', 'India', 1999, 100),
-( 'Computer', 'India', 1999,1200),
-( 'Computer', 'United States', 2000,1500),
-( 'Calculator', 'United States', 2000,75);
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1 (product varchar(32), country_id int not null, year int, profit int);
+insert into t1 values ( 'Computer', 2,2000, 1200),
+( 'TV', 1, 1999, 150),
+( 'Calculator', 1, 1999,50),
+( 'Computer', 1, 1999,1500),
+( 'Computer', 1, 2000,1500),
+( 'TV', 1, 2000, 150),
+( 'TV', 2, 2000, 100),
+( 'TV', 2, 2000, 100),
+( 'Calculator', 1, 2000,75),
+( 'Calculator', 2, 2000,75),
+( 'TV', 1, 1999, 100),
+( 'Computer', 1, 1999,1200),
+( 'Computer', 2, 2000,1500),
+( 'Calculator', 2, 2000,75),
+( 'Phone', 3, 2003,10)
+;
+
+create table t2 (country_id int primary key, country char(20) not null);
+insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
+
+# First simple rollups, with just grand total
+select product, sum(profit) from t1 group by product;
+select product, sum(profit) from t1 group by product with rollup;
+select product, sum(profit) from t1 group by 1 with rollup;
+select product, sum(profit),avg(profit) from t1 group by product with rollup;
+
+# Sub totals
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup;
+
+# limit
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 5;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 3,3;
+
+select product, country_id, count(*), count(distinct year) from t1 group by product, country_id;
+select product, country_id, count(*), count(distinct year) from t1 group by product, country_id with rollup;
+
+# Test of having
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having country_id = 1;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 200;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 7000;
+
+# Functions
+select concat(product,':',country_id) as 'prod', concat(":",year,":") as 'year',1+1, sum(profit)/count(*) from t1 group by 1,2 with rollup;
+select product, sum(profit)/count(*) from t1 group by product with rollup;
+select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
+select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup;
+
+# Joins
+select product, country , year, sum(profit) from t1,t2 where t1.country_id=t2.country_id group by product, country, year with rollup;
+
+# Derived tables and sub selects
+select product, `sum` from (select product, sum(profit) as 'sum' from t1 group by product with rollup) as tmp where product is null;
+select product from t1 where exists (select product, country_id , sum(profit) from t1 as t2 where t1.product=t2.product group by product, country_id with rollup having sum(profit) > 6000);
+
+# The following doesn't return the expected answer, but this is a limitation
+# in the implementation so we should just document it
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year having country_id is NULL;
+select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup;
+
+# Error handling
+
+# Cube is not yet implemented
--error 1235
-select product, country , year, sum(profit) from sales group by product, country, year with cube;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
--error 1235
-explain select product, country , year, sum(profit) from sales group by product, country, year with cube;
+explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
--error 1235
-select product, country , year, sum(profit) from sales group by product, country, year with rollup;
---error 1235
-explain select product, country , year, sum(profit) from sales group by product, country, year with rollup;
---error 1235
-select product, country , year, sum(profit) from sales group by product, country, year with cube union all select product, country , year, sum(profit) from sales group by product, country, year with rollup;
-drop table sales;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+
+drop table t1,t2;
+
+#
+# Test bug with const tables
+#
+
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES(100);
+CREATE TABLE t2 (i int);
+INSERT INTO t2 VALUES (100),(200);
+SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP;
+SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP;
+drop table t1,t2;
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 25790f24738..39612f680f3 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -2,7 +2,9 @@
# Use mysql-test-run with --with-openssl option.
-- source include/have_openssl_1.inc
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(f1 int);
insert into t1 values (5);
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 1fb83509ebb..702feedc3ce 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -2,7 +2,9 @@
# Bug with order by
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
CREATE TABLE t1 (
id int(6) DEFAULT '0' NOT NULL,
@@ -168,7 +170,6 @@ drop table t1,t2,t3;
#bug reported by Wouter de Jong
-drop table if exists t1;
CREATE TABLE t1 (
member_id int(11) NOT NULL auto_increment,
inschrijf_datum varchar(20) NOT NULL default '',
@@ -345,3 +346,22 @@ SELECT * FROM t1 ORDER BY (a + b);
SELECT * FROM t1 ORDER BY (a + b) DESC;
DROP TABLE t1;
+#
+# Test of test_if_subkey() function
+#
+CREATE TABLE t1 (
+ FieldKey varchar(36) NOT NULL default '',
+ LongVal bigint(20) default NULL,
+ StringVal mediumtext,
+ KEY FieldKey (FieldKey),
+ KEY LongField (FieldKey,LongVal),
+ KEY StringField (FieldKey,StringVal(32))
+);
+INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
+EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+DROP TABLE t1;
diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test
index 6419f2a93df..37620ebe331 100644
--- a/mysql-test/t/order_fill_sortbuf.test
+++ b/mysql-test/t/order_fill_sortbuf.test
@@ -3,7 +3,10 @@
# rows MySQL needs to use a merge during the sort phase.
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
CREATE TABLE `t1` (
`id` int(11) NOT NULL default '0',
`id2` int(11) NOT NULL default '0',
diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test
index c126d221bd2..a944df01051 100644
--- a/mysql-test/t/outfile.test
+++ b/mysql-test/t/outfile.test
@@ -21,3 +21,8 @@
#select * into dumpfile "/tmp/select-test.99" from t1;
#select load_file("/tmp/select-test.not-exist");
#drop table t1;
+#drop table if exists t;
+#CREATE TABLE t ( t timestamp NOT NULL, c char(200) character set latin1 NOT NULL default '', i int(11), v varchar(200), b blob, KEY t (t)) TYPE=MyISAM;
+#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb");
+#select * from t into outfile "check";
+#drop table if exists t;
diff --git a/mysql-test/t/preload.test b/mysql-test/t/preload.test
new file mode 100644
index 00000000000..7357b42c599
--- /dev/null
+++ b/mysql-test/t/preload.test
@@ -0,0 +1,100 @@
+#
+# Testing of PRELOAD
+#
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+
+create table t1 (
+ a int not null auto_increment,
+ b char(16) not null,
+ primary key (a),
+ key (b)
+);
+
+create table t2(
+ a int not null auto_increment,
+ b char(16) not null,
+ primary key (a),
+ key (b)
+);
+
+insert into t1(b) values
+ ('test0'),
+ ('test1'),
+ ('test2'),
+ ('test3'),
+ ('test4'),
+ ('test5'),
+ ('test6'),
+ ('test7');
+
+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;
+
+select count(*) from t1;
+select count(*) from t2;
+
+flush tables; flush status;
+show status like "key_read%";
+
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+select @@preload_buffer_size;
+load index into cache t1 keys;
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+set session preload_buffer_size=256*1024;
+select @@preload_buffer_size;
+load index into cache t1 keys ignore leaves;
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+set session preload_buffer_size=1*1024;
+select @@preload_buffer_size;
+load index into cache t1 keys, t2 keys (primary,b) ignore leaves;
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+select count(*) from t2 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+load index into cache t3 keys, t2 keys (primary,b) ;
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+load index into cache t3 keys (b), t2 keys (c) ;
+show status like "key_read%";
+
+drop table t1, t2;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 9e1c22ac642..dcdf70ee612 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -10,8 +10,10 @@ flush query cache; # This crashed in some versions
flush query cache; # This crashed in some versions
reset query cache;
flush status;
+--disable_warnings
drop table if exists t1,t2,t3;
drop database if exists mysqltest;
+--enable_warnings
#
# First simple test
@@ -258,8 +260,9 @@ show status like "Qcache_queries_in_cache";
#
# Charset convertion (cp1251_koi8 always present)
#
-create table t1 (a char(1) not null);
-insert into t1 values("á");
+create table t1 (a char(1) not null collate koi8r_general_ci);
+insert into t1 values(_koi8r"á");
+set CHARACTER SET koi8r;
select * from t1;
set CHARACTER SET cp1251_koi8;
select * from t1;
@@ -342,6 +345,40 @@ drop table t1;
show status like "Qcache_queries_in_cache";
#
+# Test of min result data unit size changing
+#
+show global variables like "query_cache_min_res_unit";
+set GLOBAL query_cache_min_res_unit=1001;
+show global variables like "query_cache_min_res_unit";
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+select * from t1;
+select * from t1;
+select * from t2;
+select * from t2;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+drop table t1;
+select a from t2;
+select a from t2;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+drop table t2;
+set GLOBAL query_cache_min_res_unit=default;
+show global variables like "query_cache_min_res_unit";
+
+#
+# Case sensitive test
+#
+create table t1 (a int not null);
+insert into t1 values (1);
+select "aaa" from t1;
+select "AAA" from t1;
+drop table t1;
+
+#
# Test of query cache resizing
#
create table t1 (a int);
@@ -387,6 +424,7 @@ select * from t2;
show status like "Qcache_queries_in_cache";
select * from t3;
show status like "Qcache_queries_in_cache";
+update t1 set i=(select distinct 1 from (select * from t2) a);
drop table t1, t2, t3;
#
@@ -429,7 +467,6 @@ drop table t1;
#
# INTO OUTFILE/DUMPFILE test
#
-drop table if exists t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
show status like "Qcache_queries_in_cache";
diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test
index 4032993f2da..395a04615cb 100644
--- a/mysql-test/t/raid.test
+++ b/mysql-test/t/raid.test
@@ -7,10 +7,18 @@ enable_query_log;
# Test of raided tables
#
-create database test_raid;
-create table test_raid.r1 (i int) raid_type=1;
-drop database test_raid;
+--disable_warnings
DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+#
+# Test dropping database with raid tables
+#
+
+create database test_$1;
+create table test_$1.r1 (i int) raid_type=1;
+drop database test_$1;
+
CREATE TABLE t1 (
id int unsigned not null auto_increment primary key,
c char(255) not null
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index 521709eddee..70780a0676a 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -2,7 +2,10 @@
# Problem with range optimizer
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
event_date date DEFAULT '0000-00-00' NOT NULL,
type int(11) DEFAULT '0' NOT NULL,
diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test
index ce4651d8de3..48a9cb401d9 100644
--- a/mysql-test/t/rename.test
+++ b/mysql-test/t/rename.test
@@ -2,7 +2,10 @@
# Test of rename table
#
+--disable_warnings
drop table if exists t0,t1,t2,t3,t4;
+--enable_warnings
+
create table t0 SELECT 1,"table 1";
create table t2 SELECT 2,"table 2";
create table t3 SELECT 3,"table 3";
@@ -29,4 +32,6 @@ rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
select * from t1;
select * from t2;
select * from t3;
+
+# This should give a warning for t4
drop table if exists t1,t2,t3,t4;
diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair_part1.test
index 159fc090653..2657f91cd02 100644
--- a/mysql-test/t/repair.test
+++ b/mysql-test/t/repair_part1.test
@@ -2,7 +2,10 @@
# Test of repair table
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 SELECT 1,"table 1";
repair table t1 use_frm;
alter table t1 TYPE=HEAP;
diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test
index e9e01615a62..2afce2fcc84 100644
--- a/mysql-test/t/replace.test
+++ b/mysql-test/t/replace.test
@@ -4,7 +4,9 @@
# Test of REPLACE with ISAM and MyISAM and HEAP
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
@@ -25,12 +27,13 @@ drop table t1;
# Test when using replace on a key that has used up it's whole range
#
-create table t1 (a tinyint not null auto_increment primary key, b char(20));
-insert into t1 values (126,"first"),(0,"last");
+create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
+insert into t1 values (126,"first"),(63, "middle"),(0,"last");
--error 1062
insert into t1 values (0,"error");
--error 1062
replace into t1 values (0,"error");
replace into t1 values (126,"first updated");
+replace into t1 values (63,default);
select * from t1;
drop table t1;
diff --git a/mysql-test/t/rollback.test b/mysql-test/t/rollback.test
index 6ea2cca887f..1673f1648d3 100644
--- a/mysql-test/t/rollback.test
+++ b/mysql-test/t/rollback.test
@@ -2,13 +2,20 @@
# This test should fail as MyISAM doesn't have rollback
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (n int not null primary key) type=myisam;
begin work;
insert into t1 values (4);
insert into t1 values (5);
-# Should give an error
-!$1196 rollback;
+rollback;
+select @@warning_count;
+select @@error_count;
+show warnings;
+show errors;
select * from t1;
+select @@warning_count;
+show warnings;
drop table t1;
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
new file mode 100644
index 00000000000..252830cfc98
--- /dev/null
+++ b/mysql-test/t/row.test
@@ -0,0 +1,83 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3));
+select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
+select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
+select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
+select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'));
+select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3));
+select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3));
+select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
+select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
+select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3));
+select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
+select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)));
+-- error 1240
+select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
+select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
+
+SELECT (1,2,3)=(0,NULL,3);
+SELECT (1,2,3)=(1,NULL,3);
+# here's something for Sanja to fix :)
+SELECT (1,2,3)=(1,NULL,0);
+
+SELECT ROW(1,2,3)=ROW(1,2,3);
+SELECT ROW(2,2,3)=ROW(1+1,2,3);
+SELECT ROW(1,2,3)=ROW(1+1,2,3);
+SELECT ROW(1,2,3)<ROW(1+1,2,3);
+SELECT ROW(1,2,3)>ROW(1+1,2,3);
+SELECT ROW(1,2,3)<=ROW(1+1,2,3);
+SELECT ROW(1,2,3)>=ROW(1+1,2,3);
+SELECT ROW(1,2,3)<>ROW(1+1,2,3);
+SELECT ROW(NULL,2,3)=ROW(NULL,2,3);
+SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3);
+SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5));
+SELECT ROW('test',2,3.33)=ROW('test',2,3.33);
+-- error 1240
+SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4);
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33));
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3));
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL));
+-- error 1240
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4);
+
+create table t1 ( a int, b int, c int);
+insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL);
+select * from t1 where ROW(1,2,3)=ROW(a,b,c);
+select * from t1 where ROW(0,2,3)=ROW(a,b,c);
+select * from t1 where ROW(1,2,3)<ROW(a,b,c);
+select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1;
+select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1;
+select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1;
+select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1;
+drop table t1;
+
+-- error 1240
+select ROW(1,1);
+
+create table t1 (i int);
+-- error 1240
+select 1 from t1 where ROW(1,1);
+-- error 1240
+select count(*) from t1 order by ROW(1,1);
+-- error 1240
+select count(*) from t1 having (1,1) order by i;
+drop table t1;
+
+create table t1 (a int, b int);
+insert into t1 values (1, 4);
+insert into t1 values (10, 40);
+insert into t1 values (1, 4);
+insert into t1 values (10, 43);
+insert into t1 values (1, 4);
+insert into t1 values (10, 41);
+insert into t1 values (1, 4);
+insert into t1 values (10, 43);
+insert into t1 values (1, 4);
+select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a;
+drop table t1;
+SELECT ROW(2,10) <=> ROW(3,4);
+SELECT ROW(NULL,10) <=> ROW(3,NULL);
diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test
index ebce3d0ac94..f464f1e2751 100644
--- a/mysql-test/t/rpl000001.test
+++ b/mysql-test/t/rpl000001.test
@@ -1,5 +1,5 @@
source include/master-slave.inc;
-drop table if exists t1,t2,t3;
+
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
@@ -12,11 +12,11 @@ select * from t1 limit 10;
save_master_pos;
connection slave;
sync_with_master;
-slave stop;
+stop slave;
connection master;
set password for root@"localhost" = password('foo');
connection slave;
-slave start;
+start slave;
connection master;
#
# Give slave time to do at last one failed connect retry
@@ -43,7 +43,7 @@ sync_with_master;
connection master;
reset master;
connection slave;
-slave stop;
+stop slave;
reset slave;
connection master;
@@ -62,7 +62,7 @@ enable_query_log;
# Try to cause a large relay log lag on the slave
connection slave;
select get_lock("hold_slave",10);
-slave start;
+start slave;
#hope this is long enough for I/O thread to fetch over 16K relay log data
sleep 3;
select release_lock("hold_slave");
@@ -100,7 +100,7 @@ wait_for_slave_to_stop;
# show slave status;
set global sql_slave_skip_counter=1;
-slave start;
+start slave;
select count(*) from t1;
connection master1;
drop table t1;
diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl000002.test
index caf0b4ef6d8..803eb069b66 100644
--- a/mysql-test/t/rpl000002.test
+++ b/mysql-test/t/rpl000002.test
@@ -1,33 +1,26 @@
source include/master-slave.inc;
-drop table if exists t1;
+
create table t1 (n int auto_increment primary key);
set insert_id = 2000;
insert into t1 values (NULL),(NULL),(NULL);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
--replace_result $SLAVE_MYPORT 9999
show slave hosts;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
-slave stop;
+sync_slave_with_master;
+stop slave;
connection master;
-drop table if exists t2;
create table t2(id int auto_increment primary key, created datetime);
set timestamp=12345;
insert into t2 set created=now();
select * from t2;
save_master_pos;
connection slave;
-slave start;
+start slave;
sync_with_master;
select * from t2;
connection master;
drop table t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000003.test b/mysql-test/t/rpl000003.test
deleted file mode 100644
index f994ed94371..00000000000
--- a/mysql-test/t/rpl000003.test
+++ /dev/null
@@ -1,14 +0,0 @@
-source include/master-slave.inc;
-drop table if exists t1;
-create table t1(n int primary key);
-!insert into t1 values (1),(2),(2);
-insert into t1 values (3);
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
-connection master;
-drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test
index 705e0d51b7b..8fc2977faab 100644
--- a/mysql-test/t/rpl000004.test
+++ b/mysql-test/t/rpl000004.test
@@ -1,18 +1,14 @@
source include/master-slave.inc;
+
set SQL_LOG_BIN=0;
-drop table if exists t1;
create table t1 (word char(20) not null, index(word));
load data infile '../../std_data/words.dat' into table t1;
-drop table if exists t2;
create table t2 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t2;
create table t3 (word char(20) not null primary key);
connection slave;
-drop table if exists t1;
load table t1 from master;
-drop table if exists t2;
load table t2 from master;
-drop table if exists t3;
load table t3 from master;
check table t1;
select count(*) from t2;
diff --git a/mysql-test/t/rpl000005.test b/mysql-test/t/rpl000005.test
index 1cfea242b69..ae713633df3 100644
--- a/mysql-test/t/rpl000005.test
+++ b/mysql-test/t/rpl000005.test
@@ -1,5 +1,5 @@
source include/master-slave.inc;
-drop table if exists t1;
+
CREATE TABLE t1 (name varchar(64), age smallint(3));
INSERT INTO t1 SET name='Andy', age=31;
INSERT t1 SET name='Jacob', age=2;
diff --git a/mysql-test/t/rpl000006.test b/mysql-test/t/rpl000006.test
index ad8622c2a81..c6438062bb7 100644
--- a/mysql-test/t/rpl000006.test
+++ b/mysql-test/t/rpl000006.test
@@ -5,12 +5,10 @@ source include/master-slave.inc;
# Don't log table creating to the slave as we want to test LOAD TABLE
set SQL_LOG_BIN=0,timestamp=200006;
-drop table if exists t1;
create table t1(t timestamp not null,a char(1));
insert into t1 ( a) values ('F');
select unix_timestamp(t) from t1;
connection slave;
-drop table if exists t1;
load table t1 from master;
select unix_timestamp(t) from t1;
diff --git a/mysql-test/t/rpl000008-slave.opt b/mysql-test/t/rpl000008-slave.opt
index 79b3bf6174b..177f89e0910 100644
--- a/mysql-test/t/rpl000008-slave.opt
+++ b/mysql-test/t/rpl000008-slave.opt
@@ -1 +1 @@
---replicate-ignore-table=test.foo
+--replicate-ignore-table=test.mysqltest_foo
diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl000008.test
index 12760008b6d..ea782b99d28 100644
--- a/mysql-test/t/rpl000008.test
+++ b/mysql-test/t/rpl000008.test
@@ -1,29 +1,36 @@
-#this one assumes we are ignoring updates on table foo, but doing
-#the ones on all other tables
+# This one assumes we are ignoring updates on table mysqltest_foo, but doing
+# the ones on all other tables
+
source include/master-slave.inc;
connection slave;
+
+#
+# For this test we must be in the test database
+#
use test;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(4);
+
+--disable_warnings
+drop table if exists mysqltest_foo;
+drop table if exists mysqltest_bar;
+--enable_warnings
+
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(4);
connection master;
use test;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(5);
-drop table if exists bar;
-create table bar (m int);
-insert into bar values(15);
-drop table if exists choo;
-create table choo (k int);
-insert into choo values(55);
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(5);
+create table mysqltest_bar (m int);
+insert into mysqltest_bar values(15);
+create table t1 (k int);
+insert into t1 values(55);
save_master_pos;
connection slave;
sync_with_master;
-select foo.n,bar.m,choo.k from foo,bar,choo;
+select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1;
connection master;
-drop table if exists foo,bar,choo;
+drop table mysqltest_foo,mysqltest_bar,t1;
save_master_pos;
connection slave;
sync_with_master;
-drop table if exists foo,bar,choo;
+drop table mysqltest_foo,mysqltest_bar,t1;
diff --git a/mysql-test/t/rpl000009-slave.opt b/mysql-test/t/rpl000009-slave.opt
index 245e310c5d8..c015c02ba78 100644
--- a/mysql-test/t/rpl000009-slave.opt
+++ b/mysql-test/t/rpl000009-slave.opt
@@ -1 +1 @@
---replicate-wild-do-table=bar.%
+--replicate-wild-do-table=mysqltest.%
diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test
index 5f55355271a..ffec20c793e 100644
--- a/mysql-test/t/rpl000009.test
+++ b/mysql-test/t/rpl000009.test
@@ -1,38 +1,38 @@
-# This one assumes we are ignoring updates on tables in database foo, but doing
-# the ones in database bar
+# This one assumes we are ignoring updates on tables in database mysqltest2,
+# but doing the ones in database mysqltest
source include/master-slave.inc;
-drop database if exists foo;
-create database foo;
-drop database if exists bar;
-create database bar;
+--disable_warnings
+drop database if exists mysqltest2;
+create database mysqltest2;
+drop database if exists mysqltest;
+create database mysqltest;
+--enable_warnings
+
save_master_pos;
connection slave;
sync_with_master;
-create database foo;
-drop table if exists foo.foo;
-create table foo.foo (n int);
-insert into foo.foo values(4);
+create database mysqltest2;
+create table mysqltest2.foo (n int);
+insert into mysqltest2.foo values(4);
connection master;
-drop table if exists foo.foo;
-create table foo.foo (n int);
-insert into foo.foo values(5);
-drop table if exists bar.bar;
-create table bar.bar (m int);
-insert into bar.bar values(15);
+create table mysqltest2.foo (n int);
+insert into mysqltest2.foo values(5);
+create table mysqltest.bar (m int);
+insert into mysqltest.bar values(15);
save_master_pos;
connection slave;
sync_with_master;
-select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
+select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar;
connection master;
-drop database bar;
-drop database if exists foo;
+drop database mysqltest;
+drop database if exists mysqltest2;
save_master_pos;
connection slave;
sync_with_master;
--error 1008
-drop database bar;
-drop database foo;
+drop database mysqltest;
+drop database mysqltest2;
# Now let's test load data from master
@@ -40,19 +40,19 @@ drop database foo;
connection master;
set sql_log_bin = 0;
-create database foo;
-create database bar;
+create database mysqltest2;
+create database mysqltest;
show databases;
-create table foo.t1(n int, s char(20));
-create table foo.t2(n int, s text);
-insert into foo.t1 values (1, 'one'), (2, 'two'), (3, 'three');
-insert into foo.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
+create table mysqltest2.t1(n int, s char(20));
+create table mysqltest2.t2(n int, s text);
+insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three');
+insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
-create table bar.t1(n int, s char(20));
-create table bar.t2(n int, s text);
-insert into bar.t1 values (1, 'one bar'), (2, 'two bar'), (3, 'three bar');
-insert into bar.t2 values (11, 'eleven bar'), (12, 'twelve bar'),
- (13, 'thirteen bar');
+create table mysqltest.t1(n int, s char(20));
+create table mysqltest.t2(n int, s text);
+insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test');
+insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
+ (13, 'thirteen test');
set sql_log_bin = 1;
save_master_pos;
connection slave;
@@ -64,26 +64,25 @@ load data from master;
# Now let's check if we have the right tables and the right data in them
show databases;
-use foo;
+use mysqltest2;
show tables;
-use bar;
+use mysqltest;
show tables;
-select * from bar.t1;
-select * from bar.t2;
+select * from mysqltest.t1;
+select * from mysqltest.t2;
# Now let's see if replication works
connection master;
-insert into bar.t1 values (4, 'four bar');
+insert into mysqltest.t1 values (4, 'four test');
save_master_pos;
connection slave;
sync_with_master;
-select * from bar.t1;
+select * from mysqltest.t1;
# Now time for cleanup
connection master;
-drop database bar;
-drop database foo;
+drop database mysqltest;
+drop database mysqltest2;
save_master_pos;
connection slave;
sync_with_master;
-
diff --git a/mysql-test/t/rpl000010.test b/mysql-test/t/rpl000010.test
index 05a211fbd85..0725214694a 100644
--- a/mysql-test/t/rpl000010.test
+++ b/mysql-test/t/rpl000010.test
@@ -1,10 +1,8 @@
-#this tests the offset off by 22 mystery bug
-#must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1
+# This tests the offset off by 22 mystery bug
+# Must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1
+
source include/master-slave.inc;
-connection slave;
-drop table if exists t1;
-connection master;
-drop table if exists t1;
+
create table t1 (n int not null auto_increment primary key);
insert into t1 values(NULL);
insert into t1 values(2);
diff --git a/mysql-test/t/rpl000011.test b/mysql-test/t/rpl000011.test
index d75937e3f81..3b00afe10e4 100644
--- a/mysql-test/t/rpl000011.test
+++ b/mysql-test/t/rpl000011.test
@@ -1,21 +1,15 @@
source include/master-slave.inc;
-drop table if exists t1;
+
create table t1 (n int);
insert into t1 values(1);
-save_master_pos;
-connection slave;
-sync_with_master;
-slave stop;
-slave start;
+sync_slave_with_master;
+stop slave;
+start slave;
connection master;
insert into t1 values(2);
-save_master_pos;
-connection slave;
#let slave catch up
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test
index 9f8ba9a4f91..7f440eaaa13 100644
--- a/mysql-test/t/rpl000012.test
+++ b/mysql-test/t/rpl000012.test
@@ -1,18 +1,16 @@
source include/master-slave.inc;
connection master;
-drop table if exists t1,t2,t3;
create table t2 (n int);
create temporary table t1 (n int);
insert into t1 values(1),(2),(3);
insert into t2 select * from t1;
-drop table if exists test.t3;
-create temporary table test.t3 (n int not null);
-alter table test.t3 add primary key(n);
+create temporary table t3 (n int not null);
+alter table t3 add primary key(n);
flush logs;
insert into t3 values (100);
insert into t2 select * from t3;
-drop table if exists test.t3;
+drop table if exists t3;
insert into t2 values (101);
connection master1;
create temporary table t1 (n int);
diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test
index 14619796e01..94d5feb3925 100644
--- a/mysql-test/t/rpl000013.test
+++ b/mysql-test/t/rpl000013.test
@@ -3,7 +3,7 @@ save_master_pos;
connection slave;
sync_with_master;
connection master;
-drop table if exists t2;
+
create table t2(n int);
create temporary table t1 (n int);
insert into t1 values(1),(2),(3);
@@ -31,6 +31,10 @@ show status like 'Slave_open_temp_tables';
#
connect (master2,localhost,root,,);
connection master2;
+
+# We will get a warning for t1 as this is a temporary table that doesn't
+# exist in this connection.
+
drop table if exists t1,t2;
save_master_pos;
connection slave;
diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl000015.test
index 26d32ea3e11..b5234373355 100644
--- a/mysql-test/t/rpl000015.test
+++ b/mysql-test/t/rpl000015.test
@@ -18,20 +18,18 @@ eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
--replace_result $MASTER_MYPORT MASTER_PORT
show slave status;
-slave start;
+start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
show slave status;
connection master;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (n int);
insert into t1 values (10),(45),(90);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000016-slave.opt b/mysql-test/t/rpl000016-slave.opt
deleted file mode 100644
index f27601e0d7d..00000000000
--- a/mysql-test/t/rpl000016-slave.opt
+++ /dev/null
@@ -1 +0,0 @@
--O max_binlog_size=2048
diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh
index 066b4880cc1..4dbbaec31ce 100755
--- a/mysql-test/t/rpl000017-slave.sh
+++ b/mysql-test/t/rpl000017-slave.sh
@@ -1,11 +1,11 @@
rm -f $MYSQL_TEST_DIR/var/log/*relay*
rm -f $MYSQL_TEST_DIR/var/slave-data/relay-log.info
cat > $MYSQL_TEST_DIR/var/slave-data/master.info <<EOF
-master-bin.001
+master-bin.000001
4
127.0.0.1
replicate
-aaaaaaaaaaaaaaabthispartofthepasswordisnotused
+aaaaaaaaaaaaaaab
$MASTER_MYPORT
1
0
diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test
index d4f41f1e374..cf808a2cbc0 100644
--- a/mysql-test/t/rpl000017.test
+++ b/mysql-test/t/rpl000017.test
@@ -5,17 +5,15 @@ reset master;
grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab';
connection slave;
-slave start;
+start slave;
connection master;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n int);
insert into t1 values(24);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000018.test b/mysql-test/t/rpl000018.test
index 3bd5fd0ef09..884ec9727d2 100644
--- a/mysql-test/t/rpl000018.test
+++ b/mysql-test/t/rpl000018.test
@@ -12,18 +12,16 @@ server_stop master;
server_start master;
connection slave;
reset slave;
-slave start;
+start slave;
connection master;
-show master logs;
+show binary logs;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n int);
insert into t1 values (3351);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test
index f1fbf60776b..6b8cf773150 100644
--- a/mysql-test/t/rpl_alter.test
+++ b/mysql-test/t/rpl_alter.test
@@ -1,6 +1,9 @@
source include/master-slave.inc;
+--disable_warnings
drop database if exists test_$1;
+--enable_warnings
create database test_$1;
+
create table test_$1.t1 ( n int);
alter table test_$1.t1 add m int;
insert into test_$1.t1 values (1,2);
diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test
index afa76ce10bb..9d5a7a173b0 100644
--- a/mysql-test/t/rpl_empty_master_crash.test
+++ b/mysql-test/t/rpl_empty_master_crash.test
@@ -1,6 +1,7 @@
source include/master-slave.inc;
-drop table if exists t1;
+
show slave status;
+
#
# Load table should not succeed on the master as this is not a slave
#
diff --git a/mysql-test/t/rpl_failsafe.test b/mysql-test/t/rpl_failsafe.test
index 866efbce5bf..ae61b061153 100644
--- a/mysql-test/t/rpl_failsafe.test
+++ b/mysql-test/t/rpl_failsafe.test
@@ -7,18 +7,16 @@ show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
create table t1(n int);
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_sec;
-slave start;
+start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_ter;
-slave start;
+start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test
index 8a3da1a2b02..00fab13bac7 100644
--- a/mysql-test/t/rpl_flush_log_loop.test
+++ b/mysql-test/t/rpl_flush_log_loop.test
@@ -7,13 +7,13 @@ connection slave;
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
-slave start;
+start slave;
connection master;
-slave stop;
+stop slave;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$SLAVE_MYPORT;
-slave start;
+start slave;
sleep 5;
flush logs;
sleep 5;
diff --git a/mysql-test/t/rpl_flush_tables.test b/mysql-test/t/rpl_flush_tables.test
new file mode 100644
index 00000000000..67720343e83
--- /dev/null
+++ b/mysql-test/t/rpl_flush_tables.test
@@ -0,0 +1,35 @@
+#
+# Test of replicating FLUSH TABLES to make
+# RENAME TABLE work with MERGE tables on the slave.
+# Test of FLUSH NO_WRITE_TO_BINLOG by the way.
+#
+source include/master-slave.inc;
+
+create table t1 (a int);
+insert into t1 values (10);
+create table t2 (a int);
+create table t3 (a int) type=merge union(t1);
+create table t4 (a int);
+# We force the slave to open t3 (because we want to try confusing him) with this :
+insert into t4 select * from t3;
+rename table t1 to t5, t2 to t1;
+# RENAME may have confused the master (this is a known bug): so FLUSH tables,
+# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.
+flush no_write_to_binlog tables;
+# Check that it's not in the binlog.
+--replace_result $SERVER_VERSION SERVER_VERSION
+show binlog events;
+# Check that the master is not confused.
+select * from t3;
+# This FLUSH should go into the binlog to not confuse the slave.
+flush tables;
+# Check that it's in the binlog.
+--replace_result $SERVER_VERSION SERVER_VERSION
+show binlog events;
+save_master_pos;
+connection slave;
+sync_with_master;
+# Check that the slave is not confused.
+select * from t3;
+# Note that all this confusion may cause warnings 'table xx is open on rename'
+# in the .err files; these are not fatal and are not reported by mysql-test-run.
diff --git a/mysql-test/t/rpl_insert_id-slave.opt b/mysql-test/t/rpl_insert_id-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_insert_id-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test
index 49fefae72b8..b2b92dec7aa 100644
--- a/mysql-test/t/rpl_insert_id.test
+++ b/mysql-test/t/rpl_insert_id.test
@@ -6,7 +6,6 @@
source include/master-slave.inc;
source include/have_innodb.inc
connection master;
-drop table if exists t1;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
insert into t1 values (1),(2),(3);
diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test
index 4c4ff6a093e..478d4b75a36 100644
--- a/mysql-test/t/rpl_loaddata.test
+++ b/mysql-test/t/rpl_loaddata.test
@@ -2,13 +2,14 @@
# Honours autoincrement values
# i.e. if the master and slave have the same sequence
#
-# check replication of load data for temporary tables with additional parameters
+# check replication of load data for temporary tables with additional
+# parameters
#
# check if duplicate entries trigger an error (they should unless IGNORE or
# REPLACE was used on the master) (bug 571).
#
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
-# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986).
+# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986)
source include/master-slave.inc;
diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test
index e01b3e4e09c..77be92f64fd 100644
--- a/mysql-test/t/rpl_log.test
+++ b/mysql-test/t/rpl_log.test
@@ -1,8 +1,18 @@
source include/master-slave.inc;
-#clean up slave binlogs
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
connection slave;
-slave stop;
+sync_with_master;
+stop slave;
reset master;
reset slave;
# We are going to read the slave's binlog which contains file_id (for some LOAD
@@ -59,10 +69,10 @@ connection slave;
# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
# to go into the relay log (the master always sends a fake one when replication
# starts).
-slave start;
+start slave;
sync_with_master;
flush logs;
-slave stop;
+stop slave;
connection master;
# Create some entries for second log
@@ -72,27 +82,27 @@ insert into t1 values (1);
drop table t1;
--replace_result $VERSION VERSION
show binlog events;
-show binlog events in 'master-bin.002';
-show master logs;
+show binlog events in 'master-bin.000002';
+show binary logs;
save_master_pos;
connection slave;
-slave start;
+start slave;
sync_with_master;
-show master logs;
+show binary logs;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION
-show binlog events in 'slave-bin.001' from 4;
+show binlog events in 'slave-bin.000001' from 4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION
-show binlog events in 'slave-bin.002' from 4;
+show binlog events in 'slave-bin.000002' from 4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
# Need to recode the following
-#show new master for slave with master_log_file='master-bin.001' and master_log_pos=4 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.001' and master_log_pos=79 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.001' and master_log_pos=311 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.002' and master_log_pos=4 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.002' and master_log_pos=122 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1;
--error 1220
-show binlog events in 'slave-bin.005' from 4;
+show binlog events in 'slave-bin.000005' from 4;
diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test
index e11ba92cfa7..bc1349a959a 100644
--- a/mysql-test/t/rpl_log_pos.test
+++ b/mysql-test/t/rpl_log_pos.test
@@ -3,29 +3,28 @@
#
source include/master-slave.inc;
show master status;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
-slave stop;
+stop slave;
change master to master_log_pos=73;
-slave start;
+start slave;
sleep 5;
-slave stop;
+stop slave;
change master to master_log_pos=73;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
-slave start;
+start slave;
sleep 5;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
-slave stop;
+stop slave;
change master to master_log_pos=173;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
-slave start;
+start slave;
sleep 2;
+--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
connection master;
show master status;
@@ -35,13 +34,11 @@ create table t1 (n int);
insert into t1 values (1),(2),(3);
save_master_pos;
connection slave;
-slave stop;
+stop slave;
change master to master_log_pos=79;
-slave start;
+start slave;
sync_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_misc_functions-slave.sh b/mysql-test/t/rpl_misc_functions-slave.sh
new file mode 100755
index 00000000000..c293715e16f
--- /dev/null
+++ b/mysql-test/t/rpl_misc_functions-slave.sh
@@ -0,0 +1 @@
+rm -f $MYSQL_TEST_DIR/var/master-data/test/rpl_misc_functions.outfile
diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test
new file mode 100644
index 00000000000..12eadbb25ed
--- /dev/null
+++ b/mysql-test/t/rpl_misc_functions.test
@@ -0,0 +1,30 @@
+#
+# Test of replicating some difficult functions
+#
+source include/master-slave.inc;
+
+create table t1(id int, i int, r1 int, r2 int, p varchar(100));
+insert into t1 values(1, connection_id(), 0, 0, "");
+# don't put rand and password in the same query, to see if they replicate
+# independently
+# Pure rand test
+insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
+# change the rand suite on the master (we do this because otherwise password()
+# benefits from the fact that the above rand() is well replicated :
+# it picks the same sequence element, which hides a possible bug in password() replication.
+set sql_log_bin=0;
+insert into t1 values(6, 0, rand(), rand(), "");
+delete from t1 where id=6;
+set sql_log_bin=1;
+# Pure password test
+insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
+# "altogether now"
+insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
+select * into outfile 'rpl_misc_functions.outfile' from t1;
+sync_slave_with_master;
+create table t2 like t1;
+# read the values from the master table
+load data local infile './var/master-data/test/rpl_misc_functions.outfile' into table t2;
+# compare them with the replica; the SELECT below should return no row
+select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p);
+stop slave;
diff --git a/mysql-test/t/rpl_mystery22.test b/mysql-test/t/rpl_mystery22.test
index 5280cb360dd..d49f1a210f4 100644
--- a/mysql-test/t/rpl_mystery22.test
+++ b/mysql-test/t/rpl_mystery22.test
@@ -4,9 +4,7 @@ source include/master-slave.inc;
# first, cause a duplicate key problem on the slave
create table t1(n int auto_increment primary key);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
insert into t1 values (2);
connection master;
insert into t1 values(NULL);
@@ -16,11 +14,11 @@ connection slave;
sleep 3; # there is no way around this sleep - we have to wait until
# the slave tries to run the query, fails and aborts slave thread
delete from t1 where n = 2;
-slave start;
+start slave;
sync_with_master;
#now the buggy slave would be confused on the offset but it can replicate
#in order to make it break, we need to stop/start the slave one more time
-slave stop;
+stop slave;
connection master;
# to be able to really confuse the slave, we need some non-auto-increment
# events in the log
@@ -29,7 +27,7 @@ drop table t2;
insert into t1 values(NULL);
save_master_pos;
connection slave;
-slave start;
+start slave;
#now the truth comes out - if the slave is buggy, it will never sync because
#the slave thread is not able to read events
sync_with_master;
@@ -37,7 +35,5 @@ select * from t1;
#clean up
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test
index 4082542f295..181d200b761 100644
--- a/mysql-test/t/rpl_redirect.test
+++ b/mysql-test/t/rpl_redirect.test
@@ -19,7 +19,6 @@ rpl_probe;
#turn on master/slave query direction auto-magic
enable_rpl_parse;
-drop table if exists t1;
create table t1 ( n int);
insert into t1 values (1),(2),(3),(4);
disable_rpl_parse;
diff --git a/mysql-test/t/rpl_relayrotate-slave.opt b/mysql-test/t/rpl_relayrotate-slave.opt
new file mode 100644
index 00000000000..8b671423363
--- /dev/null
+++ b/mysql-test/t/rpl_relayrotate-slave.opt
@@ -0,0 +1,4 @@
+-O max_binlog_size=16384
+--innodb
+--log-warnings
+
diff --git a/mysql-test/t/rpl_relayrotate.test b/mysql-test/t/rpl_relayrotate.test
new file mode 100644
index 00000000000..3df55eea57d
--- /dev/null
+++ b/mysql-test/t/rpl_relayrotate.test
@@ -0,0 +1,71 @@
+# When the relay log gets rotated while the I/O thread
+# is reading a transaction, the transaction spans on two or more
+# relay logs. If STOP SLAVE occurs while the SQL thread is
+# executing a part of the transaction in the non-first relay logs,
+# we test if START SLAVE will resume in the beginning of the
+# transaction (i.e., step back to the first relay log)
+
+# The slave is started with max_binlog_size=16384 bytes,
+# to force many rotations (approximately 30 rotations)
+
+# If the master or slave does not support InnoDB, this test will pass
+
+source include/master-slave.inc;
+connection slave;
+stop slave;
+connection master;
+--disable_warnings
+create table t1 (a int) type=innodb;
+--enable_warnings
+let $1=8000;
+disable_query_log;
+begin;
+while ($1)
+{
+# eval means expand $ expressions
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+commit;
+# This will generate a 500kB master's binlog,
+# which corresponds to 30 slave's relay logs.
+enable_query_log;
+save_master_pos;
+connection slave;
+reset slave;
+start slave;
+# We wait 1 sec for the SQL thread to be somewhere in
+# the middle of the transaction, hopefully not in
+# the first relay log, and hopefully before the COMMIT.
+# Usually it stops when the SQL thread is around the 15th relay log.
+# We cannot use MASTER_POS_WAIT() as master's position
+# increases only when the slave executes the COMMIT.
+system sleep 1;
+stop slave;
+# We suppose the SQL thread stopped before COMMIT.
+# If so the transaction was rolled back
+# and the table is now empty.
+# Now restart
+start slave;
+# And see if the table contains '8000'
+# which proves that the transaction restarted at
+# the right place.
+# We must wait for the transaction to commit before
+# reading, MASTER_POS_WAIT() will do it for sure
+# (the only statement with position>=3000 is COMMIT).
+# Older versions of MySQL would hang forever in MASTER_POS_WAIT
+# because COMMIT was said to be position 0 in the master's log (bug).
+# Detect this with timeout.
+select master_pos_wait('master-bin.001',3000,120)=-1;
+select * from t1 where a=8000;
+
+# The following DROP is a very important cleaning task:
+# imagine the next test is run with --skip-innodb: it will do
+# DROP TABLE IF EXISTS t1; but this will delete the frm and leave
+# some data in the InnoDB datafile (because at that time mysqld
+# does not know about InnoDB : --skip-innodb). So if later in the
+# test suite a test wants to create an InnoDB table called t1, it
+# will fail with
+# InnoDB: Error: table t1 already exists in InnoDB internal
+# InnoDB: data dictionary. Have you deleted the .frm file etc
+drop table t1;
diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test
index 0800062dc05..a1ce8d8a645 100644
--- a/mysql-test/t/rpl_replicate_do.test
+++ b/mysql-test/t/rpl_replicate_do.test
@@ -2,9 +2,12 @@
# updates on t1
source include/master-slave.inc;
+--disable_warnings
drop table if exists t11;
connection slave;
drop table if exists t11;
+--enable_warnings
+
create table t2 (n int);
insert into t2 values(4);
connection master;
@@ -24,7 +27,11 @@ select * from t2;
--error 1146
select * from t11;
connection master;
-drop table if exists t1,t2,t3,t11;
+drop table if exists t1,t2,t11;
save_master_pos;
connection slave;
sync_with_master;
+# show slave status, just to see of it prints replicate-do-table
+--replace_result $MASTER_MYPORT MASTER_PORT
+show slave status;
+
diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test
index c4dc5de38da..d36f49eee5c 100644
--- a/mysql-test/t/rpl_rotate_logs.test
+++ b/mysql-test/t/rpl_rotate_logs.test
@@ -1,5 +1,5 @@
#
-# Test are run with max_binlog_size=2048 to force automatic rotation of the
+# Test is run with max_binlog_size=2048 to force automatic rotation of the
# binary log
# Tests done:
# - Check that slaves reports correct failures if master.info has strange
@@ -8,26 +8,33 @@
# - Ensure that temporary tables works over flush logs and binary log
# changes
# - Test creating a duplicate key error and recover from it
-#
+
connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock);
+--disable_warnings
drop table if exists t1, t2, t3, t4;
+--enable_warnings
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
system cat /dev/null > var/slave-data/master.info;
system chmod 000 var/slave-data/master.info;
connection slave;
+--disable_warnings
drop table if exists t1, t2, t3, t4;
-# START SLAVE will fail because it can't read the file (mode 000) (system error 13)
+--enable_warnings
+
+# START SLAVE will fail because it can't read the file (mode 000)
+# (system error 13)
--error 1201
-slave start;
+start slave;
system chmod 600 var/slave-data/master.info;
# It will fail again because the file is empty so the slave cannot get valuable
# info about how to connect to the master from it (failure in
# init_strvar_from_file() in init_master_info()).
--error 1201
-slave start;
+start slave;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
-# CHANGE MASTER will fail because it first parses master.info before changing it
-# (so when master.info is bad, people have to use RESET SLAVE first).
+
+# CHANGE MASTER will fail because it first parses master.info before changing
+# it (so when master.info is bad, people have to use RESET SLAVE first).
--error 1201
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
reset slave;
@@ -36,7 +43,7 @@ eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master
connection master;
reset master;
connection slave;
-slave start;
+start slave;
connection master;
#
@@ -46,24 +53,19 @@ create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables");
create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
select * from t1;
connection master;
flush logs;
-drop table if exists t2;
create table t2(m int not null auto_increment primary key);
insert into t2 values (34),(67),(123);
flush logs;
-show master logs;
+show binary logs;
create table t3 select * from temp_table;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t3;
connection master;
@@ -86,21 +88,23 @@ wait_for_slave_to_stop;
#restart slave skipping one event
set global sql_slave_skip_counter=1;
-slave start;
+start slave;
connection master;
-save_master_pos;
#let slave catch up
-connection slave;
-sync_with_master;
+sync_slave_with_master;
connection master;
-purge master logs to 'master-bin.003';
+purge master logs to 'master-bin.000002';
show master logs;
+# we just tests if synonyms are accepted
+purge binary logs to 'master-bin.000002';
+show binary logs;
+--sleep 1;
+purge master logs before now();
+show binary logs;
insert into t2 values (65);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
select * from t2;
@@ -113,7 +117,7 @@ connection master;
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");
let $1=100;
-drop table if exists t3;
+
create table t3 (n int);
disable_query_log;
while ($1)
@@ -124,12 +128,10 @@ while ($1)
}
enable_query_log;
create table t4 select * from temp_table;
-show master logs;
+show binary logs;
show master status;
save_master_pos;
connection slave;
-#slave stop;
-#slave start;
sync_with_master;
select * from t4;
@@ -143,6 +145,4 @@ unlock tables;
#clean up
connection master;
drop table if exists t1,t2,t3,t4;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test
index d43c59ef024..86c89c70314 100644
--- a/mysql-test/t/rpl_skip_error.test
+++ b/mysql-test/t/rpl_skip_error.test
@@ -1,5 +1,4 @@
source include/master-slave.inc;
-drop table if exists t1;
create table t1 (n int not null primary key);
save_master_pos;
diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test
index e59b93b4475..b24901c62a9 100644
--- a/mysql-test/t/rpl_sporadic_master.test
+++ b/mysql-test/t/rpl_sporadic_master.test
@@ -9,22 +9,16 @@ insert into t1 values (NULL),(NULL);
truncate table t1;
# We have to use 4 in the following to make this test work with all table types
insert into t1 values (4),(NULL);
-save_master_pos;
-connection slave;
-sync_with_master;
-slave stop;
-slave start;
+sync_slave_with_master;
+stop slave;
+start slave;
connection master;
insert into t1 values (NULL),(NULL);
flush logs;
truncate table t1;
insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1,t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test
new file mode 100644
index 00000000000..79dba60964d
--- /dev/null
+++ b/mysql-test/t/rpl_temporary.test
@@ -0,0 +1,107 @@
+source include/master-slave.inc;
+
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, or it has but the slave hasn't had
+# enough time to catch it before STOP SLAVE,
+# and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+connection master;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,,,);
+
+# We are going to use SET PSEUDO_THREAD_ID in this test;
+# check that it requires the SUPER privilege.
+
+connection con3;
+--error 1227
+SET @@session.pseudo_thread_id=100;
+
+let $VERSION=`select version()`;
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1(f int);
+create table t2(f int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+connection con1;
+create temporary table t3(f int);
+insert into t3 select * from t1 where f<6;
+sleep 1;
+
+connection con2;
+create temporary table t3(f int);
+sleep 1;
+
+connection con1;
+insert into t2 select count(*) from t3;
+sleep 1;
+
+connection con2;
+insert into t3 select * from t1 where f>=4;
+sleep 1;
+
+connection con1;
+drop temporary table t3;
+sleep 1;
+
+connection con2;
+insert into t2 select count(*) from t3;
+drop temporary table t3;
+
+select * from t2;
+
+--replace_result $VERSION VERSION
+show binlog events;
+
+drop table t1, t2;
+
+use test;
+SET TIMESTAMP=1040323920;
+create table t1(f int);
+SET TIMESTAMP=1040323931;
+create table t2(f int);
+SET TIMESTAMP=1040323938;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+SET TIMESTAMP=1040323945;
+SET @@session.pseudo_thread_id=1;
+create temporary table t3(f int);
+SET TIMESTAMP=1040323952;
+SET @@session.pseudo_thread_id=1;
+insert into t3 select * from t1 where f<6;
+SET TIMESTAMP=1040324145;
+SET @@session.pseudo_thread_id=2;
+create temporary table t3(f int);
+SET TIMESTAMP=1040324186;
+SET @@session.pseudo_thread_id=1;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324200;
+SET @@session.pseudo_thread_id=2;
+insert into t3 select * from t1 where f>=4;
+SET TIMESTAMP=1040324211;
+SET @@session.pseudo_thread_id=1;
+drop temporary table t3;
+SET TIMESTAMP=1040324219;
+SET @@session.pseudo_thread_id=2;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324224;
+SET @@session.pseudo_thread_id=2;
+drop temporary table t3;
+
+select * from t2;
+drop table t1,t2;
diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test
new file mode 100644
index 00000000000..7eeccaf64f2
--- /dev/null
+++ b/mysql-test/t/rpl_user_variables.test
@@ -0,0 +1,49 @@
+#
+# Test of replicating user variables
+#
+source include/master-slave.inc;
+
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, or it has but the slave hasn't had
+# enough time to catch it before STOP SLAVE,
+# and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+connection master;
+
+create table t1(n char(30));
+set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1;
+set @s1:='This is a test', @r1:=12.5, @r2:=-12.5;
+set @n1:=null;
+set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def';
+insert into t1 values (@i1), (@i2), (@i3), (@i4);
+insert into t1 values (@r1), (@r2);
+insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5);
+insert into t1 values (@n1);
+insert into t1 values (@n2);
+insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1);
+insert into t1 values (@a+(@b:=@a+1));
+set @q:='abc';
+insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'));
+set @a:=5;
+insert into t1 values (@a),(@a);
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1;
+show binlog events from 141;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
diff --git a/mysql-test/t/sel000001.test b/mysql-test/t/sel000001.test
deleted file mode 100644
index ad4af1f92fb..00000000000
--- a/mysql-test/t/sel000001.test
+++ /dev/null
@@ -1,31 +0,0 @@
-# sel000001
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# This test is just a simple select.
-# Testing WHERE clause.
-#
-
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (s CHAR(20) PRIMARY KEY, id INT);
-INSERT INTO t1 VALUES ('cat', 1), ('mouse', 3), ('dog', 2), ('snake', 77);
-SELECT s, id FROM t1 WHERE s = 'mouse';
-drop table t1;
-
-#
-#test for bug #717
-#
-CREATE TABLE t1 (
- node int(11) NOT NULL default '0',
- maxchild int(11) NOT NULL default '0',
- PRIMARY KEY (`node`)
-);
-INSERT INTO t1 (node, maxchild) VALUES (4,4),(5,5),(1,244);
-SELECT * FROM t1 g1, t1 g2
- WHERE g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
-DROP TABLE t1;
diff --git a/mysql-test/t/sel000002.test b/mysql-test/t/sel000002.test
deleted file mode 100644
index 9a89db2821c..00000000000
--- a/mysql-test/t/sel000002.test
+++ /dev/null
@@ -1,17 +0,0 @@
-# sel000002
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# This test is just a simple select.
-#
-
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (n INT);
-INSERT INTO t1 VALUES (1), (2), (3);
-SELECT * FROM t1;
-drop table t1;
diff --git a/mysql-test/t/sel000003.test b/mysql-test/t/sel000003.test
deleted file mode 100644
index a3f6a7337c2..00000000000
--- a/mysql-test/t/sel000003.test
+++ /dev/null
@@ -1,18 +0,0 @@
-# sel000003
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# This test is just a simple select.
-# Testing count() function and GROUP BY clause.
-#
-
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (name CHAR(20) NOT NULL PRIMARY KEY, score SMALLINT NOT NULL, KEY(score));
-INSERT INTO t1 VALUES ('Sasha', 20), ('Matt', 20), ('Monty', 10), ('David', 10), ('Tim', 10), ('Jeremy', 10);
-SELECT COUNT(*) as n, score FROM t1 GROUP BY score;
-drop table t1;
diff --git a/mysql-test/t/sel000031.test b/mysql-test/t/sel000031.test
deleted file mode 100644
index 29bafbb3040..00000000000
--- a/mysql-test/t/sel000031.test
+++ /dev/null
@@ -1,20 +0,0 @@
-# sel000031
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# test for a bug with elt() and order by
-
-drop table if exists t1,t2;
-create table t1 (id int(10) not null unique);
-create table t2 (id int(10) not null primary key,
-val int(10) not null);
-insert into t1 values (1),(2),(4);
-insert into t2 values (1,1),(2,1),(3,1),(4,2);
-
-select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
-drop table t1,t2;
diff --git a/mysql-test/t/sel000032.test b/mysql-test/t/sel000032.test
deleted file mode 100644
index d31ba69e9d8..00000000000
--- a/mysql-test/t/sel000032.test
+++ /dev/null
@@ -1,20 +0,0 @@
-# sel000032
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# test for a bug with elt()
-
-drop table if exists t1,t2;
-create table t1 (id int(10) not null unique);
-create table t2 (id int(10) not null primary key,
-val int(10) not null);
-insert into t1 values (1),(2),(4);
-insert into t2 values (1,1),(2,1),(3,1),(4,2);
-
-select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
-drop table t1,t2;
diff --git a/mysql-test/t/sel000033.test b/mysql-test/t/sel000033.test
index 165e43ad9f8..72e096311ce 100644
--- a/mysql-test/t/sel000033.test
+++ b/mysql-test/t/sel000033.test
@@ -9,7 +9,9 @@
# -----------
# test for a bug with in() and unique key
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (id int(10) primary key);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
diff --git a/mysql-test/t/sel000100.test b/mysql-test/t/sel000100.test
index d587fa4ebd0..c9923d178c6 100644
--- a/mysql-test/t/sel000100.test
+++ b/mysql-test/t/sel000100.test
@@ -1,4 +1,6 @@
+--disable_warnings
DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 9884c88b420..4593eeb0691 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -6,7 +6,9 @@
# Simple select test
#
+--disable_warnings
drop table if exists t1,t2,t3,t4;
+--enable_warnings
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
@@ -1487,8 +1489,6 @@ select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.
# We need another table for join stuff..
#
-drop table if exists company;
-
create table t4 (
companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
@@ -1589,8 +1589,8 @@ select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld
select count(*) from t1;
select companynr,count(*),sum(fld1) from t2 group by companynr;
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
-select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 where companynr = 34 and fld4<>"";
-select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 group by companynr limit 3;
+select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
+select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ;
@@ -1779,6 +1779,10 @@ select wss_type from t1 where wss_type ='102935229216544104';
select wss_type from t1 where wss_type ='102935229216544093';
select wss_type from t1 where wss_type =102935229216544093;
drop table t1;
+select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;
+select @a;
+select @b;
+select @c;
#
# Test of removing redundant braces in the FROM part
@@ -1851,4 +1855,3 @@ select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
drop table t1,t2,t3,t4;
-
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test
index 0a483c860cb..06624d50a43 100644
--- a/mysql-test/t/select_found.test
+++ b/mysql-test/t/select_found.test
@@ -1,8 +1,10 @@
#
# Testing of found_rows()
#
-
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int not null auto_increment, b int not null, primary key(a));
insert into t1 (b) values (2),(3),(5),(5),(5),(6),(7),(9);
select SQL_CALC_FOUND_ROWS * from t1;
@@ -84,4 +86,12 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
('test1','1'),('test2','2'),('test3','3');
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost LIMIT 0;
+SELECT FOUND_ROWS();
drop table t1;
diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test
index 904479635c2..3cafd31a879 100644
--- a/mysql-test/t/select_safe.test
+++ b/mysql-test/t/select_safe.test
@@ -2,7 +2,10 @@
# test of safe selects
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
create table t1 (a int auto_increment primary key, b char(20));
insert into t1 values(1,"test");
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 2cd2012d109..633826186be 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -2,7 +2,10 @@
# Test of some show commands
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
check table t1 fast;
@@ -49,9 +52,11 @@ drop table t2;
create table t1 (
test_set set( 'val1', 'val2', 'val3' ) not null default '',
- name char(20) default 'O''Brien'
+ name char(20) default 'O''Brien' comment 'O''Brien as default',
+ c int not null comment 'int column'
) comment = 'it\'s a table' ;
show create table t1 ;
+show full columns from t1;
drop table t1;
create table t1 (a int not null, unique aa (a));
@@ -78,6 +83,7 @@ drop table t1;
create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0));
show columns from t1;
+show full columns from t1;
drop table t1;
#
diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
new file mode 100644
index 00000000000..d3531f0c440
--- /dev/null
+++ b/mysql-test/t/sql_mode.test
@@ -0,0 +1,30 @@
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE `t1` (
+ a int not null auto_increment,
+ `pseudo` varchar(35) character set latin2 NOT NULL default '',
+ `email` varchar(60) character set latin2 NOT NULL default '',
+ PRIMARY KEY (a),
+ UNIQUE KEY `email` USING BTREE (`email`)
+) TYPE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC;
+set @@sql_mode="";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="ansi_quotes";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="no_table_options";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="no_key_options";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="no_field_options,mysql323,mysql40";
+show variables like 'sql_mode';
+show create table t1;
+set sql_mode="postgresql,oracle,mssql,db2,sapdb";
+select @@sql_mode;
+show create table t1;
+drop table t1;
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index cffca437cf1..30edcc79d9e 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -4,7 +4,7 @@
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
--- source include/not_embedded.inc
+--source include/not_embedded.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
@@ -13,7 +13,10 @@ flush status;
show status like 'Table_lock%';
connection con1;
SET SQL_LOG_BIN=0;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1(n int) type=myisam;
insert into t1 values(1);
connection con2;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
new file mode 100644
index 00000000000..c9dba498428
--- /dev/null
+++ b/mysql-test/t/subselect.test
@@ -0,0 +1,924 @@
+# Initialise
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12;
+--enable_warnings
+
+select (select 2);
+explain select (select 2);
+SELECT (SELECT 1) UNION SELECT (SELECT 2);
+explain SELECT (SELECT 1) UNION SELECT (SELECT 2);
+SELECT (SELECT (SELECT 0 UNION SELECT 0));
+explain SELECT (SELECT (SELECT 0 UNION SELECT 0));
+-- error 1246
+SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
+-- error 1246
+SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
+SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
+-- error 1246
+SELECT (SELECT a) as a;
+EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
+SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
+-- error 1054
+SELECT (SELECT 1), a;
+SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
+-- error 1054
+SELECT 1 FROM (SELECT (SELECT a) b) c;
+SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id);
+-- error 1240
+SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1);
+SELECT 1 IN (SELECT 1);
+SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
+-- error 1221
+select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
+-- error 1108
+SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
+SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
+SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
+SELECT (SELECT 1,2,3) = ROW(1,2,3);
+SELECT (SELECT 1,2,3) = ROW(1,2,1);
+SELECT (SELECT 1,2,3) < ROW(1,2,1);
+SELECT (SELECT 1,2,3) > ROW(1,2,1);
+SELECT (SELECT 1,2,3) = ROW(1,2,NULL);
+SELECT ROW(1,2,3) = (SELECT 1,2,3);
+SELECT ROW(1,2,3) = (SELECT 1,2,1);
+SELECT ROW(1,2,3) < (SELECT 1,2,1);
+SELECT ROW(1,2,3) > (SELECT 1,2,1);
+SELECT ROW(1,2,3) = (SELECT 1,2,NULL);
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a');
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b');
+SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b');
+SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a');
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
+SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
+
+-- error 1240
+SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
+
+SELECT 1 as a,(SELECT a+a) b,(SELECT b);
+
+create table t1 (a int);
+create table t2 (a int, b int);
+create table t3 (a int);
+create table t4 (a int not null, b int not null);
+insert into t1 values (2);
+insert into t2 values (1,7),(2,7);
+insert into t4 values (4,8),(3,8),(5,9);
+-- error 1246
+select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
+select (select a from t1 where t1.a=t2.a), a from t2;
+select (select a from t1 where t1.a=t2.b), a from t2;
+select (select a from t1), a from t2;
+select (select a from t3), a from t2;
+select * from t2 where t2.a=(select a from t1);
+insert into t3 values (6),(7),(3);
+select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
+(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 order by a limit 2) limit 3;
+(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
+explain (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
+select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
+select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+(select * from t2 where a>1) as tt;
+explain select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+(select * from t2 where a>1) as tt;
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1);
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1);
+select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
+explain select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
+select * from t3 where exists (select * from t2 where t2.b=t3.a);
+select * from t3 where not exists (select * from t2 where t2.b=t3.a);
+select * from t3 where a in (select b from t2);
+select * from t3 where a not in (select b from t2);
+select * from t3 where a = some (select b from t2);
+select * from t3 where a <> any (select b from t2);
+
+# Rewrite: select * from t3 where not exists (select b from t2 where a <> b);
+select * from t3 where a = all (select b from t2);
+
+select * from t3 where a <> all (select b from t2);
+insert into t2 values (100, 5);
+select * from t3 where a < any (select b from t2);
+select * from t3 where a < all (select b from t2);
+select * from t3 where a >= any (select b from t2);
+select * from t3 where a >= all (select b from t2);
+delete from t2 where a=100;
+-- error 1240
+select * from t3 where a in (select a,b from t2);
+-- error 1240
+select * from t3 where a in (select * from t2);
+insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10);
+-- empty set
+select b,max(a) as ma from t4 group by b having b < (select max(t2.a) from t2 where t2.b=t4.b);
+insert into t2 values (2,10);
+select b,max(a) as ma from t4 group by b having ma < (select max(t2.a) from t2 where t2.b=t4.b);
+delete from t2 where a=2 and b=10;
+select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 where t2.b=t4.b);
+create table t5 (a int);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+insert into t5 values (5);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+insert into t5 values (2);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+-- error 1241
+select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
+create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
+create table t7( uq int primary key, name char(25));
+insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
+insert into t6 values (1,1),(1,2),(2,2),(1,3);
+select * from t6 where exists (select * from t7 where uq = clinic_uq);
+explain select * from t6 where exists (select * from t7 where uq = clinic_uq);
+
+# not unique fields
+-- error 1052
+select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
+
+# different tipes & group functions
+drop table if exists t1,t2,t3;
+
+CREATE TABLE t3 (a varchar(20),b char(1) NOT NULL default '0');
+INSERT INTO t3 VALUES ('W','a'),('A','c'),('J','b');
+CREATE TABLE t2 (a varchar(20),b int NOT NULL default '0');
+INSERT INTO t2 VALUES ('W','1'),('A','3'),('J','2');
+CREATE TABLE t1 (a varchar(20),b date NOT NULL default '0000-00-00');
+INSERT INTO t1 VALUES ('W','1732-02-22'),('A','1735-10-30'),('J','1743-04-13');
+SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1);
+SELECT * FROM t2 WHERE b = (SELECT MIN(b) FROM t2);
+SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
+
+CREATE TABLE `t8` (
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ `email` varchar(60) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`pseudo`),
+ UNIQUE KEY `email` (`email`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+INSERT INTO t8 (pseudo,email) VALUES ('joce','test');
+INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
+INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
+EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
+-- error 1240
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
+t8 WHERE pseudo='joce');
+-- error 1240
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
+pseudo='joce');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
+-- error 1241
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
+
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
+
+#searchconthardwarefr3 forumconthardwarefr7
+CREATE TABLE `t1` (
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`pseudo`,`date`,`topic`),
+ KEY `topic` (`topic`)
+) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (topic,date,pseudo) VALUES
+('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
+EXPLAIN SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+EXPLAIN SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
+-- error 1241
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
+EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
+drop table t1;
+
+#forumconthardwarefr7 searchconthardwarefr7
+CREATE TABLE `t1` (
+ `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+ `maxnumrep` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`numeropost`),
+ UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+
+CREATE TABLE `t2` (
+ `mot` varchar(30) NOT NULL default '',
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) NOT NULL default '',
+ PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`)
+ ) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+
+INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
+-- error 1054
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
+-- error 1054
+SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
+
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic);
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic);
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic);
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2;
+SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
+SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2;
+drop table t1,t2;
+
+#forumconthardwarefr7
+CREATE TABLE `t1` (
+ `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+ `maxnumrep` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`numeropost`),
+ UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
+-- error 1241
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+-- error 1241
+select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+(select * from t1) union (select * from t1) order by (select a from t1 limit 1);
+drop table t1;
+
+#iftest
+CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
+INSERT INTO t1 VALUES ();
+-- error 1241
+SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
+drop table t1;
+
+# threadhardwarefr7
+CREATE TABLE `t1` (
+ `numeropost` mediumint(8) unsigned NOT NULL default '0',
+ `numreponse` int(10) unsigned NOT NULL auto_increment,
+ `pseudo` varchar(35) NOT NULL default '',
+ PRIMARY KEY (`numeropost`,`numreponse`),
+ UNIQUE KEY `numreponse` (`numreponse`),
+ KEY `pseudo` (`pseudo`,`numeropost`)
+) TYPE=MyISAM;
+-- error 1246
+SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a;
+-- error 1054
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a;
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a;
+INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
+-- error 1241
+EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
+EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
+EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
+drop table t1;
+
+CREATE TABLE t1 (a int(1));
+INSERT INTO t1 VALUES (1);
+SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
+drop table t1;
+
+#update with subselects
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 22),(3, 23);
+select * from t1;
+-- error 1093
+update t1 set b= (select b from t1);
+-- error 1241
+update t1 set b= (select b from t2);
+update t1 set b= (select b from t2 where t1.a = t2.a);
+select * from t1;
+drop table t1, t2;
+
+#delete with subselects
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t1;
+select * from t1 where b = (select b from t2 where t1.a = t2.a);
+-- error 1093
+delete from t1 where b = (select b from t1);
+-- error 1241
+delete from t1 where b = (select b from t2);
+delete from t1 where b = (select b from t2 where t1.a = t2.a);
+select * from t1;
+drop table t1, t2;
+
+#multi-delete with subselects
+
+create table t11 (a int NOT NULL, b int, primary key (a));
+create table t12 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t11;
+select * from t12;
+-- error 1093
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
+-- error 1241
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
+select * from t11;
+select * from t12;
+drop table t11, t12, t2;
+
+#insert with subselects
+CREATE TABLE t1 (x int);
+create table t2 (a int);
+create table t3 (b int);
+insert into t2 values (1);
+insert into t3 values (1),(2);
+-- error 1093
+INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
+-- error 1241
+INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
+INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
+select * from t1;
+insert into t2 values (1);
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+-- sleep 1
+select * from t1;
+INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
+select * from t1;
+INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
+-- error 1054
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+-- sleep 1
+select * from t1;
+#
+#TODO: should be uncommented after bug 380 fix pushed
+#INSERT INTO t1 (x) SELECT (SELECT SUM(a)+b FROM t2) from t3;
+#select * from t1;
+drop table t1, t2, t3;
+
+#replace with subselects
+CREATE TABLE t1 (x int not null, y int, primary key (x));
+create table t2 (a int);
+create table t3 (a int);
+insert into t2 values (1);
+insert into t3 values (1),(2);
+select * from t1;
+-- error 1093
+replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
+-- error 1241
+replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
+select * from t1;
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
+-- sleep 1
+select * from t1;
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
+-- sleep 1
+select * from t1;
+replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
+select * from t1;
+drop table t1, t2, t3;
+
+-- error 1096
+SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *);
+
+CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES (1),(2);
+SELECT * FROM t2 WHERE id IN (SELECT 1);
+EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1);
+SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
+SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
+EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
+EXPLAIN SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
+SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
+SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
+-- error 1093
+INSERT INTO t2 VALUES ((SELECT * FROM t2));
+-- error 1093
+INSERT INTO t2 VALUES ((SELECT id FROM t2));
+SELECT * FROM t2;
+CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 values (1),(1);
+-- error 1241
+UPDATE t2 SET id=(SELECT * FROM t1);
+drop table t2, t1;
+
+#NULL test
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+select 1 IN (SELECT * from t1);
+select 10 IN (SELECT * from t1);
+select NULL IN (SELECT * from t1);
+update t1 set a=NULL where a=2;
+select 1 IN (SELECT * from t1);
+select 3 IN (SELECT * from t1);
+select 10 IN (SELECT * from t1);
+select 1 > ALL (SELECT * from t1);
+select 10 > ALL (SELECT * from t1);
+select 1 > ANY (SELECT * from t1);
+select 10 > ANY (SELECT * from t1);
+drop table t1;
+create table t1 (a varchar(20));
+insert into t1 values ('A'),('BC'),('DEF');
+select 'A' IN (SELECT * from t1);
+select 'XYZS' IN (SELECT * from t1);
+select NULL IN (SELECT * from t1);
+update t1 set a=NULL where a='BC';
+select 'A' IN (SELECT * from t1);
+select 'DEF' IN (SELECT * from t1);
+select 'XYZS' IN (SELECT * from t1);
+select 'A' > ALL (SELECT * from t1);
+select 'XYZS' > ALL (SELECT * from t1);
+select 'A' > ANY (SELECT * from t1);
+select 'XYZS' > ANY (SELECT * from t1);
+drop table t1;
+create table t1 (a float);
+insert into t1 values (1.5),(2.5),(3.5);
+select 1.5 IN (SELECT * from t1);
+select 10.5 IN (SELECT * from t1);
+select NULL IN (SELECT * from t1);
+update t1 set a=NULL where a=2.5;
+select 1.5 IN (SELECT * from t1);
+select 3.5 IN (SELECT * from t1);
+select 10.5 IN (SELECT * from t1);
+select 1.5 > ALL (SELECT * from t1);
+select 10.5 > ALL (SELECT * from t1);
+select 1.5 > ANY (SELECT * from t1);
+select 10.5 > ANY (SELECT * from t1);
+explain select (select a+1) from t1;
+select (select a+1) from t1;
+drop table t1;
+
+#
+# Null with keys
+#
+
+CREATE TABLE t1 (a int(11) NOT NULL default '0', PRIMARY KEY (a));
+CREATE TABLE t2 (a int(11) default '0', INDEX (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t2 VALUES (1),(2),(3);
+SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
+explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
+CREATE TABLE t3 (a int(11) default '0');
+INSERT INTO t3 VALUES (1),(2),(3);
+SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
+explain SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
+drop table t1,t2,t3;
+
+#LIMIT is not supported now
+create table t1 (a float);
+-- error 1235
+select 10.5 IN (SELECT * from t1 LIMIT 1);
+-- error 1235
+select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5);
+drop table t1;
+
+create table t1 (a int, b int, c varchar(10));
+create table t2 (a int);
+insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c');
+insert into t2 values (1),(2),(NULL);
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t1 where a=t2.a) from t2;
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2;
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t1 where a=t2.a) from t2;
+drop table t1,t2;
+
+create table t1 (a int, b real, c varchar(10));
+insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b');
+select ROW(1, 1, 'a') IN (select a,b,c from t1);
+select ROW(1, 2, 'a') IN (select a,b,c from t1);
+select ROW(1, 1, 'a') IN (select b,a,c from t1);
+select ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null);
+select ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null);
+select ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null);
+select ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a');
+select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a');
+select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
+-- error 1235
+select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1);
+do @a:=(SELECT a from t1);
+select @a;
+set @a:=2;
+set @a:=(SELECT a from t1);
+select @a;
+drop table t1;
+-- error 1146
+do (SELECT a from t1);
+-- error 1146
+set @a:=(SELECT a from t1);
+
+CREATE TABLE t1 (a int, KEY(a));
+HANDLER t1 OPEN;
+-- error 1149
+HANDLER t1 READ a=((SELECT 1));
+HANDLER t1 CLOSE;
+drop table t1;
+
+create table t1 (a int);
+create table t2 (b int);
+insert into t1 values (1),(2);
+insert into t2 values (1);
+select a from t1 where a in (select a from t1 where a in (select b from t2));
+drop table t1, t2;
+
+create table t1 (a int, b int);
+create table t2 like t1;
+insert into t1 values (1,2),(1,3),(1,4),(1,5);
+insert into t2 values (1,2),(1,3);
+select * from t1 where row(a,b) in (select a,b from t2);
+drop table t1, t2;
+
+CREATE TABLE `t1` (`i` int(11) NOT NULL default '0',PRIMARY KEY (`i`)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1);
+-- error 1111
+UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
+drop table t1;
+
+#test of uncacheable subqueries
+CREATE TABLE t1 (a int(1));
+EXPLAIN SELECT (SELECT RAND() FROM t1) FROM t1;
+EXPLAIN SELECT (SELECT ENCRYPT('test') FROM t1) FROM t1;
+EXPLAIN SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1;
+drop table t1;
+
+
+CREATE TABLE `t1` (
+ `mot` varchar(30) character set latin1 NOT NULL default '',
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
+ KEY `pseudo` (`pseudo`,`date`,`topic`),
+ KEY `topic` (`topic`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE `t2` (
+ `mot` varchar(30) character set latin1 NOT NULL default '',
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
+ KEY `pseudo` (`pseudo`,`date`,`topic`),
+ KEY `topic` (`topic`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE `t3` (
+ `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+ `maxnumrep` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`numeropost`),
+ UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('joce','1','','joce'),('test','2','','test');
+
+INSERT INTO t2 VALUES ('joce','1','','joce'),('test','2','','test');
+
+INSERT INTO t3 VALUES (1,1);
+
+SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE
+numeropost=topic);
+select * from t1;
+DELETE FROM t1 WHERE topic IN (SELECT DISTINCT topic FROM t2 WHERE NOT
+EXISTS(SELECT * FROM t3 WHERE numeropost=topic));
+select * from t1;
+
+drop table t1, t2, t3;
+
+SELECT * FROM (SELECT 1 as a,(SELECT a)) a;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT 1)) a;
+SHOW CREATE TABLE t1;
+drop table t1;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a)) a;
+SHOW CREATE TABLE t1;
+drop table t1;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a+0)) a;
+SHOW CREATE TABLE t1;
+drop table t1;
+CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a;
+SHOW CREATE TABLE t1;
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+explain select a,(select (select rand() from t1 limit 1) from t1 limit 1)
+from t1;
+drop table t1;
+
+#
+# error in IN
+#
+-- error 1146
+select t1.Continent, t2.Name, t2.Population from t1 LEFT JOIN t2 ON t1.Code = t2.Country where t2.Population IN (select max(t2.Population) AS Population from t2, t1 where t2.Country = t1.Code group by Continent);
+
+#
+# complex subquery
+#
+
+CREATE TABLE t1 (
+ ID int(11) NOT NULL auto_increment,
+ name char(35) NOT NULL default '',
+ t2 char(3) NOT NULL default '',
+ District char(20) NOT NULL default '',
+ Population int(11) NOT NULL default '0',
+ PRIMARY KEY (ID)
+) TYPE=MyISAM;
+
+INSERT INTO t1 VALUES (130,'Sydney','AUS','New South Wales',3276207);
+INSERT INTO t1 VALUES (131,'Melbourne','AUS','Victoria',2865329);
+INSERT INTO t1 VALUES (132,'Brisbane','AUS','Queensland',1291117);
+
+CREATE TABLE t2 (
+ Code char(3) NOT NULL default '',
+ Name char(52) NOT NULL default '',
+ Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL default 'Asia',
+ Region char(26) NOT NULL default '',
+ SurfaceArea float(10,2) NOT NULL default '0.00',
+ IndepYear smallint(6) default NULL,
+ Population int(11) NOT NULL default '0',
+ LifeExpectancy float(3,1) default NULL,
+ GNP float(10,2) default NULL,
+ GNPOld float(10,2) default NULL,
+ LocalName char(45) NOT NULL default '',
+ GovernmentForm char(45) NOT NULL default '',
+ HeadOfState char(60) default NULL,
+ Capital int(11) default NULL,
+ Code2 char(2) NOT NULL default '',
+ PRIMARY KEY (Code)
+) TYPE=MyISAM;
+
+INSERT INTO t2 VALUES ('AUS','Australia','Oceania','Australia and New Zealand',7741220.00,1901,18886000,79.8,351182.00,392911.00,'Australia','Constitutional Monarchy, Federation','Elisabeth II',135,'AU');
+INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,7734000,62.9,4127.00,4100.00,'Azärbaycan','Federal Republic','Heydär Äliyev',144,'AZ');
+
+select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent);
+
+drop table t1, t2;
+
+#
+# constants in IN
+#
+CREATE TABLE `t1` (
+ `id` mediumint(8) unsigned NOT NULL auto_increment,
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `pseudo` (`pseudo`),
+) TYPE=MyISAM PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (pseudo) VALUES ('test');
+SELECT 0 IN (SELECT 1 FROM t1 a);
+EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a);
+INSERT INTO t1 (pseudo) VALUES ('test1');
+SELECT 0 IN (SELECT 1 FROM t1 a);
+EXPLAIN SELECT 0 IN (SELECT 1 FROM t1 a);
+drop table t1;
+
+CREATE TABLE `t1` (
+ `i` int(11) NOT NULL default '0',
+ PRIMARY KEY (`i`)
+) TYPE=MyISAM CHARSET=latin1;
+
+INSERT INTO t1 VALUES (1);
+-- error 1111
+UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i));
+-- error 1111
+UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
+-- error 1109
+UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
+drop table t1;
+
+#
+# Multi update test
+#
+CREATE TABLE t1 (
+ id int(11) default NULL
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3);
+CREATE TABLE t2 (
+ id int(11) default NULL,
+ name varchar(15) default NULL
+) TYPE=MyISAM CHARSET=latin1;
+
+INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita');
+update t1, t2 set t2.name='lenka' where t2.id in (select id from t1);
+select * from t2;
+drop table t1,t2;
+
+#
+# correct NULL in <CONSTANT> IN (SELECT ...)
+#
+create table t1 (a int, unique index indexa (a));
+insert into t1 values (-1), (-4), (-2), (NULL);
+select -10 IN (select a from t1 FORCE INDEX (indexa));
+drop table t1;
+
+#
+# Test optimization for sub selects
+#
+create table t1 (id int not null auto_increment primary key, salary int, key(salary));
+insert into t1 (salary) values (100),(1000),(10000),(10),(500),(5000),(50000);
+explain SELECT id FROM t1 where salary = (SELECT MAX(salary) FROM t1);
+drop table t1;
+
+CREATE TABLE t1 (
+ ID int(10) unsigned NOT NULL auto_increment,
+ SUB_ID int(3) unsigned NOT NULL default '0',
+ REF_ID int(10) unsigned default NULL,
+ REF_SUB int(3) unsigned default '0',
+ PRIMARY KEY (ID,SUB_ID),
+ UNIQUE KEY t1_PK (ID,SUB_ID),
+ KEY t1_FK (REF_ID,REF_SUB),
+ KEY t1_REFID (REF_ID)
+) TYPE=MyISAM CHARSET=cp1251;
+INSERT INTO t1 VALUES (1,0,NULL,NULL),(2,0,NULL,NULL);
+SELECT DISTINCT REF_ID FROM t1 WHERE ID= (SELECT DISTINCT REF_ID FROM t1 WHERE ID=2);
+DROP TABLE t1;
+
+#
+# uninterruptable update
+#
+create table t1 (a int, b int);
+create table t2 (a int, b int);
+
+insert into t1 values (1,0), (2,0), (3,0);
+insert into t2 values (1,1), (2,1), (3,1), (2,2);
+
+update ignore t1 set b=(select b from t2 where t1.a=t2.a);
+select * from t1;
+
+drop table t1, t2;
+
+#
+# correct behavoiur for function from reduced subselect
+#
+create table t1(City VARCHAR(30),Location geometry);
+insert into t1 values("Paris",GeomFromText('POINT(2.33 48.87)'));
+select City from t1 where (select intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0);
+drop table t1;
+
+#
+# reduced subselect in ORDER BY & GROUP BY clauses
+#
+
+CREATE TABLE `t1` (
+ `id` mediumint(8) unsigned NOT NULL auto_increment,
+ `pseudo` varchar(35) NOT NULL default '',
+ `email` varchar(60) NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `email` (`email`),
+ UNIQUE KEY `pseudo` (`pseudo`),
+) TYPE=MyISAM CHARSET=latin1 PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (id,pseudo,email) VALUES (1,'test','test'),(2,'test1','test1');
+SELECT pseudo as a, pseudo as b FROM t1 GROUP BY (SELECT a) ORDER BY (SELECT id*1);
+drop table if exists t1;
+
+(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
+
+#
+# key field overflow test
+#
+--disable_warnings
+CREATE TABLE t1
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+--enable_warnings
+CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
+INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
+drop table t1;
+
+#
+# IN subselect optimization test
+#
+create table t1 (a int not null, b int, primary key (a));
+create table t2 (a int not null, primary key (a));
+create table t3 (a int not null, b int, primary key (a));
+insert into t1 values (1,10), (2,20), (3,30), (4,40);
+insert into t2 values (2), (3), (4), (5);
+insert into t3 values (10,3), (20,4), (30,5);
+select * from t2 where t2.a in (select a from t1);
+explain select * from t2 where t2.a in (select a from t1);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+drop table t1, t2, t3;
+create table t1 (a int, b int, index a (a,b));
+create table t2 (a int, index a (a));
+create table t3 (a int, b int, index a (a));
+insert into t1 values (1,10), (2,20), (3,30), (4,40);
+disable_query_log;
+# making table large enough
+let $1 = 10000;
+while ($1)
+ {
+ eval insert into t1 values (rand()*100000+200,rand()*100000);
+ dec $1;
+ }
+enable_query_log;
+insert into t2 values (2), (3), (4), (5);
+insert into t3 values (10,3), (20,4), (30,5);
+select * from t2 where t2.a in (select a from t1);
+explain select * from t2 where t2.a in (select a from t1);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+explain select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+insert into t1 values (3,31);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31);
+explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+drop table t1, t2, t3;
+
+#
+# alloc_group_fields() working
+#
+create table t1 (a int, b int);
+create table t2 (a int, b int);
+create table t3 (a int, b int);
+insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10);
+insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1);
+insert into t3 values (3,3), (2,2), (1,1);
+select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3;
+drop table t1,t2,t3;
+
+#
+# aggregate functions in HAVING test
+#
+create table t1 (s1 int);
+create table t2 (s1 int);
+insert into t1 values (1);
+insert into t2 values (1);
+select * from t1 where exists (select s1 from t2 having max(t2.s1)=t1.s1);
+drop table t1,t2;
+
+#
+# update subquery with wrong field (to force name resolving
+# in UPDATE name space)
+#
+create table t1 (s1 int);
+create table t2 (s1 int);
+insert into t1 values (1);
+insert into t2 values (1);
+-- error 1109
+update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
+DROP TABLE t1, t2;
+
+#
+# UNION unlocking test
+#
+create table t1 (a int) type=innodb;
+create table t2 (a int) type=innodb;
+create table t3 (a int) type=innodb;
+insert into t1 values (1),(2),(3),(4);
+insert into t2 values (10),(20),(30),(40);
+insert into t3 values (1),(2),(10),(50);
+select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
+drop table t1,t2;
+
+#
+# collation test
+#
+CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci,
+ s2 CHAR(5) COLLATE latin1_swedish_ci);
+INSERT INTO t1 VALUES ('z','?');
+-- error 1266
+select * from t1 where s1 > (select max(s2) from t1);
+-- error 1266
+select * from t1 where s1 > any (select max(s2) from t1);
+drop table t1;
+
+#
+# aggregate functions reinitialization
+#
+create table t1(toid int,rd int);
+create table t2(userid int,pmnew int,pmtotal int);
+insert into t2 values(1,0,0),(2,0,0);
+insert into t1 values(1,0),(1,0),(1,0),(1,12),(1,15),(1,123),(1,12312),(1,12312),(1,123),(2,0),(2,0),(2,1),(2,2);
+select userid,pmtotal,pmnew, (select count(rd) from t1 where toid=t2.userid) calc_total, (select count(rd) from t1 where rd=0 and toid=t2.userid) calc_new from t2 where userid in (select distinct toid from t1);
+drop table t1, t2;
diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test
new file mode 100644
index 00000000000..151e285e6d4
--- /dev/null
+++ b/mysql-test/t/subselect2.test
@@ -0,0 +1,149 @@
+-- source include/have_innodb.inc
+
+#
+# test of big query with a lot of IN subqueries.
+#
+
+--disable_warnings
+drop table if exists t1, t2, t3, t4;
+--enable_warnings
+
+CREATE TABLE t1
+(
+DOCID VARCHAR(32)BINARY NOT NULL
+, UUID VARCHAR(32)BINARY NOT NULL
+, MIMETYPE VARCHAR(80)BINARY
+, CONTENTDATA LONGBLOB
+, CONTENTSIZE INTEGER
+, VERSIONID INTEGER
+, REPID VARCHAR(32)BINARY
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( DOCID )
+) TYPE=InnoDB
+;
+
+CREATE TABLE t2
+(
+DOCID VARCHAR(32)BINARY NOT NULL
+, DOCNAME VARCHAR(255)BINARY NOT NULL
+, DOCTYPEID VARCHAR(32)BINARY NOT NULL
+, FOLDERID VARCHAR(32)BINARY NOT NULL
+, AUTHOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, TITLE VARCHAR(255)BINARY
+, SUBTITLE VARCHAR(255)BINARY
+, DOCABSTRACT LONGBLOB
+, PUBLISHDATE TIMESTAMP
+, EXPIRATIONDATE TIMESTAMP
+, LOCKEDBY VARCHAR(80)BINARY
+, STATUS VARCHAR(80)BINARY
+, PARENTDOCID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, MODIFIED TIMESTAMP NOT NULL
+, MODIFIER VARCHAR(255)BINARY NOT NULL
+, PUBLISHSTATUS INTEGER
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( DOCID )
+) TYPE=InnoDB
+;
+CREATE INDEX DDOCTYPEID_IDX ON t2 (DOCTYPEID);
+CREATE INDEX DFOLDERID_IDX ON t2 (FOLDERID);
+CREATE TABLE t3
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+
+CREATE INDEX FFOLDERID_IDX ON t3 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t3 (PARENTID);
+
+CREATE TABLE t4
+(
+DOCTYPEID VARCHAR(32)BINARY NOT NULL
+, DOCTYPENAME VARCHAR(80)BINARY NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, EXTNDATA LONGBLOB
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( DOCTYPEID )
+) TYPE=InnoDB;
+
+INSERT INTO t2 VALUES("c373e9f59cf15a6c3e57444553544200", "c373e9f59cf15a6c3e57444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-06 07:48:42", NULL, NULL, NULL, "2003-06-06 07:48:42", "2003-06-06 07:48:42", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-06 07:48:42", "admin", "0", NULL);
+
+INSERT INTO t2 VALUES("c373e9f5a472f43ba45e444553544200", "c373e9f5a472f43ba45e444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 18:50:12", NULL, NULL, NULL, "2003-06-07 18:50:12", "2003-06-07 18:50:12", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 18:50:12", "admin", "0", NULL);
+
+
+INSERT INTO t2 VALUES("c373e9f5a4a0f56014eb444553544200", "c373e9f5a4a0f56014eb444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 19:39:26", NULL, NULL, NULL, "2003-06-07 19:39:26", "2003-06-07 19:39:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 19:39:26", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5a4a0f8fa4a86444553544200", "c373e9f5a4a0f8fa4a86444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 19:43:05", NULL, NULL, NULL, "2003-06-07 19:43:05", "2003-06-07 19:43:05", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 19:43:05", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ac7b537205ce444553544200", "c373e9f5ac7b537205ce444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-09 08:15:24", NULL, NULL, NULL, "2003-06-09 08:15:24", "2003-06-09 08:15:24", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 08:15:24", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad0792012454444553544200", "c373e9f5ad0792012454444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-09 10:51:44", NULL, NULL, NULL, "2003-06-09 10:51:44", "2003-06-09 10:51:44", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 10:51:44", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad079821ef34444553544200", "First Discussion", "c373e9f5ad079174ff17444553544200", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:16:50", "Title: First Discussion", NULL, NULL, "2003-06-09 10:51:26", "2003-06-09 10:51:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:16:50", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad07993f3859444553544200", "Last Discussion", "c373e9f5ad079174ff17444553544200", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:21:06", "Title: Last Discussion", NULL, "Setting new abstract and keeping doc checked out", "2003-06-09 10:51:26", "2003-06-09 10:51:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:21:06", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad079a3219c4444553544200", "testdoclayout", "340d243c45f111d497b00010a4ef934d", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:25:31", "Title: Test doc layout", "Subtitle: test doc layout", NULL, "2003-06-09 10:51:27", "2003-06-09 10:51:27", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:25:31", "admin", "0", NULL);
+
+
+
+INSERT INTO t3 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t3 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t3 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad07919e1963444553544200", "NewDestDirectory", "admin", "2003-06-09 10:51:28", "Adding new directory", "128", "2003-06-09 10:51:28", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad07919fe525444553544200", "SubDestDirectory", "admin", "2003-06-09 10:51:28", "Adding new directory", "128", "2003-06-09 10:51:28", "admin", "0", "c373e9f5ad07919e1963444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a0dab5444553544200", "Level1", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a14669444553544200", "Level2", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "c373e9f5ad0791a0dab5444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a23c0e444553544200", "Level3", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "c373e9f5ad0791a14669444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a6b11f444553544200", "Dir1", "admin", "2003-06-09 10:51:30", NULL, "0", "2003-06-09 10:51:30", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a897d6444553544200", "Dir2", "admin", "2003-06-09 10:51:30", NULL, "0", "2003-06-09 10:51:30", "admin", "0", "c373e9f5ad0791a6b11f444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a9a063444553544200", "NewDestDirectory", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791a897d6444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791aa73e3444553544200", "LevelA", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791a0dab5444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ab034b444553544200", "LevelB", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791aa73e3444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ac7311444553544200", "LevelC", "admin", "2003-06-09 10:51:32", NULL, "0", "2003-06-09 10:51:32", "admin", "0", "c373e9f5ad0791ab034b444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ad66cf444553544200", "test2", "admin", "2003-06-09 10:51:32", NULL, "0", "2003-06-09 10:51:32", "admin", "0", "c373e9f5ad0791724315444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791aebd87444553544200", "test3", "admin", "2003-06-09 10:51:33", NULL, "0", "2003-06-09 10:51:33", "admin", "0", "c373e9f5ad0791ad66cf444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791dbaac4444553544200", "Special Café Folder", "admin", "2003-06-09 10:51:43", "test folder names with special chars", "0", "2003-06-09 10:51:43", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796bf913f444553544200", "CopiedFolder", "admin", "2003-06-09 11:09:05", "Movie Reviews", "0", "2003-06-09 11:09:05", "admin", "0", "c373e9f5ad0791a23c0e444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796c0eca4444553544200", "Movie Reviews", "admin", "2003-06-09 11:09:13", "Movie Reviews", "0", "2003-06-09 11:09:13", "admin", "33", "c373e9f5ad0796bf913f444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796d9b895444553544200", "NewBookFolder", "admin", "2003-06-09 11:12:41", "NewBooks - folder", "0", "2003-06-09 11:12:41", "admin", "0", "c373e9f5ad0796c0eca4444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad079b4c9355444553544200", "CopiedFolder", "admin", "2003-06-09 11:26:34", "Movie Reviews", "0", "2003-06-09 11:26:34", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+
+
+INSERT INTO t4 VALUES("340d243c45f111d497b00010a4ef934d", "Document Layout", "The system Document Layouts Document Type", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("340d243d45f111d497b00010a4ef934d", "Default", "The default system Document Type", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("4d09dd60850711d4998a204c4f4f5020", "__SystemResourceType", "The type for all the uploaded resources", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("91d4d595478211d497b40010a4ef934d", "__PmcSystemDefaultType", "The type for all the default available fields", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("c373e9f59cf15a59b08a444553544200", "NoFieldDocType", "plain doc type", NULL, "2003-06-06 07:48:40", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a5c6a99444553544200", "Movie Review", "This doc type is for movie reviews", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<props autocheckin=\"false\" autopublish=\"false\" binary=\"choice\" categories=\"none\" cleanup=\"false\" folder=\"none\"><![CDATA[Doc type for cm tests]]></props>\r\n", "2003-06-06 07:48:40", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a6116a5444553544200", "Special DocÃu20A4u20A4u0113ééøÉu016BType", "test special chars xxxé in doc type", NULL, "2003-06-06 07:48:41", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a695d47444553544200", "Movie", NULL, NULL, "2003-06-06 07:48:41", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f5ad079174ff17444553544200", "Discussion", NULL, NULL, "2003-06-09 10:51:25", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f5ad0791da7e2b444553544200", "Books", "list of recommended books", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<props autocheckin=\"false\" autopublish=\"false\" binary=\"choice\" categories=\"none\" cleanup=\"false\" folder=\"none\"><![CDATA[Doc type for cm tests]]><![CDATA[Doc type for book tests]]></props>\r\n", "2003-06-09 10:51:40", "admin", NULL);
+
+ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_DCTYPES ( DOCTYPEID)
+ REFERENCES t4 (DOCTYPEID );
+ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_FLDRS ( FOLDERID)
+ REFERENCES t3 (FOLDERID );
+ALTER TABLE t3 ADD FOREIGN KEY FK_FLDRS_PRNTID ( PARENTID)
+ REFERENCES t3 (FOLDERID );
+
+SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
+
+EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
+
+drop table t1, t2, t3, t4; \ No newline at end of file
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index 5e1fe313a7e..f618c342936 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -3,12 +3,15 @@ disable_query_log;
show variables like "have_symlink";
enable_query_log;
+--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");
diff --git a/mysql-test/t/tablelock.test b/mysql-test/t/tablelock.test
index fa8c4f03675..fbc5d685096 100644
--- a/mysql-test/t/tablelock.test
+++ b/mysql-test/t/tablelock.test
@@ -2,7 +2,10 @@
# Test of lock tables
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 ( n int auto_increment primary key);
lock tables t1 write;
insert into t1 values(NULL);
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 665e690a322..03b6fa35bfa 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -2,7 +2,10 @@
# Test of temporary tables
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
CREATE TABLE t1 (c int not null, d char (10) not null);
insert into t1 values(1,""),(2,"a"),(3,"b");
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
@@ -34,7 +37,6 @@ drop table t1;
# Test CONCAT_WS with temporary tables
#
-drop table if exists t1;
CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255));
INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1');
SELECT CONCAT_WS(pkCrash, strCrash) FROM t1;
@@ -74,8 +76,6 @@ drop table t1;
# In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based
# temporary table when a memory based one would be good enough.
-drop table if exists t1;
-
CREATE TABLE t1 (
d datetime default NULL
) TYPE=MyISAM;
diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test
index eeb79f497fa..dd80baba269 100644
--- a/mysql-test/t/truncate.test
+++ b/mysql-test/t/truncate.test
@@ -1,7 +1,10 @@
#
# Test of truncate
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a integer, b integer,c1 CHAR(10));
insert into t1 (a) values (1),(2);
truncate table t1;
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 4132b1f48a4..ebe342a4ef5 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -3,10 +3,43 @@
#
#
+# Basic cleanup
+#
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7;
+--enable_warnings
+
+
+#
+# Check syntax for creating BLOB/TEXT
+#
+
+CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
+show columns from t1;
+CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000));
+show columns from t2;
+create table t3 (a long, b long byte);
+show create TABLE t3;
+drop table t1,t2,t3
+
+#
+# Check errors with blob
+#
+
+--error 1074
+CREATE TABLE t1 (a char(257) default "hello");
+--error 1101
+CREATE TABLE t2 (a blob default "hello");
+
+# Safety to be able to continue with other tests if above fails
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+#
# test of full join with blob
#
-drop table if exists t1,t2,t3,t4,t5,t6,t7;
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
insert into t1 values (null,"a","A");
insert into t1 values (null,"bbb","BBB");
@@ -58,6 +91,7 @@ select b from t1 where b like "%HELLO%";
select d from t1 where d like "%HELLO%";
select c from t1 having c like "%HELLO%";
select d from t1 having d like "%HELLO%";
+select d from t1 having d like "%HE%LLO%";
select t from t1 order by t;
select c from t1 order by c;
select b from t1 order by b;
@@ -260,6 +294,13 @@ drop table t1;
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null);
insert into t1 (id) values (1);
+select
+ charset(load_file('../../std_data/words.dat')),
+ collation(load_file('../../std_data/words.dat')),
+ coercibility(load_file('../../std_data/words.dat'));
update t1 set imagem=load_file('../../std_data/words.dat') where id=1;
select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
drop table t1;
+create table t1 select load_file('../../std_data/words.dat');
+show full fields from t1;
+drop table t1;
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index bd6d8c49c22..5a53c635e6e 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -1,6 +1,10 @@
#
# test of problem with date fields
#
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
@@ -11,7 +15,6 @@ drop table t1;
# problem with date conversions
#
-drop table if exists t1,t2;
CREATE TABLE t1 (name char(6),cdate date);
INSERT INTO t1 VALUES ('name1','1998-01-01');
INSERT INTO t1 VALUES ('name2','1998-01-01');
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 51b65d00243..d2611973101 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -2,7 +2,10 @@
# testing different DATETIME ranges
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (t datetime);
insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959);
select * from t1;
@@ -19,7 +22,7 @@ drop table t1;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
-select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1;
+select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
drop table t1;
#
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 7aedc051905..36bd8eb48e4 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -1,6 +1,10 @@
# bug in decimal() with negative numbers by kaido@tradenet.ee
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
@@ -234,9 +238,9 @@ drop table t1;
# Test of wrong decimal type
#
---error 1074
+--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
---error 1074
+--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
---error 1074
+--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test
index 8f399e4364e..49ba73acaa8 100644
--- a/mysql-test/t/type_enum.test
+++ b/mysql-test/t/type_enum.test
@@ -2,7 +2,10 @@
# Problem with many enums
#
+--disable_warnings
DROP TABLE if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL,
KEY field (field)
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 23941ad2913..f6281ca6c21 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -2,11 +2,14 @@
# -----------
# Numeric floating point.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
SELECT 10,10.0,10.,.1e+2,100.0e-1;
SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
-drop table if exists t1;
create table t1 (f1 float(24),f2 float(52));
show full columns from t1;
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
@@ -44,6 +47,8 @@ drop table t1;
# Errors
-!$1063 create table t1 (f float(54)); # Should give an error
+--error 1063
+create table t1 (f float(54)); # Should give an error
+--disable_warnings
drop table if exists t1;
-
+--enable_warnings
diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test
index 63bbe43512d..09b5867e7a8 100644
--- a/mysql-test/t/type_ranges.test
+++ b/mysql-test/t/type_ranges.test
@@ -2,7 +2,10 @@
# Test ranges for all types and some other basic tests
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+SET SQL_WARNINGS=1;
CREATE TABLE t1 (
auto int(5) unsigned NOT NULL auto_increment,
@@ -53,7 +56,7 @@ DROP INDEX test ON t1;
insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
-insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3);
+insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3);
insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test
index 7f1a75e5dbd..6c0f162dc86 100644
--- a/mysql-test/t/type_set.test
+++ b/mysql-test/t/type_set.test
@@ -2,10 +2,15 @@
# Test of SET with space
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a set (' ','a','b') not null);
show create table t1;
drop table t1;
create table t1 (a set (' ','a','b ') not null default 'b ');
show create table t1;
drop table t1;
+CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) TYPE=MyISAM CHARSET=utf8;
+DROP TABLE t1;
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index 2496ec36915..2f342f8bf67 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -1,7 +1,11 @@
#
# testing of the TIME column type
#
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (t time);
insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index eb0def74a17..cd76dbe6ab0 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -2,7 +2,10 @@
# Test timestamp
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
CREATE TABLE t1 (a int, t timestamp);
CREATE TABLE t2 (a int, t datetime);
SET TIMESTAMP=1234;
@@ -35,7 +38,7 @@ drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
-select * from t1;
+select ix+0 from t1;
drop table t1;
CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
diff --git a/mysql-test/t/type_uint.test b/mysql-test/t/type_uint.test
index 32bcd61ecdb..ee5f5e8123b 100644
--- a/mysql-test/t/type_uint.test
+++ b/mysql-test/t/type_uint.test
@@ -2,7 +2,11 @@
# test of unsigned int
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
create table t1 (this int unsigned);
insert into t1 values (1);
insert into t1 values (-1);
diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test
index 8f4f23badb4..9922df447fc 100644
--- a/mysql-test/t/type_year.test
+++ b/mysql-test/t/type_year.test
@@ -1,7 +1,10 @@
#
# Test year
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (y year,y2 year(2));
insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69);
select * from t1;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index ea7bdb4ee1b..e7bda27d43e 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -2,7 +2,10 @@
# Test of unions
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
+--enable_warnings
+
CREATE TABLE t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
CREATE TABLE t2 (a int not null, b char (10) not null);
@@ -20,6 +23,8 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
(select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4;
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1);
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
+--error 1249
+(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2;
select found_rows();
@@ -70,6 +75,19 @@ replace into t3 select a,b as c from t1 union all select a,b from t2;
drop table t1,t2,t3;
#
+# Test some unions without tables
+#
+--error 1096
+select * union select 1;
+select 1 as a,(select a union select a);
+--error 1054
+(select 1) union (select 2) order by 0;
+SELECT @a:=1 UNION SELECT @a:=@a+1;
+--error 1054
+(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
+(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
+
+#
# Test bug reported by joc@presence-pc.com
#
@@ -88,7 +106,7 @@ SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pse
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce';
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1;
drop table t1;
-drop table if exists t1,t2;
+
create table t1 (a int);
create table t2 (a int);
insert into t1 values (1),(2),(3),(4),(5);
@@ -157,8 +175,12 @@ INSERT INTO t6 VALUES (1,'test',8);
SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
(SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test") UNION (SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test");
-
drop table t1,t2,t3,t4,t5,t6;
+
+#
+# Test insert ... SELECT with UNION
+#
+
CREATE TABLE t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
CREATE TABLE t2 (a int not null, b char (10) not null);
@@ -224,3 +246,47 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
drop table t1,t2;
+
+#
+# Test for another bug with UNION and LEFT JOIN
+#
+CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM;
+INSERT INTO t1 (id) VALUES("1");
+CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM;
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
+"foo1", "bar1");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
+"foo2", "bar2");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL,
+"bar3");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1",
+"foo4", "bar4");
+SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
+SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
+drop table if exists t1,t2;
+
+#
+# Test of bug when using the same table multiple times
+#
+create table t1 (a int not null primary key auto_increment, b int, key(b));
+create table t2 (a int not null primary key auto_increment, b int);
+insert into t1 (b) values (1),(2),(2),(3);
+insert into t2 (b) values (10),(11),(12),(13);
+
+explain (select * from t1 where a=1) union (select * from t2 where a=1);
+(select * from t1 where a=5) union (select * from t2 where a=1);
+(select * from t1 where a=5 and a=6) union (select * from t2 where a=1);
+(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1);
+(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a);
+explain (select * from t1 where a=1 and b=10) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a);
+explain (select * from t1 where a=1) union (select * from t1 where b=1);
+drop table t1,t2;
+create table t1 ( id int not null auto_increment, primary key (id) ,user_name text );
+create table t2 ( id int not null auto_increment, primary key (id) ,group_name text );
+create table t3 ( id int not null auto_increment, primary key (id) ,user_id int ,index user_idx (user_id) ,foreign key (user_id) references users(id) ,group_id int ,index group_idx (group_id) ,foreign key (group_id) references groups(id) );
+insert into t1 (user_name) values ('Tester');
+insert into t2 (group_name) values ('Group A');
+insert into t2 (group_name) values ('Group B');
+insert into t3 (user_id, group_id) values (1,1);
+select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c;
+drop table t1, t2, t3;
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index a455b308158..485af981fb4 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -2,7 +2,10 @@
# test of updating of keys
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int auto_increment , primary key (a));
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
update t1 set a=a+10 where a > 34;
@@ -90,7 +93,10 @@ select * from t1 order by a,b;
update t1 set b=100 where a=1 order by b desc limit 2;
update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
-drop table t1;
+create table t2 (a int not null, b int not null);
+insert into t2 values (1,1),(1,2),(1,3);
+update t1 set b=(select distinct 1 from (select * from t2) a);
+drop table t1,t2;
#
# Test with limit (Bug #393)
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index f5f91a8a680..514eace25a3 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -1,11 +1,15 @@
-error 1054;
+# Initialise
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+--error 1054
set @a := foo;
set @a := connection_id() + 3;
select @a - connection_id();
# Check using and setting variables with SELECT DISTINCT
-drop table if exists t1,t2;
CREATE TABLE t1 ( i int not null, v int not null,index (i));
insert into t1 values (1,1),(1,3),(2,1);
create table t2 (i int not null, unique (i));
diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test
index cc9ee99b7f9..d58954a189b 100644
--- a/mysql-test/t/varbinary.test
+++ b/mysql-test/t/varbinary.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
#
# varbinary as string and number
#
@@ -10,7 +15,6 @@ select x'31',X'ffff'+0;
# Test of hex constants in WHERE:
#
-drop table if exists t1;
create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) );
insert into t1 set UNIQ=0x38afba1d73e6a18a;
insert into t1 set UNIQ=123;
diff --git a/mysql-test/t/variables-master.opt b/mysql-test/t/variables-master.opt
index 5851d32ec31..a0577107f74 100644
--- a/mysql-test/t/variables-master.opt
+++ b/mysql-test/t/variables-master.opt
@@ -1 +1 @@
-max_join_size=10
+--max_join_size=10
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index fa39906fd6a..22f8406cba5 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1,7 +1,10 @@
#
# test variables
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
set @`test`=1,@TEST=3,@select=2,@t5=1.23456;
select @test,@`select`,@TEST,@not_used;
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
@@ -88,12 +91,8 @@ show variables like 'net_buffer_length';
set net_buffer_length=2000000000;
show variables like 'net_buffer_length';
-set GLOBAL character set cp1251_koi8;
-show global variables like "convert_character_set";
set character set cp1251_koi8;
-show variables like "convert_character_set";
-set global character set default, session character set default;
-show variables like "convert_character_set";
+show variables like "character_set_client";
select @@timestamp>0;
set @@rand_seed1=10000000,@@rand_seed2=1000000;
@@ -120,11 +119,9 @@ set SESSION query_cache_size=10000;
--error 1230
set GLOBAL table_type=DEFAULT;
--error 1115
-set convert_character_set=UNKNOWN_CHARACTER_SET;
---error 1115
-set character set unknown;
---error 1232
-set character set 0;
+set character_set_client=UNKNOWN_CHARACTER_SET;
+--error 1272
+set collation_connection=UNKNOWN_COLLATION;
--error 1228
set global autocommit=1;
--error 1228
@@ -149,8 +146,8 @@ set big_tables=1;
select @@autocommit, @@big_tables;
set global binlog_cache_size=100;
set bulk_insert_buffer_size=100;
-set convert_character_set=cp1251_koi8;
-set convert_character_set=default;
+set character set cp1251_koi8;
+set character set default;
set @@global.concurrent_insert=1;
set global connect_timeout=100;
select @@delay_key_write;
@@ -233,7 +230,6 @@ set log_warnings=1;
# key buffer
#
-DROP TABLE IF EXISTS t1,t2;
create table t1 (a int not null auto_increment, primary key(a));
create table t2 (a int not null auto_increment, primary key(a));
insert into t1 values(null),(null),(null);
@@ -243,6 +239,7 @@ select @@key_buffer_size;
select * from t1 where a=2;
select * from t2 where a=3;
check table t1,t2;
+select max(a) +1, max(a) +2 into @xx,@yy from t1;
drop table t1,t2;
#
diff --git a/mysql-test/t/warnings-master.opt b/mysql-test/t/warnings-master.opt
new file mode 100644
index 00000000000..3b8baeddb14
--- /dev/null
+++ b/mysql-test/t/warnings-master.opt
@@ -0,0 +1 @@
+--skip-isam
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 5fb536def71..050449f0f5b 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -1,7 +1,11 @@
#
# Test some warnings
#
-drop table if exists t1;
+--disable-warnings
+drop table if exists t1, t2;
+--enable-warnings
+SET SQL_WARNINGS=1;
+
create table t1 (a int);
insert into t1 values (1);
insert into t1 values ("hej");
@@ -11,3 +15,71 @@ insert into t1 values ("hej");
insert into t1 values ("hej"),("då");
drop table t1;
set SQL_WARNINGS=0;
+
+#
+# Test other warnings
+#
+
+drop temporary table if exists not_exists;
+drop table if exists not_exists_table;
+show warnings limit 1;
+drop database if exists not_exists_db;
+show count(*) warnings;
+create table t1(id int);
+create table if not exists t1(id int);
+select @@warning_count;
+drop table t1;
+
+#
+# Test warnings for LOAD DATA INFILE
+#
+
+create table t1(a tinyint, b int not null, c date, d char(5));
+load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ',';
+select @@warning_count;
+drop table t1;
+
+#
+# Warnings from basic INSERT, UPDATE and ALTER commands
+#
+
+create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
+insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
+alter table t1 modify c char(4);
+alter table t1 add d char(2);
+update t1 set a=NULL where a=10;
+update t1 set c='mysql ab' where c='test';
+update t1 set d=c;
+create table t2(a tinyint NOT NULL, b char(3));
+insert into t2 select b,c from t1;
+insert into t2(b) values('mysqlab');
+set sql_warnings=1;
+insert into t2(b) values('mysqlab');
+set sql_warnings=0;
+drop table t1, t2;
+
+#
+# Test for max_error_count
+#
+
+create table t1(a char(10));
+let $1=50;
+disable_query_log;
+while ($1)
+{
+ eval insert into t1 values('mysql ab');
+ dec $1;
+}
+enable_query_log;
+alter table t1 add b char;
+set max_error_count=10;
+update t1 set b=a;
+select @@warning_count;
+
+#
+# Test for handler type
+#
+drop table t1;
+create table t1 (id int) type=isam;
+alter table t1 type=isam;
+drop table t1;