summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-02-03 15:22:39 +0100
committerSergei Golubchik <sergii@pisem.net>2014-02-03 15:22:39 +0100
commit72c20282db820b0b0818aea160a485bdca897eec (patch)
tree3089e022d958990fc0a405a38ba43ae00c87103c /mysql-test
parent5e1d5d9bc0bf9ea776bffe6c4914a84be920c0b2 (diff)
parent2acc01b3cfa27074f93016b893cda20fa0a3497f (diff)
downloadmariadb-git-72c20282db820b0b0818aea160a485bdca897eec.tar.gz
10.0-base merge
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/CMakeLists.txt2
-rw-r--r--mysql-test/collections/default.experimental1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc10
-rw-r--r--mysql-test/extra/rpl_tests/rpl_innodb.test2
-rw-r--r--mysql-test/extra/rpl_tests/rpl_reset_slave.test3
-rw-r--r--mysql-test/include/mtr_check.sql5
-rw-r--r--mysql-test/include/search_pattern_in_file.inc66
-rw-r--r--mysql-test/r/alter_table_trans.result12
-rw-r--r--mysql-test/r/assign_key_cache-5405.result14
-rw-r--r--mysql-test/r/derived.result22
-rw-r--r--mysql-test/r/derived_view.result109
-rw-r--r--mysql-test/r/func_time.result34
-rw-r--r--mysql-test/r/group_by.result48
-rw-r--r--mysql-test/r/group_by_innodb.result33
-rw-r--r--mysql-test/r/group_by_null.result6
-rw-r--r--mysql-test/r/innodb_ext_key.result48
-rw-r--r--mysql-test/r/innodb_icp.result25
-rw-r--r--mysql-test/r/insert.result20
-rw-r--r--mysql-test/r/myisam_optimize.result1
-rw-r--r--mysql-test/r/mysql_tzinfo_to_sql_symlink.result40
-rw-r--r--mysql-test/r/mysql_upgrade.result3
-rw-r--r--mysql-test/r/mysqld--help.result7
-rw-r--r--mysql-test/r/order_by.result30
-rw-r--r--mysql-test/r/perror.result4
-rw-r--r--mysql-test/r/plugin_auth.result1
-rw-r--r--mysql-test/r/plugin_vars.result22
-rw-r--r--mysql-test/r/processlist.result1
-rw-r--r--mysql-test/r/quick_select_4161.result1
-rw-r--r--mysql-test/r/repair.result34
-rw-r--r--mysql-test/r/repair_symlink-5543.result14
-rw-r--r--mysql-test/r/show_explain.result2
-rw-r--r--mysql-test/r/sp-bugs.result46
-rw-r--r--mysql-test/r/subselect_mat.result36
-rw-r--r--mysql-test/r/subselect_sj.result4
-rw-r--r--mysql-test/r/subselect_sj_jcl6.result4
-rw-r--r--mysql-test/r/subselect_sj_mat.result36
-rw-r--r--mysql-test/r/timezone2.result6
-rw-r--r--mysql-test/r/type_date.result2
-rw-r--r--mysql-test/r/type_time.result2
-rw-r--r--mysql-test/r/view.result50
-rw-r--r--mysql-test/std_data/host_old.MYD0
-rw-r--r--mysql-test/std_data/host_old.MYIbin0 -> 1024 bytes
-rw-r--r--mysql-test/std_data/host_old.frmbin0 -> 8958 bytes
-rw-r--r--mysql-test/suite/federated/federated_archive.result4
-rw-r--r--mysql-test/suite/handler/innodb.result4
-rw-r--r--mysql-test/suite/handler/innodb.test5
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug13510739.result2
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc-44030.test5
-rw-r--r--mysql-test/suite/innodb/t/innodb-index.test5
-rw-r--r--mysql-test/suite/innodb/t/innodb.test6
-rw-r--r--mysql-test/suite/innodb/t/innodb_bug13510739.test4
-rw-r--r--mysql-test/suite/maria/alter.result33
-rw-r--r--mysql-test/suite/maria/alter.test27
-rw-r--r--mysql-test/suite/parts/r/insert_ignore-5421.result9
-rw-r--r--mysql-test/suite/parts/t/insert_ignore-5421.test12
-rw-r--r--mysql-test/suite/plugins/r/sql_error_log.result45
-rw-r--r--mysql-test/suite/plugins/t/sql_error_log.test55
-rw-r--r--mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result3
-rw-r--r--mysql-test/suite/rpl/r/rpl_lost_events_on_rotate.result14
-rw-r--r--mysql-test/suite/rpl/r/rpl_mdev359.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel.result411
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel_no_log_slave_updates.result122
-rw-r--r--mysql-test/suite/rpl/r/rpl_rotate_logs.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_reset_slave.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_000001.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_innodb.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_reset_slave.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_stop_slave.result2
-rw-r--r--mysql-test/suite/rpl/t/rpl_create_tmp_table_if_not_exists.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_lost_events_on_rotate.test51
-rw-r--r--mysql-test/suite/rpl/t/rpl_mdev359.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel.test677
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates.test199
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_000001.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_stop_slave.test2
-rw-r--r--mysql-test/suite/sys_vars/r/old_mode_basic.result174
-rw-r--r--mysql-test/suite/sys_vars/t/identity_func.test6
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_func.test6
-rw-r--r--mysql-test/suite/sys_vars/t/last_insert_id_func.test6
-rw-r--r--mysql-test/suite/sys_vars/t/old_mode_basic.test244
-rw-r--r--mysql-test/suite/sys_vars/t/storage_engine_basic.test6
-rw-r--r--mysql-test/suite/sys_vars/t/tx_isolation_func.test6
-rw-r--r--mysql-test/t/alter_table_trans.test20
-rw-r--r--mysql-test/t/assign_key_cache-5405.test27
-rw-r--r--mysql-test/t/date_formats.test2
-rw-r--r--mysql-test/t/derived.test29
-rw-r--r--mysql-test/t/derived_view.test112
-rw-r--r--mysql-test/t/func_time.test18
-rw-r--r--mysql-test/t/group_by.test40
-rw-r--r--mysql-test/t/group_by_innodb.test31
-rw-r--r--mysql-test/t/group_by_null.test7
-rw-r--r--mysql-test/t/innodb_ext_key.test28
-rw-r--r--mysql-test/t/innodb_icp.test28
-rw-r--r--mysql-test/t/insert.test18
-rw-r--r--mysql-test/t/myisam_optimize.test1
-rw-r--r--mysql-test/t/mysql_tzinfo_to_sql_symlink.test24
-rw-r--r--mysql-test/t/mysql_upgrade.test5
-rw-r--r--mysql-test/t/order_by.test32
-rw-r--r--mysql-test/t/perror.test2
-rw-r--r--mysql-test/t/plugin_vars.test56
-rw-r--r--mysql-test/t/processlist.test2
-rw-r--r--mysql-test/t/quick_select_4161.test1
-rw-r--r--mysql-test/t/repair.test20
-rw-r--r--mysql-test/t/repair_symlink-5543.test26
-rw-r--r--mysql-test/t/sp-bugs.test56
-rw-r--r--mysql-test/t/subselect_sj.test1
-rw-r--r--mysql-test/t/subselect_sj_mat.test40
-rw-r--r--mysql-test/t/timezone2.test6
-rw-r--r--mysql-test/t/view.test45
116 files changed, 3517 insertions, 146 deletions
diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt
index 16eb2a6f166..227e490331f 100644
--- a/mysql-test/CMakeLists.txt
+++ b/mysql-test/CMakeLists.txt
@@ -74,7 +74,7 @@ ENDIF()
IF(WITH_EMBEDDED_SERVER)
SET(TEST_EMBEDDED ${MTR_FORCE} --comment=embedded --timer --embedded-server
- --skip-rpl --skip-ndbcluster $(EXP))
+ --skip-rpl --skip-ndbcluster ${EXP})
ELSE()
SET(TEST_EMBEDDED echo "Can not test embedded, not compiled in")
ENDIF()
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index e4c839ce705..ff4bc960acb 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -15,6 +15,7 @@ main.wait_timeout @solaris # Bug#11758972 2010-04-26 alik wait_tim
rpl.rpl_innodb_bug28430 # Bug#11754425
rpl.rpl_row_sp011 @solaris # Bug#11753919 2011-07-25 sven Several test cases fail on Solaris with error Thread stack overrun
+rpl.rpl_spec_variables @solaris # Bug #17337114 2013-08-20 Luis Soares failing on pb2 with timeout for 'CHECK WARNINGS'
sys_vars.max_sp_recursion_depth_func @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun
sys_vars.wait_timeout_func # Bug#11750645 2010-04-26 alik wait_timeout_func fails
diff --git a/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc b/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc
index cea8ac56931..a7ee54658f8 100644
--- a/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc
+++ b/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc
@@ -187,10 +187,9 @@ if (`SELECT HEX(@commands) = HEX('configure')`)
}
#
-# Drops tables and synchronizes master and slave. Note that temporary
-# tables are not explitcily dropped as they will be dropped while
-# closing the connection.
+# Drops tables and synchronizes master and slave.
#
+
if (`SELECT HEX(@commands) = HEX('clean')`)
{
connection master;
@@ -207,10 +206,15 @@ if (`SELECT HEX(@commands) = HEX('clean')`)
DROP TABLE IF EXISTS nt_error_2;
+ DROP TEMPORARY TABLE IF EXISTS tt_tmp_xx_1;
+ DROP TEMPORARY TABLE IF EXISTS nt_tmp_xx_1;
+
--let $n= $tot_table
while ($n)
{
--eval DROP TABLE IF EXISTS nt_$n
+ --eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
+ --eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
--dec $n
}
diff --git a/mysql-test/extra/rpl_tests/rpl_innodb.test b/mysql-test/extra/rpl_tests/rpl_innodb.test
index c0ec5299cfd..865c97cf95d 100644
--- a/mysql-test/extra/rpl_tests/rpl_innodb.test
+++ b/mysql-test/extra/rpl_tests/rpl_innodb.test
@@ -113,7 +113,7 @@ FLUSH LOGS;
--echo -------- switch to master --------
connection master;
FLUSH LOGS;
-
+DROP TEMPORARY TABLE IF EXISTS mysqltest1.tmp2;
DROP DATABASE mysqltest1;
--echo End of 5.1 tests
diff --git a/mysql-test/extra/rpl_tests/rpl_reset_slave.test b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
index 17d949a7790..e7a78f36efc 100644
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
@@ -41,6 +41,9 @@ reset slave;
source include/start_slave.inc;
sync_with_master;
show status like 'slave_open_temp_tables';
+connection master;
+drop temporary table if exists t1;
+sync_slave_with_master;
#
#Bug#34654 RESET SLAVE does not clear LAST_IO_Err*
diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql
index de5567e91bd..31e89b84ae9 100644
--- a/mysql-test/include/mtr_check.sql
+++ b/mysql-test/include/mtr_check.sql
@@ -82,5 +82,10 @@ BEGIN
-- verify that no plugin changed its disabled/enabled state
SELECT * FROM INFORMATION_SCHEMA.PLUGINS;
+ select * from information_schema.session_variables
+ where variable_name = 'debug_sync';
+
+ show status like 'slave_open_temp_tables';
+
END||
diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc
new file mode 100644
index 00000000000..c047b5bc499
--- /dev/null
+++ b/mysql-test/include/search_pattern_in_file.inc
@@ -0,0 +1,66 @@
+# Purpose:
+# Simple search with Perl for a pattern in some file.
+#
+# The advantages compared to thinkable auxiliary constructs using the
+# mysqltest language and SQL are:
+# 1. We do not need a running MySQL server.
+# 2. SQL causes "noise" during debugging and increases the size of logs.
+# Perl code does not disturb at all.
+#
+# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
+# before sourcing this routine.
+#
+# In case of
+# - SEARCH_FILE and/or SEARCH_PATTERN is not set
+# - SEARCH_FILE cannot be opened
+# - SEARCH_FILE does not contain SEARCH_PATTERN
+# the test will abort immediate.
+# MTR will report something like
+# ....
+# worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
+# main.1st [ pass ] 3
+# innodb.innodb_page_size [ fail ]
+# Test ended at 2011-11-11 18:15:58
+#
+# CURRENT_TEST: innodb.innodb_page_size
+# # ERROR: The file '<name>' does not contain the expected pattern <pattern>
+# mysqltest: In included file "./include/search_pattern_in_file.inc":
+# included from ./include/search_pattern_in_file.inc at line 36:
+# At line 25: command "perl" failed with error 255. my_errno=175
+#
+# The result from queries just before the failure was:
+# ...
+# - saving '<some path>' to '<some path>'
+# main.1st [ pass ] 2
+#
+# Typical use case (check invalid server startup options):
+# let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
+# --error 0,1
+# --remove_file $error_log
+# let SEARCH_FILE= $error_log;
+# # Stop the server
+# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+# --exec echo "wait" > $restart_file
+# --shutdown_server 10
+# --source include/wait_until_disconnected.inc
+#
+# --error 1
+# --exec $MYSQLD_CMD <whatever wrong setting> > $error_log 2>&1
+# # The server restart aborts
+# let SEARCH_PATTERN= \[ERROR\] Aborting;
+# --source include/search_pattern_in_file.inc
+#
+# Created: 2011-11-11 mleich
+#
+
+perl;
+ use strict;
+ my $search_file= $ENV{'SEARCH_FILE'} or die "SEARCH_FILE not set";
+ my $search_pattern= $ENV{'SEARCH_PATTERN'} or die "SEARCH_PATTERN not set";
+ open(FILE, "$search_file") or die("Unable to open '$search_file': $!\n");
+ read(FILE, my $file_content, 50000, 0);
+ close(FILE);
+ if ( not $file_content =~ m{$search_pattern} ) {
+ die("# ERROR: The file '$search_file' does not contain the expected pattern $search_pattern\n->$file_content<-\n");
+ }
+EOF
diff --git a/mysql-test/r/alter_table_trans.result b/mysql-test/r/alter_table_trans.result
index 6e034e47e76..a2547708ada 100644
--- a/mysql-test/r/alter_table_trans.result
+++ b/mysql-test/r/alter_table_trans.result
@@ -4,3 +4,15 @@ ALTER TABLE t1 RENAME TO t2, DISABLE KEYS;
Warnings:
Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
DROP TABLE t2;
+CREATE TABLE t1 (
+col4 text NOT NULL,
+col2 int(11) NOT NULL DEFAULT '0',
+col3 int(11) DEFAULT NULL,
+extra int(11) DEFAULT NULL,
+KEY idx (col4(10))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+insert t1 values (repeat('1', 8193),3,1,1);
+insert t1 values (repeat('3', 8193),3,1,1);
+ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3);
+ERROR 23000: Duplicate entry '1' for key 'uidx'
+DROP TABLE t1;
diff --git a/mysql-test/r/assign_key_cache-5405.result b/mysql-test/r/assign_key_cache-5405.result
new file mode 100644
index 00000000000..4a0fc58cd4f
--- /dev/null
+++ b/mysql-test/r/assign_key_cache-5405.result
@@ -0,0 +1,14 @@
+create table t1 (f int, key(f)) engine=myisam;
+set global kc1.key_buffer_size = 65536;
+set debug_sync='assign_key_cache_op_unlock wait_for op_locked';
+cache index t1 in kc1;
+set debug_sync='assign_key_cache_op_lock signal op_locked wait_for assigned';
+cache index t1 in kc1;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+set debug_sync='now signal assigned';
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+drop table t1;
+set global kc1.key_buffer_size = 0;
+set debug_sync='reset';
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 699d3279e3e..3a3b69f1fc7 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -479,6 +479,28 @@ SELECT * FROM
WHERE tmp.a;
a b
100 200
+#
+# MDEV-5356: Server crashes in Item_equal::contains on 2nd
+# execution of a PS
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,2),(3,4);
+CREATE TABLE t2 (c INT);
+INSERT INTO t2 VALUES (5),(6);
+CREATE TABLE t3 (d INT);
+INSERT INTO t3 VALUES (7),(8);
+CREATE PROCEDURE pr()
+UPDATE t3,
+(SELECT c FROM
+(SELECT 1 FROM t1 WHERE a=72 AND NOT b) sq,
+t2
+) sq2
+SET d=sq2.c;
+CALL pr();
+CALL pr();
+CALL pr();
+drop procedure pr;
+drop table t1,t2,t3;
# End of 5.3 tests
#
# Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index 2b041448d3b..cbf5900d57c 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -2256,6 +2256,115 @@ Warnings:
Note 1003 select 4 AS `a` from dual where (4 > 100) order by 1
DROP VIEW v1;
DROP TABLE t1;
+CREATE TABLE IF NOT EXISTS `galleries` (
+`id` int(11) NOT NULL AUTO_INCREMENT,
+`name` varchar(100) NOT NULL,
+`year` int(11) DEFAULT NULL,
+PRIMARY KEY (`id`),
+UNIQUE KEY `name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1266 Using storage engine MyISAM for table 'galleries'
+CREATE TABLE IF NOT EXISTS `pictures` (
+`id` int(11) NOT NULL AUTO_INCREMENT,
+`name` varchar(100) NOT NULL,
+`width` float DEFAULT NULL,
+`height` float DEFAULT NULL,
+`year` int(4) DEFAULT NULL,
+`technique` varchar(50) DEFAULT NULL,
+`comment` varchar(2000) DEFAULT NULL,
+`gallery_id` int(11) NOT NULL,
+`type` int(11) NOT NULL,
+PRIMARY KEY (`id`),
+KEY `gallery_id` (`gallery_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1266 Using storage engine MyISAM for table 'pictures'
+ALTER TABLE `pictures`
+ADD CONSTRAINT `pictures_ibfk_1` FOREIGN KEY (`gallery_id`) REFERENCES `galleries` (`id`);
+INSERT INTO `galleries` (`id`, `name`, `year`) VALUES
+(1, 'Quand le noir et blanc invite le taupe', 2013),
+(2, 'Une touche de couleur', 2012),
+(3, 'Éclats', 2011),
+(4, 'Gris béton', 2010),
+(5, 'Expression du spalter', 2010),
+(6, 'Zénitude', 2009),
+(7, 'La force du rouge', 2008),
+(8, 'Sphères', NULL),
+(9, 'Centre', 2009),
+(10, 'Nébuleuse', NULL);
+INSERT INTO `pictures` (`id`, `name`, `width`, `height`, `year`, `technique`, `comment`, `gallery_id`, `type`) VALUES
+(1, 'Éclaircie', 72.5, 100, NULL, NULL, NULL, 1, 1),
+(2, 'Architecture', 81, 100, NULL, NULL, NULL, 1, 1),
+(3, 'Nouveau souffle', 72.5, 100, NULL, NULL, NULL, 1, 1),
+(4, 'Échanges (2)', 89, 116, NULL, NULL, NULL, 1, 1),
+(5, 'Échanges', 89, 116, NULL, NULL, NULL, 1, 1),
+(6, 'Fenêtre de vie', 81, 116, NULL, NULL, NULL, 1, 1),
+(7, 'Architecture', 81, 100, NULL, NULL, NULL, 1, 1),
+(8, 'Nouveau souffle (2)', 72.5, 100, NULL, NULL, NULL, 1, 1),
+(9, 'Fluidité', 89, 116, NULL, NULL, NULL, 1, 1),
+(10, 'Nouveau Monde', 89, 125, NULL, NULL, NULL, 1, 1),
+(11, 'Mirage', 73, 100, NULL, NULL, NULL, 1, 1),
+(12, 'Équilibre', 72.5, 116, NULL, NULL, NULL, 2, 1),
+(13, 'Fusion', 72.5, 116, NULL, NULL, NULL, 2, 1),
+(14, 'Étincelles', NULL, NULL, NULL, NULL, NULL, 3, 1),
+(15, 'Régénérescence', NULL, NULL, NULL, NULL, NULL, 3, 1),
+(16, 'Chaleur', 80, 80, NULL, NULL, NULL, 4, 1),
+(17, 'Création', 90, 90, NULL, NULL, NULL, 4, 1),
+(18, 'Horizon', 92, 73, NULL, NULL, NULL, 4, 1),
+(19, 'Labyrinthe', 81, 100, NULL, NULL, NULL, 4, 1),
+(20, 'Miroir', 80, 116, NULL, NULL, NULL, 5, 1),
+(21, 'Libération', 81, 116, NULL, NULL, NULL, 5, 1),
+(22, 'Éclats', 81, 116, NULL, NULL, NULL, 5, 1),
+(23, 'Zénitude', 116, 89, NULL, NULL, NULL, 6, 1),
+(24, 'Écritures lointaines', 90, 90, NULL, NULL, NULL, 7, 1),
+(25, 'Émergence', 80, 80, NULL, NULL, NULL, 7, 1),
+(26, 'Liberté', 50, 50, NULL, NULL, NULL, 7, 1),
+(27, 'Silhouettes amérindiennes', 701, 70, NULL, NULL, NULL, 7, 1),
+(28, 'Puissance', 81, 100, NULL, NULL, NULL, 8, 1),
+(29, 'Source', 73, 116, NULL, NULL, NULL, 8, 1),
+(30, 'Comme une ville qui prend vie', 50, 100, 2008, NULL, NULL, 9, 1),
+(31, 'Suspension azur', 80, 80, NULL, NULL, NULL, 9, 1),
+(32, 'Nébuleuse', 70, 70, NULL, NULL, NULL, 10, 1),
+(33, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(34, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(35, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(36, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(37, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(38, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2);
+explain
+SELECT g.id AS gallery_id,
+g.name AS gallery_name,
+p.id AS picture_id,
+p.name AS picture_name,
+g.p_random AS r1,
+g.p_random AS r2,
+g.p_random AS r3
+FROM
+(
+SELECT gal.id,
+gal.name,
+(
+SELECT pi.id
+FROM pictures pi
+WHERE pi.gallery_id = gal.id
+ORDER BY RAND()
+LIMIT 1
+) AS p_random
+FROM galleries gal
+) g
+LEFT JOIN pictures p
+ON p.id = g.p_random
+ORDER BY gallery_name ASC
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using filesort
+1 PRIMARY p eq_ref PRIMARY PRIMARY 4 g.p_random 1 Using where
+2 DERIVED gal ALL NULL NULL NULL NULL 10
+3 DEPENDENT SUBQUERY pi ref gallery_id gallery_id 4 test.gal.id 4 Using temporary; Using filesort
+drop table galleries, pictures;
#
# end of 5.3 tests
#
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 5b8c09cb32e..0860c81d9e8 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -2375,6 +2375,40 @@ SELECT EXTRACT(DAY FROM TIME('1 02:00:00')), EXTRACT(DAY FROM TIME('26:00:00'));
EXTRACT(DAY FROM TIME('1 02:00:00')) EXTRACT(DAY FROM TIME('26:00:00'))
1 1
#
+# MDEV-5458 RQG hits 'sql/tztime.cc:799: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.'
+#
+SET TIMESTAMP=UNIX_TIMESTAMP('2014-01-22 18:19:20');
+CREATE TABLE t1 (t TIME);
+INSERT INTO t1 VALUES ('03:22:30'),('18:30:05');
+SELECT CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00') FROM t1;
+CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00')
+NULL
+NULL
+Warnings:
+Warning 1292 Truncated incorrect time value: '1296:00:00'
+Warning 1292 Incorrect datetime value: '838:59:59'
+Warning 1292 Truncated incorrect time value: '1296:00:00'
+Warning 1292 Incorrect datetime value: '838:59:59'
+SELECT GREATEST(t, CURRENT_DATE()) FROM t1;
+GREATEST(t, CURRENT_DATE())
+838:59:59
+838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '1296:00:00'
+Warning 1292 Truncated incorrect time value: '1296:00:00'
+DROP TABLE t1;
+SET TIMESTAMP=DEFAULT;
+#
+# MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP
+#
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT 1 FROM t1 GROUP BY MONTHNAME(0) WITH ROLLUP;
+1
+1
+1
+DROP TABLE t1;
+#
# MDEV-4838 Wrong metadata for DATE_ADD('string', INVERVAL)
#
SELECT DATE_ADD('2011-01-02 12:13:14', INTERVAL 1 MINUTE);
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index eaeb2a32b29..dfe28f0e05a 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1957,12 +1957,12 @@ UNIQUE INDEX idx (col1));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
EXPLAIN SELECT col1 AS field1, col1 AS field2
-FROM t1 GROUP BY field1, field2;;
+FROM t1 GROUP BY field1, field2+0;;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx 5 NULL 20 Using index; Using temporary; Using filesort
FLUSH STATUS;
SELECT col1 AS field1, col1 AS field2
-FROM t1 GROUP BY field1, field2;;
+FROM t1 GROUP BY field1, field2+0;;
field1 field2
1 1
2 2
@@ -2054,8 +2054,12 @@ field1 field2
explain
select col1 f1, col1 f2 from t1 order by f2, f1;
id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx 5 NULL 20 Using index
+explain
+select col1 f1, col1 f2 from t1 order by f2, f1+0;
+id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx 5 NULL 20 Using index; Using filesort
-select col1 f1, col1 f2 from t1 order by f2, f1;
+select col1 f1, col1 f2 from t1 order by f2, f1+0;
f1 f2
1 1
2 2
@@ -2080,7 +2084,7 @@ f1 f2
explain
select col1 f1, col1 f2 from t1 group by f2 order by f2, f1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL idx 5 NULL 20 Using index; Using temporary; Using filesort
+1 SIMPLE t1 index NULL idx 5 NULL 20 Using index
select col1 f1, col1 f2 from t1 group by f2 order by f2, f1;
f1 f2
1 1
@@ -2106,7 +2110,7 @@ f1 f2
explain
select col1 f1, col1 f2 from t1 group by f1, f2 order by f2, f1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL idx 5 NULL 20 Using index; Using temporary; Using filesort
+1 SIMPLE t1 index NULL idx 5 NULL 20 Using index
select col1 f1, col1 f2 from t1 group by f1, f2 order by f2, f1;
f1 f2
1 1
@@ -2137,10 +2141,10 @@ INSERT INTO t2(col1, col2) VALUES
(1,20),(2,19),(3,18),(4,17),(5,16),(6,15),(7,14),(8,13),(9,12),(10,11),
(11,10),(12,9),(13,8),(14,7),(15,6),(16,5),(17,4),(18,3),(19,2),(20,1);
explain
-select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3;
+select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3+0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx 10 NULL 20 Using index; Using temporary; Using filesort
-select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3;
+select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3+0;
f1 f2 f3
1 20 1
2 19 2
@@ -2163,10 +2167,10 @@ f1 f2 f3
19 2 19
20 1 20
explain
-select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3;
+select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3+0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx 10 NULL 20 Using index; Using filesort
-select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3;
+select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3+0;
f1 f2 f3
1 20 1
2 19 2
@@ -2470,32 +2474,6 @@ v 2v,2v
NULL 1c,2v,2v
DROP TABLE t1,t2;
#
-# Test of MDEV-4002
-#
-CREATE TABLE t1 (
-pk INT NOT NULL PRIMARY KEY,
-d1 DOUBLE,
-d2 DOUBLE,
-i INT NOT NULL DEFAULT '0',
-KEY (i)
-) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,1.0,1.1,1),(2,2.0,2.2,2);
-PREPARE stmt FROM "
-SELECT DISTINCT i, GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
-FROM t1 a1 NATURAL JOIN t1 a2 GROUP BY i WITH ROLLUP
-";
-EXECUTE stmt;
-i GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
-1 11.1
-2 22.2
-NULL 11.1,22.2
-EXECUTE stmt;
-i GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
-1 11.1
-2 22.2
-NULL 11.1,22.2
-DROP TABLE t1;
-#
# Bug #58782
# Missing rows with SELECT .. WHERE .. IN subquery
# with full GROUP BY and no aggr
diff --git a/mysql-test/r/group_by_innodb.result b/mysql-test/r/group_by_innodb.result
index d165834cbe3..4b5d9990c51 100644
--- a/mysql-test/r/group_by_innodb.result
+++ b/mysql-test/r/group_by_innodb.result
@@ -1,3 +1,4 @@
+set @save_ext_key_optimizer_switch=@@optimizer_switch;
#
# MDEV-3992 Server crash or valgrind errors in test_if_skip_sort_order/test_if_cheaper_ordering
# on GROUP BY with indexes on InnoDB table
@@ -7,13 +8,14 @@ pk INT PRIMARY KEY,
a VARCHAR(1) NOT NULL,
KEY (pk)
) ENGINE=InnoDB;
+set optimizer_switch='extended_keys=on';
INSERT INTO t1 VALUES (1,'a'),(2,'b');
EXPLAIN
SELECT COUNT(*), pk field1, pk AS field2
FROM t1 WHERE a = 'r' OR pk = 183
GROUP BY field1, field2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,pk pk 4 NULL 2 Using where
+1 SIMPLE t1 index PRIMARY,pk PRIMARY 4 NULL 2 Using where
SELECT COUNT(*), pk field1, pk AS field2
FROM t1 WHERE a = 'r' OR pk = 183
GROUP BY field1, field2;
@@ -22,9 +24,36 @@ EXPLAIN
SELECT COUNT(*), pk field1 FROM t1
WHERE a = 'r' OR pk = 183 GROUP BY field1, field1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,pk pk 4 NULL 2 Using where
+1 SIMPLE t1 index PRIMARY,pk PRIMARY 4 NULL 2 Using where
SELECT COUNT(*), pk field1 FROM t1
WHERE a = 'r' OR pk = 183 GROUP BY field1, field1;
COUNT(*) field1
drop table t1;
+set optimizer_switch=@save_ext_key_optimizer_switch;
+#
+# MDEV-4002 Server crash or valgrind errors in Item_func_group_concat::setup and Item_func_group_concat::add
+#
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+d1 DOUBLE,
+d2 DOUBLE,
+i INT NOT NULL DEFAULT '0',
+KEY (i)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1.0,1.1,1),(2,2.0,2.2,2);
+PREPARE stmt FROM "
+SELECT DISTINCT i, GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
+FROM t1 a1 NATURAL JOIN t1 a2 GROUP BY i WITH ROLLUP
+";
+EXECUTE stmt;
+i GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
+1 11.1
+2 22.2
+NULL 11.1,22.2
+EXECUTE stmt;
+i GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
+1 11.1
+2 22.2
+NULL 11.1,22.2
+DROP TABLE t1;
End of 5.5 tests
diff --git a/mysql-test/r/group_by_null.result b/mysql-test/r/group_by_null.result
new file mode 100644
index 00000000000..01053514cb0
--- /dev/null
+++ b/mysql-test/r/group_by_null.result
@@ -0,0 +1,6 @@
+create table t1 (a int);
+insert into t1 values (1),(2);
+select max('foo') from t1 group by values(a), extractvalue('bar','qux') order by "v";
+max('foo')
+foo
+drop table t1;
diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result
index e4e7e44ce7c..9ef28e1ce54 100644
--- a/mysql-test/r/innodb_ext_key.result
+++ b/mysql-test/r/innodb_ext_key.result
@@ -991,6 +991,54 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref page_timestamp page_timestamp 4 const 10 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.rev_text_id 1
DROP TABLE t1,t2,t3;
+#
+# MDEV-5424 SELECT using ORDER BY DESC and LIMIT produces unexpected
+# results (InnoDB/XtraDB)
+#
+create table t1 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = myisam default character set utf8;
+create table t2 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = innodb default character set utf8;
+insert into t1 (b) values (null), (null), (null);
+insert into t2 (b) values (null), (null), (null);
+set optimizer_switch='extended_keys=on';
+explain select a from t1 where b is null order by a desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref b b 9 const 2 Using where; Using filesort
+select a from t1 where b is null order by a desc limit 2;
+a
+3
+2
+explain select a from t2 where b is null order by a desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range b b 9 NULL 3 Using where; Using filesort
+select a from t2 where b is null order by a desc limit 2;
+a
+3
+2
+set optimizer_switch='extended_keys=off';
+explain select a from t2 where b is null order by a desc limit 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range b b 9 NULL 3 Using where; Using filesort
+select a from t2 where b is null order by a desc limit 2;
+a
+3
+2
+explain select a from t2 where b is null order by a desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index b PRIMARY 8 NULL 3 Using where
+select a from t2 where b is null order by a desc;
+a
+3
+2
+1
+explain select a from t2 where b is null order by a desc,a,a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index b PRIMARY 8 NULL 3 Using where
+select a from t2 where b is null order by a desc,a,a;
+a
+3
+2
+1
+drop table t1, t2;
set optimizer_switch=@save_optimizer_switch;
set optimizer_switch=@save_ext_key_optimizer_switch;
SET SESSION STORAGE_ENGINE=DEFAULT;
diff --git a/mysql-test/r/innodb_icp.result b/mysql-test/r/innodb_icp.result
index 5e9e6d647f8..fb467494525 100644
--- a/mysql-test/r/innodb_icp.result
+++ b/mysql-test/r/innodb_icp.result
@@ -910,5 +910,30 @@ OR a = c
ORDER BY e;
a b c d e
DROP TABLE t1,t2,t3;
+#
+# MDEV-5337: Wrong result in mariadb 5.5.32 with ORDER BY + LIMIT when index_condition_pushdown=on
+# MDEV-5512: Wrong result (WHERE clause ignored) with multiple clauses using Percona-XtraDB engine
+#
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (pk int primary key,
+key1 char(32),
+key2 char(32),
+key(key1),
+key(key2)
+) engine=innodb;
+insert into t2 select
+A.a+10*B.a+100*C.a,
+concat('rare-', A.a+10*B.a),
+concat('rare-', A.a+10*B.a)
+from
+t1 A, t1 B, t1 C;
+update t2 set key1='frequent-val' where pk between 100 and 350;
+select * from t2 ignore key(PRIMARY)
+where key1='frequent-val' and key2 between 'rare-400' and 'rare-450' order by pk limit 2;
+pk key1 key2
+141 frequent-val rare-41
+142 frequent-val rare-42
+drop table t1, t2;
set optimizer_switch=@innodb_icp_tmp;
set storage_engine= @save_storage_engine;
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index a722ab8d97f..82f3977e231 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -697,3 +697,23 @@ ERROR 42000: Column 'a' specified twice
INSERT IGNORE t1 (a, a) SELECT 1,1 UNION SELECT 2,2;
ERROR 42000: Column 'a' specified twice
DROP TABLE t1;
+#
+# MDEV-5168: Ensure that we can disable duplicate key warnings
+# from INSERT IGNORE
+#
+create table t1 (f1 int unique, f2 int unique);
+insert into t1 values (1,12);
+insert into t1 values (2,13);
+insert into t1 values (1,12);
+ERROR 23000: Duplicate entry '1' for key 'f1'
+insert ignore into t1 values (1,12);
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'f1'
+set @@old_mode="NO_DUP_KEY_WARNINGS_WITH_IGNORE";
+insert ignore into t1 values (1,12);
+insert ignore into t1 values (1,12) on duplicate key update f2=13;
+set @@old_mode="";
+insert ignore into t1 values (1,12);
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'f1'
+DROP TABLE t1;
diff --git a/mysql-test/r/myisam_optimize.result b/mysql-test/r/myisam_optimize.result
index 5c9dee9a9ca..ae0c5b59d06 100644
--- a/mysql-test/r/myisam_optimize.result
+++ b/mysql-test/r/myisam_optimize.result
@@ -21,3 +21,4 @@ a left(b,10)
3 CCCCCCCCCC
4 CCCCCCCCCC
drop table t1;
+set debug_sync='reset';
diff --git a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
index fce61687c83..dda732937ee 100644
--- a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
+++ b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
@@ -1,6 +1,7 @@
#
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
#
+# Verbose run
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -11,12 +12,51 @@ INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it.
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
+# Silent run
+TRUNCATE TABLE time_zone;
+TRUNCATE TABLE time_zone_name;
+TRUNCATE TABLE time_zone_transition;
+TRUNCATE TABLE time_zone_transition_type;
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
+ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
+ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
+#
+# Testing with explicit timezonefile
+#
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+#
+# Testing --leap
+#
+TRUNCATE TABLE time_zone_leap_second;
+ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result
index 06efaf65f5e..cf4f54658b4 100644
--- a/mysql-test/r/mysql_upgrade.result
+++ b/mysql-test/r/mysql_upgrade.result
@@ -126,6 +126,9 @@ test
Phase 3/3: Running 'mysql_fix_privilege_tables'...
OK
DROP USER mysqltest1@'%';
+Version check failed. Got the following error when calling the 'mysql' command line client
+ERROR 1045 (28000): Access denied for user 'mysqltest1'@'localhost' (using password: YES)
+FATAL ERROR: Upgrade failed
Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
FATAL ERROR: Upgrade failed
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result
index 421afbbf1ba..e5d6cbc0e31 100644
--- a/mysql-test/r/mysqld--help.result
+++ b/mysql-test/r/mysqld--help.result
@@ -468,8 +468,12 @@ The following options may be given as the first argument:
--net-write-timeout=#
Number of seconds to wait for a block to be written to a
connection before aborting the write
- --old Use compatible behavior
+ --old Use compatible behavior from previous MariaDB version.
+ See also --old-mode
--old-alter-table Use old, non-optimized alter table
+ --old-mode=name Used to emulate old behavior from earlier MariaDB or
+ MySQL versions. Syntax: old_mode=mode[,mode[,mode...]].
+ See the manual for the complete list of valid old modes
--old-passwords Use old password encryption method (needed for 4.0 and
older clients)
--old-style-user-limits
@@ -1164,6 +1168,7 @@ net-retry-count 10
net-write-timeout 60
old FALSE
old-alter-table FALSE
+old-mode
old-passwords FALSE
old-style-user-limits FALSE
optimizer-prune-level 1
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index a8e610a561a..a8e5cbb295c 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -357,6 +357,12 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1 where a = 1 order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 4 const 5 Using where; Using index
+explain select * from t1 where a = 2 and b > 0 order by a desc,b desc,b,a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
+explain select * from t1 where a = 2 and b < 2 order by a desc,a,b desc,a,b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index
select * from t1 where a = 1 order by b desc;
a b c
1 3 b
@@ -2905,4 +2911,28 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
+#
+# MDEV-4974 memory leak in 5.5.32-MariaDB-1~wheezy-log
+#
+set sort_buffer_size=default;
+set max_sort_length=default;
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (b int,
+col1 varchar(255),
+col2 varchar(255)
+) character set utf8;
+insert into t2 select
+A.a+10*B.a,
+concat('wow-wow-col1-value-', A.a+10*B.a+100*C.a),
+concat('wow-wow-col2-value-', A.a+10*B.a+100*C.a)
+from
+t1 A, t1 B, t1 C where C.a < 8;
+create table t3 as
+select distinct A.col1 as XX, B.col1 as YY
+from
+t2 A, t2 B
+where A.b = B.b
+order by A.col2, B.col2 limit 10, 1000000;
+drop table t1,t2,t3;
End of 5.5 tests
diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result
index 74842b77ba1..30a56840b1b 100644
--- a/mysql-test/r/perror.result
+++ b/mysql-test/r/perror.result
@@ -1,6 +1,6 @@
Illegal error code: 10000
MySQL error code 1062 (ER_DUP_ENTRY): Duplicate entry '%-.192s' for key %d
-MySQL error code 1076 (ER_READY): %s: ready for connections.
-Version: '%s' socket: '%s' port: %d
+MySQL error code 1408 (ER_STARTUP): %s: ready for connections.
+Version: '%s' socket: '%s' port: %d %s
MySQL error code 1459 (ER_TABLE_NEEDS_UPGRADE): Table upgrade required. Please do "REPAIR TABLE `%-.32s`" or dump/reload to fix it!
MySQL error code 1461 (ER_MAX_PREPARED_STMT_COUNT_REACHED): Can't create more than max_prepared_stmt_count statements (current value: %lu)
diff --git a/mysql-test/r/plugin_auth.result b/mysql-test/r/plugin_auth.result
index 3a55055acce..0d3948dd313 100644
--- a/mysql-test/r/plugin_auth.result
+++ b/mysql-test/r/plugin_auth.result
@@ -300,7 +300,6 @@ FLUSH PRIVILEGES;
mysqld is alive
# Executing 'mysqldump'
# Executing 'mysql_upgrade'
-The --upgrade-system-tables option was used, databases won't be touched.
#
# Bug #59657: Move the client authentication_pam plugin into the
# server repository
diff --git a/mysql-test/r/plugin_vars.result b/mysql-test/r/plugin_vars.result
new file mode 100644
index 00000000000..869e0cf9a2a
--- /dev/null
+++ b/mysql-test/r/plugin_vars.result
@@ -0,0 +1,22 @@
+#
+# MDEV-5345 - Deadlock between mysql_change_user(), SHOW VARIABLES and
+# INSTALL PLUGIN
+#
+CREATE PROCEDURE p_install(x INT)
+BEGIN
+DECLARE CONTINUE HANDLER FOR 1126 BEGIN END;
+WHILE x DO
+SET x= x - 1;
+INSTALL PLUGIN no_such_plugin SONAME 'no_such_object';
+END WHILE;
+END|
+CREATE PROCEDURE p_show_vars(x INT)
+WHILE x DO
+SET x= x - 1;
+SHOW VARIABLES;
+END WHILE|
+CALL p_install(100);
+CALL p_show_vars(100);
+USE test;
+DROP PROCEDURE p_install;
+DROP PROCEDURE p_show_vars;
diff --git a/mysql-test/r/processlist.result b/mysql-test/r/processlist.result
index fc03f920533..127fa96b84b 100644
--- a/mysql-test/r/processlist.result
+++ b/mysql-test/r/processlist.result
@@ -13,3 +13,4 @@ sleep(5)
select command, time < 5 from information_schema.processlist where id != connection_id();
command time < 5
Sleep 1
+set debug_sync='reset';
diff --git a/mysql-test/r/quick_select_4161.result b/mysql-test/r/quick_select_4161.result
index 862be6055ce..18ac4362a84 100644
--- a/mysql-test/r/quick_select_4161.result
+++ b/mysql-test/r/quick_select_4161.result
@@ -29,3 +29,4 @@ kill %connection%;
set debug_sync='now signal done';
Got one of the listed errors
drop table t1;
+set debug_sync='reset';
diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result
index 241c32b4b40..c5faa27085e 100644
--- a/mysql-test/r/repair.result
+++ b/mysql-test/r/repair.result
@@ -130,26 +130,25 @@ test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" or dum
# REPAIR old table USE_FRM should fail
REPAIR TABLE t1 USE_FRM;
Table Op Msg_type Msg_text
-t1 repair error Failed repairing incompatible .frm file
+test.t1 repair warning Number of rows changed from 0 to 1
+test.t1 repair status OK
# Run REPAIR TABLE to upgrade .frm file
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
-t1 MyISAM 10 Fixed 2 7 14 1970324836974591 1024 0 NULL # # NULL latin1_swedish_ci NULL
+t1 MyISAM 10 Fixed 1 7 7 1970324836974591 1024 0 NULL # # NULL latin1_swedish_ci NULL
SELECT * FROM t1;
id
1
-2
REPAIR TABLE t1 USE_FRM;
Table Op Msg_type Msg_text
-test.t1 repair warning Number of rows changed from 0 to 2
+test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
SELECT * FROM t1;
id
1
-2
DROP TABLE t1;
DROP TABLE IF EXISTS tt1;
CREATE TEMPORARY TABLE tt1 (c1 INT);
@@ -183,3 +182,28 @@ test.t1 repair status OK
test.t2 repair status OK
set @@autocommit= default;
drop tables t1, t2;
+#
+# Check that we have decent error messages when using crashed
+# .frm file from MySQL 3.23
+#
+# Test with a saved table from 3.23
+select count(*) from t1;
+ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM
+test.t1 check error Corrupt
+repair table t1;
+Table Op Msg_type Msg_text
+test.t1 repair Error Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM
+test.t1 repair error Corrupt
+repair table t1 use_frm;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+select count(*) from t1;
+count(*)
+0
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
diff --git a/mysql-test/r/repair_symlink-5543.result b/mysql-test/r/repair_symlink-5543.result
new file mode 100644
index 00000000000..051c9ca3472
--- /dev/null
+++ b/mysql-test/r/repair_symlink-5543.result
@@ -0,0 +1,14 @@
+create table t1 (a int) engine=myisam data directory='MYSQL_TMP_DIR';
+insert t1 values (1);
+repair table t1;
+Table Op Msg_type Msg_text
+test.t1 repair error Can't create new tempfile: 'MYSQL_TMP_DIR/t1.TMD'
+test.t1 repair status Operation failed
+drop table t1;
+create table t2 (a int) engine=aria data directory='MYSQL_TMP_DIR';
+insert t2 values (1);
+repair table t2;
+Table Op Msg_type Msg_text
+test.t2 repair error Can't create new tempfile: 'MYSQL_TMP_DIR/t2.TMD'
+test.t2 repair status Operation failed
+drop table t2;
diff --git a/mysql-test/r/show_explain.result b/mysql-test/r/show_explain.result
index 5d7057a0937..a4d12ce05ce 100644
--- a/mysql-test/r/show_explain.result
+++ b/mysql-test/r/show_explain.result
@@ -1035,7 +1035,7 @@ INSERT INTO t3 VALUES
explain
SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 system NULL NULL NULL NULL 1 Using filesort
+1 SIMPLE t2 system NULL NULL NULL NULL 1
1 SIMPLE t1 index b b 6 NULL 107 Using where; Using index
1 SIMPLE t3 ref PRIMARY PRIMARY 5 test.t1.b 1 Using index
set @show_explain_probe_select_id=1;
diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result
index e34f8f9e63a..b45944a3795 100644
--- a/mysql-test/r/sp-bugs.result
+++ b/mysql-test/r/sp-bugs.result
@@ -229,3 +229,49 @@ testf_bug11763507
DROP PROCEDURE testp_bug11763507;
DROP FUNCTION testf_bug11763507;
#END OF BUG#11763507 test.
+#
+# MDEV-5531 double call procedure in one session
+#
+CREATE TABLE `t1` (
+`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+`create_ts` int(10) unsigned DEFAULT '0',
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
+CREATE PROCEDURE test_5531 (IN step TINYINT(1))
+BEGIN
+DECLARE counts INT DEFAULT 0;
+DECLARE cur1 CURSOR FOR
+SELECT ct.id
+FROM (SELECT NULL) AS z
+JOIN (
+SELECT id
+FROM `t1`
+ LIMIT 10
+) AS ct
+JOIN (SELECT NULL) AS x ON(
+EXISTS(
+SELECT 1
+FROM `t1`
+ WHERE id=ct.id
+LIMIT 1
+)
+);
+IF step=1 THEN
+TRUNCATE t1;
+REPEAT
+INSERT INTO `t1`
+ (create_ts) VALUES
+(UNIX_TIMESTAMP());
+SET counts=counts+1;
+UNTIL counts>150 END REPEAT;
+SET max_sp_recursion_depth=1;
+CALL test_5531(2);
+SET max_sp_recursion_depth=2;
+CALL test_5531(2);
+ELSEIF step=2 THEN
+OPEN cur1; CLOSE cur1;
+END IF;
+END $$
+CALL test_5531(1);
+DROP PROCEDURE test_5531;
+DROP TABLE t1;
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result
index 22a5c3abd78..cd78d9f93fb 100644
--- a/mysql-test/r/subselect_mat.result
+++ b/mysql-test/r/subselect_mat.result
@@ -2037,6 +2037,24 @@ INSERT INTO t1 VALUES (1,3,5),(2,4,6);
SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b);
pk a b
DROP TABLE t1;
+#
+# MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd
+# execution of PS with IN subqueries, materialization+semijoin
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (8),(9);
+PREPARE stmt FROM "
+SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) )
+";
+EXECUTE stmt;
+a
+EXECUTE stmt;
+a
+DROP TABLE t1, t2;
+DROP VIEW v2;
# End of 5.3 tests
#
# MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries
@@ -2058,6 +2076,24 @@ CA ML CA ML
CA ML RO ML
DROP TABLE t1,t2;
set join_cache_level=@tmp_mdev5056;
+#
+# MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd
+# execution of PS with IN subqueries, materialization+semijoin
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (8),(9);
+PREPARE stmt FROM "
+SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) )
+";
+EXECUTE stmt;
+a
+EXECUTE stmt;
+a
+DROP TABLE t1, t2;
+DROP VIEW v2;
# End of 5.5 tests
set @subselect_mat_test_optimizer_switch_value=null;
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result
index 873f8eb662e..b5263163cb1 100644
--- a/mysql-test/r/subselect_sj.result
+++ b/mysql-test/r/subselect_sj.result
@@ -2931,10 +2931,10 @@ CREATE TABLE t3 (c3 VARCHAR(1)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('x'),('d');
SELECT * FROM t1, t2 WHERE pk IN ( SELECT pk FROM t1 LEFT JOIN t3 ON (c1 = c3 ) ) ORDER BY c2, c1;
pk c1 c2
-4 NULL x
-3 c x
1 v x
2 v x
+3 c x
+4 NULL x
5 x x
# This should show that "t1 left join t3" is still in the semi-join nest:
EXPLAIN EXTENDED
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result
index 16e30253ea9..60e309cdf4a 100644
--- a/mysql-test/r/subselect_sj_jcl6.result
+++ b/mysql-test/r/subselect_sj_jcl6.result
@@ -2945,10 +2945,10 @@ CREATE TABLE t3 (c3 VARCHAR(1)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('x'),('d');
SELECT * FROM t1, t2 WHERE pk IN ( SELECT pk FROM t1 LEFT JOIN t3 ON (c1 = c3 ) ) ORDER BY c2, c1;
pk c1 c2
-4 NULL x
-3 c x
1 v x
2 v x
+3 c x
+4 NULL x
5 x x
# This should show that "t1 left join t3" is still in the semi-join nest:
EXPLAIN EXTENDED
diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result
index a5629d33bfe..efe1bcfe066 100644
--- a/mysql-test/r/subselect_sj_mat.result
+++ b/mysql-test/r/subselect_sj_mat.result
@@ -2077,6 +2077,24 @@ INSERT INTO t1 VALUES (1,3,5),(2,4,6);
SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b);
pk a b
DROP TABLE t1;
+#
+# MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd
+# execution of PS with IN subqueries, materialization+semijoin
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (8),(9);
+PREPARE stmt FROM "
+SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) )
+";
+EXECUTE stmt;
+a
+EXECUTE stmt;
+a
+DROP TABLE t1, t2;
+DROP VIEW v2;
# End of 5.3 tests
#
# MDEV-5056: Wrong result (extra rows) with materialization+semijoin, IN subqueries
@@ -2098,4 +2116,22 @@ CA ML CA ML
CA ML RO ML
DROP TABLE t1,t2;
set join_cache_level=@tmp_mdev5056;
+#
+# MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd
+# execution of PS with IN subqueries, materialization+semijoin
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (8),(9);
+PREPARE stmt FROM "
+SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) )
+";
+EXECUTE stmt;
+a
+EXECUTE stmt;
+a
+DROP TABLE t1, t2;
+DROP VIEW v2;
# End of 5.5 tests
diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result
index 70f5ef9edc1..0ac4ddca277 100644
--- a/mysql-test/r/timezone2.result
+++ b/mysql-test/r/timezone2.result
@@ -326,5 +326,11 @@ NULL
Warnings:
Warning 1292 Incorrect datetime value: '00:00:00'
#
+# MDEV-5506 safe_mutex: Trying to lock unitialized mutex at safemalloc.c on server shutdown after SELECT with CONVERT_TZ
+#
+SELECT CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' );
+CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' )
+NULL
+#
# End of 5.3 tests
#
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 4ead8f8d743..03b942be3f6 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -309,7 +309,7 @@ SELECT CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5
CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5')
NULL
Warnings:
-Warning 1292 Incorrect datetime value: '2022-00-00 00:00:00'
+Warning 1292 Incorrect datetime value: '2022-00-00'
#
# MDEV-4804 Date comparing false result
#
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index bdbfba84994..ef02368e375 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -181,7 +181,7 @@ SELECT CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5');
CONVERT_TZ(GREATEST(TIME('00:00:00'),TIME('00:00:00')),'+00:00','+7:5')
NULL
Warnings:
-Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
+Warning 1292 Incorrect datetime value: '00:00:00'
#
# MDEV-4652 Wrong result for CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
#
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index a926f975009..19fc1bda402 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4950,6 +4950,56 @@ i1 c1 i1 c1
deallocate prepare stmt;
drop view v1;
drop table t1,t2;
+create table t1 (a int);
+insert into t1 values (1),(2);
+create view v1 (a,r) as select a,rand() from t1;
+create table t2 select a, r as r1, r as r2, r as r3 from v1;
+select a, r1 = r2, r2 = r3 from t2;
+a r1 = r2 r2 = r3
+1 1 1
+2 1 1
+drop view v1;
+drop table t1,t2;
+#
+# MDEV-5515: 2nd execution of a prepared statement returns wrong results
+#
+CREATE TABLE t1 (i1 INT, j1 INT NOT NULL, PRIMARY KEY (i1));
+INSERT INTO t1 VALUES (30,300),(40,400);
+CREATE TABLE t2 (i2 INT);
+INSERT INTO t2 VALUES (50),(60);
+CREATE TABLE t3 (c3 VARCHAR(20), i3 INT);
+INSERT INTO t3 VALUES ('a',10),('b',2);
+CREATE TABLE t4 (i4 INT);
+INSERT INTO t4 VALUES (1),(2);
+DROP VIEW IF EXISTS v1;
+Warnings:
+Note 1051 Unknown table 'test.v1'
+CREATE VIEW v1 AS select coalesce(j1,i3) AS v1_field1 from t2 join t3 left join t1 on ( i1 = i2 );
+CREATE VIEW v2 AS select v1_field1 from t4 join v1;
+prepare my_stmt from "select v1_field1 from v2";
+execute my_stmt;
+v1_field1
+10
+10
+10
+10
+2
+2
+2
+2
+execute my_stmt;
+v1_field1
+10
+10
+10
+10
+2
+2
+2
+2
+deallocate prepare my_stmt;
+DROP VIEW v1,v2;
+DROP TABLE t1,t2,t3,t4;
# -----------------------------------------------------------------
# -- End of 5.3 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/std_data/host_old.MYD b/mysql-test/std_data/host_old.MYD
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mysql-test/std_data/host_old.MYD
diff --git a/mysql-test/std_data/host_old.MYI b/mysql-test/std_data/host_old.MYI
new file mode 100644
index 00000000000..c4c3f225e25
--- /dev/null
+++ b/mysql-test/std_data/host_old.MYI
Binary files differ
diff --git a/mysql-test/std_data/host_old.frm b/mysql-test/std_data/host_old.frm
new file mode 100644
index 00000000000..10ef3ec58be
--- /dev/null
+++ b/mysql-test/std_data/host_old.frm
Binary files differ
diff --git a/mysql-test/suite/federated/federated_archive.result b/mysql-test/suite/federated/federated_archive.result
index c2f43458126..6ff1da69725 100644
--- a/mysql-test/suite/federated/federated_archive.result
+++ b/mysql-test/suite/federated/federated_archive.result
@@ -20,13 +20,13 @@ id name
1 foo
2 bar
DELETE FROM federated.t1 WHERE id = 1;
-ERROR HY000: Got error 10000 'Error on remote system: 1031: Storage engine ARCHIVE of the table `federated`.`archive_table` doesn'' from FEDERATED
+ERROR HY000: Got error 10000 'Error on remote system: 1031: Storage engine ARCHIVE of the table `federated`.`archive_table` doesn't have this option' from FEDERATED
SELECT * FROM federated.t1;
id name
1 foo
2 bar
UPDATE federated.t1 SET name='baz' WHERE id = 1;
-ERROR HY000: Got error 10000 'Error on remote system: 1031: Storage engine ARCHIVE of the table `federated`.`archive_table` doesn'' from FEDERATED
+ERROR HY000: Got error 10000 'Error on remote system: 1031: Storage engine ARCHIVE of the table `federated`.`archive_table` doesn't have this option' from FEDERATED
SELECT * FROM federated.t1;
id name
1 foo
diff --git a/mysql-test/suite/handler/innodb.result b/mysql-test/suite/handler/innodb.result
index eb054136b8d..78660b0ef9c 100644
--- a/mysql-test/suite/handler/innodb.result
+++ b/mysql-test/suite/handler/innodb.result
@@ -256,7 +256,7 @@ handler t1 read a=(1);
a b
handler t1 read a next;
a b
-16 ccc
+14 aaa
handler t1 close;
handler t1 open;
prepare stmt from 'handler t1 read a=(?) limit ?,?';
@@ -563,7 +563,7 @@ HANDLER t1 READ `primary` = (1, 1000);
no1 no2
HANDLER t1 READ `primary` NEXT;
no1 no2
-2 8
+2 6
DROP TABLE t1;
create table t1 (c1 int);
insert into t1 values (14397);
diff --git a/mysql-test/suite/handler/innodb.test b/mysql-test/suite/handler/innodb.test
index 6527c4bb8bb..d752da7dc31 100644
--- a/mysql-test/suite/handler/innodb.test
+++ b/mysql-test/suite/handler/innodb.test
@@ -9,6 +9,11 @@
# rename t/innodb_handler.test to t/handler_innodb.test
#
+if (`select plugin_auth_version < "5.6.15" from information_schema.plugins where plugin_name='innodb'`)
+{
+ --skip Not fixed in InnoDB before 5.6.15
+}
+
--source include/have_innodb.inc
let $engine_type= InnoDB;
diff --git a/mysql-test/suite/innodb/r/innodb_bug13510739.result b/mysql-test/suite/innodb/r/innodb_bug13510739.result
index 8aa4323eeb0..e1e6e27239c 100644
--- a/mysql-test/suite/innodb/r/innodb_bug13510739.result
+++ b/mysql-test/suite/innodb/r/innodb_bug13510739.result
@@ -6,5 +6,5 @@ HANDLER bug13510739 READ `primary` = (2);
c
HANDLER bug13510739 READ `primary` NEXT;
c
-4
+3
DROP TABLE bug13510739;
diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test
index c3754b47ba5..256e7d838ea 100644
--- a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test
+++ b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test
@@ -2,11 +2,6 @@
# embedded server does not support restarting
-- source include/not_embedded.inc
-if (`select plugin_auth_version <= "5.6.10" from information_schema.plugins where plugin_name='innodb'`)
-{
- --skip Not fixed in InnoDB 5.6.10 or earlier
-}
-
#
# 44030: Error: (1500) Couldn't read the MAX(ID) autoinc value from
# the index (PRIMARY)
diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test
index 01592ae9bb8..8598647de66 100644
--- a/mysql-test/suite/innodb/t/innodb-index.test
+++ b/mysql-test/suite/innodb/t/innodb-index.test
@@ -1,10 +1,5 @@
-- source include/have_innodb.inc
-if (`select plugin_auth_version <= "5.6.10" from information_schema.plugins where plugin_name='innodb'`)
-{
- --skip Not fixed in InnoDB 5.6.10 or earlier
-}
-
let $innodb_file_format_orig=`select @@innodb_file_format`;
let $innodb_file_format_max_orig=`select @@innodb_file_format_max`;
diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test
index 157e2480740..f687f089d78 100644
--- a/mysql-test/suite/innodb/t/innodb.test
+++ b/mysql-test/suite/innodb/t/innodb.test
@@ -1,9 +1,3 @@
---source include/not_windows_embedded.inc
-# remove this when
-# Bug#53947 InnoDB: Assertion failure in thread 4224 in file
-# .\sync\sync0sync.c line 324
-# is fixed
-
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
diff --git a/mysql-test/suite/innodb/t/innodb_bug13510739.test b/mysql-test/suite/innodb/t/innodb_bug13510739.test
index f10bcd8e272..d2193996d68 100644
--- a/mysql-test/suite/innodb/t/innodb_bug13510739.test
+++ b/mysql-test/suite/innodb/t/innodb_bug13510739.test
@@ -2,6 +2,10 @@
# Bug#13510739 63775: SERVER CRASH ON HANDLER READ NEXT AFTER DELETE RECORD.
#
+if (`select plugin_auth_version < "5.6.15" from information_schema.plugins where plugin_name='innodb'`)
+{
+ --skip Not fixed in InnoDB before 5.6.15
+}
-- source include/have_innodb.inc
CREATE TABLE bug13510739 (c INTEGER NOT NULL, PRIMARY KEY (c)) ENGINE=INNODB;
diff --git a/mysql-test/suite/maria/alter.result b/mysql-test/suite/maria/alter.result
new file mode 100644
index 00000000000..1a7daf5a1ee
--- /dev/null
+++ b/mysql-test/suite/maria/alter.result
@@ -0,0 +1,33 @@
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 'test.t1'
+CREATE TABLE t1 (pk INT, d DATETIME, PRIMARY KEY(pk), KEY(d)) ENGINE=Aria;
+ALTER TABLE t1 DISABLE KEYS;
+INSERT INTO t1 VALUES (1,'2000-01-01 22:22:22'),(2,'2012-12-21 12:12:12');
+INSERT INTO t1 VALUES (3, '2008-07-24');
+ALTER TABLE t1 ENABLE KEYS;
+SELECT t1a.pk FROM t1 AS t1a LEFT JOIN t1 AS t1b ON t1a.pk = t1b.pk;
+pk
+1
+2
+3
+SELECT * FROM t1 AS t1a LEFT JOIN t1 AS t1b ON t1a.pk = t1b.pk;
+pk d pk d
+1 2000-01-01 22:22:22 1 2000-01-01 22:22:22
+2 2012-12-21 12:12:12 2 2012-12-21 12:12:12
+3 2008-07-24 00:00:00 3 2008-07-24 00:00:00
+DROP TABLE t1;
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=Aria;
+ALTER TABLE t1 DISABLE KEYS;
+INSERT INTO t1 VALUES (1,11);
+INSERT INTO t1 VALUES (2,0),(3,33),(4,0),(5,55),(6,66),(7,0),(8,88),(9,99);
+ALTER TABLE t1 ENABLE KEYS;
+SELECT * FROM t1 WHERE i = 0 OR pk BETWEEN 6 AND 10;
+pk i
+2 0
+4 0
+6 66
+7 0
+8 88
+9 99
+DROP TABLE t1;
diff --git a/mysql-test/suite/maria/alter.test b/mysql-test/suite/maria/alter.test
new file mode 100644
index 00000000000..abca4865688
--- /dev/null
+++ b/mysql-test/suite/maria/alter.test
@@ -0,0 +1,27 @@
+# Testing of potential problems in Aria and alter table
+
+-- source include/have_maria.inc
+
+drop table if exists t1;
+
+#
+# MDEV-4970 Wrong result with Aria table populated with disabled keys
+#
+
+CREATE TABLE t1 (pk INT, d DATETIME, PRIMARY KEY(pk), KEY(d)) ENGINE=Aria;
+ALTER TABLE t1 DISABLE KEYS;
+INSERT INTO t1 VALUES (1,'2000-01-01 22:22:22'),(2,'2012-12-21 12:12:12');
+INSERT INTO t1 VALUES (3, '2008-07-24');
+ALTER TABLE t1 ENABLE KEYS;
+
+SELECT t1a.pk FROM t1 AS t1a LEFT JOIN t1 AS t1b ON t1a.pk = t1b.pk;
+SELECT * FROM t1 AS t1a LEFT JOIN t1 AS t1b ON t1a.pk = t1b.pk;
+DROP TABLE t1;
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=Aria;
+ALTER TABLE t1 DISABLE KEYS;
+INSERT INTO t1 VALUES (1,11);
+INSERT INTO t1 VALUES (2,0),(3,33),(4,0),(5,55),(6,66),(7,0),(8,88),(9,99);
+ALTER TABLE t1 ENABLE KEYS;
+SELECT * FROM t1 WHERE i = 0 OR pk BETWEEN 6 AND 10;
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/r/insert_ignore-5421.result b/mysql-test/suite/parts/r/insert_ignore-5421.result
new file mode 100644
index 00000000000..6cbb21fe2d7
--- /dev/null
+++ b/mysql-test/suite/parts/r/insert_ignore-5421.result
@@ -0,0 +1,9 @@
+CREATE TABLE t1 (i INT) ENGINE=MyISAM
+PARTITION BY RANGE (i) (
+PARTITION p00 VALUES LESS THAN (1),
+PARTITION p01 VALUES LESS THAN (2)
+);
+INSERT IGNORE INTO t1 VALUES (3);
+Warnings:
+Warning 1526 Table has no partition for value 3
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/t/insert_ignore-5421.test b/mysql-test/suite/parts/t/insert_ignore-5421.test
new file mode 100644
index 00000000000..889f2ccae7b
--- /dev/null
+++ b/mysql-test/suite/parts/t/insert_ignore-5421.test
@@ -0,0 +1,12 @@
+#
+# MDEV-5421 Assertion `! is_set()' fails on INSERT IGNORE when a table has no partition for a value
+#
+
+--source include/have_partition.inc
+CREATE TABLE t1 (i INT) ENGINE=MyISAM
+PARTITION BY RANGE (i) (
+ PARTITION p00 VALUES LESS THAN (1),
+ PARTITION p01 VALUES LESS THAN (2)
+);
+INSERT IGNORE INTO t1 VALUES (3);
+DROP TABLE t1;
diff --git a/mysql-test/suite/plugins/r/sql_error_log.result b/mysql-test/suite/plugins/r/sql_error_log.result
new file mode 100644
index 00000000000..f3e6716302b
--- /dev/null
+++ b/mysql-test/suite/plugins/r/sql_error_log.result
@@ -0,0 +1,45 @@
+drop procedure if exists test_error;
+drop table if exists t1;
+install plugin SQL_ERROR_LOG soname 'sql_errlog';
+show variables like 'sql_error_log%';
+Variable_name Value
+sql_error_log_filename sql_errors.log
+sql_error_log_rate 1
+sql_error_log_rotate OFF
+sql_error_log_rotations 9
+sql_error_log_size_limit 1000000
+set global sql_error_log_rate=1;
+select * from t_doesnt_exist;
+ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
+syntax_error_query;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'syntax_error_query' at line 1
+CREATE PROCEDURE test_error()
+BEGIN
+DECLARE CONTINUE HANDLER
+FOR 1146
+BEGIN
+RESIGNAL SQLSTATE '40000' SET
+MYSQL_ERRNO = 1000,
+MESSAGE_TEXT = 'new message';
+END;
+SELECT `c` FROM `temptab`;
+END|
+CALL test_error();
+ERROR 40000: new message
+drop procedure test_error;
+SET SQL_MODE = STRICT_ALL_TABLES;
+create table t1(id int);
+insert into t1 values ('aa');
+ERROR 22007: Incorrect integer value: 'aa' for column 'id' at row 1
+SET SQL_MODE = '';
+drop table t1;
+uninstall plugin SQL_ERROR_LOG;
+Warnings:
+Warning 1620 Plugin is busy and will be uninstalled on shutdown
+TIME HOSTNAME ERROR 1146: Table 'test.t_doesnt_exist' doesn't exist : select * from t_doesnt_exist
+TIME HOSTNAME ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'syntax_error_query' at line 1 : syntax_error_query
+TIME HOSTNAME ERROR 1146: Table 'test.temptab' doesn't exist : SELECT `c` FROM `temptab`
+TIME HOSTNAME ERROR 1000: new message : RESIGNAL SQLSTATE '40000' SET
+MYSQL_ERRNO = 1000,
+MESSAGE_TEXT = 'new message'
+TIME HOSTNAME ERROR 1366: Incorrect integer value: 'aa' for column 'id' at row 1 : insert into t1 values ('aa')
diff --git a/mysql-test/suite/plugins/t/sql_error_log.test b/mysql-test/suite/plugins/t/sql_error_log.test
new file mode 100644
index 00000000000..8d04720aac3
--- /dev/null
+++ b/mysql-test/suite/plugins/t/sql_error_log.test
@@ -0,0 +1,55 @@
+
+--source include/not_embedded.inc
+
+if (!$SQL_ERRLOG_SO) {
+ skip No SQL_ERROR_LOG plugin;
+}
+
+--disable_warnings
+drop procedure if exists test_error;
+drop table if exists t1;
+--enable_warnings
+
+install plugin SQL_ERROR_LOG soname 'sql_errlog';
+
+show variables like 'sql_error_log%';
+set global sql_error_log_rate=1;
+--error ER_NO_SUCH_TABLE
+select * from t_doesnt_exist;
+--error 1064
+syntax_error_query;
+
+delimiter |;
+
+CREATE PROCEDURE test_error()
+BEGIN
+DECLARE CONTINUE HANDLER
+FOR 1146
+BEGIN
+RESIGNAL SQLSTATE '40000' SET
+MYSQL_ERRNO = 1000,
+MESSAGE_TEXT = 'new message';
+END;
+SELECT `c` FROM `temptab`;
+END|
+
+delimiter ;|
+
+--error 1000
+CALL test_error();
+drop procedure test_error;
+
+SET SQL_MODE = STRICT_ALL_TABLES;
+create table t1(id int);
+--error 1366
+insert into t1 values ('aa');
+SET SQL_MODE = '';
+drop table t1;
+
+uninstall plugin SQL_ERROR_LOG;
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+# replace the timestamp and the hostname with constant values
+--replace_regex /[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [^E]*/TIME HOSTNAME /
+cat_file $MYSQLD_DATADIR/sql_errors.log;
+
diff --git a/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result b/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result
index 3b20282adff..257c16845dd 100644
--- a/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result
+++ b/mysql-test/suite/rpl/r/rpl_create_tmp_table_if_not_exists.result
@@ -21,4 +21,7 @@ master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp
+DROP TEMPORARY TABLE tmp;
+DROP TEMPORARY TABLE tmp1;
+DROP TEMPORARY TABLE tmp2;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_lost_events_on_rotate.result b/mysql-test/suite/rpl/r/rpl_lost_events_on_rotate.result
new file mode 100644
index 00000000000..573517d6af8
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_lost_events_on_rotate.result
@@ -0,0 +1,14 @@
+include/master-slave.inc
+[connection master]
+SET @debug_saved= @@GLOBAL.DEBUG_DBUG;
+CREATE TABLE t (i INT);
+SET GLOBAL DEBUG_DBUG= "d,wait_after_binlog_EOF";
+INSERT INTO t VALUES (1);
+INSERT INTO t VALUES (2);
+FLUSH LOGS;
+SET DEBUG_SYNC= 'now SIGNAL signal.rotate_finished';
+include/diff_tables.inc [master:t,slave:t]
+SET @@GLOBAL.DEBUG_DBUG= @debug_saved;
+SET DEBUG_SYNC= 'RESET';
+DROP TABLE t;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_mdev359.result b/mysql-test/suite/rpl/r/rpl_mdev359.result
index c0c7bac1175..337a35a7a92 100644
--- a/mysql-test/suite/rpl/r/rpl_mdev359.result
+++ b/mysql-test/suite/rpl/r/rpl_mdev359.result
@@ -8,4 +8,5 @@ SET DEBUG_SYNC= "now WAIT_FOR m1_ready";
SET GLOBAL rpl_semi_sync_master_enabled = OFF;
SET DEBUG_SYNC= "now SIGNAL m1_cont";
DROP TABLE t1;
+SET DEBUG_SYNC= "RESET";
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result b/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result
index f24f34fa0bf..5a258647b07 100644
--- a/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result
+++ b/mysql-test/suite/rpl/r/rpl_mixed_ddl_dml.result
@@ -43,4 +43,5 @@ t5 CREATE TABLE `t5` (
`created` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t2,t3,t5;
+drop temporary table t4;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result b/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result
index 6c419031f1f..da807748cee 100644
--- a/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result
+++ b/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result
@@ -2126,8 +2126,14 @@ DROP TABLE IF EXISTS tt_error_1;
DROP TABLE IF EXISTS nt_error_1;
DROP TABLE IF EXISTS tt_error_2;
DROP TABLE IF EXISTS nt_error_2;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_xx_1;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_xx_1;
DROP TABLE IF EXISTS nt_2;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_2;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
DROP TABLE IF EXISTS nt_1;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_1;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_1;
DROP TABLE IF EXISTS tt_2;
DROP TABLE IF EXISTS tt_1;
SET @commands= '';
diff --git a/mysql-test/suite/rpl/r/rpl_parallel.result b/mysql-test/suite/rpl/r/rpl_parallel.result
index b7fca7ea442..007b167bdd7 100644
--- a/mysql-test/suite/rpl/r/rpl_parallel.result
+++ b/mysql-test/suite/rpl/r/rpl_parallel.result
@@ -7,6 +7,7 @@ SET GLOBAL slave_parallel_threads=10;
CHANGE MASTER TO master_use_gtid=slave_pos;
include/start_slave.inc
*** Test long-running query in domain 1 can run in parallel with short queries in domain 0 ***
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
@@ -259,6 +260,416 @@ SET GLOBAL binlog_format=@old_format;
SET GLOBAL slave_parallel_threads=0;
SET GLOBAL slave_parallel_threads=10;
include/start_slave.inc
+*** Test killing slave threads at various wait points ***
+*** 1. Test killing transaction waiting in commit for previous transaction to commit ***
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (31, foo(31,
+'commit_before_prepare_ordered WAIT_FOR t2_waiting',
+'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
+SET debug_sync='now WAIT_FOR master_queued1';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+INSERT INTO t3 VALUES (32, foo(32,
+'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+''));
+INSERT INTO t3 VALUES (33, foo(33,
+'group_commit_waiting_for_prior SIGNAL t2_waiting',
+'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
+COMMIT;
+SET debug_sync='now WAIT_FOR master_queued2';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (34, foo(34,
+'',
+''));
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+a b
+31 31
+32 32
+33 33
+34 34
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Query execution was interrupted");
+CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends");
+CALL mtr.add_suppression("Slave: Connection was killed");
+SET sql_log_bin=1;
+SET debug_sync='now WAIT_FOR t2_query';
+SET debug_sync='now SIGNAL t2_cont';
+SET debug_sync='now WAIT_FOR t1_ready';
+KILL THD_ID;
+SET debug_sync='now WAIT_FOR t2_killed';
+SET debug_sync='now SIGNAL t1_cont';
+include/wait_for_slave_sql_error.inc [errno=1317,1963]
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+a b
+31 31
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+INSERT INTO t3 VALUES (39,0);
+include/start_slave.inc
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+a b
+31 31
+32 32
+33 33
+34 34
+39 0
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+include/start_slave.inc
+*** 2. Same as (1), but without restarting IO thread after kill of SQL threads ***
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (41, foo(41,
+'commit_before_prepare_ordered WAIT_FOR t2_waiting',
+'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
+SET debug_sync='now WAIT_FOR master_queued1';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+INSERT INTO t3 VALUES (42, foo(42,
+'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+''));
+INSERT INTO t3 VALUES (43, foo(43,
+'group_commit_waiting_for_prior SIGNAL t2_waiting',
+'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
+COMMIT;
+SET debug_sync='now WAIT_FOR master_queued2';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (44, foo(44,
+'',
+''));
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
+a b
+41 41
+42 42
+43 43
+44 44
+SET debug_sync='now WAIT_FOR t2_query';
+SET debug_sync='now SIGNAL t2_cont';
+SET debug_sync='now WAIT_FOR t1_ready';
+KILL THD_ID;
+SET debug_sync='now WAIT_FOR t2_killed';
+SET debug_sync='now SIGNAL t1_cont';
+include/wait_for_slave_sql_error.inc [errno=1317,1963]
+SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
+a b
+41 41
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+INSERT INTO t3 VALUES (49,0);
+START SLAVE SQL_THREAD;
+SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
+a b
+41 41
+42 42
+43 43
+44 44
+49 0
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+include/start_slave.inc
+*** 3. Same as (2), but not using gtid mode ***
+include/stop_slave.inc
+CHANGE MASTER TO master_use_gtid=no;
+include/start_slave.inc
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (51, foo(51,
+'commit_before_prepare_ordered WAIT_FOR t2_waiting',
+'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
+SET debug_sync='now WAIT_FOR master_queued1';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+INSERT INTO t3 VALUES (52, foo(52,
+'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+''));
+INSERT INTO t3 VALUES (53, foo(53,
+'group_commit_waiting_for_prior SIGNAL t2_waiting',
+'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
+COMMIT;
+SET debug_sync='now WAIT_FOR master_queued2';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (54, foo(54,
+'',
+''));
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
+a b
+51 51
+52 52
+53 53
+54 54
+SET debug_sync='now WAIT_FOR t2_query';
+SET debug_sync='now SIGNAL t2_cont';
+SET debug_sync='now WAIT_FOR t1_ready';
+KILL THD_ID;
+SET debug_sync='now WAIT_FOR t2_killed';
+SET debug_sync='now SIGNAL t1_cont';
+include/wait_for_slave_sql_error.inc [errno=1317,1963]
+SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
+a b
+51 51
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+INSERT INTO t3 VALUES (59,0);
+START SLAVE SQL_THREAD;
+SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
+a b
+51 51
+52 52
+53 53
+54 54
+59 0
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+include/stop_slave.inc
+CHANGE MASTER TO master_use_gtid=slave_pos;
+include/start_slave.inc
+include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=3;
+include/start_slave.inc
+*** 4. Test killing thread that is waiting to start transaction until previous transaction commits ***
+SET binlog_format=statement;
+SET gtid_domain_id=2;
+INSERT INTO t3 VALUES (60, foo(60,
+'ha_write_row_end SIGNAL d2_query WAIT_FOR d2_cont2',
+'rpl_parallel_end_of_group SIGNAL d2_done WAIT_FOR d2_cont'));
+SET gtid_domain_id=0;
+SET debug_sync='now WAIT_FOR d2_query';
+SET gtid_domain_id=1;
+BEGIN;
+INSERT INTO t3 VALUES (61, foo(61,
+'rpl_parallel_start_waiting_for_prior SIGNAL t3_waiting',
+'rpl_parallel_start_waiting_for_prior_killed SIGNAL t3_killed'));
+INSERT INTO t3 VALUES (62, foo(62,
+'ha_write_row_end SIGNAL d1_query WAIT_FOR d1_cont2',
+'rpl_parallel_end_of_group SIGNAL d1_done WAIT_FOR d1_cont'));
+COMMIT;
+SET gtid_domain_id=0;
+SET debug_sync='now WAIT_FOR d1_query';
+SET gtid_domain_id=0;
+INSERT INTO t3 VALUES (63, foo(63,
+'ha_write_row_end SIGNAL d0_query WAIT_FOR d0_cont2',
+'rpl_parallel_end_of_group SIGNAL d0_done WAIT_FOR d0_cont'));
+SET debug_sync='now WAIT_FOR d0_query';
+SET debug_sync='now SIGNAL d2_cont2';
+SET debug_sync='now WAIT_FOR d2_done';
+SET debug_sync='now SIGNAL d1_cont2';
+SET debug_sync='now WAIT_FOR d1_done';
+SET debug_sync='now SIGNAL d0_cont2';
+SET debug_sync='now WAIT_FOR d0_done';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (64, foo(64,
+'commit_before_prepare_ordered SIGNAL t1_waiting WAIT_FOR t1_cont', ''));
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2 WAIT_FOR master_cont2';
+INSERT INTO t3 VALUES (65, foo(65, '', ''));
+SET debug_sync='now WAIT_FOR master_queued2';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+INSERT INTO t3 VALUES (66, foo(66, '', ''));
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued4';
+INSERT INTO t3 VALUES (67, foo(67, '', ''));
+SET debug_sync='now WAIT_FOR master_queued4';
+SET debug_sync='now SIGNAL master_cont2';
+SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
+a b
+60 60
+61 61
+62 62
+63 63
+64 64
+65 65
+66 66
+67 67
+SET debug_sync='now SIGNAL d0_cont';
+SET debug_sync='now WAIT_FOR t1_waiting';
+SET debug_sync='now SIGNAL d1_cont';
+SET debug_sync='now WAIT_FOR t3_waiting';
+SET debug_sync='now SIGNAL d2_cont';
+KILL THD_ID;
+SET debug_sync='now WAIT_FOR t3_killed';
+SET debug_sync='now SIGNAL t1_cont';
+include/wait_for_slave_sql_error.inc [errno=1317,1927,1963]
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
+a b
+60 60
+61 61
+62 62
+63 63
+64 64
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+INSERT INTO t3 VALUES (69,0);
+include/start_slave.inc
+SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
+a b
+60 60
+61 61
+62 62
+63 63
+64 64
+65 65
+66 66
+67 67
+69 0
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+include/start_slave.inc
+*** 5. Test killing thread that is waiting for queue of max length to shorten ***
+SET @old_max_queued= @@GLOBAL.slave_parallel_max_queued;
+SET GLOBAL slave_parallel_max_queued=9000;
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (70, foo(0,
+'ha_write_row_end SIGNAL query_waiting WAIT_FOR query_cont', ''));
+SET debug_sync='now WAIT_FOR query_waiting';
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_wait_queue_max";
+INSERT INTO t3 VALUES (72, 0);
+SELECT * FROM t3 WHERE a >= 70 ORDER BY a;
+a b
+70 0
+71 10000
+72 0
+SET debug_sync='now WAIT_FOR wait_queue_ready';
+KILL THD_ID;
+SET debug_sync='now WAIT_FOR wait_queue_killed';
+SET debug_sync='now SIGNAL query_cont';
+include/wait_for_slave_sql_error.inc [errno=1317,1927,1963]
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 70 ORDER BY a;
+a b
+70 0
+71 10000
+SET GLOBAL debug_dbug=@old_dbug;
+SET GLOBAL slave_parallel_max_queued= @old_max_queued;
+INSERT INTO t3 VALUES (73,0);
+include/start_slave.inc
+SELECT * FROM t3 WHERE a >= 70 ORDER BY a;
+a b
+70 0
+71 10000
+72 0
+73 0
+include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+include/start_slave.inc
include/stop_slave.inc
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
include/start_slave.inc
diff --git a/mysql-test/suite/rpl/r/rpl_parallel_no_log_slave_updates.result b/mysql-test/suite/rpl/r/rpl_parallel_no_log_slave_updates.result
new file mode 100644
index 00000000000..067d92a962f
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_parallel_no_log_slave_updates.result
@@ -0,0 +1,122 @@
+include/rpl_init.inc [topology=1->2]
+*** Test killing transaction waiting in commit for previous transaction to commit, when not using 2-phase commit ***
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=10;
+CHANGE MASTER TO master_use_gtid=slave_pos;
+include/start_slave.inc
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+SET sql_log_bin=0;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+SET sql_log_bin=0;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (31, foo(31,
+'ha_commit_one_phase WAIT_FOR t2_waiting',
+'commit_one_phase_2 SIGNAL t1_ready WAIT_FOR t1_cont'));
+SET debug_sync='now WAIT_FOR master_queued1';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+INSERT INTO t3 VALUES (32, foo(32,
+'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+''));
+INSERT INTO t3 VALUES (33, foo(33,
+'wait_for_prior_commit_waiting SIGNAL t2_waiting',
+'wait_for_prior_commit_killed SIGNAL t2_killed'));
+COMMIT;
+SET debug_sync='now WAIT_FOR master_queued2';
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (34, foo(34,
+'',
+''));
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+a b
+31 31
+32 32
+33 33
+34 34
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Query execution was interrupted");
+CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends");
+CALL mtr.add_suppression("Slave: Connection was killed");
+SET sql_log_bin=1;
+SET debug_sync='now WAIT_FOR t2_query';
+SET debug_sync='now SIGNAL t2_cont';
+SET debug_sync='now WAIT_FOR t1_ready';
+KILL THD_ID;
+SET debug_sync='now WAIT_FOR t2_killed';
+SET debug_sync='now SIGNAL t1_cont';
+include/wait_for_slave_sql_error.inc [errno=1317,1927,1963]
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+a b
+31 31
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+INSERT INTO t3 VALUES (39,0);
+include/start_slave.inc
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+a b
+31 31
+32 32
+33 33
+34 34
+39 0
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+RETURNS INT DETERMINISTIC
+BEGIN
+IF d1 != '' THEN
+SET debug_sync = d1;
+END IF;
+IF d2 != '' THEN
+SET debug_sync = d2;
+END IF;
+RETURN x;
+END
+||
+SET sql_log_bin=1;
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+include/start_slave.inc
+include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+include/start_slave.inc
+DROP function foo;
+DROP TABLE t3;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
index ecf6f5109f7..f2dbfa3cba4 100644
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
@@ -98,6 +98,7 @@ count(*)
103
unlock tables;
drop table if exists t1,t2,t3,t4;
+drop temporary table temp_table;
End of 4.1 tests
show binlog events in 'non existing_binlog_file';
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
diff --git a/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result b/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result
index 9c8088b4657..280955c66ef 100644
--- a/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result
+++ b/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result
@@ -2211,8 +2211,14 @@ DROP TABLE IF EXISTS tt_error_1;
DROP TABLE IF EXISTS nt_error_1;
DROP TABLE IF EXISTS tt_error_2;
DROP TABLE IF EXISTS nt_error_2;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_xx_1;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_xx_1;
DROP TABLE IF EXISTS nt_2;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_2;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
DROP TABLE IF EXISTS nt_1;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_1;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_1;
DROP TABLE IF EXISTS tt_2;
DROP TABLE IF EXISTS tt_1;
SET @commands= '';
diff --git a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
index 41fe0b1a9f3..1cf70ba7e67 100644
--- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
@@ -23,6 +23,7 @@ include/start_slave.inc
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
+drop temporary table if exists t1;
include/stop_slave.inc
reset slave;
include/check_slave_no_error.inc
diff --git a/mysql-test/suite/rpl/r/rpl_stm_000001.result b/mysql-test/suite/rpl/r/rpl_stm_000001.result
index 80a3240021a..2401fda52f9 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_000001.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_000001.result
@@ -48,6 +48,7 @@ select (@id := id) - id from t2;
0
kill @id;
drop table t2;
+drop temporary table t3;
Got one of the listed errors
include/wait_for_slave_sql_error_and_skip.inc [errno=1927]
select count(*) from t1;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result b/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result
index 7d3984bb383..9dc86c0bfa7 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result
@@ -2220,8 +2220,14 @@ DROP TABLE IF EXISTS tt_error_1;
DROP TABLE IF EXISTS nt_error_1;
DROP TABLE IF EXISTS tt_error_2;
DROP TABLE IF EXISTS nt_error_2;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_xx_1;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_xx_1;
DROP TABLE IF EXISTS nt_2;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_2;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
DROP TABLE IF EXISTS nt_1;
+DROP TEMPORARY TABLE IF EXISTS tt_tmp_1;
+DROP TEMPORARY TABLE IF EXISTS nt_tmp_1;
DROP TABLE IF EXISTS tt_2;
DROP TABLE IF EXISTS tt_1;
SET @commands= '';
diff --git a/mysql-test/suite/rpl/r/rpl_stm_innodb.result b/mysql-test/suite/rpl/r/rpl_stm_innodb.result
index 0e9531317b9..6f54b232e71 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_innodb.result
@@ -79,6 +79,7 @@ COUNT(*)
FLUSH LOGS;
-------- switch to master --------
FLUSH LOGS;
+DROP TEMPORARY TABLE IF EXISTS mysqltest1.tmp2;
DROP DATABASE mysqltest1;
End of 5.1 tests
#
diff --git a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
index b1473c937a1..e5870cec2c9 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
@@ -23,6 +23,7 @@ include/start_slave.inc
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 1
+drop temporary table if exists t1;
include/stop_slave.inc
reset slave;
include/check_slave_no_error.inc
diff --git a/mysql-test/suite/rpl/r/rpl_stop_slave.result b/mysql-test/suite/rpl/r/rpl_stop_slave.result
index 3d9bad18ab6..5959ee09993 100644
--- a/mysql-test/suite/rpl/r/rpl_stop_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stop_slave.result
@@ -113,7 +113,6 @@ ROLLBACK;
[connection master]
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
-SET DEBUG_SYNC= 'RESET';
[connection slave]
include/wait_for_slave_to_stop.inc
[connection slave1]
@@ -121,3 +120,4 @@ include/start_slave.inc
[connection master]
DROP TABLE t1, t2;
include/rpl_end.inc
+SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/suite/rpl/t/rpl_create_tmp_table_if_not_exists.test b/mysql-test/suite/rpl/t/rpl_create_tmp_table_if_not_exists.test
index e1fd7abb47f..3107fdfaaa9 100644
--- a/mysql-test/suite/rpl/t/rpl_create_tmp_table_if_not_exists.test
+++ b/mysql-test/suite/rpl/t/rpl_create_tmp_table_if_not_exists.test
@@ -38,4 +38,8 @@ CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp;
source include/show_binlog_events.inc;
+DROP TEMPORARY TABLE tmp;
+DROP TEMPORARY TABLE tmp1;
+DROP TEMPORARY TABLE tmp2;
+
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_lost_events_on_rotate.test b/mysql-test/suite/rpl/t/rpl_lost_events_on_rotate.test
new file mode 100644
index 00000000000..3a4a24e1762
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_lost_events_on_rotate.test
@@ -0,0 +1,51 @@
+#
+# Whenever the mysql_binlog_send method (dump thread) reaches the
+# end of file when reading events from the binlog, before checking
+# if it should wait for more events, there was a test to check if
+# the file being read was still active, i.e, it was the last known
+# binlog. However, it was possible that something was written to
+# the binary log and then a rotation would happen, after EOF was
+# detected and before the check for active was performed. In this
+# case, the end of the binary log would not be read by the dump
+# thread, and this would cause the slave to lose updates.
+#
+# This test verifies that the problem has been fixed. It waits
+# during this window while forcing a rotation in the binlog.
+#
+--source include/have_debug.inc
+--source include/master-slave.inc
+
+--connection master
+
+SET @debug_saved= @@GLOBAL.DEBUG_DBUG;
+
+CREATE TABLE t (i INT);
+
+# When reaching the EOF the dump thread will wait before deciding if
+# it should move to a new binlong file.
+SET GLOBAL DEBUG_DBUG= "d,wait_after_binlog_EOF";
+
+INSERT INTO t VALUES (1);
+
+--sleep 1
+
+# A insert and a rotate happens before the decision
+INSERT INTO t VALUES (2);
+FLUSH LOGS;
+
+SET DEBUG_SYNC= 'now SIGNAL signal.rotate_finished';
+
+--sync_slave_with_master
+
+# All the rows should be sent to the slave.
+--let $diff_tables=master:t,slave:t
+--source include/diff_tables.inc
+
+##Clean up
+--connection master
+
+SET @@GLOBAL.DEBUG_DBUG= @debug_saved;
+SET DEBUG_SYNC= 'RESET';
+
+DROP TABLE t;
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_mdev359.test b/mysql-test/suite/rpl/t/rpl_mdev359.test
index 96c7ac859d9..3026c6d363e 100644
--- a/mysql-test/suite/rpl/t/rpl_mdev359.test
+++ b/mysql-test/suite/rpl/t/rpl_mdev359.test
@@ -27,5 +27,6 @@ SET DEBUG_SYNC= "now SIGNAL m1_cont";
connection master;
DROP TABLE t1;
+SET DEBUG_SYNC= "RESET";
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test b/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
index c5b821ca906..f4a1615a20f 100644
--- a/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
+++ b/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
@@ -44,6 +44,7 @@ show create table t3;
show create table t5;
connection master;
drop table t2,t3,t5;
+drop temporary table t4;
sync_slave_with_master;
# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_parallel.test b/mysql-test/suite/rpl/t/rpl_parallel.test
index 5709cab19c0..a0232ac71e0 100644
--- a/mysql-test/suite/rpl/t/rpl_parallel.test
+++ b/mysql-test/suite/rpl/t/rpl_parallel.test
@@ -19,6 +19,7 @@ CHANGE MASTER TO master_use_gtid=slave_pos;
--echo *** Test long-running query in domain 1 can run in parallel with short queries in domain 0 ***
--connection server_1
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
@@ -334,6 +335,682 @@ SELECT * FROM t3 WHERE a >= 20 ORDER BY a;
--connection server_2
+# Respawn all worker threads to clear any left-over debug_sync or other stuff.
+--source include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+--source include/start_slave.inc
+
+
+--echo *** Test killing slave threads at various wait points ***
+--echo *** 1. Test killing transaction waiting in commit for previous transaction to commit ***
+
+# Set up three transactions on the master that will be group-committed
+# together so they can be replicated in parallel on the slave.
+--connection con_temp3
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (31, foo(31,
+ 'commit_before_prepare_ordered WAIT_FOR t2_waiting',
+ 'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued1';
+
+--connection con_temp4
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+# This insert is just so we can get T2 to wait while a query is running that we
+# can see in SHOW PROCESSLIST so we can get its thread_id to kill later.
+INSERT INTO t3 VALUES (32, foo(32,
+ 'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+ ''));
+# This insert sets up debug_sync points so that T2 will tell when it is at its
+# wait point where we want to kill it - and when it has been killed.
+INSERT INTO t3 VALUES (33, foo(33,
+ 'group_commit_waiting_for_prior SIGNAL t2_waiting',
+ 'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
+send COMMIT;
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued2';
+
+--connection con_temp5
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (34, foo(34,
+ '',
+ ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+
+--connection con_temp3
+REAP;
+--connection con_temp4
+REAP;
+--connection con_temp5
+REAP;
+
+--connection server_1
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+
+--connection server_2
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Query execution was interrupted");
+CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends");
+CALL mtr.add_suppression("Slave: Connection was killed");
+SET sql_log_bin=1;
+# Wait until T2 is inside executing its insert of 32, then find it in SHOW
+# PROCESSLIST to know its thread id for KILL later.
+SET debug_sync='now WAIT_FOR t2_query';
+--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(32%' AND INFO NOT LIKE '%LIKE%'`
+SET debug_sync='now SIGNAL t2_cont';
+
+# Wait until T2 has entered its wait for T1 to commit, and T1 has
+# progressed into its commit phase.
+SET debug_sync='now WAIT_FOR t1_ready';
+
+# Now kill the transaction T2.
+--replace_result $thd_id THD_ID
+eval KILL $thd_id;
+
+# Wait until T2 has reacted on the kill.
+SET debug_sync='now WAIT_FOR t2_killed';
+
+# Now we can allow T1 to proceed.
+SET debug_sync='now SIGNAL t1_cont';
+
+--let $slave_sql_errno= 1317,1963
+--source include/wait_for_slave_sql_error.inc
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+
+# Now we have to disable the debug_sync statements, so they do not trigger
+# when the events are retried.
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_1
+INSERT INTO t3 VALUES (39,0);
+--save_master_pos
+
+--connection server_2
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+# Restore the foo() function.
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+
+--connection server_2
+# Respawn all worker threads to clear any left-over debug_sync or other stuff.
+--source include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+--source include/start_slave.inc
+
+
+--echo *** 2. Same as (1), but without restarting IO thread after kill of SQL threads ***
+
+# Set up three transactions on the master that will be group-committed
+# together so they can be replicated in parallel on the slave.
+--connection con_temp3
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (41, foo(41,
+ 'commit_before_prepare_ordered WAIT_FOR t2_waiting',
+ 'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued1';
+
+--connection con_temp4
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+# This insert is just so we can get T2 to wait while a query is running that we
+# can see in SHOW PROCESSLIST so we can get its thread_id to kill later.
+INSERT INTO t3 VALUES (42, foo(42,
+ 'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+ ''));
+# This insert sets up debug_sync points so that T2 will tell when it is at its
+# wait point where we want to kill it - and when it has been killed.
+INSERT INTO t3 VALUES (43, foo(43,
+ 'group_commit_waiting_for_prior SIGNAL t2_waiting',
+ 'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
+send COMMIT;
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued2';
+
+--connection con_temp5
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (44, foo(44,
+ '',
+ ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+
+--connection con_temp3
+REAP;
+--connection con_temp4
+REAP;
+--connection con_temp5
+REAP;
+
+--connection server_1
+SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
+
+--connection server_2
+# Wait until T2 is inside executing its insert of 42, then find it in SHOW
+# PROCESSLIST to know its thread id for KILL later.
+SET debug_sync='now WAIT_FOR t2_query';
+--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(42%' AND INFO NOT LIKE '%LIKE%'`
+SET debug_sync='now SIGNAL t2_cont';
+
+# Wait until T2 has entered its wait for T1 to commit, and T1 has
+# progressed into its commit phase.
+SET debug_sync='now WAIT_FOR t1_ready';
+
+# Now kill the transaction T2.
+--replace_result $thd_id THD_ID
+eval KILL $thd_id;
+
+# Wait until T2 has reacted on the kill.
+SET debug_sync='now WAIT_FOR t2_killed';
+
+# Now we can allow T1 to proceed.
+SET debug_sync='now SIGNAL t1_cont';
+
+--let $slave_sql_errno= 1317,1963
+--source include/wait_for_slave_sql_error.inc
+SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
+
+# Now we have to disable the debug_sync statements, so they do not trigger
+# when the events are retried.
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_1
+INSERT INTO t3 VALUES (49,0);
+--save_master_pos
+
+--connection server_2
+START SLAVE SQL_THREAD;
+--sync_with_master
+SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
+# Restore the foo() function.
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+
+--connection server_2
+# Respawn all worker threads to clear any left-over debug_sync or other stuff.
+--source include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+--source include/start_slave.inc
+
+
+--echo *** 3. Same as (2), but not using gtid mode ***
+
+--connection server_2
+--source include/stop_slave.inc
+CHANGE MASTER TO master_use_gtid=no;
+--source include/start_slave.inc
+
+--connection server_1
+# Set up three transactions on the master that will be group-committed
+# together so they can be replicated in parallel on the slave.
+--connection con_temp3
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (51, foo(51,
+ 'commit_before_prepare_ordered WAIT_FOR t2_waiting',
+ 'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued1';
+
+--connection con_temp4
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+# This insert is just so we can get T2 to wait while a query is running that we
+# can see in SHOW PROCESSLIST so we can get its thread_id to kill later.
+INSERT INTO t3 VALUES (52, foo(52,
+ 'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+ ''));
+# This insert sets up debug_sync points so that T2 will tell when it is at its
+# wait point where we want to kill it - and when it has been killed.
+INSERT INTO t3 VALUES (53, foo(53,
+ 'group_commit_waiting_for_prior SIGNAL t2_waiting',
+ 'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
+send COMMIT;
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued2';
+
+--connection con_temp5
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (54, foo(54,
+ '',
+ ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+
+--connection con_temp3
+REAP;
+--connection con_temp4
+REAP;
+--connection con_temp5
+REAP;
+
+--connection server_1
+SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
+
+--connection server_2
+# Wait until T2 is inside executing its insert of 52, then find it in SHOW
+# PROCESSLIST to know its thread id for KILL later.
+SET debug_sync='now WAIT_FOR t2_query';
+--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(52%' AND INFO NOT LIKE '%LIKE%'`
+SET debug_sync='now SIGNAL t2_cont';
+
+# Wait until T2 has entered its wait for T1 to commit, and T1 has
+# progressed into its commit phase.
+SET debug_sync='now WAIT_FOR t1_ready';
+
+# Now kill the transaction T2.
+--replace_result $thd_id THD_ID
+eval KILL $thd_id;
+
+# Wait until T2 has reacted on the kill.
+SET debug_sync='now WAIT_FOR t2_killed';
+
+# Now we can allow T1 to proceed.
+SET debug_sync='now SIGNAL t1_cont';
+
+--let $slave_sql_errno= 1317,1963
+--source include/wait_for_slave_sql_error.inc
+SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
+
+# Now we have to disable the debug_sync statements, so they do not trigger
+# when the events are retried.
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_1
+INSERT INTO t3 VALUES (59,0);
+--save_master_pos
+
+--connection server_2
+START SLAVE SQL_THREAD;
+--sync_with_master
+SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
+# Restore the foo() function.
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+
+--source include/stop_slave.inc
+CHANGE MASTER TO master_use_gtid=slave_pos;
+--source include/start_slave.inc
+
+--connection server_2
+# Respawn all worker threads to clear any left-over debug_sync or other stuff.
+--source include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=3;
+--source include/start_slave.inc
+
+
+--echo *** 4. Test killing thread that is waiting to start transaction until previous transaction commits ***
+
+# We set up four transactions T1, T2, T3, and T4 on the master. T2, T3, and T4
+# can run in parallel with each other (same group commit and commit id),
+# but not in parallel with T1.
+#
+# We use three worker threads. T1 and T2 will be queued on the first, T3 on
+# the second, and T4 on the third. We will delay T1 commit, T3 will wait for
+# T1 to commit before it can start. We will kill T3 during this wait, and
+# check that everything works correctly.
+#
+# It is rather tricky to get the correct thread id of the worker to kill.
+# We start by injecting three dummy transactions in a debug_sync-controlled
+# manner to be able to get known thread ids for the workers in a pool with
+# just 3 worker threads. Then we let in each of the real test transactions
+# T1-T4 one at a time in a way which allows us to know which transaction
+# ends up with which thread id.
+
+--connection server_1
+SET binlog_format=statement;
+SET gtid_domain_id=2;
+INSERT INTO t3 VALUES (60, foo(60,
+ 'ha_write_row_end SIGNAL d2_query WAIT_FOR d2_cont2',
+ 'rpl_parallel_end_of_group SIGNAL d2_done WAIT_FOR d2_cont'));
+SET gtid_domain_id=0;
+
+--connection server_2
+SET debug_sync='now WAIT_FOR d2_query';
+--let $d2_thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(60%' AND INFO NOT LIKE '%LIKE%'`
+
+--connection server_1
+SET gtid_domain_id=1;
+BEGIN;
+# These debug_sync's will linger on and be used to control T3 later.
+INSERT INTO t3 VALUES (61, foo(61,
+ 'rpl_parallel_start_waiting_for_prior SIGNAL t3_waiting',
+ 'rpl_parallel_start_waiting_for_prior_killed SIGNAL t3_killed'));
+INSERT INTO t3 VALUES (62, foo(62,
+ 'ha_write_row_end SIGNAL d1_query WAIT_FOR d1_cont2',
+ 'rpl_parallel_end_of_group SIGNAL d1_done WAIT_FOR d1_cont'));
+COMMIT;
+SET gtid_domain_id=0;
+
+--connection server_2
+SET debug_sync='now WAIT_FOR d1_query';
+--let $d1_thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(62%' AND INFO NOT LIKE '%LIKE%'`
+
+--connection server_1
+SET gtid_domain_id=0;
+INSERT INTO t3 VALUES (63, foo(63,
+ 'ha_write_row_end SIGNAL d0_query WAIT_FOR d0_cont2',
+ 'rpl_parallel_end_of_group SIGNAL d0_done WAIT_FOR d0_cont'));
+
+--connection server_2
+SET debug_sync='now WAIT_FOR d0_query';
+--let $d0_thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(63%' AND INFO NOT LIKE '%LIKE%'`
+
+SET debug_sync='now SIGNAL d2_cont2';
+SET debug_sync='now WAIT_FOR d2_done';
+SET debug_sync='now SIGNAL d1_cont2';
+SET debug_sync='now WAIT_FOR d1_done';
+SET debug_sync='now SIGNAL d0_cont2';
+SET debug_sync='now WAIT_FOR d0_done';
+
+# Now prepare the real transactions T1, T2, T3, T4 on the master.
+
+--connection con_temp3
+# Create transaction T1.
+SET binlog_format=statement;
+INSERT INTO t3 VALUES (64, foo(64,
+ 'commit_before_prepare_ordered SIGNAL t1_waiting WAIT_FOR t1_cont', ''));
+
+# Create transaction T2, as a group commit leader on the master.
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2 WAIT_FOR master_cont2';
+send INSERT INTO t3 VALUES (65, foo(65, '', ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued2';
+
+--connection con_temp4
+# Create transaction T3, participating in T2's group commit.
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+send INSERT INTO t3 VALUES (66, foo(66, '', ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued3';
+
+--connection con_temp5
+# Create transaction T4, participating in group commit with T2 and T3.
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued4';
+send INSERT INTO t3 VALUES (67, foo(67, '', ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued4';
+SET debug_sync='now SIGNAL master_cont2';
+
+--connection con_temp3
+REAP;
+--connection con_temp4
+REAP;
+--connection con_temp5
+REAP;
+
+--connection server_1
+SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
+
+--connection server_2
+# Now we have the four transactions pending for replication on the slave.
+# Let them be queued for our three worker threads in a controlled fashion.
+# We put them at a stage where T1 is delayed and T3 is waiting for T1 to
+# commit before T3 can start. Then we kill T3.
+
+# Make the worker D0 free, and wait for T1 to be queued in it.
+SET debug_sync='now SIGNAL d0_cont';
+SET debug_sync='now WAIT_FOR t1_waiting';
+
+# T2 will be queued on the same worker D0 as T1.
+# Now release worker D1, and wait for T3 to be queued in it.
+# T3 will wait for T1 to commit before it can start.
+SET debug_sync='now SIGNAL d1_cont';
+SET debug_sync='now WAIT_FOR t3_waiting';
+
+# Release worker D2. T4 may or may not have time to be queued on it, but
+# it will not be able to complete due to T3 being killed.
+SET debug_sync='now SIGNAL d2_cont';
+
+# Now we kill the waiting transaction T3 in worker D1.
+--replace_result $d1_thd_id THD_ID
+eval KILL $d1_thd_id;
+
+# Wait until T3 has reacted on the kill.
+SET debug_sync='now WAIT_FOR t3_killed';
+
+# Now we can allow T1 to proceed.
+SET debug_sync='now SIGNAL t1_cont';
+
+--let $slave_sql_errno= 1317,1927,1963
+--source include/wait_for_slave_sql_error.inc
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
+
+# Now we have to disable the debug_sync statements, so they do not trigger
+# when the events are retried.
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_1
+INSERT INTO t3 VALUES (69,0);
+--save_master_pos
+
+--connection server_2
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
+# Restore the foo() function.
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_2
+# Respawn all worker threads to clear any left-over debug_sync or other stuff.
+--source include/stop_slave.inc
+SET GLOBAL binlog_format=@old_format;
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+--source include/start_slave.inc
+
+
+--echo *** 5. Test killing thread that is waiting for queue of max length to shorten ***
+
+--let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%Slave has read all relay log%'
+--source include/wait_condition.inc
+--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%Slave has read all relay log%'`
+SET @old_max_queued= @@GLOBAL.slave_parallel_max_queued;
+SET GLOBAL slave_parallel_max_queued=9000;
+
+--connection server_1
+--let bigstring= `SELECT REPEAT('x', 10000)`
+SET binlog_format=statement;
+# Create an event that will wait to be signalled.
+INSERT INTO t3 VALUES (70, foo(0,
+ 'ha_write_row_end SIGNAL query_waiting WAIT_FOR query_cont', ''));
+--disable_query_log
+# Create an event that will fill up the queue.
+eval INSERT INTO t3 VALUES (71, LENGTH('$bigstring'));
+--enable_query_log
+
+--connection server_2
+SET debug_sync='now WAIT_FOR query_waiting';
+# Inject that the SQL driver thread will signal `wait_queue_ready' to debug_sync
+# as it goes to wait for the event queue to become smaller than the value of
+# @@slave_parallel_max_queued.
+SET @old_dbug= @@GLOBAL.debug_dbug;
+SET GLOBAL debug_dbug="+d,rpl_parallel_wait_queue_max";
+
+--connection server_1
+# This event will have to wait for the queue to become shorter before it can
+# be queued. We will test that things work when we kill the SQL driver thread
+# during this wait.
+INSERT INTO t3 VALUES (72, 0);
+SELECT * FROM t3 WHERE a >= 70 ORDER BY a;
+
+--connection server_2
+SET debug_sync='now WAIT_FOR wait_queue_ready';
+
+--replace_result $thd_id THD_ID
+eval KILL $thd_id;
+
+SET debug_sync='now WAIT_FOR wait_queue_killed';
+SET debug_sync='now SIGNAL query_cont';
+
+--let $slave_sql_errno= 1317,1927,1963
+--source include/wait_for_slave_sql_error.inc
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 70 ORDER BY a;
+
+SET GLOBAL debug_dbug=@old_dbug;
+SET GLOBAL slave_parallel_max_queued= @old_max_queued;
+
+--connection server_1
+INSERT INTO t3 VALUES (73,0);
+--save_master_pos
+
+--connection server_2
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t3 WHERE a >= 70 ORDER BY a;
+
+
+--connection server_2
--source include/stop_slave.inc
SET GLOBAL binlog_format=@old_format;
SET GLOBAL slave_parallel_threads=0;
diff --git a/mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates-slave.opt b/mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates-slave.opt
new file mode 100644
index 00000000000..acd68493e0a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates-slave.opt
@@ -0,0 +1 @@
+--log-slave-updates=0
diff --git a/mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates.test b/mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates.test
new file mode 100644
index 00000000000..98f919e4727
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_parallel_no_log_slave_updates.test
@@ -0,0 +1,199 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/have_binlog_format_statement.inc
+--let $rpl_topology=1->2
+--source include/rpl_init.inc
+
+--echo *** Test killing transaction waiting in commit for previous transaction to commit, when not using 2-phase commit ***
+
+--connection server_2
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=10;
+CHANGE MASTER TO master_use_gtid=slave_pos;
+--source include/start_slave.inc
+
+--connection server_1
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+# Use a stored function to inject a debug_sync into the appropriate THD.
+# The function does nothing on the master, and on the slave it injects the
+# desired debug_sync action(s).
+SET sql_log_bin=0;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+--save_master_pos
+
+--connection server_2
+SET sql_log_bin=0;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+--sync_with_master
+
+
+# Set up three transactions on the master that will be group-committed
+# together so they can be replicated in parallel on the slave.
+--connect (con_temp3,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (31, foo(31,
+ 'ha_commit_one_phase WAIT_FOR t2_waiting',
+ 'commit_one_phase_2 SIGNAL t1_ready WAIT_FOR t1_cont'));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued1';
+
+--connect (con_temp4,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
+SET binlog_format=statement;
+BEGIN;
+# This insert is just so we can get T2 to wait while a query is running that we
+# can see in SHOW PROCESSLIST so we can get its thread_id to kill later.
+INSERT INTO t3 VALUES (32, foo(32,
+ 'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
+ ''));
+# This insert sets up debug_sync points so that T2 will tell when it is at its
+# wait point where we want to kill it - and when it has been killed.
+INSERT INTO t3 VALUES (33, foo(33,
+ 'wait_for_prior_commit_waiting SIGNAL t2_waiting',
+ 'wait_for_prior_commit_killed SIGNAL t2_killed'));
+send COMMIT;
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued2';
+
+--connect (con_temp5,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
+SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
+SET binlog_format=statement;
+send INSERT INTO t3 VALUES (34, foo(34,
+ '',
+ ''));
+
+--connection server_1
+SET debug_sync='now WAIT_FOR master_queued3';
+SET debug_sync='now SIGNAL master_cont1';
+
+--connection con_temp3
+REAP;
+--connection con_temp4
+REAP;
+--connection con_temp5
+REAP;
+
+--connection server_1
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+
+--connection server_2
+SET sql_log_bin=0;
+CALL mtr.add_suppression("Query execution was interrupted");
+CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends");
+CALL mtr.add_suppression("Slave: Connection was killed");
+SET sql_log_bin=1;
+# Wait until T2 is inside executing its insert of 32, then find it in SHOW
+# PROCESSLIST to know its thread id for KILL later.
+SET debug_sync='now WAIT_FOR t2_query';
+--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(32%' AND INFO NOT LIKE '%LIKE%'`
+SET debug_sync='now SIGNAL t2_cont';
+
+# Wait until T2 has entered its wait for T1 to commit, and T1 has
+# progressed into its commit phase.
+SET debug_sync='now WAIT_FOR t1_ready';
+
+# Now kill the transaction T2.
+--replace_result $thd_id THD_ID
+eval KILL $thd_id;
+
+# Wait until T2 has reacted on the kill.
+SET debug_sync='now WAIT_FOR t2_killed';
+
+# Now we can allow T1 to proceed.
+SET debug_sync='now SIGNAL t1_cont';
+
+--let $slave_sql_errno= 1317,1927,1963
+--source include/wait_for_slave_sql_error.inc
+STOP SLAVE IO_THREAD;
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+
+# Now we have to disable the debug_sync statements, so they do not trigger
+# when the events are retried.
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+--connection server_1
+INSERT INTO t3 VALUES (39,0);
+--save_master_pos
+
+--connection server_2
+--source include/start_slave.inc
+--sync_with_master
+SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
+# Restore the foo() function.
+SET sql_log_bin=0;
+DROP FUNCTION foo;
+--delimiter ||
+CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
+ RETURNS INT DETERMINISTIC
+ BEGIN
+ IF d1 != '' THEN
+ SET debug_sync = d1;
+ END IF;
+ IF d2 != '' THEN
+ SET debug_sync = d2;
+ END IF;
+ RETURN x;
+ END
+||
+--delimiter ;
+SET sql_log_bin=1;
+
+
+--connection server_2
+# Respawn all worker threads to clear any left-over debug_sync or other stuff.
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=0;
+SET GLOBAL slave_parallel_threads=10;
+--source include/start_slave.inc
+
+
+--connection server_2
+--source include/stop_slave.inc
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+--source include/start_slave.inc
+
+--connection server_1
+DROP function foo;
+DROP TABLE t3;
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
index 4dd4fccc363..273786cf807 100644
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
@@ -176,6 +176,7 @@ unlock tables;
#clean up
connection master;
drop table if exists t1,t2,t3,t4;
+drop temporary table temp_table;
sync_slave_with_master;
--echo End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_stm_000001.test b/mysql-test/suite/rpl/t/rpl_stm_000001.test
index 0805308aa73..3a87a8f1ef9 100644
--- a/mysql-test/suite/rpl/t/rpl_stm_000001.test
+++ b/mysql-test/suite/rpl/t/rpl_stm_000001.test
@@ -92,8 +92,8 @@ let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHE
source include/wait_condition.inc;
select (@id := id) - id from t2;
kill @id;
-# We don't drop t3 as this is a temporary table
drop table t2;
+drop temporary table t3;
connection master;
# The get_lock function causes warning for unsafe statement.
--disable_warnings
diff --git a/mysql-test/suite/rpl/t/rpl_stop_slave.test b/mysql-test/suite/rpl/t/rpl_stop_slave.test
index 7e57359877b..d9d7f39c321 100644
--- a/mysql-test/suite/rpl/t/rpl_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_stop_slave.test
@@ -107,7 +107,6 @@ ROLLBACK;
--source include/rpl_connection_master.inc
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
-SET DEBUG_SYNC= 'RESET';
--source include/rpl_connection_slave.inc
source include/wait_for_slave_to_stop.inc;
@@ -122,3 +121,4 @@ DROP TABLE t1, t2;
eval SET GLOBAL debug_dbug= '$debug_save';
--enable_query_log
--source include/rpl_end.inc
+SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/suite/sys_vars/r/old_mode_basic.result b/mysql-test/suite/sys_vars/r/old_mode_basic.result
new file mode 100644
index 00000000000..c9a650e7b15
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/old_mode_basic.result
@@ -0,0 +1,174 @@
+SET @global_start_value = @@global.old_mode;
+SELECT @global_start_value;
+@global_start_value
+
+SET @session_start_value = @@session.old_mode;
+SELECT @session_start_value;
+@session_start_value
+
+'#--------------------FN_DYNVARS_152_01------------------------#'
+SET @@global.old_mode = "NO_PROGRESS_INFO";
+SET @@global.old_mode = DEFAULT;
+SELECT @@global.old_mode;
+@@global.old_mode
+
+SET @@session.old_mode = "NO_PROGRESS_INFO";
+SET @@session.old_mode = DEFAULT;
+SELECT @@session.old_mode;
+@@session.old_mode
+
+'#---------------------FN_DYNVARS_152_02-------------------------#'
+SET @@global.old_mode = NULL;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'NULL'
+SET @@global.old_mode = '';
+SELECT @@global.old_mode;
+@@global.old_mode
+
+SET @@global.old_mode = ' ';
+SELECT @@global.old_mode;
+@@global.old_mode
+
+SET @@session.old_mode = NULL;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'NULL'
+SET @@session.old_mode = '';
+SELECT @@session.old_mode;
+@@session.old_mode
+
+SET @@session.old_mode = ' ';
+SELECT @@session.old_mode;
+@@session.old_mode
+
+'#--------------------FN_DYNVARS_152_03------------------------#'
+SET @@global.old_mode = NO_PROGRESS_INFO;
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_PROGRESS_INFO
+SET @@global.old_mode = NO_DUP_KEY_WARNINGS_WITH_IGNORE;
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE
+SET @@global.old_mode = OFF;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'OFF'
+SET @@session.old_mode = NO_PROGRESS_INFO;
+SELECT @@session.old_mode;
+@@session.old_mode
+NO_PROGRESS_INFO
+SET @@session.old_mode = NO_DUP_KEY_WARNINGS_WITH_IGNORE;
+SELECT @@session.old_mode;
+@@session.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE
+SET @@session.old_mode = OFF;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'OFF'
+SET @@global.old_mode = '?';
+ERROR 42000: Variable 'old_mode' can't be set to the value of '?'
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE
+'#--------------------FN_DYNVARS_152_04-------------------------#'
+SET @@global.old_mode = -1;
+ERROR 42000: Variable 'old_mode' can't be set to the value of '-1'
+SET @@global.old_mode = ASCII;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'ASCII'
+SET @@global.old_mode = NON_TRADITIONAL;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'NON_TRADITIONAL'
+SET @@global.old_mode = 'OF';
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'OF'
+SET @@global.old_mode = NONE;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'NONE'
+SET @@session.old_mode = -1;
+ERROR 42000: Variable 'old_mode' can't be set to the value of '-1'
+SET @@session.old_mode = ANSI_SINGLE_QUOTES;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'ANSI_SINGLE_QUOTES'
+SET @@session.old_mode = 'ON';
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'ON'
+SET @@session.old_mode = 'OF';
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'OF'
+SET @@session.old_mode = DISABLE;
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'DISABLE'
+'#-------------------FN_DYNVARS_152_05----------------------------#'
+SELECT @@session.old_mode = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='old_mode';
+@@session.old_mode = VARIABLE_VALUE
+1
+'#----------------------FN_DYNVARS_152_06------------------------#'
+SELECT @@global.old_mode = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='old_mode';
+@@global.old_mode = VARIABLE_VALUE
+1
+'#---------------------FN_DYNVARS_152_07-------------------------#'
+SET @@global.old_mode = 0;
+SELECT @@global.old_mode;
+@@global.old_mode
+
+SET @@global.old_mode = 1;
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE
+SET @@global.old_mode = 2;
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_PROGRESS_INFO
+SET @@global.old_mode = 4;
+ERROR 42000: Variable 'old_mode' can't be set to the value of '4'
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_PROGRESS_INFO
+SET @@global.old_mode = 0.4;
+ERROR 42000: Incorrect argument type to variable 'old_mode'
+'#---------------------FN_DYNVARS_152_08----------------------#'
+SET @@global.old_mode = TRUE;
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE
+SET @@global.old_mode = FALSE;
+SELECT @@global.old_mode;
+@@global.old_mode
+
+'#---------------------FN_DYNVARS_152_09----------------------#'
+SET old_mode = 'NO_PROGRESS_INFO';
+SET session.old_mode = 'ANSI';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'old_mode = 'ANSI'' at line 1
+SET global.old_mode = 'ANSI';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'old_mode = 'ANSI'' at line 1
+SET session old_mode = 1;
+SELECT @@old_mode;
+@@old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE
+SET global old_mode = 0;
+SELECT @@global.old_mode;
+@@global.old_mode
+
+'#---------------------FN_DYNVARS_152_10----------------------#'
+SET @@session.old_mode = 'NO_PROGRESS_INFO,NO_DUP_KEY_WARNINGS_WITH_IGNORE';
+SELECT @@session.old_mode;
+@@session.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO
+SET @@global.old_mode = 'NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO';
+SELECT @@global.old_mode;
+@@global.old_mode
+NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO
+SET @@session.old_mode = 'NO_PROGRESS_INFO,NO_SUCH_MODE';
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'NO_SUCH_MODE'
+SET @@old_mode=',';
+SELECT @@old_mode;
+@@old_mode
+
+SET @@old_mode=',,,,NO_PROGRESS_INFO,,,';
+SELECT @@old_mode;
+@@old_mode
+NO_PROGRESS_INFO
+SET @@old_mode=',,,,FOOBAR,,,,,';
+ERROR 42000: Variable 'old_mode' can't be set to the value of 'FOOBAR'
+SELECT @@old_mode;
+@@old_mode
+NO_PROGRESS_INFO
+SET @@global.old_mode = @global_start_value;
+SELECT @@global.old_mode;
+@@global.old_mode
+
+SET @@session.old_mode = @session_start_value;
+SELECT @@session.old_mode;
+@@session.old_mode
+
diff --git a/mysql-test/suite/sys_vars/t/identity_func.test b/mysql-test/suite/sys_vars/t/identity_func.test
index 6f7b6bac18e..ff93607a2cd 100644
--- a/mysql-test/suite/sys_vars/t/identity_func.test
+++ b/mysql-test/suite/sys_vars/t/identity_func.test
@@ -1,9 +1,3 @@
---source include/not_windows_embedded.inc
-# remove this when
-# Bug#53947 InnoDB: Assertion failure in thread 4224 in file
-# .\sync\sync0sync.c line 324
-# is fixed
-
#################### mysql-test\t\identity_func.test ##########################
# #
# Variable Name: identity #
diff --git a/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_func.test b/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_func.test
index 082507efd07..89c1c80a6dc 100644
--- a/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_func.test
+++ b/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_func.test
@@ -1,9 +1,3 @@
---source include/not_windows_embedded.inc
-# remove this when
-# Bug#53947 InnoDB: Assertion failure in thread 4224 in file
-# .\sync\sync0sync.c line 324
-# is fixed
-
################# mysql-test\t\innodb_autoinc_lock_mode_func.test ############
# #
# Variable Name: innodb_autoinc_lock_mode #
diff --git a/mysql-test/suite/sys_vars/t/last_insert_id_func.test b/mysql-test/suite/sys_vars/t/last_insert_id_func.test
index bb3adbc1c64..2309c539bd9 100644
--- a/mysql-test/suite/sys_vars/t/last_insert_id_func.test
+++ b/mysql-test/suite/sys_vars/t/last_insert_id_func.test
@@ -1,9 +1,3 @@
---source include/not_windows_embedded.inc
-# remove this when
-# Bug#53947 InnoDB: Assertion failure in thread 4224 in file
-# .\sync\sync0sync.c line 324
-# is fixed
-
################# mysql-test\t\last_insert_id_func.test #######################
# #
# Variable Name: last_insert_id #
diff --git a/mysql-test/suite/sys_vars/t/old_mode_basic.test b/mysql-test/suite/sys_vars/t/old_mode_basic.test
new file mode 100644
index 00000000000..6770219887d
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/old_mode_basic.test
@@ -0,0 +1,244 @@
+#################### mysql-test\t\sql_mode_basic.test #########################
+# #
+# Variable Name: old_mode #
+# Scope: GLOBAL | SESSION #
+# Access Type: Dynamic #
+# Data Type: enumeration #
+# Default Value: YES #
+# Valid Values : NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO #
+# #
+# #
+# Description: Test Cases of Dynamic System Variable old_mode #
+# that checks the behavior of this variable in the following ways#
+# * Default Value #
+# * Valid & Invalid values #
+# * Scope & Access method #
+# * Data Integrity #
+# #
+# #
+###############################################################################
+
+--source include/load_sysvars.inc
+
+################################################################
+# START OF sql_mode TESTS #
+################################################################
+
+
+###################################################################
+# Saving initial value of sql_mode in a temporary variable #
+###################################################################
+
+SET @global_start_value = @@global.old_mode;
+SELECT @global_start_value;
+
+SET @session_start_value = @@session.old_mode;
+SELECT @session_start_value;
+
+--echo '#--------------------FN_DYNVARS_152_01------------------------#'
+################################################################
+# Display the DEFAULT value of old_mode #
+################################################################
+
+SET @@global.old_mode = "NO_PROGRESS_INFO";
+SET @@global.old_mode = DEFAULT;
+SELECT @@global.old_mode;
+
+SET @@session.old_mode = "NO_PROGRESS_INFO";
+SET @@session.old_mode = DEFAULT;
+SELECT @@session.old_mode;
+
+--echo '#---------------------FN_DYNVARS_152_02-------------------------#'
+#########################################################
+# Check if NULL or empty value is accepeted #
+#########################################################
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = NULL;
+
+# resets sql mode to nothing
+SET @@global.old_mode = '';
+SELECT @@global.old_mode;
+
+SET @@global.old_mode = ' ';
+SELECT @@global.old_mode;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = NULL;
+
+SET @@session.old_mode = '';
+SELECT @@session.old_mode;
+
+SET @@session.old_mode = ' ';
+SELECT @@session.old_mode;
+
+
+--echo '#--------------------FN_DYNVARS_152_03------------------------#'
+########################################################################
+# Change the value of old_mode to a valid value #
+########################################################################
+
+# sql modes ref: http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
+
+# check valid values for global
+
+SET @@global.old_mode = NO_PROGRESS_INFO;
+SELECT @@global.old_mode;
+SET @@global.old_mode = NO_DUP_KEY_WARNINGS_WITH_IGNORE;
+SELECT @@global.old_mode;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = OFF;
+
+#check valid values for session
+SET @@session.old_mode = NO_PROGRESS_INFO;
+SELECT @@session.old_mode;
+SET @@session.old_mode = NO_DUP_KEY_WARNINGS_WITH_IGNORE;
+SELECT @@session.old_mode;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = OFF;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = '?';
+SELECT @@global.old_mode;
+
+--echo '#--------------------FN_DYNVARS_152_04-------------------------#'
+###########################################################################
+# Change the value of old_mode to invalid value #
+###########################################################################
+
+# invalid values for global
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = -1;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = ASCII;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = NON_TRADITIONAL;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = 'OF';
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = NONE;
+
+#invalid values for session
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = -1;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = ANSI_SINGLE_QUOTES;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = 'ON';
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = 'OF';
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = DISABLE;
+
+
+--echo '#-------------------FN_DYNVARS_152_05----------------------------#'
+#########################################################################
+# Check if the value in session Table matches value in variable #
+#########################################################################
+
+SELECT @@session.old_mode = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='old_mode';
+
+--echo '#----------------------FN_DYNVARS_152_06------------------------#'
+#########################################################################
+# Check if the value in GLOBAL Table matches value in variable #
+#########################################################################
+
+SELECT @@global.old_mode = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='old_mode';
+
+
+--echo '#---------------------FN_DYNVARS_152_07-------------------------#'
+###################################################################
+# Check if numbers can be used on variable #
+###################################################################
+
+# test if variable accepts 0,1,2
+SET @@global.old_mode = 0;
+SELECT @@global.old_mode;
+
+SET @@global.old_mode = 1;
+SELECT @@global.old_mode;
+
+SET @@global.old_mode = 2;
+SELECT @@global.old_mode;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.old_mode = 4;
+SELECT @@global.old_mode;
+
+# use of decimal values
+
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@global.old_mode = 0.4;
+
+--echo '#---------------------FN_DYNVARS_152_08----------------------#'
+###################################################################
+# Check if TRUE and FALSE values can be used on variable #
+###################################################################
+
+SET @@global.old_mode = TRUE;
+SELECT @@global.old_mode;
+SET @@global.old_mode = FALSE;
+SELECT @@global.old_mode;
+
+--echo '#---------------------FN_DYNVARS_152_09----------------------#'
+#########################################################################
+# Check if old_mode can be accessed with and without @@ sign #
+#########################################################################
+
+SET old_mode = 'NO_PROGRESS_INFO';
+
+--Error ER_PARSE_ERROR
+SET session.old_mode = 'ANSI';
+--Error ER_PARSE_ERROR
+SET global.old_mode = 'ANSI';
+
+SET session old_mode = 1;
+SELECT @@old_mode;
+
+SET global old_mode = 0;
+SELECT @@global.old_mode;
+
+--echo '#---------------------FN_DYNVARS_152_10----------------------#'
+#######################################################################
+# Check if old_mode values can be combined as specified #
+#######################################################################
+
+SET @@session.old_mode = 'NO_PROGRESS_INFO,NO_DUP_KEY_WARNINGS_WITH_IGNORE';
+SELECT @@session.old_mode;
+
+SET @@global.old_mode = 'NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO';
+SELECT @@global.old_mode;
+
+#try combining invalid mode with correct mode
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.old_mode = 'NO_PROGRESS_INFO,NO_SUCH_MODE';
+
+#zero-length values are ok
+SET @@old_mode=',';
+SELECT @@old_mode;
+SET @@old_mode=',,,,NO_PROGRESS_INFO,,,';
+SELECT @@old_mode;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@old_mode=',,,,FOOBAR,,,,,';
+SELECT @@old_mode;
+
+##############################
+# Restore initial value #
+##############################
+
+SET @@global.old_mode = @global_start_value;
+SELECT @@global.old_mode;
+
+SET @@session.old_mode = @session_start_value;
+SELECT @@session.old_mode;
+
+################################################################
+# END OF old_mode TESTS #
+################################################################
diff --git a/mysql-test/suite/sys_vars/t/storage_engine_basic.test b/mysql-test/suite/sys_vars/t/storage_engine_basic.test
index 2d1e94e6620..964166daae7 100644
--- a/mysql-test/suite/sys_vars/t/storage_engine_basic.test
+++ b/mysql-test/suite/sys_vars/t/storage_engine_basic.test
@@ -1,9 +1,3 @@
---source include/not_windows_embedded.inc
-# remove this when
-# Bug#53947 InnoDB: Assertion failure in thread 4224 in file
-# .\sync\sync0sync.c line 324
-# is fixed
-
############## mysql-test\t\storage_engine_basic.test ##################
# #
# #
diff --git a/mysql-test/suite/sys_vars/t/tx_isolation_func.test b/mysql-test/suite/sys_vars/t/tx_isolation_func.test
index 3a78d46e527..7072de6b086 100644
--- a/mysql-test/suite/sys_vars/t/tx_isolation_func.test
+++ b/mysql-test/suite/sys_vars/t/tx_isolation_func.test
@@ -1,9 +1,3 @@
---source include/not_windows_embedded.inc
-# remove this when
-# Bug#53947 InnoDB: Assertion failure in thread 4224 in file
-# .\sync\sync0sync.c line 324
-# is fixed
-
############# mysql-test\t\tx_isolation_func.test #######################################
# #
# Variable Name: tx_isolation #
diff --git a/mysql-test/t/alter_table_trans.test b/mysql-test/t/alter_table_trans.test
index 9096a392af4..29b9b4c212f 100644
--- a/mysql-test/t/alter_table_trans.test
+++ b/mysql-test/t/alter_table_trans.test
@@ -13,3 +13,23 @@ drop table if exists t1,t2;
CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb;
ALTER TABLE t1 RENAME TO t2, DISABLE KEYS;
DROP TABLE t2;
+
+#
+# MDEV-5406 add index to an innodb table with a uniqueness violation crashes mysqld
+#
+
+CREATE TABLE t1 (
+ col4 text NOT NULL,
+ col2 int(11) NOT NULL DEFAULT '0',
+ col3 int(11) DEFAULT NULL,
+ extra int(11) DEFAULT NULL,
+ KEY idx (col4(10))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+insert t1 values (repeat('1', 8193),3,1,1);
+insert t1 values (repeat('3', 8193),3,1,1);
+--error ER_DUP_ENTRY
+ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3);
+DROP TABLE t1;
+
+
diff --git a/mysql-test/t/assign_key_cache-5405.test b/mysql-test/t/assign_key_cache-5405.test
new file mode 100644
index 00000000000..2839e040bd3
--- /dev/null
+++ b/mysql-test/t/assign_key_cache-5405.test
@@ -0,0 +1,27 @@
+#
+# MDEV-5405 RQG induced crash in mi_assign_to_key_cache in safe mutex unlock
+#
+--source include/have_debug_sync.inc
+create table t1 (f int, key(f)) engine=myisam;
+set global kc1.key_buffer_size = 65536;
+
+connect (con1, localhost, root);
+
+set debug_sync='assign_key_cache_op_unlock wait_for op_locked';
+send cache index t1 in kc1;
+
+connection default;
+sleep 1;
+set debug_sync='assign_key_cache_op_lock signal op_locked wait_for assigned';
+send cache index t1 in kc1;
+
+connection con1;
+reap;
+set debug_sync='now signal assigned';
+disconnect con1;
+connection default;
+reap;
+
+drop table t1;
+set global kc1.key_buffer_size = 0;
+set debug_sync='reset';
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index 7e6990f4754..972543aefc2 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -32,6 +32,8 @@ ORDER BY variable_name;
# SET date_format='%d.%m.%Y';
# SET date_format='%m-%d-%Y';
#
+# --error ER_WRONG_VALUE_FOR_VAR
+# SET datetime_format= NULL;
# set datetime_format= '%Y%m%d%H%i%s';
# set datetime_format= '%Y-%m-%d %H:%i:%s';
# set datetime_format= '%m-%d-%y %H:%i:%s.%f';
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 559a8b76280..4b1d7604b9d 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -394,6 +394,35 @@ WHERE tmp.b;
SELECT * FROM
( SELECT 100 a, subsel.b FROM ( SELECT 200 b ) subsel ) tmp
WHERE tmp.a;
+
+--echo #
+--echo # MDEV-5356: Server crashes in Item_equal::contains on 2nd
+--echo # execution of a PS
+--echo #
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,2),(3,4);
+
+CREATE TABLE t2 (c INT);
+INSERT INTO t2 VALUES (5),(6);
+
+CREATE TABLE t3 (d INT);
+INSERT INTO t3 VALUES (7),(8);
+
+CREATE PROCEDURE pr()
+ UPDATE t3,
+ (SELECT c FROM
+ (SELECT 1 FROM t1 WHERE a=72 AND NOT b) sq,
+ t2
+ ) sq2
+ SET d=sq2.c;
+
+CALL pr();
+CALL pr();
+CALL pr();
+
+drop procedure pr;
+drop table t1,t2,t3;
+
--echo # End of 5.3 tests
--echo #
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test
index 3da58d8ae23..61e11cebad4 100644
--- a/mysql-test/t/derived_view.test
+++ b/mysql-test/t/derived_view.test
@@ -1591,6 +1591,118 @@ EXPLAIN EXTENDED SELECT a FROM v1 WHERE a > 100 ORDER BY b;
DROP VIEW v1;
DROP TABLE t1;
+#
+# MDEV-5414: RAND() in a subselect : different behavior in MariaDB and MySQL
+#
+CREATE TABLE IF NOT EXISTS `galleries` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(100) NOT NULL,
+ `year` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `pictures` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(100) NOT NULL,
+ `width` float DEFAULT NULL,
+ `height` float DEFAULT NULL,
+ `year` int(4) DEFAULT NULL,
+ `technique` varchar(50) DEFAULT NULL,
+ `comment` varchar(2000) DEFAULT NULL,
+ `gallery_id` int(11) NOT NULL,
+ `type` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `gallery_id` (`gallery_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
+
+ALTER TABLE `pictures`
+ ADD CONSTRAINT `pictures_ibfk_1` FOREIGN KEY (`gallery_id`) REFERENCES `galleries` (`id`);
+
+INSERT INTO `galleries` (`id`, `name`, `year`) VALUES
+(1, 'Quand le noir et blanc invite le taupe', 2013),
+(2, 'Une touche de couleur', 2012),
+(3, 'Éclats', 2011),
+(4, 'Gris béton', 2010),
+(5, 'Expression du spalter', 2010),
+(6, 'Zénitude', 2009),
+(7, 'La force du rouge', 2008),
+(8, 'Sphères', NULL),
+(9, 'Centre', 2009),
+(10, 'Nébuleuse', NULL);
+
+INSERT INTO `pictures` (`id`, `name`, `width`, `height`, `year`, `technique`, `comment`, `gallery_id`, `type`) VALUES
+(1, 'Éclaircie', 72.5, 100, NULL, NULL, NULL, 1, 1),
+(2, 'Architecture', 81, 100, NULL, NULL, NULL, 1, 1),
+(3, 'Nouveau souffle', 72.5, 100, NULL, NULL, NULL, 1, 1),
+(4, 'Échanges (2)', 89, 116, NULL, NULL, NULL, 1, 1),
+(5, 'Échanges', 89, 116, NULL, NULL, NULL, 1, 1),
+(6, 'Fenêtre de vie', 81, 116, NULL, NULL, NULL, 1, 1),
+(7, 'Architecture', 81, 100, NULL, NULL, NULL, 1, 1),
+(8, 'Nouveau souffle (2)', 72.5, 100, NULL, NULL, NULL, 1, 1),
+(9, 'Fluidité', 89, 116, NULL, NULL, NULL, 1, 1),
+(10, 'Nouveau Monde', 89, 125, NULL, NULL, NULL, 1, 1),
+(11, 'Mirage', 73, 100, NULL, NULL, NULL, 1, 1),
+(12, 'Équilibre', 72.5, 116, NULL, NULL, NULL, 2, 1),
+(13, 'Fusion', 72.5, 116, NULL, NULL, NULL, 2, 1),
+(14, 'Étincelles', NULL, NULL, NULL, NULL, NULL, 3, 1),
+(15, 'Régénérescence', NULL, NULL, NULL, NULL, NULL, 3, 1),
+(16, 'Chaleur', 80, 80, NULL, NULL, NULL, 4, 1),
+(17, 'Création', 90, 90, NULL, NULL, NULL, 4, 1),
+(18, 'Horizon', 92, 73, NULL, NULL, NULL, 4, 1),
+(19, 'Labyrinthe', 81, 100, NULL, NULL, NULL, 4, 1),
+(20, 'Miroir', 80, 116, NULL, NULL, NULL, 5, 1),
+(21, 'Libération', 81, 116, NULL, NULL, NULL, 5, 1),
+(22, 'Éclats', 81, 116, NULL, NULL, NULL, 5, 1),
+(23, 'Zénitude', 116, 89, NULL, NULL, NULL, 6, 1),
+(24, 'Écritures lointaines', 90, 90, NULL, NULL, NULL, 7, 1),
+(25, 'Émergence', 80, 80, NULL, NULL, NULL, 7, 1),
+(26, 'Liberté', 50, 50, NULL, NULL, NULL, 7, 1),
+(27, 'Silhouettes amérindiennes', 701, 70, NULL, NULL, NULL, 7, 1),
+(28, 'Puissance', 81, 100, NULL, NULL, NULL, 8, 1),
+(29, 'Source', 73, 116, NULL, NULL, NULL, 8, 1),
+(30, 'Comme une ville qui prend vie', 50, 100, 2008, NULL, NULL, 9, 1),
+(31, 'Suspension azur', 80, 80, NULL, NULL, NULL, 9, 1),
+(32, 'Nébuleuse', 70, 70, NULL, NULL, NULL, 10, 1),
+(33, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(34, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(35, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(36, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(37, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2),
+(38, 'Œuvre commandée 120 P', 114, 195, NULL, NULL, NULL, 1, 2);
+
+# Now we only lest explain to be sure that table materialized. If
+# in the future merged derived table will be processed in a way that
+# rand() can be called only once then other way of testing correctness
+# of this query should be put here.
+explain
+SELECT g.id AS gallery_id,
+ g.name AS gallery_name,
+ p.id AS picture_id,
+ p.name AS picture_name,
+ g.p_random AS r1,
+ g.p_random AS r2,
+ g.p_random AS r3
+FROM
+(
+ SELECT gal.id,
+ gal.name,
+ (
+ SELECT pi.id
+ FROM pictures pi
+ WHERE pi.gallery_id = gal.id
+ ORDER BY RAND()
+ LIMIT 1
+ ) AS p_random
+ FROM galleries gal
+) g
+LEFT JOIN pictures p
+ ON p.id = g.p_random
+ORDER BY gallery_name ASC
+;
+
+drop table galleries, pictures;
+
--echo #
--echo # end of 5.3 tests
--echo #
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 9b1d71db10d..0d1e0fe3fb2 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1450,6 +1450,24 @@ SELECT EXTRACT(HOUR FROM TIME'1 02:00:00'), EXTRACT(HOUR FROM TIME'26:00:00');
SELECT EXTRACT(HOUR FROM TIME('1 02:00:00')), EXTRACT(HOUR FROM TIME('26:00:00'));
SELECT EXTRACT(DAY FROM TIME('1 02:00:00')), EXTRACT(DAY FROM TIME('26:00:00'));
+--echo #
+--echo # MDEV-5458 RQG hits 'sql/tztime.cc:799: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.'
+--echo #
+SET TIMESTAMP=UNIX_TIMESTAMP('2014-01-22 18:19:20');
+CREATE TABLE t1 (t TIME);
+INSERT INTO t1 VALUES ('03:22:30'),('18:30:05');
+SELECT CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00') FROM t1;
+SELECT GREATEST(t, CURRENT_DATE()) FROM t1;
+DROP TABLE t1;
+SET TIMESTAMP=DEFAULT;
+
+--echo #
+--echo # MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP
+--echo #
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT 1 FROM t1 GROUP BY MONTHNAME(0) WITH ROLLUP;
+DROP TABLE t1;
--echo #
--echo # MDEV-4838 Wrong metadata for DATE_ADD('string', INVERVAL)
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index f88b6fbb2fe..8ee17d2b2d3 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1,5 +1,3 @@
---source include/have_innodb.inc
-
# Initialise
--disable_warnings
drop table if exists t1,t2,t3;
@@ -1336,7 +1334,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
let $query0=SELECT col1 AS field1, col1 AS field2
- FROM t1 GROUP BY field1, field2;
+ FROM t1 GROUP BY field1, field2+0;
# Needs to be range to exercise bug
--eval EXPLAIN $query0;
@@ -1366,7 +1364,9 @@ LIMIT 3;
explain
select col1 f1, col1 f2 from t1 order by f2, f1;
-select col1 f1, col1 f2 from t1 order by f2, f1;
+explain
+select col1 f1, col1 f2 from t1 order by f2, f1+0;
+select col1 f1, col1 f2 from t1 order by f2, f1+0;
explain
select col1 f1, col1 f2 from t1 group by f2 order by f2, f1;
@@ -1386,12 +1386,12 @@ INSERT INTO t2(col1, col2) VALUES
(11,10),(12,9),(13,8),(14,7),(15,6),(16,5),(17,4),(18,3),(19,2),(20,1);
explain
-select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3;
-select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3;
+select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3+0;
+select col1 f1, col2 f2, col1 f3 from t2 group by f1, f2, f3+0;
explain
-select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3;
-select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3;
+select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3+0;
+select col1 f1, col2 f2, col1 f3 from t2 order by f1, f2, f3+0;
DROP VIEW v1;
DROP TABLE t1, t2;
@@ -1644,30 +1644,6 @@ FROM t1 JOIN t2 ON c = b GROUP BY b WITH ROLLUP;
DROP TABLE t1,t2;
--echo #
---echo # Test of MDEV-4002
---echo #
-
-CREATE TABLE t1 (
- pk INT NOT NULL PRIMARY KEY,
- d1 DOUBLE,
- d2 DOUBLE,
- i INT NOT NULL DEFAULT '0',
- KEY (i)
-) ENGINE=InnoDB;
-
-INSERT INTO t1 VALUES (1,1.0,1.1,1),(2,2.0,2.2,2);
-
-PREPARE stmt FROM "
-SELECT DISTINCT i, GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
-FROM t1 a1 NATURAL JOIN t1 a2 GROUP BY i WITH ROLLUP
-";
-
-EXECUTE stmt;
-EXECUTE stmt;
-
-DROP TABLE t1;
-
---echo #
--echo # Bug #58782
--echo # Missing rows with SELECT .. WHERE .. IN subquery
--echo # with full GROUP BY and no aggr
diff --git a/mysql-test/t/group_by_innodb.test b/mysql-test/t/group_by_innodb.test
index 0d5e5e9ae30..df213cc189f 100644
--- a/mysql-test/t/group_by_innodb.test
+++ b/mysql-test/t/group_by_innodb.test
@@ -4,6 +4,8 @@
--source include/have_innodb.inc
+set @save_ext_key_optimizer_switch=@@optimizer_switch;
+
--echo #
--echo # MDEV-3992 Server crash or valgrind errors in test_if_skip_sort_order/test_if_cheaper_ordering
--echo # on GROUP BY with indexes on InnoDB table
@@ -15,6 +17,8 @@ CREATE TABLE t1 (
KEY (pk)
) ENGINE=InnoDB;
+set optimizer_switch='extended_keys=on';
+
INSERT INTO t1 VALUES (1,'a'),(2,'b');
EXPLAIN
@@ -35,4 +39,31 @@ WHERE a = 'r' OR pk = 183 GROUP BY field1, field1;
drop table t1;
+set optimizer_switch=@save_ext_key_optimizer_switch;
+
+--echo #
+--echo # MDEV-4002 Server crash or valgrind errors in Item_func_group_concat::setup and Item_func_group_concat::add
+--echo #
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY,
+ d1 DOUBLE,
+ d2 DOUBLE,
+ i INT NOT NULL DEFAULT '0',
+ KEY (i)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (1,1.0,1.1,1),(2,2.0,2.2,2);
+
+PREPARE stmt FROM "
+SELECT DISTINCT i, GROUP_CONCAT( d1, d2 ORDER BY d1, d2 )
+FROM t1 a1 NATURAL JOIN t1 a2 GROUP BY i WITH ROLLUP
+";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+DROP TABLE t1;
+
--echo End of 5.5 tests
+
diff --git a/mysql-test/t/group_by_null.test b/mysql-test/t/group_by_null.test
new file mode 100644
index 00000000000..b3fa2a003ec
--- /dev/null
+++ b/mysql-test/t/group_by_null.test
@@ -0,0 +1,7 @@
+#
+# MDEV-5461 Assertion `length <= column->length' fails in write_block_record with functions in select list, GROUP BY, ORDER BY
+#
+create table t1 (a int);
+insert into t1 values (1),(2);
+select max('foo') from t1 group by values(a), extractvalue('bar','qux') order by "v";
+drop table t1;
diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test
index d62217dd54f..9f3a89ff948 100644
--- a/mysql-test/t/innodb_ext_key.test
+++ b/mysql-test/t/innodb_ext_key.test
@@ -663,6 +663,34 @@ ORDER BY rev_timestamp ASC LIMIT 10;
DROP TABLE t1,t2,t3;
+--echo #
+--echo # MDEV-5424 SELECT using ORDER BY DESC and LIMIT produces unexpected
+--echo # results (InnoDB/XtraDB)
+--echo #
+
+create table t1 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = myisam default character set utf8;
+create table t2 (a bigint not null unique auto_increment, b varchar(10), primary key (a), key (b(2))) engine = innodb default character set utf8;
+
+insert into t1 (b) values (null), (null), (null);
+insert into t2 (b) values (null), (null), (null);
+
+set optimizer_switch='extended_keys=on';
+explain select a from t1 where b is null order by a desc limit 2;
+select a from t1 where b is null order by a desc limit 2;
+explain select a from t2 where b is null order by a desc limit 2;
+select a from t2 where b is null order by a desc limit 2;
+set optimizer_switch='extended_keys=off';
+explain select a from t2 where b is null order by a desc limit 2;
+select a from t2 where b is null order by a desc limit 2;
+
+explain select a from t2 where b is null order by a desc;
+select a from t2 where b is null order by a desc;
+
+explain select a from t2 where b is null order by a desc,a,a;
+select a from t2 where b is null order by a desc,a,a;
+
+drop table t1, t2;
+
set optimizer_switch=@save_optimizer_switch;
set optimizer_switch=@save_ext_key_optimizer_switch;
diff --git a/mysql-test/t/innodb_icp.test b/mysql-test/t/innodb_icp.test
index d6caa36a88e..acb8238e01f 100644
--- a/mysql-test/t/innodb_icp.test
+++ b/mysql-test/t/innodb_icp.test
@@ -45,6 +45,34 @@ ORDER BY e;
DROP TABLE t1,t2,t3;
+--echo #
+--echo # MDEV-5337: Wrong result in mariadb 5.5.32 with ORDER BY + LIMIT when index_condition_pushdown=on
+--echo # MDEV-5512: Wrong result (WHERE clause ignored) with multiple clauses using Percona-XtraDB engine
+--echo #
+
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2 (pk int primary key,
+ key1 char(32),
+ key2 char(32),
+ key(key1),
+ key(key2)
+) engine=innodb;
+
+insert into t2 select
+ A.a+10*B.a+100*C.a,
+ concat('rare-', A.a+10*B.a),
+ concat('rare-', A.a+10*B.a)
+from
+ t1 A, t1 B, t1 C;
+update t2 set key1='frequent-val' where pk between 100 and 350;
+select * from t2 ignore key(PRIMARY)
+where key1='frequent-val' and key2 between 'rare-400' and 'rare-450' order by pk limit 2;
+
+drop table t1, t2;
+
+
set optimizer_switch=@innodb_icp_tmp;
set storage_engine= @save_storage_engine;
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index f9b9fcf266d..ff8396fd7fd 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -555,3 +555,21 @@ INSERT IGNORE t1 (a, a) SELECT 1,1;
INSERT IGNORE t1 (a, a) SELECT 1,1 UNION SELECT 2,2;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-5168: Ensure that we can disable duplicate key warnings
+--echo # from INSERT IGNORE
+--echo #
+
+create table t1 (f1 int unique, f2 int unique);
+insert into t1 values (1,12);
+insert into t1 values (2,13);
+--error ER_DUP_ENTRY
+insert into t1 values (1,12);
+insert ignore into t1 values (1,12);
+set @@old_mode="NO_DUP_KEY_WARNINGS_WITH_IGNORE";
+insert ignore into t1 values (1,12);
+insert ignore into t1 values (1,12) on duplicate key update f2=13;
+set @@old_mode="";
+insert ignore into t1 values (1,12);
+DROP TABLE t1;
diff --git a/mysql-test/t/myisam_optimize.test b/mysql-test/t/myisam_optimize.test
index 2d630f7dbd0..5f0b8fc7666 100644
--- a/mysql-test/t/myisam_optimize.test
+++ b/mysql-test/t/myisam_optimize.test
@@ -44,4 +44,5 @@ disconnect con2;
connection default;
drop table t1;
+set debug_sync='reset';
diff --git a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test
index d29d40f5679..1ba4e91be3c 100644
--- a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test
+++ b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test
@@ -8,8 +8,32 @@
--exec mkdir $MYSQLTEST_VARDIR/zoneinfo
--exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix
--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT
+--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage
+--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab
+--echo # Verbose run
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1
+
+--echo # Silent run
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1
+--echo #
+--echo # Testing with explicit timezonefile
+--echo #
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
+
+--echo #
+--echo # Testing --leap
+--echo #
+
+--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
+
+#
+# Cleanup
+#
+
--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test
index efb1551150f..0261928ac08 100644
--- a/mysql-test/t/mysql_upgrade.test
+++ b/mysql-test/t/mysql_upgrade.test
@@ -41,6 +41,11 @@ GRANT ALL ON *.* TO mysqltest1@'%';
DROP USER mysqltest1@'%';
+#
+# check that we get proper error messages if wrong user
+
+--error 1
+--exec $MYSQL_UPGRADE --force --user=mysqltest1 --password=sakila 2>&1
#
# Bug #26639 mysql_upgrade exits successfully even if external command failed
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index d573c3b5b8a..c4a85e4b111 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -261,6 +261,9 @@ desc,b desc;
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
explain select * from t1 where a = 1 order by b desc;
+explain select * from t1 where a = 2 and b > 0 order by a desc,b desc,b,a;
+explain select * from t1 where a = 2 and b < 2 order by a desc,a,b desc,a,b;
+
select * from t1 where a = 1 order by b desc;
#
# Test things when we don't have NULL keys
@@ -1913,6 +1916,35 @@ SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100;
DROP TABLE t1,t2;
+--echo #
+--echo # MDEV-4974 memory leak in 5.5.32-MariaDB-1~wheezy-log
+--echo #
+set sort_buffer_size=default;
+set max_sort_length=default;
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2 (b int,
+ col1 varchar(255),
+ col2 varchar(255)
+ ) character set utf8;
+
+insert into t2 select
+ A.a+10*B.a,
+ concat('wow-wow-col1-value-', A.a+10*B.a+100*C.a),
+ concat('wow-wow-col2-value-', A.a+10*B.a+100*C.a)
+from
+ t1 A, t1 B, t1 C where C.a < 8;
+
+create table t3 as
+select distinct A.col1 as XX, B.col1 as YY
+from
+ t2 A, t2 B
+where A.b = B.b
+order by A.col2, B.col2 limit 10, 1000000;
+
+drop table t1,t2,t3;
+
--echo End of 5.5 tests
diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test
index 2b9907c0542..69f1cb3257e 100644
--- a/mysql-test/t/perror.test
+++ b/mysql-test/t/perror.test
@@ -27,7 +27,7 @@ enable_query_log;
--exec $MY_PERROR 1062 2>&1
# test errors that contain characters to escape in the text.
---exec $MY_PERROR 1076 2>&1
+--exec $MY_PERROR 1408 2>&1
--exec $MY_PERROR 1459 2>&1
--exec $MY_PERROR 1461 2>&1
diff --git a/mysql-test/t/plugin_vars.test b/mysql-test/t/plugin_vars.test
new file mode 100644
index 00000000000..8ba8fe2ec0e
--- /dev/null
+++ b/mysql-test/t/plugin_vars.test
@@ -0,0 +1,56 @@
+--echo #
+--echo # MDEV-5345 - Deadlock between mysql_change_user(), SHOW VARIABLES and
+--echo # INSTALL PLUGIN
+--echo #
+
+# Prepare test
+delimiter |;
+CREATE PROCEDURE p_install(x INT)
+BEGIN
+ DECLARE CONTINUE HANDLER FOR 1126 BEGIN END;
+ WHILE x DO
+ SET x= x - 1;
+ INSTALL PLUGIN no_such_plugin SONAME 'no_such_object';
+ END WHILE;
+END|
+
+CREATE PROCEDURE p_show_vars(x INT)
+WHILE x DO
+ SET x= x - 1;
+ SHOW VARIABLES;
+END WHILE|
+delimiter ;|
+
+connect(con1, localhost, root,,);
+connect(con2, localhost, root,,);
+
+# Start test
+connection con1;
+--send CALL p_install(100)
+
+connection con2;
+--send CALL p_show_vars(100)
+
+connection default;
+
+disable_result_log;
+let $i= 100;
+while ($i)
+{
+ change_user;
+ dec $i;
+}
+
+# Cleanup
+connection con1;
+reap;
+connection con2;
+reap;
+connection default;
+enable_result_log;
+
+disconnect con1;
+disconnect con2;
+USE test;
+DROP PROCEDURE p_install;
+DROP PROCEDURE p_show_vars;
diff --git a/mysql-test/t/processlist.test b/mysql-test/t/processlist.test
index c7b775cf992..7a2b33699d5 100644
--- a/mysql-test/t/processlist.test
+++ b/mysql-test/t/processlist.test
@@ -32,4 +32,4 @@ connection default;
select command, time < 5 from information_schema.processlist where id != connection_id();
disconnect con1;
-
+set debug_sync='reset';
diff --git a/mysql-test/t/quick_select_4161.test b/mysql-test/t/quick_select_4161.test
index 1e746754b41..87323087622 100644
--- a/mysql-test/t/quick_select_4161.test
+++ b/mysql-test/t/quick_select_4161.test
@@ -50,4 +50,5 @@ connection default;
disconnect killee;
drop table t1;
+set debug_sync='reset';
diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test
index 6536c052019..5b78a352863 100644
--- a/mysql-test/t/repair.test
+++ b/mysql-test/t/repair.test
@@ -190,3 +190,23 @@ set @@autocommit= 0;
repair table t1, t2;
set @@autocommit= default;
drop tables t1, t2;
+
+--echo #
+--echo # Check that we have decent error messages when using crashed
+--echo # .frm file from MySQL 3.23
+--echo #
+
+--echo # Test with a saved table from 3.23
+let $MYSQLD_DATADIR= `select @@datadir`;
+--copy_file std_data/host_old.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/host_old.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/host_old.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+--error ER_GET_ERRNO
+select count(*) from t1;
+check table t1;
+repair table t1;
+repair table t1 use_frm;
+select count(*) from t1;
+check table t1;
+drop table t1;
diff --git a/mysql-test/t/repair_symlink-5543.test b/mysql-test/t/repair_symlink-5543.test
new file mode 100644
index 00000000000..bad65a4175a
--- /dev/null
+++ b/mysql-test/t/repair_symlink-5543.test
@@ -0,0 +1,26 @@
+#
+# MDEV-5543 MyISAM repair unsafe usage of TMD files
+#
+--source include/have_symlink.inc
+--source include/not_windows.inc
+--source include/have_maria.inc
+
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval create table t1 (a int) engine=myisam data directory='$MYSQL_TMP_DIR';
+insert t1 values (1);
+--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t1.TMD
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+repair table t1;
+drop table t1;
+
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval create table t2 (a int) engine=aria data directory='$MYSQL_TMP_DIR';
+insert t2 values (1);
+--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t2.TMD
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+repair table t2;
+drop table t2;
+
+--list_files $MYSQL_TMP_DIR foobar5543
+--system rm $MYSQL_TMP_DIR/t1.TMD $MYSQL_TMP_DIR/t2.TMD
+
diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test
index 1ec154f1c69..8e6a25709aa 100644
--- a/mysql-test/t/sp-bugs.test
+++ b/mysql-test/t/sp-bugs.test
@@ -238,3 +238,59 @@ DROP FUNCTION testf_bug11763507;
--echo #END OF BUG#11763507 test.
+--echo #
+--echo # MDEV-5531 double call procedure in one session
+--echo #
+
+CREATE TABLE `t1` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `create_ts` int(10) unsigned DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
+
+DELIMITER $$;
+
+CREATE PROCEDURE test_5531 (IN step TINYINT(1))
+BEGIN
+ DECLARE counts INT DEFAULT 0;
+ DECLARE cur1 CURSOR FOR
+
+ SELECT ct.id
+ FROM (SELECT NULL) AS z
+ JOIN (
+ SELECT id
+ FROM `t1`
+ LIMIT 10
+ ) AS ct
+ JOIN (SELECT NULL) AS x ON(
+ EXISTS(
+ SELECT 1
+ FROM `t1`
+ WHERE id=ct.id
+ LIMIT 1
+ )
+ );
+
+ IF step=1 THEN
+ TRUNCATE t1;
+ REPEAT
+ INSERT INTO `t1`
+ (create_ts) VALUES
+ (UNIX_TIMESTAMP());
+
+ SET counts=counts+1;
+ UNTIL counts>150 END REPEAT;
+
+ SET max_sp_recursion_depth=1;
+
+ CALL test_5531(2);
+ SET max_sp_recursion_depth=2;
+ CALL test_5531(2);
+ ELSEIF step=2 THEN
+ OPEN cur1; CLOSE cur1;
+ END IF;
+END $$
+DELIMITER ;$$
+CALL test_5531(1);
+DROP PROCEDURE test_5531;
+DROP TABLE t1;
diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test
index 536606175bb..a6ce3f25617 100644
--- a/mysql-test/t/subselect_sj.test
+++ b/mysql-test/t/subselect_sj.test
@@ -2634,6 +2634,7 @@ INSERT INTO t2 VALUES ('x');
CREATE TABLE t3 (c3 VARCHAR(1)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('x'),('d');
+--sorted_result
SELECT * FROM t1, t2 WHERE pk IN ( SELECT pk FROM t1 LEFT JOIN t3 ON (c1 = c3 ) ) ORDER BY c2, c1;
--echo # This should show that "t1 left join t3" is still in the semi-join nest:
diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test
index 58831c4ffb3..52a73d24822 100644
--- a/mysql-test/t/subselect_sj_mat.test
+++ b/mysql-test/t/subselect_sj_mat.test
@@ -1725,6 +1725,26 @@ INSERT INTO t1 VALUES (1,3,5),(2,4,6);
SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b);
DROP TABLE t1;
+--echo #
+--echo # MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd
+--echo # execution of PS with IN subqueries, materialization+semijoin
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3);
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (8),(9);
+
+PREPARE stmt FROM "
+SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) )
+";
+
+EXECUTE stmt;
+EXECUTE stmt;
+DROP TABLE t1, t2;
+DROP VIEW v2;
+
--echo # End of 5.3 tests
@@ -1750,5 +1770,25 @@ WHERE ( alias2.c2, alias1.c1 ) IN ( SELECT c4, c3 FROM t2 ) AND alias1.c1 IN ( S
DROP TABLE t1,t2;
set join_cache_level=@tmp_mdev5056;
+--echo #
+--echo # MDEV-5368: Server crashes in Item_in_subselect::optimize on 2nd
+--echo # execution of PS with IN subqueries, materialization+semijoin
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3);
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (8),(9);
+
+PREPARE stmt FROM "
+SELECT * FROM t1 WHERE 1 IN ( SELECT b FROM v2 WHERE 2 IN ( SELECT MAX(a) FROM t1 ) )
+";
+
+EXECUTE stmt;
+EXECUTE stmt;
+DROP TABLE t1, t2;
+DROP VIEW v2;
+
--echo # End of 5.5 tests
diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test
index 7764b39bf33..2d61c7631f2 100644
--- a/mysql-test/t/timezone2.test
+++ b/mysql-test/t/timezone2.test
@@ -298,5 +298,11 @@ SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5');
SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5');
--echo #
+--echo # MDEV-5506 safe_mutex: Trying to lock unitialized mutex at safemalloc.c on server shutdown after SELECT with CONVERT_TZ
+--echo #
+SELECT CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' );
+
+
+--echo #
--echo # End of 5.3 tests
--echo #
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 5cb9d920c0c..c7a7e332236 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -4873,6 +4873,51 @@ deallocate prepare stmt;
drop view v1;
drop table t1,t2;
+#
+# MDEV-5414: RAND() in a subselect : different behavior in MariaDB and MySQL
+#
+create table t1 (a int);
+insert into t1 values (1),(2);
+
+create view v1 (a,r) as select a,rand() from t1;
+
+
+create table t2 select a, r as r1, r as r2, r as r3 from v1;
+
+select a, r1 = r2, r2 = r3 from t2;
+
+drop view v1;
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-5515: 2nd execution of a prepared statement returns wrong results
+--echo #
+CREATE TABLE t1 (i1 INT, j1 INT NOT NULL, PRIMARY KEY (i1));
+
+INSERT INTO t1 VALUES (30,300),(40,400);
+
+CREATE TABLE t2 (i2 INT);
+INSERT INTO t2 VALUES (50),(60);
+
+CREATE TABLE t3 (c3 VARCHAR(20), i3 INT);
+INSERT INTO t3 VALUES ('a',10),('b',2);
+
+CREATE TABLE t4 (i4 INT);
+INSERT INTO t4 VALUES (1),(2);
+
+DROP VIEW IF EXISTS v1;
+CREATE VIEW v1 AS select coalesce(j1,i3) AS v1_field1 from t2 join t3 left join t1 on ( i1 = i2 );
+
+CREATE VIEW v2 AS select v1_field1 from t4 join v1;
+
+prepare my_stmt from "select v1_field1 from v2";
+execute my_stmt;
+execute my_stmt;
+deallocate prepare my_stmt;
+
+DROP VIEW v1,v2;
+DROP TABLE t1,t2,t3,t4;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.3 tests.
--echo # -----------------------------------------------------------------