summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-12-15 15:57:26 +0100
committerSergei Golubchik <sergii@pisem.net>2013-12-15 15:57:26 +0100
commit6bf10fac445d73fb796d4863612c87bff5f28b66 (patch)
tree4d51e193684163c21e47e9de6536cd8dae0613eb /mysql-test
parent8efaff4959efe32ff9bc47c1bf1710cfe9ab21b5 (diff)
parent39a8d7965d912d8fb32436735449ce04e85583d1 (diff)
downloadmariadb-git-6bf10fac445d73fb796d4863612c87bff5f28b66.tar.gz
5.5 merge
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/CMakeLists.txt24
-rw-r--r--mysql-test/lib/My/Suite.pm1
-rw-r--r--mysql-test/lib/mtr_cases.pm67
-rwxr-xr-xmysql-test/mysql-test-run.pl70
-rw-r--r--mysql-test/r/derived.result14
-rw-r--r--mysql-test/r/func_time.result31
-rw-r--r--mysql-test/r/merge.result7
-rw-r--r--mysql-test/r/ps.result23
-rw-r--r--mysql-test/r/table_elim.result28
-rw-r--r--mysql-test/r/union.result15
-rw-r--r--mysql-test/t/derived.test10
-rw-r--r--mysql-test/t/func_time.test12
-rw-r--r--mysql-test/t/merge.test9
-rw-r--r--mysql-test/t/ps.test22
-rw-r--r--mysql-test/t/table_elim.test31
-rw-r--r--mysql-test/t/union.test16
16 files changed, 303 insertions, 77 deletions
diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt
index 5ffbd78316c..16eb2a6f166 100644
--- a/mysql-test/CMakeLists.txt
+++ b/mysql-test/CMakeLists.txt
@@ -13,29 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-IF(INSTALL_MYSQLTESTDIR)
-INSTALL(
- DIRECTORY .
- DESTINATION ${INSTALL_MYSQLTESTDIR}
- USE_SOURCE_PERMISSIONS
- COMPONENT Test
- PATTERN "var/" EXCLUDE
- PATTERN "lib/My/SafeProcess" EXCLUDE
- PATTERN "lib/t*" EXCLUDE
- PATTERN "CPack" EXCLUDE
- PATTERN "CMake*" EXCLUDE
- PATTERN "mtr.out*" EXCLUDE
- PATTERN ".cvsignore" EXCLUDE
- PATTERN "*.am" EXCLUDE
- PATTERN "*.in" EXCLUDE
- PATTERN "*.vcxproj" EXCLUDE
- PATTERN "*.vcxproj.filters" EXCLUDE
- PATTERN "*.vcxproj.user" EXCLUDE
- PATTERN "CTest" EXCLUDE
-)
-ENDIF()
-
-
+INSTALL_MYSQL_TEST("." ".")
IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# Enable running mtr from build directory
diff --git a/mysql-test/lib/My/Suite.pm b/mysql-test/lib/My/Suite.pm
index b5870ea1e16..a603008fabe 100644
--- a/mysql-test/lib/My/Suite.pm
+++ b/mysql-test/lib/My/Suite.pm
@@ -3,6 +3,7 @@
package My::Suite;
+sub is_default { 0 }
sub config_files { () }
sub servers { () }
sub skip_combinations { () }
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index 1327afdb426..870df115f58 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -23,7 +23,7 @@ package mtr_cases;
use strict;
use base qw(Exporter);
-our @EXPORT= qw(collect_option collect_test_cases);
+our @EXPORT= qw(collect_option collect_test_cases collect_default_suites);
use Carp;
@@ -62,6 +62,21 @@ use My::Suite;
require "mtr_misc.pl";
+# locate plugin suites, depending on whether it's a build tree or installed
+my @plugin_suitedirs;
+my $plugin_suitedir_regex;
+my $overlay_regex;
+
+if (-d '../sql') {
+ @plugin_suitedirs= ('storage/*/mysql-test', 'plugin/*/mysql-test');
+ $overlay_regex= '\b(?:storage|plugin)/(\w+)/mysql-test\b';
+} else {
+ @plugin_suitedirs= ('mysql-test/plugin/*');
+ $overlay_regex= '\bmysql-test/plugin/(\w+)\b';
+}
+$plugin_suitedir_regex= $overlay_regex;
+$plugin_suitedir_regex=~ s/\Q(\w+)\E/\\w+/;
+
# Precompiled regex's for tests to do or skip
my $do_test_reg;
my $skip_test_reg;
@@ -263,12 +278,11 @@ sub load_suite_object {
# returns a pair of (suite, suitedir)
-sub load_suite_for_file($) {
+sub suite_for_file($) {
my ($file) = @_;
- return load_suite_object($2, $1)
- if $file =~ m@^(.*/(?:storage|plugin)/\w+/mysql-test/(\w+))/@;
- return load_suite_object($2, $1) if $file =~ m@^(.*/mysql-test/suite/(\w+))/@;
- return load_suite_object('main', $1) if $file =~ m@^(.*/mysql-test)/@;
+ return ($2, $1) if $file =~ m@^(.*/$plugin_suitedir_regex/(\w+))/@o;
+ return ($2, $1) if $file =~ m@^(.*/mysql-test/suite/(\w+))/@;
+ return ('main', $1) if $file =~ m@^(.*/mysql-test)/@;
mtr_error("Cannot determine suite for $file");
}
@@ -316,10 +330,32 @@ sub parse_disabled {
}
#
+# load suite.pm files from plugin suites
+# collect the list of default plugin suites.
+# XXX currently it does not support nested suites
+#
+sub collect_default_suites(@)
+{
+ my @dirs = my_find_dir(dirname($::glob_mysql_test_dir),
+ [ @plugin_suitedirs ], '*');
+ for my $d (@dirs) {
+ next unless -f "$d/suite.pm";
+ my $sname= basename($d);
+ # ignore overlays here, otherwise we'd need accurate
+ # duplicate detection with overlay support for the default suite list
+ next if $sname eq 'main' or -d "$::glob_mysql_test_dir/suite/$sname";
+ my $s = load_suite_object($sname, $d);
+ push @_, $sname if $s->is_default();
+ }
+ return @_;
+}
+
+
+#
# processes one user-specified suite name.
# it could contain wildcards, e.g engines/*
#
-sub collect_suite_name
+sub collect_suite_name($$)
{
my $suitename= shift; # Test suite name
my $opt_cases= shift;
@@ -339,25 +375,22 @@ sub collect_suite_name
else
{
my @dirs = my_find_dir(dirname($::glob_mysql_test_dir),
- ["mysql-test/suite",
- "storage/*/mysql-test",
- "plugin/*/mysql-test"],
- [$suitename]);
+ ["mysql-test/suite", @plugin_suitedirs ],
+ $suitename);
#
# if $suitename contained wildcards, we'll have many suites and
# their overlays here. Let's group them appropriately.
#
for (@dirs) {
- m@^.*/mysql-test/(?:suite/)?(.*)$@ or confess $_;
+ m@^.*/(?:mysql-test/suite|$plugin_suitedir_regex)/(.*)$@o or confess $_;
push @{$suites{$1}}, $_;
}
}
} else {
$suites{$suitename} = [ $::glob_mysql_test_dir,
my_find_dir(dirname($::glob_mysql_test_dir),
- ["storage/*/mysql-test",
- "plugin/*/mysql-test"],
- ['main'], NOT_REQUIRED) ];
+ [ @plugin_suitedirs ],
+ 'main', NOT_REQUIRED) ];
}
my @cases;
@@ -404,7 +437,7 @@ sub collect_one_suite {
local %file_combinations = ();
local %file_in_overlay = ();
- confess $_ unless m@/(?:storage|plugin)/(\w+)/mysql-test/[\w/]*\w$@;
+ confess $_ unless m@/$overlay_regex/@o;
next unless defined $over and ($over eq '' or $over eq $1);
push @cases,
# don't add cases that take *all* data from the parent suite
@@ -1050,7 +1083,7 @@ sub get_tags_from_file($$) {
# for combinations we need to make sure that its suite object is loaded,
# even if this file does not belong to a current suite!
my $comb_file = "$suffix.combinations";
- $suite = load_suite_for_file($comb_file) if $prefix[0] eq '';
+ $suite = load_suite_object(suite_for_file($comb_file)) if $prefix[0] eq '';
my @comb;
unless ($suite->{skip}) {
my $from = "$prefix[0]$comb_file";
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 26d1bfd420a..d368e968014 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -162,32 +162,32 @@ my $path_config_file; # The generated config file, var/my.cnf
# executables will be used by the test suite.
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
-my $DEFAULT_SUITES= join(',', map { "$_-" } qw(
- main
- archive
- binlog
- csv
- federated
- funcs_1
- funcs_2
- handler
- heap
- innodb
- maria
- multi_source
- optimizer_unfixed_bugs
- oqgraph
- parts
- percona
- perfschema
- plugins
- roles
- rpl
- sphinx
- sys_vars
- unit
- vcol
- ));
+my @DEFAULT_SUITES= qw(
+ main-
+ archive-
+ binlog-
+ csv-
+ federated-
+ funcs_1-
+ funcs_2-
+ handler-
+ heap-
+ innodb-
+ maria-
+ multi_source-
+ optimizer_unfixed_bugs-
+ oqgraph-
+ parts-
+ percona-
+ perfschema-
+ plugins-
+ roles-
+ rpl-
+ sphinx-
+ sys_vars-
+ unit-
+ vcol-
+ );
my $opt_suites;
our $opt_verbose= 0; # Verbose output, enable with --verbose
@@ -378,8 +378,6 @@ sub main {
# directly before it executes them, like "make test-force-pl" in RPM builds.
mtr_report("Logging: $0 ", join(" ", @ARGV));
- $DEFAULT_SUITES.=",sequence,sql_discovery,query_response_time" if $source_dist;
-
command_line_setup();
# --help will not reach here, so now it's safe to assume we have binaries
@@ -390,11 +388,6 @@ sub main {
}
- if (!$opt_suites) {
- $opt_suites= $DEFAULT_SUITES;
- }
- mtr_report("Using suites: $opt_suites") unless @opt_cases;
-
print "vardir: $opt_vardir\n";
initialize_servers();
init_timers();
@@ -403,6 +396,11 @@ sub main {
executable_setup();
+ if (!$opt_suites) {
+ $opt_suites= join ',', collect_default_suites(@DEFAULT_SUITES);
+ }
+ mtr_report("Using suites: $opt_suites") unless @opt_cases;
+
# --debug[-common] implies we run debug server
$opt_debug_server= 1 if $opt_debug || $opt_debug_common;
@@ -2950,7 +2948,7 @@ sub check_ndbcluster_support {
mtr_report(" - enabling ndbcluster");
$ndbcluster_enabled= 1;
# Add MySQL Cluster test suites
- $DEFAULT_SUITES.=",ndb,ndb_binlog,rpl_ndb,ndb_rpl,ndb_memcache";
+ push @DEFAULT_SUITES, qw(ndb ndb_binlog rpl_ndb ndb_rpl ndb_memcache);
return;
}
@@ -6319,6 +6317,8 @@ sub usage ($) {
exit;
}
+ local $"= ','; # for @DEFAULT_SUITES below
+
print <<HERE;
$0 [ OPTIONS ] [ TESTCASE ]
@@ -6386,7 +6386,7 @@ Options to control what test suites or cases to run
suite[s]=NAME1,..,NAMEN
Collect tests in suites from the comma separated
list of suite names.
- The default is: "$DEFAULT_SUITES"
+ The default is: "@DEFAULT_SUITES"
skip-rpl Skip the replication test cases.
big-test Also run tests marked as "big". Repeat this option
twice to run only "big" tests.
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 9d31ceab4d1..699d3279e3e 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -465,6 +465,20 @@ t1.val=t3.val
;
ERROR 42S22: Unknown column 'v.val' in 'field list'
drop table t1, t2;
+#
+# MDEV-5353: server crash on subselect if WHERE applied to some
+# result field
+#
+SELECT * FROM
+( SELECT 100 a, subsel.b FROM ( SELECT 200 b ) subsel ) tmp
+WHERE tmp.b;
+a b
+100 200
+SELECT * FROM
+( SELECT 100 a, subsel.b FROM ( SELECT 200 b ) subsel ) tmp
+WHERE tmp.a;
+a b
+100 200
# End of 5.3 tests
#
# Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 45457e6a4fd..938b0ee005f 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -365,7 +365,7 @@ extract(DAY_MINUTE FROM "02 10:11:12")
21011
select extract(DAY_SECOND FROM "225 10:11:12");
extract(DAY_SECOND FROM "225 10:11:12")
-8385959
+34225959
Warnings:
Warning 1292 Truncated incorrect time value: '225 10:11:12'
select extract(HOUR FROM "1999-01-02 10:11:12");
@@ -1025,7 +1025,7 @@ Note 1105 Cast to unsigned converted negative integer to it's positive complemen
Warning 1292 Truncated incorrect time value: '18446744073709551615:00:00'
SELECT EXTRACT(HOUR FROM '10000:02:03');
EXTRACT(HOUR FROM '10000:02:03')
-838
+22
Warnings:
Warning 1292 Truncated incorrect time value: '10000:02:03'
CREATE TABLE t1(f1 TIME);
@@ -2347,3 +2347,30 @@ DROP TABLE t1;
SELECT MAKETIME(0, 0, -0.1);
MAKETIME(0, 0, -0.1)
NULL
+#
+# MDEV-4857 Wrong result of HOUR('1 00:00:00')
+#
+SELECT HOUR('1 02:00:00'), HOUR('26:00:00');
+HOUR('1 02:00:00') HOUR('26:00:00')
+26 26
+SELECT HOUR(TIME'1 02:00:00'), HOUR(TIME'26:00:00');
+HOUR(TIME'1 02:00:00') HOUR(TIME'26:00:00')
+26 26
+SELECT HOUR(TIME('1 02:00:00')), HOUR(TIME('26:00:00'));
+HOUR(TIME('1 02:00:00')) HOUR(TIME('26:00:00'))
+26 26
+SELECT DAY(TIME('1 02:00:00')), DAY(TIME('26:00:00'));
+DAY(TIME('1 02:00:00')) DAY(TIME('26:00:00'))
+0 0
+SELECT EXTRACT(HOUR FROM '1 02:00:00'), EXTRACT(HOUR FROM '26:00:00');
+EXTRACT(HOUR FROM '1 02:00:00') EXTRACT(HOUR FROM '26:00:00')
+2 2
+SELECT EXTRACT(HOUR FROM TIME'1 02:00:00'), EXTRACT(HOUR FROM TIME'26:00:00');
+EXTRACT(HOUR FROM TIME'1 02:00:00') EXTRACT(HOUR FROM TIME'26:00:00')
+2 2
+SELECT EXTRACT(HOUR FROM TIME('1 02:00:00')), EXTRACT(HOUR FROM TIME('26:00:00'));
+EXTRACT(HOUR FROM TIME('1 02:00:00')) EXTRACT(HOUR FROM TIME('26:00:00'))
+2 2
+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
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 5c4261e7d6d..c0b23651e70 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -2394,6 +2394,13 @@ REPAIR TABLE m1;
Table Op Msg_type Msg_text
test.m1 repair note The storage engine for the table doesn't support repair
DROP TABLE m1, t1;
+create temporary table t1_temp(i int);
+create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last;
+alter table tm_temp_temp insert_method=first;
+check table tm_temp_temp;
+Table Op Msg_type Msg_text
+test.tm_temp_temp check status OK
+drop temporary table t1_temp, tm_temp_temp;
End of 5.1 tests
#
# MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 4f41151f555..fa15bcf5576 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -3996,4 +3996,27 @@ Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
deallocate prepare st;
drop table t1;
+#
+# Bug mdev-5410: crash at the execution of PS with subselect
+# formed by UNION with global ORDER BY
+#
+CREATE TABLE t1 (a int DEFAULT NULL);
+INSERT INTO t1 VALUES (2), (4);
+CREATE TABLE t2 (b int DEFAULT NULL);
+INSERT INTO t2 VALUES (1), (3);
+PREPARE stmt FROM "
+SELECT c1 FROM (SELECT (SELECT a FROM t1 WHERE t1.a <= t2.b
+ UNION ALL
+ SELECT a FROM t1 WHERE t1.a+3<= t2.b
+ ORDER BY a DESC) AS c1 FROM t2) t3;
+";
+EXECUTE stmt;
+c1
+NULL
+2
+EXECUTE stmt;
+c1
+NULL
+2
+DROP TABLE t1,t2;
# End of 5.3 tests
diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result
index 59054607acb..ff488fea427 100644
--- a/mysql-test/r/table_elim.result
+++ b/mysql-test/r/table_elim.result
@@ -610,6 +610,34 @@ id select_type table type possible_keys key key_len ref rows Extra
drop view v1;
DROP TABLE t1,t2,t3;
#
+# MDEV-5344: LEFT OUTER JOIN table data is lost in ON DUPLICATE KEY UPDATE section
+#
+create table t1 (
+id int(10) unsigned NOT NULL DEFAULT '0',
+v int(10) unsigned DEFAULT '0',
+PRIMARY KEY (id)
+);
+create table t2 (
+id int(10) unsigned NOT NULL DEFAULT '0',
+PRIMARY KEY (id)
+) ;
+create table t3 (
+id int(10) unsigned NOT NULL DEFAULT '0',
+v int(10) unsigned DEFAULT '0',
+PRIMARY KEY (id)
+);
+insert into t1 values (1, 10), (2, 10);
+insert into t2 values (1), (2);
+insert into t3 values (1, 20);
+insert into t1
+select t2.id, 5 from t2 LEFT OUTER JOIN t3 ON t2.id = t3.id
+on duplicate key update t1.v = t3.v;
+select * from t1;
+id v
+1 20
+2 NULL
+drop table t1,t2,t3;
+#
# BUG#919878: Assertion `!eliminated_tables...
#
CREATE TABLE t1 ( a INT );
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index d1be5e233df..a3ad63c035a 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1734,6 +1734,21 @@ i
6
DROP VIEW v1;
DROP TABLE t1;
+#
+# mdev-5382: UNION with ORDER BY in subselect
+#
+CREATE TABLE t1 (a int DEFAULT NULL);
+INSERT INTO t1 VALUES (2), (4);
+CREATE TABLE t2 (b int DEFAULT NULL);
+INSERT INTO t2 VALUES (1), (3);
+SELECT c1 FROM (SELECT (SELECT a FROM t1 WHERE t1.a <= t2.b
+UNION ALL
+SELECT a FROM t1 WHERE t1.a+3<= t2.b
+ORDER BY a DESC) AS c1 FROM t2) t3;
+c1
+NULL
+2
+DROP TABLE t1,t2;
End of 5.3 tests
#
# Bug#57986 ORDER BY clause is not used after a UNION,
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index a67a0e6c9d0..559a8b76280 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -383,7 +383,17 @@ set
drop table t1, t2;
+--echo #
+--echo # MDEV-5353: server crash on subselect if WHERE applied to some
+--echo # result field
+--echo #
+SELECT * FROM
+( SELECT 100 a, subsel.b FROM ( SELECT 200 b ) subsel ) tmp
+WHERE tmp.b;
+SELECT * FROM
+( SELECT 100 a, subsel.b FROM ( SELECT 200 b ) subsel ) tmp
+WHERE tmp.a;
--echo # End of 5.3 tests
--echo #
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 045b91b3e7b..b9e57483b7e 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1437,3 +1437,15 @@ DROP TABLE t1;
--echo #
SELECT MAKETIME(0, 0, -0.1);
+--echo #
+--echo # MDEV-4857 Wrong result of HOUR('1 00:00:00')
+--echo #
+SELECT HOUR('1 02:00:00'), HOUR('26:00:00');
+SELECT HOUR(TIME'1 02:00:00'), HOUR(TIME'26:00:00');
+SELECT HOUR(TIME('1 02:00:00')), HOUR(TIME('26:00:00'));
+SELECT DAY(TIME('1 02:00:00')), DAY(TIME('26:00:00'));
+
+SELECT EXTRACT(HOUR FROM '1 02:00:00'), EXTRACT(HOUR FROM '26:00:00');
+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'));
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 7e198275730..6573c2b09c0 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -1830,6 +1830,15 @@ REPAIR TABLE m1;
#
DROP TABLE m1, t1;
+#
+# MDEV-5266 MySQL:57657 - Temporary MERGE table with temporary underlying is broken by ALTER
+#
+create temporary table t1_temp(i int);
+create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last;
+alter table tm_temp_temp insert_method=first;
+check table tm_temp_temp;
+drop temporary table t1_temp, tm_temp_temp;
+
--echo End of 5.1 tests
--echo #
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index ff28631862c..5f4c815a192 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -3572,4 +3572,26 @@ show status like '%Handler_read%';
deallocate prepare st;
drop table t1;
+--echo #
+--echo # Bug mdev-5410: crash at the execution of PS with subselect
+--echo # formed by UNION with global ORDER BY
+--echo #
+
+CREATE TABLE t1 (a int DEFAULT NULL);
+INSERT INTO t1 VALUES (2), (4);
+CREATE TABLE t2 (b int DEFAULT NULL);
+INSERT INTO t2 VALUES (1), (3);
+
+PREPARE stmt FROM "
+SELECT c1 FROM (SELECT (SELECT a FROM t1 WHERE t1.a <= t2.b
+ UNION ALL
+ SELECT a FROM t1 WHERE t1.a+3<= t2.b
+ ORDER BY a DESC) AS c1 FROM t2) t3;
+";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+DROP TABLE t1,t2;
+
--echo # End of 5.3 tests
diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test
index 357953290c4..0d42dca57b7 100644
--- a/mysql-test/t/table_elim.test
+++ b/mysql-test/t/table_elim.test
@@ -544,6 +544,37 @@ drop view v1;
DROP TABLE t1,t2,t3;
--echo #
+--echo # MDEV-5344: LEFT OUTER JOIN table data is lost in ON DUPLICATE KEY UPDATE section
+--echo #
+create table t1 (
+ id int(10) unsigned NOT NULL DEFAULT '0',
+ v int(10) unsigned DEFAULT '0',
+ PRIMARY KEY (id)
+);
+
+create table t2 (
+ id int(10) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (id)
+) ;
+
+create table t3 (
+ id int(10) unsigned NOT NULL DEFAULT '0',
+ v int(10) unsigned DEFAULT '0',
+ PRIMARY KEY (id)
+);
+
+insert into t1 values (1, 10), (2, 10);
+insert into t2 values (1), (2);
+insert into t3 values (1, 20);
+
+insert into t1
+select t2.id, 5 from t2 LEFT OUTER JOIN t3 ON t2.id = t3.id
+on duplicate key update t1.v = t3.v;
+
+select * from t1;
+drop table t1,t2,t3;
+
+--echo #
--echo # BUG#919878: Assertion `!eliminated_tables...
--echo #
CREATE TABLE t1 ( a INT );
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index faa35de3ec1..a53427f7fc6 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -1188,6 +1188,22 @@ deallocate prepare stmt1;
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # mdev-5382: UNION with ORDER BY in subselect
+--echo #
+
+ CREATE TABLE t1 (a int DEFAULT NULL);
+ INSERT INTO t1 VALUES (2), (4);
+ CREATE TABLE t2 (b int DEFAULT NULL);
+ INSERT INTO t2 VALUES (1), (3);
+
+ SELECT c1 FROM (SELECT (SELECT a FROM t1 WHERE t1.a <= t2.b
+ UNION ALL
+ SELECT a FROM t1 WHERE t1.a+3<= t2.b
+ ORDER BY a DESC) AS c1 FROM t2) t3;
+
+ DROP TABLE t1,t2;
+
--echo End of 5.3 tests
--echo #