summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2010-06-26 14:05:41 +0400
committerSergey Petrunya <psergey@askmonty.org>2010-06-26 14:05:41 +0400
commit27f9fc063c54ad8c9c0e35e78bbbb14a3e2419af (patch)
treeaf692374b15c7e8186406a1009e678cfedc3e78b /mysql-test/t
parent7754be7f4c19d442564d8fef6853e711aa0e3cec (diff)
parent50cc6c9d8a7d68ace0802702f3bc10cb2afb3730 (diff)
downloadmariadb-git-27f9fc063c54ad8c9c0e35e78bbbb14a3e2419af.tar.gz
MariaDB 5.2 -> MariaDB 5.3 merge
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/archive.test34
-rw-r--r--mysql-test/t/bigint.test35
-rw-r--r--mysql-test/t/bug39022.test63
-rw-r--r--mysql-test/t/bug46261-master.opt1
-rw-r--r--mysql-test/t/bug46261.test16
-rw-r--r--mysql-test/t/bug47671-master.opt2
-rw-r--r--mysql-test/t/change_user.test57
-rw-r--r--mysql-test/t/connect.test28
-rw-r--r--mysql-test/t/csv.test20
-rw-r--r--mysql-test/t/ctype_latin1_de-master.opt2
-rw-r--r--mysql-test/t/ctype_ldml.test8
-rw-r--r--mysql-test/t/ctype_ucs.test9
-rw-r--r--mysql-test/t/ctype_ucs2_def-master.opt2
-rw-r--r--mysql-test/t/delete.test29
-rw-r--r--mysql-test/t/disabled.def2
-rw-r--r--mysql-test/t/error_simulation.test16
-rw-r--r--mysql-test/t/events_bugs.test1
-rw-r--r--mysql-test/t/explain.test52
-rw-r--r--mysql-test/t/fulltext.test30
-rw-r--r--mysql-test/t/func_concat.test20
-rw-r--r--mysql-test/t/func_gconcat.test27
-rw-r--r--mysql-test/t/func_str.test11
-rw-r--r--mysql-test/t/func_time.test2
-rw-r--r--mysql-test/t/gis-rtree.test25
-rw-r--r--mysql-test/t/grant.test25
-rw-r--r--mysql-test/t/group_by.test50
-rw-r--r--mysql-test/t/group_min_max.test41
-rw-r--r--mysql-test/t/handler_myisam.test11
-rw-r--r--mysql-test/t/having.test101
-rw-r--r--mysql-test/t/information_schema_all_engines.test3
-rw-r--r--mysql-test/t/innodb-autoinc-44030.test40
-rw-r--r--mysql-test/t/innodb-autoinc.test637
-rw-r--r--mysql-test/t/innodb-use-sys-malloc.test51
-rw-r--r--mysql-test/t/innodb_bug21704.test96
-rw-r--r--mysql-test/t/innodb_bug38231.test75
-rw-r--r--mysql-test/t/innodb_bug39438-master.opt1
-rw-r--r--mysql-test/t/innodb_bug39438.test31
-rw-r--r--mysql-test/t/innodb_bug40565.test10
-rw-r--r--mysql-test/t/innodb_bug42101-nonzero-master.opt1
-rw-r--r--mysql-test/t/innodb_bug42101-nonzero.test21
-rw-r--r--mysql-test/t/innodb_bug42101.test19
-rw-r--r--mysql-test/t/innodb_bug44032.test13
-rw-r--r--mysql-test/t/innodb_bug44369.test17
-rw-r--r--mysql-test/t/innodb_bug45357.test10
-rw-r--r--mysql-test/t/innodb_bug46000.test34
-rw-r--r--mysql-test/t/innodb_bug47777.test24
-rw-r--r--mysql-test/t/innodb_mysql.test95
-rw-r--r--mysql-test/t/join.test48
-rw-r--r--mysql-test/t/join_outer.test18
-rw-r--r--mysql-test/t/key_cache.test277
-rw-r--r--mysql-test/t/loaddata.test35
-rw-r--r--mysql-test/t/log_tables_upgrade.test32
-rw-r--r--mysql-test/t/merge.test72
-rw-r--r--mysql-test/t/metadata.test13
-rw-r--r--mysql-test/t/multi_update.test12
-rw-r--r--mysql-test/t/myisam.test83
-rw-r--r--mysql-test/t/mysql_upgrade.test2
-rw-r--r--mysql-test/t/mysqlbinlog.test35
-rw-r--r--mysql-test/t/mysqltest.test200
-rw-r--r--mysql-test/t/no_binlog.test6
-rw-r--r--mysql-test/t/partition.test13
-rw-r--r--mysql-test/t/partition_debug_sync.test81
-rw-r--r--mysql-test/t/partition_error.test24
-rw-r--r--mysql-test/t/partition_example-master.opt1
-rw-r--r--mysql-test/t/partition_example.test23
-rw-r--r--mysql-test/t/partition_innodb.test61
-rw-r--r--mysql-test/t/partition_innodb_plugin.test1
-rw-r--r--mysql-test/t/partition_innodb_semi_consistent.test2
-rw-r--r--mysql-test/t/partition_pruning.test28
-rw-r--r--mysql-test/t/partition_range.test18
-rw-r--r--mysql-test/t/plugin.test51
-rw-r--r--mysql-test/t/plugin_not_embedded-master.opt1
-rw-r--r--mysql-test/t/plugin_not_embedded.test20
-rw-r--r--mysql-test/t/ps.test14
-rw-r--r--mysql-test/t/query_cache_with_views.test17
-rw-r--r--mysql-test/t/row.test11
-rw-r--r--mysql-test/t/select_pkeycache-master.opt1
-rw-r--r--mysql-test/t/select_pkeycache.test8
-rw-r--r--mysql-test/t/skip_name_resolve.test21
-rw-r--r--mysql-test/t/sp-bugs.test43
-rw-r--r--mysql-test/t/sp.test1
-rw-r--r--mysql-test/t/sp_notembedded.test37
-rw-r--r--mysql-test/t/status_user.test14
-rw-r--r--mysql-test/t/subselect.test100
-rw-r--r--mysql-test/t/symlink.test22
-rw-r--r--mysql-test/t/table_options.test68
-rw-r--r--mysql-test/t/trigger.test74
-rw-r--r--mysql-test/t/type_bit.test13
-rw-r--r--mysql-test/t/type_date.test20
-rw-r--r--mysql-test/t/type_year.test16
-rw-r--r--mysql-test/t/udf.test5
-rw-r--r--mysql-test/t/update.test16
-rw-r--r--mysql-test/t/variables.test8
-rw-r--r--mysql-test/t/variables_community.test (renamed from mysql-test/t/variables+c.test)0
-rw-r--r--mysql-test/t/variables_debug.test13
-rw-r--r--mysql-test/t/view.test55
-rw-r--r--mysql-test/t/view_alias.test92
-rw-r--r--mysql-test/t/view_grant.test14
-rw-r--r--mysql-test/t/xa.test16
99 files changed, 2602 insertions, 1152 deletions
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index ba166571076..6704257f9af 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1646,3 +1646,37 @@ INSERT INTO t1 (col1, col2) VALUES (1, "value");
REPAIR TABLE t1;
DROP TABLE t1;
remove_file $MYSQLD_DATADIR/test/t1.ARM;
+
+--echo #
+--echo # BUG#48757 - missing .ARZ file causes server crash
+--echo #
+CREATE TABLE t1(a INT) ENGINE=ARCHIVE;
+FLUSH TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.ARZ
+--error ER_FILE_NOT_FOUND
+SELECT * FROM t1;
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t1;
+
+
+--echo #
+--echo # BUG#46565 - repair of partition fail for archive engine
+--echo #
+--echo # Installing corrupted table files for t1.
+# bug46565 was created, filled and damaged as following:
+# CREATE TABLE bug46565(a INT) ENGINE=archive;
+# INSERT INTO bug46565 VALUES(1);
+# FLUSH TABLE bug46565;
+# INSERT INTO bug46565 VALUES(2),(3);
+# FLUSH TABLE bug46565;
+# dd if=bug46565.ARZ of=std_data/bug46565.ARZ bs=1 count=8670
+copy_file std_data/bug46565.frm $MYSQLD_DATADIR/test/t1.frm;
+copy_file std_data/bug46565.ARZ $MYSQLD_DATADIR/test/t1.ARZ;
+--error ER_CRASHED_ON_USAGE
+SELECT * FROM t1;
+REPAIR TABLE t1;
+--error ER_CRASHED_ON_USAGE
+SELECT * FROM t1;
+REPAIR TABLE t1 EXTENDED;
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index 5a589816dcd..e19bba971f9 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -327,3 +327,38 @@ drop table t1;
create table t1 select -9223372036854775809 bi;
describe t1;
drop table t1;
+
+--echo #
+--echo # Bug #45360: wrong results
+--echo #
+
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY,
+ a BIGINT(20) UNSIGNED,
+ b VARCHAR(20));
+
+INSERT INTO t1 (a) VALUES
+ (0),
+ (CAST(0x7FFFFFFFFFFFFFFF AS UNSIGNED)),
+ (CAST(0x8000000000000000 AS UNSIGNED)),
+ (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED));
+
+UPDATE t1 SET b = a;
+
+let $n = `SELECT MAX(id) FROM t1`;
+while($n) {
+ let $x = `SELECT a FROM t1 WHERE id = $n`;
+ dec $n;
+ let $hex = `SELECT HEX($x)`;
+ echo # $hex;
+
+ --disable_result_log
+ eval EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = $x AND TRIM(a) = b;
+ --enable_result_log
+ SHOW WARNINGS;
+}
+
+DROP TABLE t1;
+
+--echo # End of 5.1 tests
+
+
diff --git a/mysql-test/t/bug39022.test b/mysql-test/t/bug39022.test
new file mode 100644
index 00000000000..268b207e0e5
--- /dev/null
+++ b/mysql-test/t/bug39022.test
@@ -0,0 +1,63 @@
+-- source include/have_log_bin.inc
+-- source include/have_innodb.inc
+-- source include/not_binlog_format_row.inc
+
+--echo #
+--echo # Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees
+--echo #
+
+CREATE TABLE t1(a TINYINT NOT NULL,b TINYINT,PRIMARY KEY(b)) ENGINE=innodb;
+CREATE TABLE t2(d TINYINT NOT NULL,UNIQUE KEY(d)) ENGINE=innodb;
+INSERT INTO t1 VALUES (13,0),(8,1),(9,2),(6,3),
+(11,5),(11,6),(7,7),(7,8),(4,9),(6,10),(3,11),(11,12),
+(12,13),(7,14);
+INSERT INTO t2 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
+(11),(12),(13),(14);
+
+connect (thread1, localhost, root,,);
+connect (thread2, localhost, root,,);
+
+connection thread1;
+--echo # in thread1
+START TRANSACTION;
+
+connection thread2;
+--echo # in thread2
+REPLACE INTO t2 VALUES (-17);
+SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d);
+
+connection thread1;
+--echo # in thread1
+REPLACE INTO t1(a,b) VALUES (67,20);
+
+connection thread2;
+--echo # in thread2
+COMMIT;
+START TRANSACTION;
+REPLACE INTO t1(a,b) VALUES (65,-50);
+REPLACE INTO t2 VALUES (-91);
+send;
+SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); #waits
+
+connection thread1;
+--echo # in thread1
+
+--echo # should not crash
+--error ER_LOCK_DEADLOCK
+SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); #crashes
+
+connection thread2;
+--echo # in thread2
+REAP;
+
+disconnect thread2;
+--source include/wait_until_disconnected.inc
+
+connection thread1;
+--echo # in thread1;
+disconnect thread1;
+--source include/wait_until_disconnected.inc
+
+connection default;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/bug46261-master.opt b/mysql-test/t/bug46261-master.opt
new file mode 100644
index 00000000000..6be4269e809
--- /dev/null
+++ b/mysql-test/t/bug46261-master.opt
@@ -0,0 +1 @@
+--skip-grant-tables $EXAMPLE_PLUGIN_OPT
diff --git a/mysql-test/t/bug46261.test b/mysql-test/t/bug46261.test
new file mode 100644
index 00000000000..67bdc995850
--- /dev/null
+++ b/mysql-test/t/bug46261.test
@@ -0,0 +1,16 @@
+--source include/not_embedded.inc
+--source include/have_example_plugin.inc
+
+--echo #
+--echo # Bug#46261 Plugins can be installed with --skip-grant-tables
+--echo #
+
+--replace_regex /\.dll/.so/
+--error ER_OPTION_PREVENTS_STATEMENT
+eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+
+--replace_regex /\.dll/.so/
+--error ER_OPTION_PREVENTS_STATEMENT
+eval UNINSTALL PLUGIN example;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/bug47671-master.opt b/mysql-test/t/bug47671-master.opt
index 0afdf49e022..ad54fbc3467 100644
--- a/mysql-test/t/bug47671-master.opt
+++ b/mysql-test/t/bug47671-master.opt
@@ -1 +1 @@
---default-character-set=utf8 --skip-character-set-client-handshake
+--character-set-server=utf8 --skip-character-set-client-handshake
diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test
index 46bf1d2a92c..5639e013de8 100644
--- a/mysql-test/t/change_user.test
+++ b/mysql-test/t/change_user.test
@@ -1,4 +1,61 @@
#
+# functional change user tests
+#
+
+grant select on test.* to test_nopw;
+grant select on test.* to test_oldpw identified by password "09301740536db389";
+grant select on test.* to test_newpw identified by "newpw";
+
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+#
+# massaging the data for tests to pass in the embedded server,
+# that has authentication completely disabled or, if enabled, can
+# only do new auth (20-byte scramble).
+#
+
+change_user test_nopw;
+--replace_result <@> <test_nopw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+#
+# embedded with enabled privilege control cannot do plugin negotiation.
+# that is, it cannot try to authenticate with a new scramble, receive a request
+# to switch to an old scramble, and retry with an old scramble.
+# As a result, it cannot change to a user that has old scramble and
+# and it stays logged as a previous user - test_nopw in this test file.
+# For the embedded with auth we replace nopw with oldpw in the results.
+#
+let $repl = `select if(version() like '%embedded%' and user() like '%nopw%', 'nopw', 'oldpw')`;
+
+change_user test_oldpw, oldpw;
+--replace_result <@> <test_oldpw@%> @> @localhost> $repl oldpw
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_newpw, newpw;
+--replace_result <@> <test_newpw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user root;
+--replace_result <@> <root@localhost> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+change_user test_nopw,,test;
+--replace_result <@> <test_nopw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_oldpw,oldpw,test;
+--replace_result <@> <test_oldpw@%> @> @localhost> $repl oldpw
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_newpw,newpw,test;
+--replace_result <@> <test_newpw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user root,,test;
+--replace_result <@> <root@localhost> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+drop user test_nopw;
+drop user test_oldpw;
+drop user test_newpw;
+
+#
# Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS
# The replace's are here to fix things for 32 bit systems
#
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index 255a4634bca..a8c8b659c3c 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -328,6 +328,34 @@ if ($error)
--disconnect extracon2
--connection default
+#
+# A couple of plugin tests - for builtin plugins only
+#
+CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password using '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB';
+CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db389';
+
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+connect(pcon1,localhost,mysqltest_up1,foo,,$MASTER_MYPORT,);
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+connect(pcon2,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,);
+connection pcon2;
+select user(), current_user();
+disconnect pcon2;
+
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,);
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,);
+connection pcon4;
+select user(), current_user();
+disconnect pcon4;
+
+connection default;
+DROP USER mysqltest_up1@'%';
+DROP USER mysqltest_up2@'%';
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test
index cdf274190dd..b31fa83588b 100644
--- a/mysql-test/t/csv.test
+++ b/mysql-test/t/csv.test
@@ -1807,16 +1807,16 @@ unlock tables;
drop table t1;
#
-# Bug#41441 repair csv table crashes debug server
-#
-# Note: The test should be removed after Bug#33717 is fixed
+# Bug#33717 INSERT...(default) fails for enum. Crashes CSV tables, loads spaces for MyISAM
+#
+CREATE TABLE t1 (e enum('foo','bar') NOT NULL) ENGINE = CSV;
+INSERT INTO t1 VALUES();
+INSERT INTO t1 VALUES(default);
+INSERT INTO t1 VALUES(0);
+INSERT INTO t1 VALUES(3);
+INSERT INTO t1 VALUES(-1);
+SELECT * FROM t1;
+DROP TABLE t1;
-create table t1(a enum ('a') not null) engine=csv;
-insert into t1 values (2);
---error ER_CRASHED_ON_USAGE
-select * from t1 limit 1;
-repair table t1;
-select * from t1 limit 1;
-drop table t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/ctype_latin1_de-master.opt b/mysql-test/t/ctype_latin1_de-master.opt
index 79fdb1c63dc..063fe5b7792 100644
--- a/mysql-test/t/ctype_latin1_de-master.opt
+++ b/mysql-test/t/ctype_latin1_de-master.opt
@@ -1 +1 @@
---default-character-set=latin1 --default-collation=latin1_german2_ci
+--character-set-server=latin1 --default-collation=latin1_german2_ci
diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test
index 0395de273de..9ab458ba516 100644
--- a/mysql-test/t/ctype_ldml.test
+++ b/mysql-test/t/ctype_ldml.test
@@ -46,6 +46,14 @@ SELECT * FROM t1 WHERE LOWER(a)=LOWER('N');
DROP TABLE t1;
--echo #
+--echo # Bug#51976 LDML collations issue (cyrillic example)
+--echo #
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_test_ci);
+INSERT INTO t1 (a) VALUES ('Hello');
+SELECT a, UPPER(a), LOWER(a) FROM t1;
+DROP TABLE t1;
+
+--echo #
--echo # Bug#43827 Server closes connections and restarts
--echo #
# Crash happened with a user-defined utf8 collation,
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 6f1a3cafecd..583334b0c04 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -732,6 +732,15 @@ SELECT HEX(MONTHNAME(19700101));
SELECT HEX(DAYNAME(19700101));
SET character_set_connection=latin1;
+--echo #
+--echo # Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
+--echo #
+CREATE TABLE t1 (a CHAR(1) CHARSET ascii, b CHAR(1) CHARSET latin1);
+CREATE VIEW v1 AS SELECT 1 from t1
+WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/ctype_ucs2_def-master.opt b/mysql-test/t/ctype_ucs2_def-master.opt
index 84d2a52b639..d42c50f3c7e 100644
--- a/mysql-test/t/ctype_ucs2_def-master.opt
+++ b/mysql-test/t/ctype_ucs2_def-master.opt
@@ -1 +1 @@
---default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1
+--default-collation=ucs2_unicode_ci --character-set-server=ucs2,latin1
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index 2f51fafd6a6..7bbc470137a 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -291,6 +291,21 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1;
DROP TABLE t1;
DROP FUNCTION f1;
+
+--echo #
+--echo # Bug #49552 : sql_buffer_result cause crash + not found records
+--echo # in multitable delete/subquery
+--echo #
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SET SESSION SQL_BUFFER_RESULT=1;
+DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1;
+
+SET SESSION SQL_BUFFER_RESULT=DEFAULT;
+SELECT * FROM t1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
--echo #
@@ -360,18 +375,4 @@ DELETE IGNORE FROM t1;
DROP TABLE t1;
---echo #
---echo # Bug #49552 : sql_buffer_result cause crash + not found records
---echo # in multitable delete/subquery
---echo #
-
-CREATE TABLE t1(a INT);
-INSERT INTO t1 VALUES (1),(2),(3);
-SET SESSION SQL_BUFFER_RESULT=1;
-DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1;
-
-SET SESSION SQL_BUFFER_RESULT=DEFAULT;
-SELECT * FROM t1;
-DROP TABLE t1;
-
--echo End of 5.1 tests
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index a3dd9069a06..a07aa95aec8 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -12,3 +12,5 @@
kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
subselect_notembedded : MariaDB LPBUG#545137: crashes on some platforms
+# partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings
+# ps_3innodb : Bug#53309 2010-04-30 VasilDimov valgrind warnings
diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test
index f730c95208e..7cd16a6bc5a 100644
--- a/mysql-test/t/error_simulation.test
+++ b/mysql-test/t/error_simulation.test
@@ -33,3 +33,19 @@ set tmp_table_size=default;
DROP TABLE t1;
+--echo #
+--echo # Bug #50946: fast index creation still seems to copy the table
+--echo #
+CREATE TABLE t1 (a INT(100) NOT NULL);
+INSERT INTO t1 VALUES (1), (0), (2);
+SET SESSION debug='+d,alter_table_only_index_change';
+ALTER TABLE t1 ADD INDEX a(a);
+SET SESSION debug=DEFAULT;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 5.1 tests
+--echo #
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
index 81397b333f9..f2a82f40cff 100644
--- a/mysql-test/t/events_bugs.test
+++ b/mysql-test/t/events_bugs.test
@@ -1204,7 +1204,6 @@ create event e1 on schedule every 1 day do select 1;
select @@sql_mode;
set @@sql_mode= @old_mode;
# Rename SQL modes that differ in name between the server and the table definition.
-select replace(@full_mode, '?', 'NOT_USED') into @full_mode;
select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode;
select name from mysql.event where name = 'p' and sql_mode = @full_mode;
drop event e1;
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index 77b49a8b1a5..ba6be72dbdc 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -147,7 +147,27 @@ EXPLAIN SELECT DISTINCT 1 FROM t1,
WHERE t1.a = d1.a;
DROP TABLE t1;
-# End of 5.0 tests.
+--echo #
+--echo # Bug#48295:
+--echo # explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode
+--echo #
+
+CREATE TABLE t1 (f1 INT);
+
+SELECT @@session.sql_mode INTO @old_sql_mode;
+SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
+
+# EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE.
+--error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
+EXPLAIN EXTENDED SELECT 1 FROM t1
+ WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
+SHOW WARNINGS;
+
+SET SESSION sql_mode=@old_sql_mode;
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
--echo #
--echo # Bug#37870: Usage of uninitialized value caused failed assertion.
@@ -168,23 +188,29 @@ SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR
drop tables t1, t2;
--echo #
---echo # Bug#48295:
---echo # explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode
+--echo # Bug#47669: Query showed by EXPLAIN EXTENDED gives different result from original query
--echo #
-CREATE TABLE t1 (f1 INT);
+CREATE TABLE t1 (c int);
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2 (d int);
+INSERT INTO t2 VALUES (NULL), (0);
+EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1;
+DROP TABLE t1, t2;
-SELECT @@session.sql_mode INTO @old_sql_mode;
-SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
-# EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE.
---error ER_MIX_OF_GROUP_FUNC_AND_FIELDS
-EXPLAIN EXTENDED SELECT 1 FROM t1
- WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
-SHOW WARNINGS;
+--echo #
+--echo # Bug #48419: another explain crash..
+--echo #
-SET SESSION sql_mode=@old_sql_mode;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b BLOB, KEY b(b(100)));
+INSERT INTO t2 VALUES ('1'), ('2'), ('3');
-DROP TABLE t1;
+FLUSH TABLES;
+
+EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT 1 FROM t1 t JOIN t2 WHERE b <= 1 AND t.a);
+
+DROP TABLE t1, t2;
--echo End of 5.1 tests.
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 4df910d366b..71a7f3bbc62 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -556,6 +556,27 @@ SELECT count(*) FROM t1 WHERE
DROP TABLE t1,t2,t3;
+#
+# BUG#50351 - ft_min_word_len=2 Causes query to hang
+#
+CREATE TABLE t1 (a VARCHAR(4), FULLTEXT(a));
+INSERT INTO t1 VALUES
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),
+('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('awrd'),('cwrd'),
+('awrd');
+SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("+awrd bwrd* +cwrd*" IN BOOLEAN MODE);
+DROP TABLE t1;
--echo #
--echo # Bug #49445: Assertion failed: 0, file .\item_row.cc, line 55 with
@@ -566,5 +587,14 @@ CREATE TABLE t1(a CHAR(1),FULLTEXT(a));
SELECT 1 FROM t1 WHERE MATCH(a) AGAINST ('') AND ROW(a,a) > ROW(1,1);
DROP TABLE t1;
+--echo #
+--echo # BUG#51866 - crash with repair by sort and fulltext keys
+--echo #
+CREATE TABLE t1(a CHAR(4), FULLTEXT(a));
+INSERT INTO t1 VALUES('aaaa');
+SET myisam_sort_buffer_size=4;
+REPAIR TABLE t1;
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+DROP TABLE t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test
index e24b4354b61..e56d1121808 100644
--- a/mysql-test/t/func_concat.test
+++ b/mysql-test/t/func_concat.test
@@ -124,4 +124,24 @@ SELECT @query;
DROP PROCEDURE p1;
+--echo #
+--echo # Bug #40625: Concat fails on DOUBLE values in a Stored Procedure,
+--echo # while DECIMAL works
+--echo #
+
+DELIMITER //;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE v1 DOUBLE(10,3);
+ SET v1= 100;
+ SET @s = CONCAT('########################################', 40 , v1);
+ SELECT @s;
+END;//
+DELIMITER ;//
+
+CALL p1();
+CALL p1();
+
+DROP PROCEDURE p1;
+
--echo # End of 5.1 tests
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index e92f3e96303..e832ea316eb 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -693,4 +693,31 @@ SELECT 1 FROM t1 WHERE t1.a NOT IN
DROP TABLE t1, t2;
+#
+# Bug #49487: crash with explain extended and group_concat in a derived table
+#
+
+CREATE TABLE t1 (f1 INT);
+INSERT INTO t1 VALUES (),();
+
+EXPLAIN EXTENDED SELECT 1 FROM
+ (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
+
+SELECT 1 FROM
+ (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug #52397: another crash with explain extended and group_concat
+--echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0), (0);
+EXPLAIN EXTENDED SELECT 1 FROM
+ (SELECT GROUP_CONCAT(t1.a ORDER BY t1.a ASC) FROM
+ t1 t2, t1 GROUP BY t1.a) AS d;
+DROP TABLE t1;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 8942b0a2faf..3392a41519b 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1352,3 +1352,14 @@ SELECT DECODE((SELECT ENCODE('secret', t1.a) FROM t1,t2 WHERE t1.a = t2.a GROUP
FROM t2 WHERE t2.b = 1 GROUP BY t2.b;
DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#52164 Assertion failed: param.sort_length, file .\filesort.cc, line 149
+--echo #
+CREATE TABLE t1 (a LONGBLOB NOT NULL);
+INSERT INTO t1 VALUES (''),('');
+SELECT 1 FROM t1, t1 t2
+ORDER BY QUOTE(t1.a);
+DROP TABLE t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index b9da946a55f..2f9a48ffd6a 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -650,7 +650,7 @@ drop table t1;
SET GLOBAL log_bin_trust_function_creators = 0;
create table t1 (a datetime, i int, b datetime);
-insert into t1 select sysdate(), sleep(1), sysdate() from dual;
+insert into t1 select sysdate(), sleep(2), sysdate() from dual;
select a != b from t1;
drop table t1;
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
index 8ce4abf45d4..9e6002a1faf 100644
--- a/mysql-test/t/gis-rtree.test
+++ b/mysql-test/t/gis-rtree.test
@@ -914,4 +914,29 @@ SELECT 1 FROM t1 WHERE a >= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1
DROP TABLE t1;
+--echo #
+--echo # Bug #51357: crash when using handler commands on spatial indexes
+--echo #
+
+CREATE TABLE t1(a GEOMETRY NOT NULL,SPATIAL INDEX a(a));
+HANDLER t1 OPEN;
+HANDLER t1 READ a FIRST;
+HANDLER t1 READ a NEXT;
+HANDLER t1 READ a PREV;
+HANDLER t1 READ a LAST;
+HANDLER t1 CLOSE;
+
+# second crash fixed when the tree has changed since the last search.
+HANDLER t1 OPEN;
+HANDLER t1 READ a FIRST;
+INSERT INTO t1 VALUES (GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+--echo # should not crash
+--disable_result_log
+HANDLER t1 READ a NEXT;
+--enable_result_log
+HANDLER t1 CLOSE;
+
+DROP TABLE t1;
+
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index e89650c7aec..5bdb3ebe9bf 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -1525,5 +1525,30 @@ DROP USER 'user1'@'localhost';
DROP USER 'user2';
DROP DATABASE db1;
+
+#
+# Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants.
+#
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+GRANT SELECT ON db1.* to 'testbug'@localhost;
+USE db2;
+CREATE TABLE t1 (a INT);
+USE test;
+connect (con1,localhost,testbug,,db1);
+--error ER_NO_SUCH_TABLE
+SELECT * FROM `../db2/tb2`;
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT * FROM `../db2`.tb2;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM `#mysql50#/../db2/tb2`;
+connection default;
+disconnect con1;
+DROP USER 'testbug'@localhost;
+DROP TABLE db2.t1;
+DROP DATABASE db1;
+DROP DATABASE db2;
+
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 5b96213034a..e6ea5ecc7f6 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1158,3 +1158,53 @@ SELECT COUNT(i) FROM t1 WHERE i > 1;
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
+--echo #
+--echo # Bug #45640: optimizer bug produces wrong results
+--echo #
+
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (4, 40), (1, 10), (2, 20), (2, 20), (3, 30);
+
+--echo # should return 4 ordered records:
+SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa;
+
+SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa;
+
+SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0;
+
+--echo # should return the same result in a reverse order:
+SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa;
+
+--echo # execution plan should not use temporary table:
+EXPLAIN EXTENDED
+SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0;
+
+EXPLAIN EXTENDED
+SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa;
+
+--echo # should return only one record
+SELECT (SELECT tt.a FROM t1 tt LIMIT 1) aa, COUNT(DISTINCT b) FROM t1
+ GROUP BY aa;
+
+CREATE TABLE t2 SELECT DISTINCT a FROM t1;
+
+--echo # originally reported queries (1st two columns of next two query
+--echo # results should be same):
+
+SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b)
+ FROM t1 GROUP BY aa, b;
+SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b)
+ FROM t1 GROUP BY aa, b;
+
+--echo # ORDER BY for sure:
+
+SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b)
+ FROM t1 GROUP BY aa, b ORDER BY -aa, -b;
+SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b)
+ FROM t1 GROUP BY aa, b ORDER BY -aa, -b;
+
+DROP TABLE t1, t2;
+
+--echo #
+
+--echo # End of 5.1 tests
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index f623df372fa..b06f0c09fc5 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -1044,4 +1044,45 @@ SELECT a, MAX(b) FROM t WHERE b GROUP BY a;
DROP TABLE t;
+#
+# BUG#49902 - SELECT returns incorrect results
+#
+CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b));
+INSERT INTO t1 VALUES(1,1),(2,1);
+ANALYZE TABLE t1;
+SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b;
+SELECT a FROM t1 WHERE b=1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#47762: Incorrect result from MIN() when WHERE tests NOT NULL column
+--echo # for NULL
+--echo #
+
+--echo ## Test for NULLs allowed
+CREATE TABLE t1 ( a INT, KEY (a) );
+INSERT INTO t1 VALUES (1), (2), (3);
+--source include/min_null_cond.inc
+INSERT INTO t1 VALUES (NULL), (NULL);
+--source include/min_null_cond.inc
+DROP TABLE t1;
+
+--echo ## Test for NOT NULLs
+CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY);
+INSERT INTO t1 VALUES (1), (2), (3);
+--echo #
+--echo # NULL-safe operator test disabled for non-NULL indexed columns.
+--echo #
+--echo # See bugs
+--echo #
+--echo # - Bug#52173: Reading NULL value from non-NULL index gives
+--echo # wrong result in embedded server
+--echo #
+--echo # - Bug#52174: Sometimes wrong plan when reading a MAX value from
+--echo # non-NULL index
+--echo #
+--let $skip_null_safe_test= 1
+--source include/min_null_cond.inc
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/handler_myisam.test b/mysql-test/t/handler_myisam.test
index da02a90af0f..868ba14480a 100644
--- a/mysql-test/t/handler_myisam.test
+++ b/mysql-test/t/handler_myisam.test
@@ -37,4 +37,15 @@ TRUNCATE t1;
HANDLER t1 READ FIRST;
DROP TABLE t1;
+--echo #
+--echo # BUG#51877 - HANDLER interface causes invalid memory read
+--echo #
+CREATE TABLE t1(a INT, KEY(a));
+HANDLER t1 OPEN;
+HANDLER t1 READ a FIRST;
+INSERT INTO t1 VALUES(1);
+HANDLER t1 READ a NEXT;
+HANDLER t1 CLOSE;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index af9af4fe1fc..65bf9518a5c 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -442,4 +442,105 @@ INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL);
SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#50995 Having clause on subquery result produces incorrect results.
+--echo #
+
+CREATE TABLE t1
+(
+ id1 INT,
+ id2 INT NOT NULL,
+ INDEX id1(id2)
+);
+
+INSERT INTO t1 SET id1=1, id2=1;
+INSERT INTO t1 SET id1=2, id2=1;
+INSERT INTO t1 SET id1=3, id2=1;
+
+SELECT t1.id1,
+(SELECT 0 FROM DUAL
+ WHERE t1.id1=t1.id1) AS amount FROM t1
+WHERE t1.id2 = 1
+HAVING amount > 0
+ORDER BY t1.id1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
+--echo #
+CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT, f3 INT);
+INSERT INTO t1 VALUES (2,7,9), (4,7,9), (6,2,9), (17,0,9);
+
+SELECT table1.f1, table2.f2
+FROM t1 AS table1
+JOIN t1 AS table2 ON table1.f3 = table2.f3
+WHERE table2.f1 = 2
+GROUP BY table1.f1, table2.f2
+HAVING (table2.f2 = 8 AND table1.f1 >= 6);
+
+EXPLAIN EXTENDED
+SELECT table1.f1, table2.f2
+FROM t1 AS table1
+JOIN t1 AS table2 ON table1.f3 = table2.f3
+WHERE table2.f1 = 2
+GROUP BY table1.f1, table2.f2
+HAVING (table2.f2 = 8 AND table1.f1 >= 6);
+
+EXPLAIN EXTENDED
+SELECT table1.f1, table2.f2
+FROM t1 AS table1
+JOIN t1 AS table2 ON table1.f3 = table2.f3
+WHERE table2.f1 = 2
+GROUP BY table1.f1, table2.f2
+HAVING (table2.f2 = 8);
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355
+--echo #
+CREATE TABLE t1(f1 INT, f2 INT);
+INSERT INTO t1 VALUES (10,8);
+CREATE TABLE t2 (f1 INT);
+INSERT INTO t2 VALUES (5);
+
+SELECT COUNT(f1) FROM t2
+HAVING (7, 9) IN (SELECT f1, MIN(f2) FROM t1);
+
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (f1 INT, f2 VARCHAR(1));
+INSERT INTO t1 VALUES (16,'f');
+INSERT INTO t1 VALUES (16,'f');
+CREATE TABLE t2 (f1 INT, f2 VARCHAR(1));
+INSERT INTO t2 VALUES (13,'f');
+INSERT INTO t2 VALUES (20,'f');
+CREATE TABLE t3 (f1 INT, f2 VARCHAR(1));
+INSERT INTO t3 VALUES (7,'f');
+
+SELECT t1.f2 FROM t1
+STRAIGHT_JOIN (t2 JOIN t3 ON t3.f2 = t2.f2 ) ON t3 .f2 = t2 .f2
+HAVING ('v', 'i') NOT IN (SELECT f2, MIN(f2) FROM t1)
+ORDER BY f2;
+
+DROP TABLES t1,t2,t3;
+
+--echo #
+--echo # Bug#52340 Segfault: read_cached_record (tab=0x94a2634) at sql_select.cc:14411
+--echo #
+CREATE TABLE t1 (f1 INT, f2 VARCHAR(1));
+INSERT INTO t1 VALUES (16,'d');
+CREATE TABLE t2 (f1 INT, f2 VARCHAR(1));
+INSERT INTO t2 VALUES (13,'e');
+INSERT INTO t2 VALUES (20,'d');
+
+SELECT MAX(t2.f2) FROM t2 JOIN t1 ON t1.f2
+HAVING ('e' , 'd') IN
+(SELECT ts1.f2, ts2.f2 FROM t2 ts1 JOIN t2 ts2 ON ts1.f1)
+ORDER BY t1.f2;
+
+DROP TABLE t1,t2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/information_schema_all_engines.test b/mysql-test/t/information_schema_all_engines.test
index cb8fcf55c56..b3b1d2d2f6b 100644
--- a/mysql-test/t/information_schema_all_engines.test
+++ b/mysql-test/t/information_schema_all_engines.test
@@ -4,7 +4,8 @@
--source include/not_embedded.inc
--source include/have_pbxt.inc
--- source include/not_staging.inc
+--source include/have_innodb.inc
+--source include/not_staging.inc
use INFORMATION_SCHEMA;
--replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema
diff --git a/mysql-test/t/innodb-autoinc-44030.test b/mysql-test/t/innodb-autoinc-44030.test
deleted file mode 100644
index 2524ceb4009..00000000000
--- a/mysql-test/t/innodb-autoinc-44030.test
+++ /dev/null
@@ -1,40 +0,0 @@
--- source include/have_innodb.inc
-# embedded server ignores 'delayed', so skip this
--- source include/not_embedded.inc
-
-let $file_format_check=`select @@innodb_file_format_check`;
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-#
-# 44030: Error: (1500) Couldn't read the MAX(ID) autoinc value from
-# the index (PRIMARY)
-# This test requires a restart of the server
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (null);
-INSERT INTO t1 VALUES (null);
-ALTER TABLE t1 CHANGE c1 d1 INT NOT NULL AUTO_INCREMENT;
-SELECT * FROM t1;
-# Restart the server
--- source include/restart_mysqld.inc
-# The MySQL and InnoDB data dictionaries should now be out of sync.
-# The select should print message to the error log
-SELECT * FROM t1;
-# MySQL have made a change (http://lists.mysql.com/commits/75268) that no
-# longer results in the two data dictionaries being out of sync. If they
-# revert their changes then this check for ER_AUTOINC_READ_FAILED will need
-# to be enabled. Also, see http://bugs.mysql.com/bug.php?id=47621.
--- error ER_AUTOINC_READ_FAILED,1467
-INSERT INTO t1 VALUES(null);
-ALTER TABLE t1 AUTO_INCREMENT = 3;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES(null);
-SELECT * FROM t1;
-DROP TABLE t1;
-
---disable_query_log
-EVAL SET GLOBAL innodb_file_format_check=$file_format_check;
---enable_query_log
diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test
deleted file mode 100644
index 37ca1e5a2ab..00000000000
--- a/mysql-test/t/innodb-autoinc.test
+++ /dev/null
@@ -1,637 +0,0 @@
--- source include/have_innodb.inc
-# embedded server ignores 'delayed', so skip this
--- source include/not_embedded.inc
-
-let $file_format_check=`select @@innodb_file_format_check`;
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-#
-# Bug #34335
-#
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (9223372036854775807, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-## Test AUTOINC overflow
-##
-
-# TINYINT
-CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (127, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (255, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# SMALLINT
-#
-CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (32767, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (65535, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# MEDIUMINT
-#
-CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (8388607, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (16777215, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# INT
-#
-CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (2147483647, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (4294967295, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# BIGINT
-#
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (9223372036854775807, null);
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (18446744073709551615, null);
--- error ER_AUTOINC_READ_FAILED,1467
-INSERT INTO t1 (c2) VALUES ('innodb');
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Bug 37531
-# After truncate, auto_increment behaves incorrectly for InnoDB
-#
-CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-TRUNCATE TABLE t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
-#
-# Deleting all records should not reset the AUTOINC counter.
-#
-CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-DELETE FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (1), (2), (3);
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
-SELECT c1 FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
-#
-# Bug 38839
-# Reset the last value generated at end of statement
-#
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL, 1);
-DELETE FROM t1 WHERE c1 = 1;
-INSERT INTO t1 VALUES (2,1);
-INSERT INTO t1 VALUES (NULL,8);
-SELECT * FROM t1;
-DROP TABLE t1;
-# Bug 38839 -- same as above but for multi value insert
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL, 1);
-DELETE FROM t1 WHERE c1 = 1;
-INSERT INTO t1 VALUES (2,1), (NULL, 8);
-INSERT INTO t1 VALUES (NULL,9);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Test changes to AUTOINC next value calculation
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (NULL),(5),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with SIGNED INT column, by inserting a 0 for the first column value
-# 0 is treated in the same was NULL.
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(0);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-INSERT INTO t1 VALUES (-1), (NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-SET @@INSERT_ID=400;
-# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with SIGNED INT column
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (-2), (NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with UNSIGNED INT column, single insert
-# The sign in the value is ignored and a new column value is generated
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (-2);
-INSERT INTO t1 VALUES (NULL);
-INSERT INTO t1 VALUES (2);
-INSERT INTO t1 VALUES (NULL);
-INSERT INTO t1 VALUES (250);
-INSERT INTO t1 VALUES (NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Test with UNSIGNED INT column, multi-value inserts
-# The sign in the value is ignored and a new column value is generated
-# Reset the AUTOINC session variables
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 INT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(-1);
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=100, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (-2),(NULL),(2),(NULL);
-INSERT INTO t1 VALUES (250),(NULL);
-SELECT * FROM t1;
-INSERT INTO t1 VALUES (1000);
-SET @@INSERT_ID=400;
-# Duplicate error expected here for autoinc_lock_mode != TRADITIONAL
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 VALUES(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for overflow handling when increment is > 1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (9223372036854775794); #-- 2^63 - 14
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should just fit
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for overflow handling when increment and offser are > 1
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=2, @@SESSION.AUTO_INCREMENT_OFFSET=10;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should fail because of overflow but it doesn't, it seems to be
-# a MySQL server bug. It wraps around to 0 for the last value.
-# See MySQL Bug# 39828
-#
-# Instead of wrapping around, it asserts when MySQL is compiled --with-debug
-# (see sql/handler.cc:handler::update_auto_increment()). Don't test for
-# overflow until Bug #39828 is fixed.
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed. For now, this test is meaningless.
-#if Bug #39828 is fixed
-#INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-#else
-INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-#endif
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for overflow handling when increment and offset are odd numbers
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551603); #-- 2^64 - 13
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=5, @@SESSION.AUTO_INCREMENT_OFFSET=7;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should fail because of overflow but it doesn't. It fails with
-# a duplicate entry message because of a MySQL server bug, it wraps
-# around. See MySQL Bug# 39828, once MySQL fix the bug we can replace
-# the ER_DUP_ENTRY, 1062 below with the appropriate error message
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed. For now, this test is meaningless.
-#if Bug #39828 is fixed
-# Still need to fix this error code, error should mention overflow
-#-- error ER_DUP_ENTRY,1062
-#INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-#else
-INSERT INTO t1 VALUES (NULL),(NULL);
-#endif
-SELECT * FROM t1;
-DROP TABLE t1;
-
-# Check for overflow handling when increment and offset are odd numbers
-# and check for large -ve numbers
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES(-9223372036854775806); #-- -2^63 + 2
-INSERT INTO t1 VALUES(-9223372036854775807); #-- -2^63 + 1
-INSERT INTO t1 VALUES(-9223372036854775808); #-- -2^63
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=3, @@SESSION.AUTO_INCREMENT_OFFSET=3;
-SHOW VARIABLES LIKE "auto_inc%";
-INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# Check for overflow handling when increment and offset are very
-# large numbers 2^60
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY(c1)) ENGINE=InnoDB;
-# TODO: Fix the autoinc init code
-# We have to do this because of a bug in the AUTOINC init code.
-INSERT INTO t1 VALUES(NULL);
-INSERT INTO t1 VALUES (18446744073709551610); #-- 2^64 - 2
-SELECT * FROM t1;
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976;
-SHOW VARIABLES LIKE "auto_inc%";
-# This should fail because of overflow but it doesn't. It wraps around
-# and the autoinc values look bogus too.
-# See MySQL Bug# 39828, once MySQL fix the bug we can enable the error
-# code expected test.
-# -- error ER_AUTOINC_READ_FAILED,1467
-#
-# Since this asserts when compiled --with-debug, we can't properly test this
-# until Bug #39828 is fixed. For now, this test is meaningless.
-#if Bug #39828 is fixed
-#-- error ER_AUTOINC_READ_FAILED,1467
-#INSERT INTO t1 VALUES (NULL),(NULL);
-#else
-INSERT INTO t1 VALUES (NULL);
-#endif
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Check for floating point autoinc column handling
-#
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SET @@INSERT_ID=1;
-SHOW VARIABLES LIKE "auto_inc%";
-CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL, 1);
-INSERT INTO t1 VALUES(NULL, 2);
-SELECT * FROM t1;
-ALTER TABLE t1 CHANGE c1 c1 SERIAL;
-SELECT * FROM t1;
-INSERT INTO t1 VALUES(NULL, 3);
-INSERT INTO t1 VALUES(NULL, 4);
-SELECT * FROM t1;
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES(NULL, 1);
-INSERT INTO t1 VALUES(NULL, 2);
-SELECT * FROM t1;
-ALTER TABLE t1 CHANGE c1 c1 SERIAL;
-SELECT * FROM t1;
-INSERT INTO t1 VALUES(NULL, 3);
-INSERT INTO t1 VALUES(NULL, 4);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-#
-# Bug# 42714: AUTOINC column calculated next value not greater than highest
-# value stored in table.
-#
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-CREATE TABLE t1 (
- a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
- b INT(10) UNSIGNED NOT NULL,
- c ENUM('FALSE','TRUE') DEFAULT NULL,
- PRIMARY KEY (a)) ENGINE = InnoDB;
-CREATE TABLE t2 (
- m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
- n INT(10) UNSIGNED NOT NULL,
- o enum('FALSE','TRUE') DEFAULT NULL,
- PRIMARY KEY (m)) ENGINE = InnoDB;
-INSERT INTO t2 (n,o) VALUES
- (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
- (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
-SHOW CREATE TABLE t2;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-DROP TABLE t2;
-#
-# 43203: Overflow from auto incrementing causes server segv
-#
-
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-CREATE TABLE t1(
- c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
- PRIMARY KEY) ENGINE=InnoDB;
-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),(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),(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),(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),(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),(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),(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),(NULL),(NULL),(NULL),(NULL);
-CREATE TABLE t2(
- c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
- PRIMARY KEY) ENGINE=InnoDB;
--- error ER_DUP_ENTRY,1062
-INSERT INTO t2 SELECT c1 FROM t1;
--- error ER_DUP_ENTRY,1467
-INSERT INTO t2 SELECT NULL FROM t1;
-DROP TABLE t1;
-DROP TABLE t2;
-
-# If the user has specified negative values for an AUTOINC column then
-# InnoDB should ignore those values when setting the table's max value.
-SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
-SHOW VARIABLES LIKE "auto_inc%";
-# TINYINT
-CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-127, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-127, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# SMALLINT
-#
-CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-32767, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-32757, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# MEDIUMINT
-#
-CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-8388607, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-8388607, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# INT
-#
-CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-2147483647, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-2147483647, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# BIGINT
-#
-CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-9223372036854775807, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1, NULL);
-INSERT INTO t1 VALUES (-1, 'innodb');
-INSERT INTO t1 VALUES (-9223372036854775807, 'innodb');
-INSERT INTO t1 VALUES (NULL, NULL);
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
-DROP TABLE t1;
-#
-# End negative number check
-
-##
-# 47125: auto_increment start value is ignored if an index is created
-# and engine=innodb
-#
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT, c2 INT, PRIMARY KEY(c1)) AUTO_INCREMENT=10 ENGINE=InnoDB;
-CREATE INDEX i1 on t1(c2);
-SHOW CREATE TABLE t1;
-INSERT INTO t1 (c2) values (0);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-##
-# 49032: Use the correct function to read the AUTOINC column value
-#
-CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
-# Restart the server
--- source include/restart_mysqld.inc
-INSERT INTO t1(C2) VALUES ('innodb');
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-CREATE TABLE t1(C1 FLOAT AUTO_INCREMENT KEY, C2 CHAR(10)) ENGINE=InnoDB;
-INSERT INTO t1(C1, C2) VALUES (1, 'innodb'), (3, 'innodb');
-# Restart the server
--- source include/restart_mysqld.inc
-INSERT INTO t1(C2) VALUES ('innodb');
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
-##
-# 47720: REPLACE INTO Autoincrement column with negative values
-#
-CREATE TABLE t1 (c1 INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
-INSERT INTO t1 SET c1 = 1;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 SET c1 = 2;
-INSERT INTO t1 SET c1 = -1;
-SELECT * FROM t1;
--- error ER_DUP_ENTRY,1062
-INSERT INTO t1 SET c1 = -1;
-SHOW CREATE TABLE t1;
-REPLACE INTO t1 VALUES (-1);
-SELECT * FROM t1;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
---disable_query_log
-EVAL SET GLOBAL innodb_file_format_check=$file_format_check;
---enable_query_log
diff --git a/mysql-test/t/innodb-use-sys-malloc.test b/mysql-test/t/innodb-use-sys-malloc.test
deleted file mode 100644
index 07ccf261713..00000000000
--- a/mysql-test/t/innodb-use-sys-malloc.test
+++ /dev/null
@@ -1,51 +0,0 @@
---source include/have_innodb.inc
-# XtraDB has lots of "still reachable" memory leak warnings at shutdown when
-# --innodb-use-sys-malloc
---source include/not_valgrind.inc
-
-#display current value of innodb_use_sys_malloc
-SELECT @@GLOBAL.innodb_use_sys_malloc;
---echo 1 Expected
-
-#try changing it. Should fail.
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-SET @@GLOBAL.innodb_use_sys_malloc=0;
---echo Expected error 'Read only variable'
-
-SELECT @@GLOBAL.innodb_use_sys_malloc;
---echo 1 Expected
-
-
-#do some stuff to see if it works.
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2),(3),(4),(5),(6),(7);
-select * from t1;
-drop table t1;
---source include/have_innodb.inc
-
-#display current value of innodb_use_sys_malloc
-SELECT @@GLOBAL.innodb_use_sys_malloc;
---echo 1 Expected
-
-#try changing it. Should fail.
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-SET @@GLOBAL.innodb_use_sys_malloc=0;
---echo Expected error 'Read only variable'
-
-SELECT @@GLOBAL.innodb_use_sys_malloc;
---echo 1 Expected
-
-
-#do some stuff to see if it works.
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
-insert into t1 values (1),(2),(3),(4),(5),(6),(7);
-select * from t1;
-drop table t1;
diff --git a/mysql-test/t/innodb_bug21704.test b/mysql-test/t/innodb_bug21704.test
deleted file mode 100644
index c649b61034c..00000000000
--- a/mysql-test/t/innodb_bug21704.test
+++ /dev/null
@@ -1,96 +0,0 @@
--- source include/have_innodb.inc
-
---echo #
---echo # Bug#21704: Renaming column does not update FK definition.
---echo #
-
---echo
---echo # Test that it's not possible to rename columns participating in a
---echo # foreign key (either in the referencing or referenced table).
---echo
-
---disable_warnings
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-DROP TABLE IF EXISTS t3;
---enable_warnings
-
-CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB;
-
-CREATE TABLE t2 (a INT PRIMARY KEY, b INT,
- CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a))
-ROW_FORMAT=COMPACT ENGINE=INNODB;
-
-CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT,
- CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a))
-ROW_FORMAT=COMPACT ENGINE=INNODB;
-
-INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
-INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
-INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3);
-
---echo
---echo # Test renaming the column in the referenced table.
---echo
-
-# mysqltest first does replace_regex, then replace_result
---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
---error ER_ERROR_ON_RENAME
-ALTER TABLE t1 CHANGE a c INT;
-
---echo # Ensure that online column rename works.
-
---enable_info
-ALTER TABLE t1 CHANGE b c INT;
---disable_info
-
---echo
---echo # Test renaming the column in the referencing table
---echo
-
-# mysqltest first does replace_regex, then replace_result
---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
---error ER_ERROR_ON_RENAME
-ALTER TABLE t2 CHANGE a c INT;
-
---echo # Ensure that online column rename works.
-
---enable_info
-ALTER TABLE t2 CHANGE b c INT;
---disable_info
-
---echo
---echo # Test with self-referential constraints
---echo
-
-# mysqltest first does replace_regex, then replace_result
---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
---error ER_ERROR_ON_RENAME
-ALTER TABLE t3 CHANGE a d INT;
-
-# mysqltest first does replace_regex, then replace_result
---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
-# Embedded server doesn't chdir to data directory
---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
---error ER_ERROR_ON_RENAME
-ALTER TABLE t3 CHANGE b d INT;
-
---echo # Ensure that online column rename works.
-
---enable_info
-ALTER TABLE t3 CHANGE c d INT;
---disable_info
-
---echo
---echo # Cleanup.
---echo
-
-DROP TABLE t3;
-DROP TABLE t2;
-DROP TABLE t1;
diff --git a/mysql-test/t/innodb_bug38231.test b/mysql-test/t/innodb_bug38231.test
deleted file mode 100644
index b3fcd89f371..00000000000
--- a/mysql-test/t/innodb_bug38231.test
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK
-# http://bugs.mysql.com/38231
-#
-
--- source include/have_innodb.inc
-
-SET storage_engine=InnoDB;
-
-# we care only that the following SQL commands do not crash the server
--- disable_query_log
--- disable_result_log
-
-DROP TABLE IF EXISTS bug38231;
-CREATE TABLE bug38231 (a INT);
-
--- connect (con1,localhost,root,,)
--- connect (con2,localhost,root,,)
-
--- connection con1
-SET autocommit=0;
-LOCK TABLE bug38231 WRITE;
-
--- connection con2
-SET autocommit=0;
--- send
-LOCK TABLE bug38231 WRITE;
-
--- connection default
--- send
-TRUNCATE TABLE bug38231;
-
--- connection con1
-# give time to TRUNCATE and others to be executed; without sleep, sometimes
-# UNLOCK executes before TRUNCATE
-# TODO: Replace with wait_condition once possible under embedded server.
--- sleep 0.2
-# this crashes the server if the bug is present
-UNLOCK TABLES;
-
-# clean up
-
--- connection con2
--- reap
-UNLOCK TABLES;
-
--- connection default
--- reap
--- disconnect con1
--- disconnect con2
-
-# test that TRUNCATE works with with row-level locks
-
--- enable_query_log
--- enable_result_log
-
-INSERT INTO bug38231 VALUES (1), (10), (300);
-
--- connect (con4,localhost,root,,)
-
--- connection con4
-SET autocommit=0;
-SELECT * FROM bug38231 FOR UPDATE;
-
--- connection default
-TRUNCATE TABLE bug38231;
-
--- connection con4
-COMMIT;
-
--- connection default
-
--- disconnect con4
-
-DROP TABLE bug38231;
diff --git a/mysql-test/t/innodb_bug39438-master.opt b/mysql-test/t/innodb_bug39438-master.opt
deleted file mode 100644
index 43fac202fd4..00000000000
--- a/mysql-test/t/innodb_bug39438-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---innodb-file-per-table=1
diff --git a/mysql-test/t/innodb_bug39438.test b/mysql-test/t/innodb_bug39438.test
deleted file mode 100644
index 2a51e5fcbb8..00000000000
--- a/mysql-test/t/innodb_bug39438.test
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch
-# http://bugs.mysql.com/39438
-#
-# This test must be run with innodb_file_per_table=1 because the crash
-# only occurs if that option is turned on and DISCARD TABLESPACE only
-# works with innodb_file_per_table.
-#
-
--- source include/have_innodb.inc
-
---disable_query_log
-call mtr.add_suppression("InnoDB: Error: table 'test/bug39438'");
---enable_query_log
-
-SET storage_engine=InnoDB;
-
-# we care only that the following SQL commands do not crash the server
--- disable_query_log
--- disable_result_log
-
-DROP TABLE IF EXISTS bug39438;
-
-CREATE TABLE bug39438 (id INT) ENGINE=INNODB;
-
-ALTER TABLE bug39438 DISCARD TABLESPACE;
-
-# this crashes the server if the bug is present
-SHOW TABLE STATUS;
-
-DROP TABLE bug39438;
diff --git a/mysql-test/t/innodb_bug40565.test b/mysql-test/t/innodb_bug40565.test
deleted file mode 100644
index d7aa0fd514a..00000000000
--- a/mysql-test/t/innodb_bug40565.test
+++ /dev/null
@@ -1,10 +0,0 @@
-# Bug #40565 Update Query Results in "1 Row Affected" But Should Be "Zero Rows"
--- source include/have_innodb.inc
-
-create table bug40565(value decimal(4,2)) engine=innodb;
-insert into bug40565 values (1), (null);
---enable_info
-update bug40565 set value=NULL;
-update bug40565 set value=NULL;
---disable_info
-drop table bug40565;
diff --git a/mysql-test/t/innodb_bug42101-nonzero-master.opt b/mysql-test/t/innodb_bug42101-nonzero-master.opt
deleted file mode 100644
index 455d66a06b8..00000000000
--- a/mysql-test/t/innodb_bug42101-nonzero-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---loose_innodb_commit_concurrency=1
diff --git a/mysql-test/t/innodb_bug42101-nonzero.test b/mysql-test/t/innodb_bug42101-nonzero.test
deleted file mode 100644
index 685fdf20489..00000000000
--- a/mysql-test/t/innodb_bug42101-nonzero.test
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Bug#42101 Race condition in innodb_commit_concurrency
-# http://bugs.mysql.com/42101
-#
-
--- source include/have_innodb.inc
-
---error ER_WRONG_ARGUMENTS
-set global innodb_commit_concurrency=0;
-select @@innodb_commit_concurrency;
-set global innodb_commit_concurrency=1;
-select @@innodb_commit_concurrency;
-set global innodb_commit_concurrency=42;
-select @@innodb_commit_concurrency;
-set global innodb_commit_concurrency=DEFAULT;
-select @@innodb_commit_concurrency;
---error ER_WRONG_ARGUMENTS
-set global innodb_commit_concurrency=0;
-select @@innodb_commit_concurrency;
-set global innodb_commit_concurrency=1;
-select @@innodb_commit_concurrency;
diff --git a/mysql-test/t/innodb_bug42101.test b/mysql-test/t/innodb_bug42101.test
deleted file mode 100644
index b6536490d48..00000000000
--- a/mysql-test/t/innodb_bug42101.test
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Bug#42101 Race condition in innodb_commit_concurrency
-# http://bugs.mysql.com/42101
-#
-
--- source include/have_innodb.inc
-
-set global innodb_commit_concurrency=0;
-select @@innodb_commit_concurrency;
---error ER_WRONG_ARGUMENTS
-set global innodb_commit_concurrency=1;
-select @@innodb_commit_concurrency;
---error ER_WRONG_ARGUMENTS
-set global innodb_commit_concurrency=42;
-select @@innodb_commit_concurrency;
-set global innodb_commit_concurrency=0;
-select @@innodb_commit_concurrency;
-set global innodb_commit_concurrency=DEFAULT;
-select @@innodb_commit_concurrency;
diff --git a/mysql-test/t/innodb_bug44032.test b/mysql-test/t/innodb_bug44032.test
deleted file mode 100644
index a963cb8b68f..00000000000
--- a/mysql-test/t/innodb_bug44032.test
+++ /dev/null
@@ -1,13 +0,0 @@
-# Bug44032 no update-in-place of UTF-8 columns in ROW_FORMAT=REDUNDANT
-# (btr_cur_update_in_place not invoked when updating from/to NULL;
-# the update is performed by delete and insert instead)
-
--- source include/have_innodb.inc
-
-CREATE TABLE bug44032(c CHAR(3) CHARACTER SET UTF8) ROW_FORMAT=REDUNDANT
-ENGINE=InnoDB;
-INSERT INTO bug44032 VALUES('abc'),(0xEFBCA4EFBCA4EFBCA4);
-UPDATE bug44032 SET c='DDD' WHERE c=0xEFBCA4EFBCA4EFBCA4;
-UPDATE bug44032 SET c=NULL WHERE c='DDD';
-UPDATE bug44032 SET c='DDD' WHERE c IS NULL;
-DROP TABLE bug44032;
diff --git a/mysql-test/t/innodb_bug44369.test b/mysql-test/t/innodb_bug44369.test
deleted file mode 100644
index f5d85cd5815..00000000000
--- a/mysql-test/t/innodb_bug44369.test
+++ /dev/null
@@ -1,17 +0,0 @@
-# This is the test for bug 44369. We should
-# block table creation with columns match
-# some innodb internal reserved key words,
-# both case sensitively and insensitely.
-
---source include/have_innodb.inc
-
-# This create table operation should fail.
---error ER_WRONG_COLUMN_NAME
-create table bug44369 (DB_ROW_ID int) engine=innodb;
-
-# This create should fail as well
---error ER_WRONG_COLUMN_NAME
-create table bug44369 (db_row_id int) engine=innodb;
-
---error ER_WRONG_COLUMN_NAME
-create table bug44369 (db_TRX_Id int) engine=innodb;
diff --git a/mysql-test/t/innodb_bug45357.test b/mysql-test/t/innodb_bug45357.test
deleted file mode 100644
index 81727f352dd..00000000000
--- a/mysql-test/t/innodb_bug45357.test
+++ /dev/null
@@ -1,10 +0,0 @@
--- source include/have_innodb.inc
-
-set session transaction isolation level read committed;
-
-create table bug45357(a int, b int,key(b))engine=innodb;
-insert into bug45357 values (25170,6122);
-update bug45357 set a=1 where b=30131;
-delete from bug45357 where b < 20996;
-delete from bug45357 where b < 7001;
-drop table bug45357;
diff --git a/mysql-test/t/innodb_bug46000.test b/mysql-test/t/innodb_bug46000.test
deleted file mode 100644
index 03942c86c98..00000000000
--- a/mysql-test/t/innodb_bug46000.test
+++ /dev/null
@@ -1,34 +0,0 @@
-# This is the test for bug 46000. We shall
-# block any index creation with the name of
-# "GEN_CLUST_INDEX", which is the reserved
-# name for innodb default primary index.
-
---source include/have_innodb.inc
-
-# This 'create table' operation should fail because of
-# using the reserve name as its index name.
---error ER_WRONG_NAME_FOR_INDEX
-create table bug46000(`id` int,key `GEN_CLUST_INDEX`(`id`))engine=innodb;
-
-# Mixed upper/lower case of the reserved key words
---error ER_WRONG_NAME_FOR_INDEX
-create table bug46000(`id` int, key `GEN_clust_INDEX`(`id`))engine=innodb;
-
-show warnings;
-
-create table bug46000(id int) engine=innodb;
-
-# This 'create index' operation should fail.
---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
---error ER_WRONG_NAME_FOR_INDEX
-create index GEN_CLUST_INDEX on bug46000(id);
-
---replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
-show warnings;
-
-# This 'create index' operation should succeed, no
-# temp table left from last failed create index
-# operation.
-create index idx on bug46000(id);
-
-drop table bug46000;
diff --git a/mysql-test/t/innodb_bug47777.test b/mysql-test/t/innodb_bug47777.test
deleted file mode 100644
index 8f2985b2cf0..00000000000
--- a/mysql-test/t/innodb_bug47777.test
+++ /dev/null
@@ -1,24 +0,0 @@
-# This is the test for bug 47777. GEOMETRY
-# data is treated as BLOB data in innodb.
-# Consequently, its key value generation/storing
-# should follow the process for the BLOB
-# datatype as well.
-
---source include/have_innodb.inc
-
-create table bug47777(c2 linestring not null, primary key (c2(1))) engine=innodb;
-
-insert into bug47777 values (geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)'));
-
-# Verify correct row get inserted.
-select count(*) from bug47777 where c2 =geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)');
-
-# Update table bug47777 should be successful.
-update bug47777 set c2=GeomFromText('POINT(1 1)');
-
-# Verify the row get updated successfully. The original
-# c2 value should be changed to GeomFromText('POINT(1 1)').
-select count(*) from bug47777 where c2 =geomfromtext('linestring(1 2,3 4,5 6,7 8,9 10)');
-select count(*) from bug47777 where c2 = GeomFromText('POINT(1 1)');
-
-drop table bug47777;
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index 4a06abfe3c8..ada4323dcee 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -538,4 +538,99 @@ DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug #49324: more valgrind errors in test_if_skip_sort_order
+--echo #
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
+--echo #should not cause valgrind warnings
+SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#50843: Filesort used instead of clustered index led to
+--echo # performance degradation.
+--echo #
+create table t1(f1 int not null primary key, f2 int) engine=innodb;
+create table t2(f1 int not null, key (f1)) engine=innodb;
+insert into t1 values (1,1),(2,2),(3,3);
+insert into t2 values (1),(2),(3);
+explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
+drop table t1,t2;
+--echo #
+
+
+--echo #
+--echo # Bug #49838: DROP INDEX and ADD UNIQUE INDEX for same index may
+--echo # corrupt definition at engine
+--echo #
+
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, KEY k (a,b))
+ ENGINE=InnoDB;
+
+ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b);
+
+--query_vertical SHOW INDEXES FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #53334: wrong result for outer join with impossible ON condition
+--echo # (see the same test case for MyISAM in join.test)
+--echo #
+
+create table t1 (id int primary key);
+create table t2 (id int);
+
+insert into t1 values (75);
+insert into t1 values (79);
+insert into t1 values (78);
+insert into t1 values (77);
+replace into t1 values (76);
+replace into t1 values (76);
+insert into t1 values (104);
+insert into t1 values (103);
+insert into t1 values (102);
+insert into t1 values (101);
+insert into t1 values (105);
+insert into t1 values (106);
+insert into t1 values (107);
+
+insert into t2 values (107),(75),(1000);
+
+select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0
+ where t2.id=75 and t1.id is null;
+explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0
+ where t2.id=75 and t1.id is null;
+
+drop table t1,t2;
+
+--echo #
+--echo # Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when
+--echo # JOINed during an UPDATE
+--echo #
+
+CREATE TABLE t1 (d INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT, b INT,
+ c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+ ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB;
+
+--echo set up our data elements
+INSERT INTO t1 (d) VALUES (1);
+INSERT INTO t2 (a,b) VALUES (1,1);
+SELECT SECOND(c) INTO @bug47453 FROM t2;
+
+SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a;
+UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1;
+SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a;
+
+SELECT SLEEP(1);
+
+UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1;
+
+--echo #should be 0
+SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a;
+
+DROP TABLE t1, t2;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index dbf36dedec8..43b373c9703 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -784,6 +784,40 @@ FROM
DROP TABLE t1,t2,t3,t4,t5,t6;
+--echo #
+--echo # Bug#48483: crash in get_best_combination()
+--echo #
+
+CREATE TABLE t1(f1 INT);
+INSERT INTO t1 VALUES (1),(2);
+CREATE VIEW v1 AS SELECT 1 FROM t1 LEFT JOIN t1 AS t2 on 1=1;
+EXPLAIN EXTENDED
+SELECT 1 FROM v1 right join v1 AS v2 ON RAND();
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#52177 crash with explain, row comparison, join, text field
+--echo #
+CREATE TABLE t1 (a TINYINT, b TEXT, KEY (a));
+INSERT INTO t1 VALUES (0,''),(0,'');
+FLUSH TABLES;
+EXPLAIN SELECT 1 FROM t1 LEFT JOIN t1 a ON 1
+WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND
+ROW(t1.b, 1111.11) <=> ROW('','');
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #50335: Assertion `!(order->used & map)' in eq_ref_table
+--echo #
+
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b));
+INSERT INTO t1 VALUES (0,0), (1,1);
+
+SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests.
@@ -804,3 +838,17 @@ DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1, t2;
+
+#
+# Bug#45195 valgrind warnings about uninitialized values in store_record_in_cache()
+#
+CREATE TABLE t1(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM;
+CREATE TABLE t2(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM;
+INSERT INTO t1 VALUES ('1',null),(null,null);
+INSERT INTO t2 VALUES ('1',null),(null,null);
+CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a))
+ENGINE=MERGE UNION=(t1,t2);
+SELECT t1.a FROM mm1,t1;
+DROP TABLE t1, t2, mm1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index c670944c9b2..2c243aabeb6 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -897,3 +897,21 @@ FROM t1 JOIN t2 USING( a )
GROUP BY t1.a WITH ROLLUP;
DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison
+--echo #
+CREATE TABLE t1(f1 INT, f2 INT, f3 INT);
+INSERT INTO t1 VALUES (1, NULL, 3);
+CREATE TABLE t2(f1 INT, f2 INT);
+INSERT INTO t2 VALUES (2, 1);
+
+EXPLAIN EXTENDED SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
+WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
+
+SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
+WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
+
+DROP TABLE t1, t2;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test
index 4c14dc96aaa..d77ce243e32 100644
--- a/mysql-test/t/key_cache.test
+++ b/mysql-test/t/key_cache.test
@@ -1,11 +1,13 @@
#
-# Test of multiple key caches
+# Test of multiple key caches, simple and segmented
#
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
-SET @save_key_buffer=@@key_buffer_size;
+SET @save_key_buffer_size=@@key_buffer_size;
+SET @save_key_cache_block_size=@@key_cache_block_size;
+SET @save_key_cache_segments=@@key_cache_segments;
SELECT @@key_buffer_size, @@small.key_buffer_size;
@@ -33,7 +35,7 @@ SELECT @@`default`.key_buffer_size;
SELECT @@small.key_buffer_size;
SELECT @@medium.key_buffer_size;
-SET @@global.key_buffer_size=@save_key_buffer;
+SET @@global.key_buffer_size=@save_key_buffer_size;
#
# Errors
@@ -247,3 +249,272 @@ SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size;
DROP TABLE t1;
# End of 4.1 tests
+
+# End of 5.1 tests
+
+#
+# Test cases for segmented key caches
+#
+
+# Test usage of the KEY_CACHE table from information schema
+# for a simple key cache
+
+set global key_buffer_size=@save_key_buffer_size;
+set global key_cache_block_size=@save_key_cache_block_size;
+select @@key_buffer_size;
+select @@key_cache_block_size;
+select @@key_cache_segments;
+
+create table t1 (
+ p int not null auto_increment primary key,
+ a char(10));
+create table t2 (
+ p int not null auto_increment primary key,
+ i int, a char(10), key k1(i), key k2(a));
+
+select @@key_cache_segments;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+insert into t1 values (1, 'qqqq'), (2, 'yyyy');
+insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
+ (3, 1, 'yyyy'), (4, 3, 'zzzz');
+select * from t1;
+select * from t2;
+update t1 set p=3 where p=1;
+update t2 set i=2 where i=1;
+
+--replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED
+show status like 'key_%';
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+delete from t2 where a='zzzz';
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+delete from t1;
+delete from t2;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+# For the key cache with 2 segments execute the same sequence of
+# statements as for the simple cache above.
+# The statistical information on the number of i/o requests and
+# the number of is expected to be the same.
+
+set global key_cache_segments=2;
+select @@key_cache_segments;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+insert into t1 values (1, 'qqqq'), (2, 'yyyy');
+insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
+ (3, 1, 'yyyy'), (4, 3, 'zzzz');
+select * from t1;
+select * from t2;
+update t1 set p=3 where p=1;
+update t2 set i=2 where i=1;
+
+--replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1788 KEY_BLOCKS_UNUSED
+show status like 'key_%';
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+delete from t1;
+delete from t2;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+# Check that we can work with one segment with the same results
+
+set global key_cache_segments=1;
+select @@key_cache_segments;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+insert into t1 values (1, 'qqqq'), (2, 'yyyy');
+insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
+ (3, 1, 'yyyy'), (4, 3, 'zzzz');
+select * from t1;
+select * from t2;
+update t1 set p=3 where p=1;
+update t2 set i=2 where i=1;
+
+--replace_result 1808 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED
+show status like 'key_%';
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+delete from t1;
+delete from t2;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+flush tables; flush status;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+# Switch back to 2 segments
+
+set global key_buffer_size=32*1024;
+select @@key_buffer_size;
+set global key_cache_segments=2;
+select @@key_cache_segments;
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+insert into t1 values (1, 'qqqq'), (2, 'yyyy');
+insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
+ (3, 1, 'yyyy'), (4, 3, 'zzzz');
+select * from t1;
+select * from t2;
+update t1 set p=3 where p=1;
+update t2 set i=2 where i=1;
+
+--replace_column 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+# Add more rows to tables t1 and t2
+
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+insert into t1(a) select a from t1;
+
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+insert into t2(i,a) select i,a from t2;
+
+--replace_column 6 # 7 # 10 #
+select * from information_schema.key_caches where segment_number is null;
+
+select * from t1 where p between 1010 and 1020 ;
+select * from t2 where p between 1010 and 1020 ;
+--replace_column 6 # 7 # 10 #
+select * from information_schema.key_caches where segment_number is null;
+
+flush tables; flush status;
+update t1 set a='zzzz' where a='qqqq';
+update t2 set i=1 where i=2;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+# Now test how we can work with 7 segments
+
+set global keycache1.key_buffer_size=256*1024;
+select @@keycache1.key_buffer_size;
+set global keycache1.key_cache_segments=7;
+select @@keycache1.key_cache_segments;
+
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+--replace_column 7 #
+select * from information_schema.key_caches where key_cache_name like "key%"
+ and segment_number is null;
+
+cache index t1 key (`primary`) in keycache1;
+
+explain select p from t1 where p between 1010 and 1020;
+select p from t1 where p between 1010 and 1020;
+explain select i from t2 where p between 1010 and 1020;
+select i from t2 where p between 1010 and 1020;
+explain select count(*) from t1, t2 where t1.p = t2.i;
+select count(*) from t1, t2 where t1.p = t2.i;
+
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+--replace_column 7 #
+select * from information_schema.key_caches where key_cache_name like "key%"
+ and segment_number is null;
+
+cache index t2 in keycache1;
+update t2 set p=p+3000, i=2 where a='qqqq';
+--replace_column 7 #
+select * from information_schema.key_caches where key_cache_name like "key%"
+ and segment_number is null;
+
+set global keycache2.key_buffer_size=1024*1024;
+cache index t2 in keycache2;
+insert into t2 values (2000, 3, 'yyyy');
+--replace_column 7 #
+select * from information_schema.key_caches where key_cache_name like "keycache2"
+ and segment_number is null;
+--replace_column 7 #
+select * from information_schema.key_caches where key_cache_name like "key%"
+ and segment_number is null;
+
+cache index t2 in keycache1;
+update t2 set p=p+5000 where a='zzzz';
+select * from t2 where p between 1010 and 1020;
+explain select p from t2 where p between 1010 and 1020;
+select p from t2 where p between 1010 and 1020;
+explain select i from t2 where a='yyyy' and i=3;
+select i from t2 where a='yyyy' and i=3;
+explain select a from t2 where a='yyyy' and i=3;
+select a from t2 where a='yyyy' and i=3 ;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_cache_block_size=2*1024;
+insert into t2 values (7000, 3, 'yyyy');
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_cache_block_size=8*1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+insert into t2 values (8000, 3, 'yyyy');
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_buffer_size=64*1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_cache_block_size=2*1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_cache_block_size=8*1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_buffer_size=0;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_cache_block_size=8*1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_buffer_size=0;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_buffer_size=128*1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+set global keycache1.key_cache_block_size=1024;
+--replace_column 6 # 7 #
+select * from information_schema.key_caches where segment_number is null;
+
+drop table t1,t2;
+
+set global keycache1.key_buffer_size=0;
+set global keycache2.key_buffer_size=0;
+
+set global key_buffer_size=@save_key_buffer_size;
+set global key_cache_segments=@save_key_cache_segments;
+
+# End of 5.2 tests
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 7bfe2491c7c..126bd5c8838 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -153,10 +153,16 @@ select * from t1;
#
# It should not be possible to load from a file outside of vardir
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-show variables like "secure_file_pri%";
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-select @@secure_file_priv;
+## The following lines were disabled because of patch for
+## bug 50373. MYSQLTEST_VARDIR doesn't rewrite symlinks
+## to real paths, but this is done for secure_file_priv.
+## Because of this the result can't be replaced if the
+## test suite runs with the --mem option which creates
+## symlinks to the ramdisk.
+#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+#show variables like "secure_file_pri%";
+#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+#select @@secure_file_priv;
--error 1238
set @@secure_file_priv= 0;
@@ -502,6 +508,13 @@ set session sql_mode=@OLD_SQL_MODE;
DROP TABLE t1,t2;
+--echo #
+--echo # Bug #51893: crash with certain characters given to load_file
+--echo # function on windows
+--echo #
+
+select load_file(0x0A9FB76C661B409C4BEC88098C5DD71B1072F9691F2E827D7EC8F092B299868A3CE196C04F0FB18CAB4E1557EB72331D812379DE7A75CA21C32E7C722C59E5CC33EF262EF04187B0F0EE756FA984DF2EAD37B1E4ADB064C3C5038F2E3B2D661B1C1150AAEB5425512E14D7506166D92D4533872E662F4B2D1428AAB5CCA72E75AA2EF325E196A5A02E2E8278873C64375845994B0F39BE2FF7B478332A7B0AA5E48877C47B6F513E997848AF8CCB8A899F3393AB35333CF0871E36698193862D486B4B9078B70C0A0A507B8A250F3F876F5A067632D5E65193E4445A1EC3A2C9B4C6F07AC334F0F62BC33357CB502E9B1C19D2398B6972AEC2EF21630F8C9134C4F7DD662D8AD7BDC9E19C46720F334B66C22D4BF32ED275144E20E7669FFCF6FC143667C9F02A577F32960FA9F2371BE1FA90E49CBC69C01531F140556854D588DD0E55E1307D78CA38E975CD999F9AEA604266329EE62BFB5ADDA67F549E211ECFBA906C60063696352ABB82AA782D25B17E872EA587871F450446DB1BAE0123D20404A8F2D2698B371002E986C8FCB969A99FF0E150A2709E2ED7633D02ADA87D5B3C9487D27B2BD9D21E2EC3215DCC3CDCD884371281B95A2E9987AAF82EB499C058D9C3E7DC1B66635F60DB121C72F929622DD47B6B2E69F59FF2AE6B63CC2EC60FFBA20EA50569DBAB5DAEFAEB4F03966C9637AB55662EDD28439155A82D053A5299448EDB2E7BEB0F62889E2F84E6C7F34B3212C9AAC32D521D5AB8480993F1906D5450FAB342A0FA6ED223E178BAC036B81E15783604C32A961EA1EF20BE2EBB93D34ED37BC03142B7583303E4557E48551E4BD7CBDDEA146D5485A5D212C35189F0BD6497E66912D2780A59A53B532E12C0A5ED1EC0445D96E8F2DD825221CFE4A65A87AA21DC8750481B9849DD81694C3357A0ED9B78D608D8EDDE28FAFBEC17844DE5709F41E121838DB55639D77E32A259A416D7013B2EB1259FDE1B498CBB9CAEE1D601DF3C915EA91C69B44E6B72062F5F4B3C73F06F2D5AD185E1692E2E0A01E7DD5133693681C52EE13B2BE42D03BDCF48E4E133CF06662339B778E1C3034F9939A433E157449172F7969ACCE1F5D2F65A4E09E4A5D5611EBEDDDBDB0C0C0A);
+
--echo End of 5.0 tests
@@ -532,5 +545,19 @@ SET character_set_filesystem=default;
select @@character_set_filesystem;
+--echo #
+--echo # Bug #51850: crash/memory overlap when using load data infile and set
+--echo # col equal to itself!
+--echo #
+
+CREATE TABLE t1(col0 LONGBLOB);
+SELECT 'test' INTO OUTFILE 't1.txt';
+LOAD DATA INFILE 't1.txt' IGNORE INTO TABLE t1 SET col0=col0;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t1.txt;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/log_tables_upgrade.test b/mysql-test/t/log_tables_upgrade.test
new file mode 100644
index 00000000000..5d1b2b5aed6
--- /dev/null
+++ b/mysql-test/t/log_tables_upgrade.test
@@ -0,0 +1,32 @@
+--source include/not_embedded.inc
+--source include/have_csv.inc
+
+# Only run test if "mysql_upgrade" is found
+--require r/have_mysql_upgrade.result
+--disable_query_log
+select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
+--enable_query_log
+
+--echo #
+--echo # Bug#49823: mysql_upgrade fatal error due to general_log / slow_low CSV NULL
+--echo #
+
+USE test;
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/bug49823.frm $MYSQLD_DATADIR/test/bug49823.frm;
+copy_file std_data/bug49823.CSM $MYSQLD_DATADIR/test/bug49823.CSM;
+copy_file std_data/bug49823.CSV $MYSQLD_DATADIR/test/bug49823.CSV;
+
+SET @saved_general_log = @@GLOBAL.general_log;
+SET GLOBAL general_log = OFF;
+USE mysql;
+FLUSH TABLES;
+REPAIR TABLE test.bug49823;
+RENAME TABLE general_log TO renamed_general_log;
+RENAME TABLE test.bug49823 TO general_log;
+--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
+DROP TABLE general_log;
+RENAME TABLE renamed_general_log TO general_log;
+SET GLOBAL general_log = @saved_general_log;
+USE test;
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index f44f4649099..df99d6150ab 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -12,6 +12,8 @@ drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
--enable_warnings
+let $MYSQLD_DATADIR= `select @@datadir`;
+
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");
@@ -1643,6 +1645,76 @@ SHOW CREATE TRIGGER tr1;
DROP TRIGGER tr1;
DROP TABLE t1, t2, t3;
+--echo #
+--echo # BUG#48265 - MRG_MYISAM problem (works in 5.0.85, does't work in 5.1.40)
+--echo #
+CREATE DATABASE `test/1`;
+
+CREATE TABLE `test/1`.`t/1`(a INT);
+CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`);
+SELECT * FROM m1;
+SHOW CREATE TABLE m1;
+DROP TABLE m1;
+
+CREATE TABLE `test/1`.m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`);
+SELECT * FROM `test/1`.m1;
+SHOW CREATE TABLE `test/1`.m1;
+DROP TABLE `test/1`.m1;
+DROP TABLE `test/1`.`t/1`;
+
+CREATE TEMPORARY TABLE `test/1`.`t/1`(a INT);
+CREATE TEMPORARY TABLE m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`);
+SELECT * FROM m1;
+SHOW CREATE TABLE m1;
+DROP TABLE m1;
+
+CREATE TEMPORARY TABLE `test/1`.m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`);
+SELECT * FROM `test/1`.m1;
+SHOW CREATE TABLE `test/1`.m1;
+DROP TABLE `test/1`.m1;
+DROP TABLE `test/1`.`t/1`;
+
+DROP DATABASE `test/1`;
+
+# Test compatibility. Use '@' instead of '/' (was not allowed in 5.0)
+
+CREATE TABLE `t@1`(a INT);
+copy_file std_data/bug48265.frm $MYSQLD_DATADIR/test/m1.frm;
+write_file $MYSQLD_DATADIR/test/m1.MRG;
+t@1
+EOF
+SELECT * FROM m1;
+SHOW CREATE TABLE m1;
+DROP TABLE `t@1`;
+
+CREATE DATABASE `test@1`;
+CREATE TABLE `test@1`.`t@1`(a INT);
+FLUSH TABLE m1;
+remove_file $MYSQLD_DATADIR/test/m1.MRG;
+write_file $MYSQLD_DATADIR/test/m1.MRG;
+./test@1/t@1
+EOF
+SELECT * FROM m1;
+SHOW CREATE TABLE m1;
+DROP TABLE m1;
+DROP TABLE `test@1`.`t@1`;
+DROP DATABASE `test@1`;
+
+--echo #
+--echo # Bug#51494c rash with join, explain and 'sounds like' operator
+--echo #
+
+CREATE TABLE t1 (a INT) ENGINE=MYISAM;
+INSERT INTO t1 VALUES(1);
+
+CREATE TABLE t2 (b INT NOT NULL,c INT,d INT,e BLOB NOT NULL,
+KEY idx0 (d, c)) ENGINE=MERGE;
+
+EXPLAIN SELECT * FROM t1 NATURAL RIGHT JOIN
+t2 WHERE b SOUNDS LIKE e AND d = 1;
+
+DROP TABLE t2, t1;
+
--echo End of 5.1 tests
--disable_result_log
diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test
index a10767579fb..9bfb47c53be 100644
--- a/mysql-test/t/metadata.test
+++ b/mysql-test/t/metadata.test
@@ -129,4 +129,17 @@ SELECT COALESCE(d, d), IFNULL(d, d), IF(i, d, d),
DROP TABLE t1;
+--echo #
+--echo # Bug#41788 mysql_fetch_field returns org_table == table by a view
+--echo #
+
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT f1 FROM t1;
+--enable_metadata
+SELECT f1 FROM v1 va;
+--disable_metadata
+
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index ebf6a6219fc..b32a329f827 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -641,5 +641,17 @@ drop table t1, t2, t3;
# Add further tests from here
#
+--echo #
+--echo # Bug#49534: multitable IGNORE update with sql_safe_updates error
+--echo # causes debug assertion
+--echo #
+CREATE TABLE t1( a INT, KEY( a ) );
+INSERT INTO t1 VALUES (1), (2), (3);
+SET SESSION sql_safe_updates = 1;
+--echo # Must not cause failed assertion
+--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
+UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1;
+DROP TABLE t1;
+
--echo end of tests
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index e1982a623da..d498d4e95ad 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1204,6 +1204,17 @@ CHECKSUM TABLE t1 EXTENDED;
DROP TABLE t1;
+--echo #
+--echo # BUG#48438 - crash with error in unioned query against merge table and view...
+--echo #
+SET GLOBAL table_open_cache=3;
+CREATE TABLE t1(a INT);
+SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE;
+SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+DROP TABLE t1;
+SET GLOBAL table_open_cache=DEFAULT;
+
--echo End of 5.0 tests
@@ -1609,4 +1620,76 @@ SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
CHECK TABLE t1;
DROP TABLE t1;
+
+--echo #
+--echo # BUG#49628 - corrupt table after legal SQL, LONGTEXT column
+--echo #
+CREATE TABLE t1(a INT, b LONGTEXT, UNIQUE(a));
+REPLACE INTO t1 VALUES
+(1, REPEAT('a', 129015)),(1, NULL),
+(2, NULL),(3, NULL),(4, NULL),(5, NULL),(6, NULL),(7, NULL),
+(1, REPEAT('b', 129016)),(1, NULL),
+(1, REPEAT('c', 129015)),(1, REPEAT('d', 129015));
+CHECK TABLE t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#51304: checksum table gives different results
+--echo # for same data when using bit fields
+--echo #
+CREATE TABLE t1(a INT, b BIT(1));
+INSERT INTO t1 VALUES(1, 0), (2, 1);
+CREATE TABLE t2 SELECT * FROM t1;
+FLUSH TABLES;
+--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t3.frm
+--copy_file $MYSQLD_DATADIR/test/t1.MYD $MYSQLD_DATADIR/test/t3.MYD
+--copy_file $MYSQLD_DATADIR/test/t1.MYI $MYSQLD_DATADIR/test/t3.MYI
+CHECKSUM TABLE t1 EXTENDED;
+CHECKSUM TABLE t2 EXTENDED;
+CHECKSUM TABLE t3 EXTENDED;
+DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # BUG#51307 - widespread corruption with partitions and insert...select
+--echo #
+CREATE TABLE t1(a CHAR(255), KEY(a));
+SELECT * FROM t1, t1 AS a1;
+SET myisam_sort_buffer_size=4;
+INSERT INTO t1 VALUES
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
+('0'),('0'),('0'),('0'),('0'),('0'),('0');
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+INSERT INTO t1 VALUES('1');
+SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1;
+DROP TABLE t1;
+
+--echo #
+--echo # BUG#47444 - --myisam_repair_threads>1can result in all index
+--echo # cardinalities=1
+--echo #
+SET myisam_repair_threads=2;
+SET myisam_sort_buffer_size=4096;
+CREATE TABLE t1(a CHAR(255), KEY(a), KEY(a), KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(0),(1),(2),(3);
+REPAIR TABLE t1;
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+DROP TABLE t1;
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+SET myisam_repair_threads=@@global.myisam_repair_threads;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test
index 87457c36382..485302600c1 100644
--- a/mysql-test/t/mysql_upgrade.test
+++ b/mysql-test/t/mysql_upgrade.test
@@ -33,7 +33,7 @@ if (`SELECT $VALGRIND_TEST`)
# expected binaries it uses.
#
--echo Run mysql_upgrade once
---exec $MYSQL_UPGRADE --skip-verbose 2>&1
+--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
# It should have created a file in the MySQL Servers datadir
let $MYSQLD_DATADIR= `select @@datadir`;
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index 687ad62b17c..7c9fbf031bb 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -434,12 +434,43 @@ FLUSH LOGS;
# Transaction3 end
--echo #
---echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist
+--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified exists
--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
--echo #
---echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is not exist
+--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified does not exist
--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
+--echo #
+--echo # Test if the 'SAVEPOINT', 'ROLLBACK TO' are output if the database specified exists
+--exec $MYSQL_BINLOG --database=db1 --short-form $MYSQLTEST_VARDIR/std_data/binlog_savepoint.000001
+--echo #
+--echo # Test if the 'SAVEPOINT', 'ROLLBACK TO' are output if the database specified does not exist
+--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_savepoint.000001
+
--echo End of 5.0 tests
--echo End of 5.1 tests
+
+#
+# BUG#38468 Memory leak detected when using mysqlbinlog utility;
+#
+disable_query_log;
+RESET MASTER;
+CREATE TABLE t1 SELECT 1;
+FLUSH LOGS;
+DROP TABLE t1;
+enable_query_log;
+
+# Write an empty file for comparison
+write_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
+EOF
+
+# Before fix of BUG#38468, this would generate some warnings
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 >/dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
+# Make sure the command above does not generate any error or warnings
+diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
+
+# Cleanup for this part of test
+remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
+remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index c86ebda3a24..b103140190f 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -613,6 +613,15 @@ echo ;
--error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1
+# Multi-line exec
+exec $MYSQL
+ test -e "select 1";
+exec $MYSQL test -e "select
+ 2";
+let $query = select 3
+ as X;
+exec $MYSQL test -e "$query";
+
# ----------------------------------------------------------------------------
# Test let command
# ----------------------------------------------------------------------------
@@ -919,6 +928,28 @@ sleep 0.5;
sleep 1;
real_sleep 1;
+# Parameter from variable, legal and illegal
+let $sleep_var= 0.1;
+sleep $sleep_var;
+let $sleep_var= 1;
+--real_sleep $sleep_var
+
+--write_file $MYSQL_TMP_DIR/sleep.inc
+let $sleep_var= xyz;
+--sleep $sleep_var
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1
+--remove_file $MYSQL_TMP_DIR/sleep.inc
+
+--write_file $MYSQL_TMP_DIR/sleep.inc
+let $sleep_var= xyz;
+real_sleep $sleep_var;
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQL_TMP_DIR/sleep.inc 2>&1
+--remove_file $MYSQL_TMP_DIR/sleep.inc
+
# Missing parameter
--error 1
--exec echo "sleep ;" | $MYSQL_TEST 2>&1
@@ -1014,6 +1045,37 @@ echo test3stop
--delimiter ;
echo test4;
+# ----------------------------------------------------------------------------
+# Test that delimiter within if() works in in various combinations
+# ----------------------------------------------------------------------------
+
+if (0)
+{
+ delimiter ||;
+ echo false-inner||
+ if (0)
+ {
+ delimiter *||
+ echo false-innerer*
+ delimiter ||*
+ }
+ echo false-inner again||
+}
+echo outer;
+if (1)
+{
+ delimiter /;
+ echo true-inner/
+ if (0)
+ {
+ delimiter %/
+ echo true-innerer%
+ }
+ echo true-inner again/
+}
+echo true-outer/
+delimiter ;/
+
# ----------------------------------------------------------------------------
# Test if
@@ -1293,6 +1355,17 @@ select "a" as col1, "c" as col2;
--error 1
--exec echo "--replace_column 1 b c " | $MYSQL_TEST 2>&1
+let $long_rep= 1234567890123456789012345678901234567890;
+let $long_rep= $long_rep,$long_rep;
+let $long_rep= $long_rep,$long_rep;
+let $long_rep= $long_rep,$long_rep;
+let $long_rep= $long_rep,$long_rep;
+let $long_rep= $long_rep,$long_rep;
+
+# This tests from strings > 1024 (here 1311)
+
+--replace_result $long_rep LONG_STRING
+eval select "$long_rep" as x;
# ----------------------------------------------------------------------------
# Test sync_with_master
@@ -1614,6 +1687,57 @@ select * from t1;
drop table t1;
# ----------------------------------------------------------------------------
+# Tests of send
+# ----------------------------------------------------------------------------
+
+create table t1 ( f1 char(10));
+insert into t1 values ("Abcd");
+
+# 1. Basic test
+
+send select * from t1;
+reap;
+
+# 2. Test with error
+
+--send select * from t2;
+--error ER_NO_SUCH_TABLE
+--reap
+
+# 3. test send of next stmt
+
+--send
+select * from t1;
+--reap
+
+# 4. Non-query stmt betwen send and reap allowed
+
+--send select * from t1;
+--sleep 0.05
+--echo Result coming up
+--reap
+
+# 5. Test of send_eval
+
+--let $my_stmt= select * from t1;
+--send_eval $my_stmt
+--reap
+
+# 6. Test that mysqltest does not allow query stmt between send and reap
+# Untestable directly as it causes mysqltest to fail
+
+--write_file $MYSQLTEST_VARDIR/tmp/mysqltest.in
+--send select * from t1;
+select 1;
+--reap
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.in 2>&1
+remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.in;
+
+drop table t1;
+
+# ----------------------------------------------------------------------------
# test for remove_file
# ----------------------------------------------------------------------------
@@ -1624,6 +1748,19 @@ drop table t1;
remove_file non_existing_file;
# ----------------------------------------------------------------------------
+# test for remove_files_wildcard
+# ----------------------------------------------------------------------------
+
+--error 1
+--exec echo "remove_files_wildcard ;" | $MYSQL_TEST 2>&1
+
+--error 1
+remove_files_wildcard non_existing_dir;
+
+--error 1
+remove_files_wildcard non_existing_dir non_existing_file;
+
+# ----------------------------------------------------------------------------
# test for write_file
# ----------------------------------------------------------------------------
--error 1
@@ -1913,6 +2050,20 @@ perl;
print "hello\n";
EOF
+# Test perl within while, also with if being false first iteration
+let $outer= 3;
+let $ifval= 0;
+while ($outer) {
+ if ($ifval) {
+ perl UNTIL;
+ my $val= 5;
+ print "val is $val\n";
+UNTIL
+ }
+ inc $ifval;
+ dec $outer;
+}
+
# ----------------------------------------------------------------------------
# test for die
# ----------------------------------------------------------------------------
@@ -2053,6 +2204,44 @@ INSERT INTO t1 SELECT f1 - 512 FROM t1;
SELECT * FROM t1;
--enable_result_log
DROP TABLE t1;
+
+# ----------------------------------------------------------------------------
+# test for lowercase_result
+# ----------------------------------------------------------------------------
+
+# 1. Basic test
+--lowercase_result
+SELECT "500g BLÅBÆRSYLTETØY" AS "WILL BE lower cased";
+
+# 2. test that it does not apply to next statement
+SELECT "UPPER" AS "WILL NOT BE lower cased";
+
+# 3. test that it does not affect non-SQL or the following statement
+--lowercase_result
+--echo UP
+SELECT 0 as "UP AGAIN";
+
+# 4. test that it works with eval and variables
+let $lower_stmt=SELECT "ABCdef" AS "uvwXYZ";
+--lowercase_result
+eval $lower_stmt;
+
+# 5. test that it works in combination with sort
+sorted_result;
+lowercase_result;
+SELECT "Xyz" AS Name UNION SELECT "Abc" as Name ORDER BY Name DESC;
+
+# 6. Test combination with replace, and that lower casing is done first
+--lowercase_result
+--replace_result old new
+SELECT 1 as "SOME OLD TEXT";
+
+# 7. Test missing lower casing of "unknown" characters
+--character_set utf8
+--lowercase_result
+SELECT 0 as "WILL NOT lower case ÄËÐ";
+--character_set latin1
+
# ----------------------------------------------------------------------------
# Some coverage tests
# ----------------------------------------------------------------------------
@@ -2238,9 +2427,14 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir;
cat_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
-remove_file $MYSQLTEST_VARDIR/tmp/testdir/file1.txt;
-remove_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt;
-remove_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
+list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file11.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
+remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
+list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
+cat_file $MYSQLTEST_VARDIR/tmp/testdir/dir-list.txt;
+remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
+list_files $MYSQLTEST_VARDIR/tmp/testdir;
+remove_files_wildcard $MYSQLTEST_VARDIR/tmp/testdir;
+list_files $MYSQLTEST_VARDIR/tmp/testdir;
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
#
diff --git a/mysql-test/t/no_binlog.test b/mysql-test/t/no_binlog.test
new file mode 100644
index 00000000000..fa9c87079de
--- /dev/null
+++ b/mysql-test/t/no_binlog.test
@@ -0,0 +1,6 @@
+-- source include/not_embedded.inc
+
+# BUG#50780: 'show binary logs' debug assertion when binary logging is disabled
+
+-- error ER_NO_BINARY_LOGGING
+SHOW BINARY LOGS;
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index af8cb1c168c..e6e000ec916 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -2085,4 +2085,17 @@ INSERT INTO t1 VALUES (6,8,10);
SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
DROP TABLE t1;
+
+--echo #
+--echo # BUG#51868 - crash with myisam_use_mmap and partitioned myisam tables
+--echo #
+SET GLOBAL myisam_use_mmap=1;
+CREATE TABLE t1(a INT) PARTITION BY HASH(a) PARTITIONS 1;
+INSERT INTO t1 VALUES(0);
+FLUSH TABLE t1;
+TRUNCATE TABLE t1;
+INSERT INTO t1 VALUES(0);
+DROP TABLE t1;
+SET GLOBAL myisam_use_mmap=default;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_debug_sync.test b/mysql-test/t/partition_debug_sync.test
new file mode 100644
index 00000000000..69bc86a8bb7
--- /dev/null
+++ b/mysql-test/t/partition_debug_sync.test
@@ -0,0 +1,81 @@
+#--disable_abort_on_error
+#
+# Test for the partition storage engine which require DEBUG_SYNC feature to
+# Created by Mattias Jonsson
+#
+--source include/have_partition.inc
+--source include/have_debug_sync.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+SET DEBUG_SYNC= 'RESET';
+--enable_warnings
+
+--echo #
+--echo # Bug#42438: Crash ha_partition::change_table_ptr
+--echo # Test when remove partitioning is done while drop table is waiting
+--echo # for the table.
+connect(con1, localhost, root,,);
+--echo # Con 1
+SET DEBUG_SYNC= 'RESET';
+CREATE TABLE t1
+(a INTEGER,
+ b INTEGER NOT NULL,
+ KEY (b))
+ENGINE = MYISAM
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (2),
+ PARTITION p1 VALUES LESS THAN (20),
+ PARTITION p2 VALUES LESS THAN (100),
+ PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
+SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter';
+SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL partitioning_removed';
+--send ALTER TABLE t1 REMOVE PARTITIONING
+connection default;
+--echo # Con default
+SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning';
+SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter';
+SET DEBUG_SYNC= 'rm_table_part2_before_delete_table WAIT_FOR partitioning_removed';
+DROP TABLE IF EXISTS t1;
+--echo # Con 1
+connection con1;
+--reap
+connection default;
+SET DEBUG_SYNC= 'RESET';
+connection con1;
+SET DEBUG_SYNC= 'RESET';
+
+--echo #
+--echo # Bug#42438: Crash ha_partition::change_table_ptr
+--echo # Test when remove partitioning is failing due to drop table is already
+--echo # in progress.
+CREATE TABLE t2
+(a INTEGER,
+ b INTEGER NOT NULL,
+ KEY (b))
+ENGINE = MYISAM
+/*!50100 PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (2),
+ PARTITION p1 VALUES LESS THAN (20),
+ PARTITION p2 VALUES LESS THAN (100),
+ PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
+SET DEBUG_SYNC= 'before_lock_tables_takes_lock SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
+SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done';
+--send ALTER TABLE t2 REMOVE PARTITIONING
+connection default;
+--echo # Con default
+SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions';
+SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter';
+SET DEBUG_SYNC= 'rm_table_part2_before_binlog SIGNAL delete_done';
+DROP TABLE IF EXISTS t2;
+--echo # Con 1
+connection con1;
+--error ER_NO_SUCH_TABLE
+--reap
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+connection default;
+--echo # Con default
+SET DEBUG_SYNC= 'RESET';
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 1f011f36257..8da8f54b774 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -8,6 +8,30 @@
drop table if exists t1;
--enable_warnings
+--echo #
+--echo # Bug#50392: insert_id is not reset for partitioned tables
+--echo # auto_increment on duplicate entry
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
+SET INSERT_ID= 13;
+INSERT INTO t1 VALUES (NULL);
+SET INSERT_ID= 12;
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY(a);
+SET INSERT_ID= 13;
+INSERT INTO t1 VALUES (NULL);
+SET INSERT_ID= 12;
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
#
# Bug#38719: Partitioning returns a different error code for a
# duplicate key error
diff --git a/mysql-test/t/partition_example-master.opt b/mysql-test/t/partition_example-master.opt
new file mode 100644
index 00000000000..367d5233e0e
--- /dev/null
+++ b/mysql-test/t/partition_example-master.opt
@@ -0,0 +1 @@
+$EXAMPLE_PLUGIN_OPT
diff --git a/mysql-test/t/partition_example.test b/mysql-test/t/partition_example.test
new file mode 100644
index 00000000000..e6ac1bd222a
--- /dev/null
+++ b/mysql-test/t/partition_example.test
@@ -0,0 +1,23 @@
+--source include/not_windows_embedded.inc
+--source include/have_example_plugin.inc
+--source include/have_partition.inc
+
+--replace_regex /\.dll/.so/
+eval install plugin example soname $HA_EXAMPLE_SO;
+
+create table t1 (a int not null)
+engine=example
+partition by list (a)
+(partition p0 values in (1), partition p1 values in (2));
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null)
+engine=example ull=12340
+partition by list (a)
+(partition p0 values in (1), partition p1 values in (2));
+show create table t1;
+drop table t1;
+
+select 1;
+uninstall plugin example;
diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index 91ecfa15d60..0a32e6104b3 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -2,11 +2,70 @@
--source include/have_innodb.inc
--disable_warnings
-drop table if exists t1;
+drop table if exists t1, t2;
--enable_warnings
let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--echo #
+--echo # Bug#51830: Incorrect partition pruning on range partition (regression)
+--echo #
+CREATE TABLE t1 (a INT NOT NULL)
+ENGINE = InnoDB
+PARTITION BY RANGE(a)
+(PARTITION p10 VALUES LESS THAN (10),
+ PARTITION p30 VALUES LESS THAN (30),
+ PARTITION p50 VALUES LESS THAN (50),
+ PARTITION p70 VALUES LESS THAN (70),
+ PARTITION p90 VALUES LESS THAN (90));
+INSERT INTO t1 VALUES (10),(30),(50);
+INSERT INTO t1 VALUES (70);
+INSERT INTO t1 VALUES (80);
+INSERT INTO t1 VALUES (89);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO t1 VALUES (90);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO t1 VALUES (100);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert INTO t1 VALUES (110);
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 89;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#50104: Partitioned table with just 1 partion works with fk
+--echo #
+CREATE TABLE t2 (
+ id INT,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ;
+
+CREATE TABLE t1 (
+ id INT NOT NULL AUTO_INCREMENT,
+ parent_id INT DEFAULT NULL,
+ PRIMARY KEY (id),
+ KEY parent_id (parent_id)
+) ENGINE=InnoDB;
+
+ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
+
+--error ER_FOREIGN_KEY_ON_PARTITIONED
+ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
+
+ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
+
+--error ER_FOREIGN_KEY_ON_PARTITIONED
+ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
+
+DROP TABLE t1, t2;
+
#
# Bug#47029: Crash when reorganize partition with subpartition
#
diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test
index fed8c96424a..04c72127394 100644
--- a/mysql-test/t/partition_innodb_plugin.test
+++ b/mysql-test/t/partition_innodb_plugin.test
@@ -1,6 +1,5 @@
--source include/have_partition.inc
--source include/have_innodb.inc
---source suite/innodb/include/have_innodb_plugin.inc
#
# Bug#32430 - show engine innodb status causes errors
diff --git a/mysql-test/t/partition_innodb_semi_consistent.test b/mysql-test/t/partition_innodb_semi_consistent.test
index 5eda2f142c6..2711d79f194 100644
--- a/mysql-test/t/partition_innodb_semi_consistent.test
+++ b/mysql-test/t/partition_innodb_semi_consistent.test
@@ -187,7 +187,7 @@ SELECT * FROM t1;
--echo # Switch to connection con2
connection con2;
---reap
+reap;
SELECT * FROM t1;
connection default;
diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test
index 315b8393d93..358832496e5 100644
--- a/mysql-test/t/partition_pruning.test
+++ b/mysql-test/t/partition_pruning.test
@@ -702,15 +702,29 @@ insert into t7 values (10),(30),(50);
# leftmost intervals
explain partitions select * from t7 where a < 5;
+explain partitions select * from t7 where a < 9;
+explain partitions select * from t7 where a <= 9;
+explain partitions select * from t7 where a = 9;
+explain partitions select * from t7 where a >= 9;
+explain partitions select * from t7 where a > 9;
explain partitions select * from t7 where a < 10;
explain partitions select * from t7 where a <= 10;
explain partitions select * from t7 where a = 10;
+explain partitions select * from t7 where a >= 10;
+explain partitions select * from t7 where a > 10;
#rightmost intervals
+explain partitions select * from t7 where a < 89;
+explain partitions select * from t7 where a <= 89;
+explain partitions select * from t7 where a = 89;
+explain partitions select * from t7 where a > 89;
+explain partitions select * from t7 where a >= 89;
explain partitions select * from t7 where a < 90;
+explain partitions select * from t7 where a <= 90;
explain partitions select * from t7 where a = 90;
explain partitions select * from t7 where a > 90;
explain partitions select * from t7 where a >= 90;
+explain partitions select * from t7 where a > 91;
# misc intervals
explain partitions select * from t7 where a > 11 and a < 29;
@@ -728,15 +742,29 @@ insert into t7 values (10),(30),(50);
# leftmost intervals
explain partitions select * from t7 where a < 5;
+explain partitions select * from t7 where a < 9;
+explain partitions select * from t7 where a <= 9;
+explain partitions select * from t7 where a = 9;
+explain partitions select * from t7 where a >= 9;
+explain partitions select * from t7 where a > 9;
explain partitions select * from t7 where a < 10;
explain partitions select * from t7 where a <= 10;
explain partitions select * from t7 where a = 10;
+explain partitions select * from t7 where a >= 10;
+explain partitions select * from t7 where a > 10;
#rightmost intervals
+explain partitions select * from t7 where a < 89;
+explain partitions select * from t7 where a <= 89;
+explain partitions select * from t7 where a = 89;
+explain partitions select * from t7 where a > 89;
+explain partitions select * from t7 where a >= 89;
explain partitions select * from t7 where a < 90;
+explain partitions select * from t7 where a <= 90;
explain partitions select * from t7 where a = 90;
explain partitions select * from t7 where a > 90;
explain partitions select * from t7 where a >= 90;
+explain partitions select * from t7 where a > 91;
# misc intervals
explain partitions select * from t7 where a > 11 and a < 29;
diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test
index c02d9049f2e..4d011ddc468 100644
--- a/mysql-test/t/partition_range.test
+++ b/mysql-test/t/partition_range.test
@@ -9,6 +9,24 @@
drop table if exists t1, t2;
--enable_warnings
+--echo #
+--echo # Bug#48229: group by performance issue of partitioned table
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ KEY a (a,b)
+)
+PARTITION BY HASH (a) PARTITIONS 1;
+
+# insert some rows (i.e. so that rows/blocks > 1)
+INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020);
+
+# Before the fix the 'Extra' column showed 'Using index for group-by'
+EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a;
+
+DROP TABLE t1;
+
#
# BUG 33429: Succeeds in adding partition when maxvalue on last partition
#
diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test
index 0bf86b47dd7..7a1ca27d589 100644
--- a/mysql-test/t/plugin.test
+++ b/mysql-test/t/plugin.test
@@ -84,4 +84,55 @@ set session sql_mode=@old_sql_mode;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session old=bla;
+###############################################################
+# engine-specific clauses in the CREATE TABLE:
+
+--echo #legal values
+CREATE TABLE t1 ( a int complex='c,f,f,f' ) ENGINE=example ULL=10000 STR='dskj' one_or_two='one' YESNO=0;
+show create table t1;
+drop table t1;
+
+SET @OLD_SQL_MODE=@@SQL_MODE;
+SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
+
+--echo #illegal value fixed
+CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
+show create table t1;
+
+--echo #alter table
+alter table t1 ULL=10000000;
+show create table t1;
+alter table t1 change a a int complex='c,c,c';
+show create table t1;
+drop table t1;
+
+--echo #illegal value error
+SET SQL_MODE='';
+--error ER_BAD_OPTION_VALUE
+CREATE TABLE t1 (a int) ENGINE=example ULL=10000000000000000000 one_or_two='ttt' YESNO=SSS;
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1 (a int) ENGINE=example ULL=10.00;
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1 (a int) ENGINE=example ULL=1e2;
+
+CREATE TABLE t1 (a int) ENGINE=example ULL=0x1234;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ULL=DEFAULT;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+SET @@SQL_MODE=@OLD_SQL_MODE;
+
+#
+# The only preparable statement above was CREATE TABLE.
+# We need to prepare another statement here to force the
+# previous one to be deallocated (mysqltest reuses the same handle)
+# and to unlock all thread-local plugin locks. Otherwise the plugin won't
+# uninstall.
+#
+select 1;
UNINSTALL PLUGIN example;
diff --git a/mysql-test/t/plugin_not_embedded-master.opt b/mysql-test/t/plugin_not_embedded-master.opt
new file mode 100644
index 00000000000..367d5233e0e
--- /dev/null
+++ b/mysql-test/t/plugin_not_embedded-master.opt
@@ -0,0 +1 @@
+$EXAMPLE_PLUGIN_OPT
diff --git a/mysql-test/t/plugin_not_embedded.test b/mysql-test/t/plugin_not_embedded.test
new file mode 100644
index 00000000000..15aff548c29
--- /dev/null
+++ b/mysql-test/t/plugin_not_embedded.test
@@ -0,0 +1,20 @@
+--source include/not_embedded.inc
+--source include/have_example_plugin.inc
+
+--echo #
+--echo # Bug#51770: UNINSTALL PLUGIN requires no privileges
+--echo #
+
+GRANT INSERT ON mysql.plugin TO bug51770@localhost;
+connect(con1,localhost,bug51770,,);
+--replace_regex /\.dll/.so/
+eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+--error ER_TABLEACCESS_DENIED_ERROR
+UNINSTALL PLUGIN example;
+connection default;
+GRANT DELETE ON mysql.plugin TO bug51770@localhost;
+connection con1;
+UNINSTALL PLUGIN example;
+disconnect con1;
+connection default;
+DROP USER bug51770@localhost;
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 21551b32ee8..a6b24de76b9 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -3070,4 +3070,18 @@ select @plaintext;
deallocate prepare encode;
deallocate prepare decode;
+--echo #
+--echo # Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
+--echo #
+CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
+INSERT INTO t1 VALUES (0, 0),(0, 0);
+PREPARE stmt FROM "SELECT 1 FROM t1 WHERE
+ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234))";
+--disable_warnings
+EXECUTE stmt;
+EXECUTE stmt;
+--enable_warnings
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
--echo End of 5.1 tests.
diff --git a/mysql-test/t/query_cache_with_views.test b/mysql-test/t/query_cache_with_views.test
index d4ebe45b7ac..97e37c53aa3 100644
--- a/mysql-test/t/query_cache_with_views.test
+++ b/mysql-test/t/query_cache_with_views.test
@@ -126,5 +126,22 @@ show status like "Qcache_inserts";
show status like "Qcache_hits";
drop table t1;
+--echo #
+--echo # Bug46615 Assertion in Query_cache::invalidate in INSERT in a VIEW of a MERGE table
+--echo #
+CREATE TABLE t1 (c1 INT, c2 INT);
+CREATE TABLE t2 LIKE t1;
+SET AUTOCOMMIT=OFF;
+CREATE VIEW t1_view AS SELECT c1 FROM t1 NATURAL JOIN t2 ;
+# Before the bug patch the below INSERT stmt used to
+# crash when other fields than the ones listed in the
+# view definition were used.
+--error ER_BAD_FIELD_ERROR
+INSERT INTO t1_view (c1, c2) SELECT c1, c2 FROM t1;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP VIEW t1_view;
+SET AUTOCOMMIT=DEFAULT;
+
# Reset default environment.
set GLOBAL query_cache_size=default;
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
index fcc4259168b..cec44078279 100644
--- a/mysql-test/t/row.test
+++ b/mysql-test/t/row.test
@@ -255,3 +255,14 @@ select * from t1,t2 where (a,b) = (c,d);
select host,user from mysql.user where (host,user) = ('localhost','test');
drop table t1,t2;
+
+--echo #
+--echo # Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
+--echo #
+CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
+INSERT INTO t1 VALUES (0, 0),(0, 0);
+--disable_warnings
+SELECT 1 FROM t1 WHERE ROW(a, b) >=
+ROW('1', (SELECT 1 FROM t1 WHERE a > 1234));
+--enable_warnings
+DROP TABLE t1;
diff --git a/mysql-test/t/select_pkeycache-master.opt b/mysql-test/t/select_pkeycache-master.opt
new file mode 100644
index 00000000000..a6c0f247334
--- /dev/null
+++ b/mysql-test/t/select_pkeycache-master.opt
@@ -0,0 +1 @@
+--key_cache_segments=7
diff --git a/mysql-test/t/select_pkeycache.test b/mysql-test/t/select_pkeycache.test
new file mode 100644
index 00000000000..e0ee96e937a
--- /dev/null
+++ b/mysql-test/t/select_pkeycache.test
@@ -0,0 +1,8 @@
+
+#
+# Run select.test with the segmented default key cache (with 7 segments)
+# (see setting the number of segments in select_pkecache-master.opt)
+# The result is expected the same as for select.test
+#
+
+--source t/select.test
diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test
index df010d15fa0..0edbdbcd22c 100644
--- a/mysql-test/t/skip_name_resolve.test
+++ b/mysql-test/t/skip_name_resolve.test
@@ -29,3 +29,24 @@ disconnect con1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
+--echo #
+--echo # Bug #37168: Missing variable - skip_name_resolve
+--echo #
+
+SHOW VARIABLES LIKE 'skip_name_resolve';
+SHOW GLOBAL VARIABLES LIKE 'skip_name_resolve';
+SHOW SESSION VARIABLES LIKE 'skip_name_resolve';
+
+SELECT @@skip_name_resolve;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@LOCAL.skip_name_resolve;
+SELECT @@GLOBAL.skip_name_resolve;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@skip_name_resolve=0;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@LOCAL.skip_name_resolve=0;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET @@GLOBAL.skip_name_resolve=0;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test
index 7b94e65a5e9..8aa0791e265 100644
--- a/mysql-test/t/sp-bugs.test
+++ b/mysql-test/t/sp-bugs.test
@@ -57,5 +57,48 @@ SELECT f2 ();
DROP SCHEMA testdb;
+USE test;
+
+--echo #
+--echo # Bug#50423: Crash on second call of a procedure dropping a trigger
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TRIGGER IF EXISTS tr1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (f1 INTEGER);
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+CREATE PROCEDURE p1 () DROP TRIGGER tr1;
+
+CALL p1 ();
+--error ER_TRG_DOES_NOT_EXIST
+CALL p1 ();
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug#50423: Crash on second call of a procedure dropping a trigger
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TRIGGER IF EXISTS tr1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (f1 INTEGER);
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+CREATE PROCEDURE p1 () DROP TRIGGER tr1;
+
+CALL p1 ();
+--error ER_TRG_DOES_NOT_EXIST
+CALL p1 ();
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 5cf050146dd..db8077bbbef 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -8210,7 +8210,6 @@ call p();
select @@sql_mode;
set @@sql_mode= @old_mode;
# Rename SQL modes that differ in name between the server and the table definition.
-select replace(@full_mode, '?', 'NOT_USED') into @full_mode;
select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode;
select name from mysql.proc where name = 'p' and sql_mode = @full_mode;
drop procedure p;
diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test
index f8803e28e0a..e4b6a5deefe 100644
--- a/mysql-test/t/sp_notembedded.test
+++ b/mysql-test/t/sp_notembedded.test
@@ -367,6 +367,43 @@ let $wait_condition=
--source include/wait_condition.inc
DROP PROCEDURE p;
+#
+# Bug#47736 killing a select from a view when the view is processing a function, asserts
+#
+CREATE TABLE t1(a int);
+INSERT INTO t1 VALUES (1);
+CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN sleep(60);
+CREATE VIEW v1 AS SELECT f1('a') FROM t1;
+
+--connect (con1, localhost, root,,)
+--let $ID_1= `SELECT connection_id()`
+--send SELECT * FROM v1;
+
+--connect (con2, localhost, root,,)
+--let $ID_2= `SELECT connection_id()`
+--send SELECT * FROM v1
+
+--connection default
+--disable_query_log
+--eval KILL QUERY $ID_2
+--eval KILL QUERY $ID_1
+--enable_query_log
+
+--connection con1
+--error ER_QUERY_INTERRUPTED
+--reap
+--connection con2
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--connection default
+DROP VIEW v1;
+DROP TABLE t1;
+DROP FUNCTION f1;
+--disconnect con1
+--disconnect con2
+
+
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
diff --git a/mysql-test/t/status_user.test b/mysql-test/t/status_user.test
index 1c011828237..d42f81b20e5 100644
--- a/mysql-test/t/status_user.test
+++ b/mysql-test/t/status_user.test
@@ -22,7 +22,7 @@ set @@global.general_log=0;
set @@global.userstat=1;
flush status;
-create table t1 (a int, primary key (a), b int default 0) engine=myisam;
+create table t1 (a int, primary key (a), b int default 0) engine=innodb;
insert into t1 (a) values (1),(2),(3),(4);
update t1 set b=1;
update t1 set b=5 where a=2;
@@ -66,16 +66,8 @@ select * from information_schema.index_statistics;
select * from information_schema.table_statistics;
show table_statistics;
show index_statistics;
-select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT,
- ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS,
- UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS,
- ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS,
- ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;
-select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT,
- ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS,
- UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS,
- ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS,
- ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;
+--query_vertical select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;
+--query_vertical select TOTAL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;
flush table_statistics;
flush index_statistics;
select * from information_schema.index_statistics;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 65e2d332b24..20388641d83 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -4080,4 +4080,104 @@ SELECT 1 FROM t1 WHERE a <> SOME
);
DROP TABLE t1;
+--echo #
+--echo # Bug #45989 take 2 : memory leak after explain encounters an
+--echo # error in the query
+--echo #
+
+CREATE TABLE t1(a LONGTEXT);
+INSERT INTO t1 VALUES (repeat('a',@@global.max_allowed_packet));
+INSERT INTO t1 VALUES (repeat('b',@@global.max_allowed_packet));
+
+--error ER_BAD_FIELD_ERROR
+EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1,
+(SELECT DISTINCTROW a AS away FROM t1 GROUP BY a WITH ROLLUP) AS d1
+WHERE t1.a = d1.a;
+
+DROP TABLE t1;
+
+
--echo End of 5.1 tests.
+
+#
+# Bug #47904 Incorrect results w/ table subquery, derived SQs, and LEFT JOIN on index
+#
+
+--echo Set up test tables.
+CREATE TABLE t1 (
+ t1_id INT UNSIGNED,
+
+ PRIMARY KEY(t1_id)
+) Engine=MyISAM;
+
+INSERT INTO t1 (t1_id) VALUES (1), (2), (3), (4), (5);
+
+CREATE TABLE t2 SELECT * FROM t1;
+
+CREATE TABLE t3 (
+ t3_id INT UNSIGNED AUTO_INCREMENT,
+ t1_id INT UNSIGNED,
+ amount DECIMAL(16,2),
+
+ PRIMARY KEY(t3_id),
+ KEY(t1_id)
+) Engine=MyISAM;
+
+INSERT INTO t3 (t1_id, t3_id, amount)
+ VALUES (1, 1, 100.00), (2, 2, 200.00), (4, 4, 400.00);
+
+--echo This is the 'inner query' running by itself.
+--echo Produces correct results.
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id
+;
+
+--echo SELECT * FROM (the same inner query)
+--echo Produces correct results.
+SELECT * FROM (
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id
+) AS t;
+
+--echo Now make t2.t1_id part of a key.
+ALTER TABLE t2 ADD PRIMARY KEY(t1_id);
+
+--echo Same inner query by itself.
+--echo Still correct results.
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id;
+
+--echo SELECT * FROM (the same inner query), now with indexes on the LEFT JOIN
+SELECT * FROM (
+SELECT
+ t1.t1_id,
+ IFNULL((SELECT SUM(amount) FROM t3 WHERE t3.t1_id=t1.t1_id), 0) AS total_amount
+FROM
+ t1
+ LEFT JOIN t2 ON t2.t1_id=t1.t1_id
+GROUP BY
+ t1.t1_id
+) AS t;
+
+
+DROP TABLE t3;
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index c805dd40fe8..073fcd28246 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -249,4 +249,26 @@ eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTO
DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
+--echo #
+--echo # BUG#40980 - Drop table can remove another MyISAM table's
+--echo # data and index files
+--echo #
+--mkdir $MYSQL_TMP_DIR/mysql
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE TABLE user(a INT) DATA DIRECTORY='$MYSQL_TMP_DIR/mysql'
+ INDEX DIRECTORY='$MYSQL_TMP_DIR/mysql';
+FLUSH TABLE user;
+--echo # Symlinking mysql database to tmpdir
+--remove_file $MYSQL_TMP_DIR/mysql/user.MYD
+--remove_file $MYSQL_TMP_DIR/mysql/user.MYI
+--rmdir $MYSQL_TMP_DIR/mysql
+--exec ln -s $MYSQLD_DATADIR/mysql $MYSQL_TMP_DIR/mysql
+FLUSH TABLE mysql.user;
+DROP TABLE user;
+FLUSH TABLE mysql.user;
+--disable_result_log
+SELECT * FROM mysql.user;
+--enable_result_log
+--remove_file $MYSQL_TMP_DIR/mysql
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/table_options.test b/mysql-test/t/table_options.test
new file mode 100644
index 00000000000..533e6829c00
--- /dev/null
+++ b/mysql-test/t/table_options.test
@@ -0,0 +1,68 @@
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+SET @OLD_SQL_MODE=@@SQL_MODE;
+SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS';
+
+create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1';
+show create table t1;
+drop table t1;
+
+--echo #reassiginig options in the same line
+create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1 TKEY1=DEFAULT tkey1=1v2 tkey2=2v1;
+show create table t1;
+
+-- echo #add option
+alter table t1 tkey4=4v1;
+show create table t1;
+
+--echo #remove options
+alter table t1 tkey3=DEFAULT tkey4=DEFAULT;
+show create table t1;
+
+drop table t1;
+
+create table t1 (a int fkey1=v1, key akey (a) kkey1=v1) tkey1=1v1 tkey1=1v2 TKEY1=DEFAULT tkey2=2v1 tkey3=3v1;
+show create table t1;
+
+--echo #change field with option with the same value
+alter table t1 change a a int `FKEY1`='v1';
+show create table t1;
+--echo #change field with option with a different value
+alter table t1 change a a int fkey1=v2;
+show create table t1;
+--echo #new column no options
+alter table t1 add column b int;
+show create table t1;
+--echo #new key with options
+alter table t1 add key bkey (b) kkey2=v1;
+show create table t1;
+--echo #new column with options
+alter table t1 add column c int fkey1=v1 fkey2=v2;
+show create table t1;
+--echo #new key no options
+alter table t1 add key ckey (c);
+show create table t1;
+--echo #drop column
+alter table t1 drop b;
+show create table t1;
+--echo #add column with options after delete
+alter table t1 add column b int fkey2=v1;
+show create table t1;
+--echo #add key
+alter table t1 add key bkey (b) kkey2=v2;
+show create table t1;
+drop table t1;
+
+#numeric (unquoted) value
+create table t1 (a int) tkey1=100;
+show create table t1;
+drop table t1;
+
+--echo #error on unknown option
+SET SQL_MODE='';
+--error ER_UNKNOWN_OPTION
+create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1;
+
+SET @@SQL_MODE=@OLD_SQL_MODE;
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 57b5431fa1b..a968e146d20 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -2334,4 +2334,78 @@ SELECT * FROM t2;
DROP TABLE t1, t2;
+--echo #
+--echo # Bug#51650 crash with user variables and triggers
+--echo #
+
+--disable_warnings
+DROP TRIGGER IF EXISTS trg1;
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (b VARCHAR(50) NOT NULL);
+CREATE TABLE t2 (a VARCHAR(10) NOT NULL DEFAULT '');
+
+delimiter //;
+CREATE TRIGGER trg1 AFTER INSERT ON t2
+FOR EACH ROW BEGIN
+ SELECT 1 FROM t1 c WHERE
+ (@bug51650 IS NULL OR @bug51650 != c.b) AND c.b = NEW.a LIMIT 1 INTO @foo;
+END//
+delimiter ;//
+
+SET @bug51650 = 1;
+INSERT IGNORE INTO t2 VALUES();
+INSERT IGNORE INTO t1 SET b = '777';
+INSERT IGNORE INTO t2 SET a = '111';
+SET @bug51650 = 1;
+INSERT IGNORE INTO t2 SET a = '777';
+
+DROP TRIGGER trg1;
+DROP TABLE t1, t2;
+
+#
+# Bug #48525: trigger changes "Column 'id' cannot be null" behaviour
+#
+CREATE TABLE t1 (id INT NOT NULL);
+CREATE TABLE t2 (id INT NOT NULL);
+INSERT t1 VALUES (1),(2),(3);
+UPDATE t1 SET id=NULL;
+CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
+ INSERT INTO t2 VALUES (3);
+UPDATE t1 SET id=NULL;
+DROP TRIGGER t1_bu;
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#50755: Crash if stored routine def contains version comments
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP TRIGGER IF EXISTS trg1;
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE DATABASE db1;
+USE db1;
+
+CREATE TABLE t1 (b INT);
+CREATE TABLE t2 (a INT);
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t2 FOR EACH ROW INSERT/*!INTO*/t1 VALUES (1);
+--echo # Used to crash
+SHOW TRIGGERS IN db1;
+--error ER_PARSE_ERROR
+INSERT INTO t2 VALUES (1);
+SELECT * FROM t1;
+
+--echo # Work around Bug#45235
+let $MYSQLD_DATADIR = `select @@datadir`;
+--remove_file $MYSQLD_DATADIR/db1/t2.TRG
+--remove_file $MYSQLD_DATADIR/db1/trg1.TRN
+
+DROP DATABASE db1;
+USE test;
+
--echo End of 5.1 tests.
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index 530389b3ab9..8bedf9357ef 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -425,4 +425,17 @@ select hex(a) from t1;
show create table t1;
drop table t1;
+--echo #
+--echo # Bug#50591 bit(31) causes Duplicate entry '1-NULL' for key 'group_key'
+--echo #
+CREATE TABLE t1(a INT, b BIT(7) NOT NULL);
+INSERT INTO t1 VALUES (NULL, 0),(NULL, 0);
+SELECT SUM(a) FROM t1 GROUP BY b, a;
+DROP TABLE t1;
+
+CREATE TABLE t1(a INT, b BIT(7) NOT NULL, c BIT(8) NOT NULL);
+INSERT INTO t1 VALUES (NULL, 0, 0),(NULL, 0, 0);
+SELECT SUM(a) FROM t1 GROUP BY c, b, a;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index aec60bc2dee..899f912a5a5 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -246,4 +246,24 @@ insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01');
select * from t1 where a between '0000-00-01' and '0000-00-02';
drop table t1;
+--echo #
+--echo # Bug#50918: Date columns treated differently in Views than in Base
+--echo # Tables
+--echo #
+CREATE TABLE t1 ( the_date DATE, the_time TIME );
+INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' );
+
+SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) =
+ addtime( t12.the_date, t12.the_time );
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) =
+ addtime( v1.the_date, v1.the_time );
+
+SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) =
+ addtime( cast(v1.the_date AS DATETIME), v1.the_time );
+
+DROP TABLE t1;
+DROP VIEW v1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test
index 16fd39a59d8..d8da4ccc82c 100644
--- a/mysql-test/t/type_year.test
+++ b/mysql-test/t/type_year.test
@@ -134,5 +134,21 @@ SELECT * FROM t4 WHERE yyyy > 123;
DROP TABLE t2, t4;
--echo #
+--echo # Bug #49910: Behavioural change in SELECT/WHERE on YEAR(4) data type
+--echo #
+
+CREATE TABLE t1 (y YEAR NOT NULL, s VARCHAR(4));
+INSERT INTO t1 (s) VALUES ('bad');
+INSERT INTO t1 (y, s) VALUES (0, 0), (2000, 2000), (2001, 2001);
+
+SELECT * FROM t1 ta, t1 tb WHERE ta.y = tb.y;
+SELECT * FROM t1 WHERE t1.y = 0;
+SELECT * FROM t1 WHERE t1.y = 2000;
+
+SELECT ta.y AS ta_y, ta.s, tb.y AS tb_y, tb.s FROM t1 ta, t1 tb HAVING ta_y = tb_y;
+
+DROP TABLE t1;
+
+--echo #
--echo End of 5.1 tests
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index 642f77fd741..283bb1a833c 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -51,11 +51,14 @@ select lookup("localhost");
--error ER_CANT_INITIALIZE_UDF
select reverse_lookup();
-# These two functions should return "localhost", but it's
+# These two function calls should return "localhost", but it's
# depending on configuration, so just call them and don't log the result
--disable_result_log
select reverse_lookup("127.0.0.1");
select reverse_lookup(127,0,0,1);
+
+# This function call may return different results depending on platform,
+# so ignore results (see Bug#52060).
select reverse_lookup("localhost");
--enable_result_log
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index 02e8763a630..f6708828a6b 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -467,3 +467,19 @@ UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9;
ALTER TABLE t2 COMMENT = 'DEF';
DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#50545: Single table UPDATE IGNORE crashes on join view in
+--echo # sql_safe_updates mode.
+--echo #
+CREATE TABLE t1 ( a INT, KEY( a ) );
+INSERT INTO t1 VALUES (0), (1);
+CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12;
+SET SESSION sql_safe_updates = 1;
+
+--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
+UPDATE IGNORE v1 SET a = 1;
+
+SET SESSION sql_safe_updates = DEFAULT;
+DROP TABLE t1;
+DROP VIEW v1;
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 42bf7e5174d..94dba1e8ff6 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1224,4 +1224,12 @@ SET @old_max_binlog_cache_size = @@GLOBAL.max_binlog_cache_size;
SET GLOBAL max_binlog_cache_size = 5 * 1024 * 1024 * 1024;
SELECT @@GLOBAL.max_binlog_cache_size;
SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size;
+
+--echo #
+--echo # Bug #37168 : Missing variable - skip_name_resolve
+--echo #
+
+SELECT @@skip_name_resolve;
+SHOW VARIABLES LIKE 'skip_name_resolve';
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/variables+c.test b/mysql-test/t/variables_community.test
index 0092d34133d..0092d34133d 100644
--- a/mysql-test/t/variables+c.test
+++ b/mysql-test/t/variables_community.test
diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test
index 7dcaf246803..8f2bde7ae42 100644
--- a/mysql-test/t/variables_debug.test
+++ b/mysql-test/t/variables_debug.test
@@ -10,3 +10,16 @@ set debug= '+P';
select @@debug;
set debug= '-P';
select @@debug;
+
+--echo #
+--echo # Bug #52629: memory leak from sys_var_thd_dbug in
+--echo # binlog.binlog_write_error
+--echo #
+
+SET GLOBAL debug='d,injecting_fault_writing';
+SELECT @@global.debug;
+SET GLOBAL debug='';
+SELECT @@global.debug;
+
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 92edfdb4ad5..4fb397fe142 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3869,6 +3869,61 @@ ALTER TABLE v1;
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # Bug#48449: hang on show create view after upgrading when
+--echo # view contains function of view
+--echo #
+
+--disable_warnings
+DROP VIEW IF EXISTS v1,v2;
+DROP TABLE IF EXISTS t1,t2;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+
+delimiter //;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ SELECT a FROM v2 INTO @a;
+ RETURN @a;
+END//
+delimiter ;//
+
+--echo # Trigger pre-locking when opening v2.
+CREATE VIEW v1 AS SELECT f1() FROM t1;
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm;
+
+SHOW CREATE VIEW v1;
+
+DROP VIEW v1,v2;
+DROP TABLE t1,t2;
+DROP FUNCTION f1;
+
+
+#
+# Bug#48294 assertion when creating a view based on some row() construct in select query
+#
+CREATE TABLE t1(f1 INT);
+INSERT INTO t1 VALUES ();
+
+CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE
+ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' )));
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
+--echo #
+CREATE TABLE t1 (a CHAR(1) CHARSET latin1, b CHAR(1) CHARSET utf8);
+CREATE VIEW v1 AS SELECT 1 from t1
+WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
+DROP VIEW v1;
+DROP TABLE t1;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
diff --git a/mysql-test/t/view_alias.test b/mysql-test/t/view_alias.test
new file mode 100644
index 00000000000..b155ba6c2a9
--- /dev/null
+++ b/mysql-test/t/view_alias.test
@@ -0,0 +1,92 @@
+--echo #
+--echo # Bug#40277 SHOW CREATE VIEW returns invalid SQL
+--echo # Bug#41999 SHOW CREATE VIEW returns invalid SQL if subquery is used in SELECT list
+--echo #
+
+--echo # 65 characters exceed the maximum length of a column identifier. The system cannot derive the name from statement.
+--echo # Constant with length = 65 . Expect to get the identifier 'Name_exp_1'.
+let $after_select= '<--- 65 char including the arrows --->';
+--source include/view_alias.inc
+--echo # Subquery with length = 65 . Expect to get the identifier 'Name_exp_1'.
+--echo # Attention: Identifier for the column within the subquery will be not generated.
+let $after_select= (SELECT '<--- 54 char including the arrows (+ 11 outside) -->');
+--source include/view_alias.inc
+--echo # -----------------------------------------------------------------------------------------------------------------
+#
+--echo # 64 characters are the maximum length of a column identifier. The system can derive the name from the statement.
+let $after_select= '<--- 64 char including the arrows --->';
+--source include/view_alias.inc
+let $after_select= (SELECT '<--- 53 char including the arrows (+ 11 outside) --->');
+--source include/view_alias.inc
+--echo # -----------------------------------------------------------------------------------------------------------------
+#
+--echo # Identifiers must not have trailing spaces. The system cannot derive the name from a constant with trailing space.
+--echo # Generated identifiers have at their end the position within the select column list.
+--echo # 'c2 ' -> 'Name_exp_1' , ' c4 ' -> 'Name_exp_2'
+let $after_select= 'c1', 'c2 ', ' c3', ' c4 ';
+--source include/view_alias.inc
+
+--echo #
+--echo # Bug#40277 SHOW CREATE VIEW returns invalid SQL
+--echo #
+
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--echo # Column name exceeds the maximum length.
+CREATE VIEW v1 AS SELECT '0000000000 1111111111 2222222222 3333333333 4444444444 5555555555';
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+--echo # Column names with leading trailing spaces.
+CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 ';
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+--echo # Column name conflicts with a auto-generated one.
+CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 ', 'Name_exp_2';
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+--echo # Invalid conlumn name in subquery.
+CREATE VIEW v1 AS SELECT (SELECT ' c1 ');
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+CREATE TABLE t1(a INT);
+CREATE TABLE t2 LIKE t1;
+
+--echo # Test alias in subquery
+CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT 1 FROM t2 AS b WHERE b.a = 0);
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+--echo # Test column alias in subquery
+CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT a AS alias FROM t1 GROUP BY alias);
+SHOW CREATE VIEW v1;
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+--echo # Alias as the expression column name.
+CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT ' a ' AS alias FROM t1 GROUP BY alias);
+SHOW CREATE VIEW v1;
+let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+DROP VIEW v1;
+eval CREATE VIEW v1 AS $query;
+DROP VIEW v1;
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 175468db702..ba603bde7f8 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -1532,3 +1532,17 @@ SELECT a FROM v2;
--disconnect mysqluser1
DROP USER mysqluser1;
DROP DATABASE mysqltest1;
+USE test;
+
+--echo #
+--echo # Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer
+--echo #
+
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1;
+--error ER_NO_SUCH_USER
+LOCK TABLES v1 READ;
+DROP VIEW v1;
diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test
index f84d822170f..9db8842f068 100644
--- a/mysql-test/t/xa.test
+++ b/mysql-test/t/xa.test
@@ -122,6 +122,22 @@ xa start 'a','c';
--connection default
drop table t1;
+--echo #
+--echo # BUG#51342 - more xid crashing
+--echo #
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+XA START 'x';
+SET SESSION autocommit=0;
+INSERT INTO t1 VALUES(1);
+--error ER_XAER_RMFAIL
+SET SESSION autocommit=1;
+SELECT @@autocommit;
+INSERT INTO t1 VALUES(1);
+XA END 'x';
+XA COMMIT 'x' ONE PHASE;
+DROP TABLE t1;
+SET SESSION autocommit=1;
+
--echo End of 5.0 tests
#