summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-09-18 20:14:21 +0200
committerSergei Golubchik <sergii@pisem.net>2013-09-18 20:14:21 +0200
commit275101c624897588b97a872da0589a03dd01e5fb (patch)
tree65cc50a9653190a63c545594b46a2a8e6d78f16f /mysql-test
parentd4f83cc40c03996b2e4dcaa5d9e0a75b815d6d58 (diff)
parent4ec2e9d7eda78d409d1b017ef4d8928fe9055438 (diff)
downloadmariadb-git-275101c624897588b97a872da0589a03dd01e5fb.tar.gz
merge
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/CMakeLists.txt20
-rw-r--r--mysql-test/include/default_mysqld.cnf4
-rw-r--r--mysql-test/include/have_pbxt.opt1
-rw-r--r--mysql-test/lib/mtr_cases.pm37
-rwxr-xr-xmysql-test/mysql-test-run.pl12
-rw-r--r--mysql-test/r/bad_frm_crash_5029.result2
-rw-r--r--mysql-test/r/ctype_binary.result20
-rw-r--r--mysql-test/r/ctype_cp1251.result20
-rw-r--r--mysql-test/r/ctype_latin1.result20
-rw-r--r--mysql-test/r/ctype_ucs.result20
-rw-r--r--mysql-test/r/ctype_utf8.result20
-rw-r--r--mysql-test/r/date_formats.result108
-rw-r--r--mysql-test/r/derived.result39
-rw-r--r--mysql-test/r/drop_bad_db_type.result12
-rw-r--r--mysql-test/r/func_group.result13
-rw-r--r--mysql-test/r/func_sapdb.result6
-rw-r--r--mysql-test/r/func_str.result4
-rw-r--r--mysql-test/r/func_time.result411
-rw-r--r--mysql-test/r/func_time_hires.result20
-rw-r--r--mysql-test/r/grant.result2
-rw-r--r--mysql-test/r/group_min_max.result5
-rw-r--r--mysql-test/r/information_schema.result2
-rw-r--r--mysql-test/r/join.result21
-rw-r--r--mysql-test/r/join_outer.result84
-rw-r--r--mysql-test/r/join_outer_jcl6.result84
-rw-r--r--mysql-test/r/myisam_optimize.result23
-rw-r--r--mysql-test/r/mysqldump.result2
-rw-r--r--mysql-test/r/null.result30
-rw-r--r--mysql-test/r/partition_myisam.result7
-rw-r--r--mysql-test/r/plugin.result82
-rw-r--r--mysql-test/r/ps_2myisam.result12
-rw-r--r--mysql-test/r/ps_3innodb.result12
-rw-r--r--mysql-test/r/ps_4heap.result12
-rw-r--r--mysql-test/r/ps_5merge.result24
-rw-r--r--mysql-test/r/range.result49
-rw-r--r--mysql-test/r/range_mrr_icp.result49
-rw-r--r--mysql-test/r/select.result114
-rw-r--r--mysql-test/r/select_jcl6.result114
-rw-r--r--mysql-test/r/select_pkeycache.result114
-rw-r--r--mysql-test/r/sp.result39
-rw-r--r--mysql-test/r/subselect2.result53
-rw-r--r--mysql-test/r/subselect_mat.result22
-rw-r--r--mysql-test/r/subselect_sj.result2
-rw-r--r--mysql-test/r/subselect_sj2_mat.result2
-rw-r--r--mysql-test/r/subselect_sj_jcl6.result2
-rw-r--r--mysql-test/r/subselect_sj_mat.result22
-rw-r--r--mysql-test/r/table_elim.result20
-rw-r--r--mysql-test/r/timezone.result4
-rw-r--r--mysql-test/r/timezone4.result2
-rw-r--r--mysql-test/r/type_date.result38
-rw-r--r--mysql-test/r/type_datetime.result9
-rw-r--r--mysql-test/r/type_time.result4
-rw-r--r--mysql-test/r/view.result2
-rw-r--r--mysql-test/r/view_grant.result2
-rw-r--r--mysql-test/std_data/mdev5029.frmbin0 -> 8602 bytes
-rw-r--r--mysql-test/std_data/pbxt_load_unique_error1.inc5
-rw-r--r--mysql-test/suite/binlog/t/binlog_killed_simulate.test9
-rw-r--r--mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc2
-rw-r--r--mysql-test/suite/engines/rr_trx/include/rr_init.test8
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is_embedded.result5
-rw-r--r--mysql-test/suite/funcs_1/r/is_tables_is.result4
-rw-r--r--mysql-test/suite/funcs_1/r/is_tables_is_embedded.result4
-rw-r--r--mysql-test/suite/funcs_1/t/is_columns_is_embedded.test3
-rw-r--r--mysql-test/suite/funcs_1/t/is_tables_is.test2
-rw-r--r--mysql-test/suite/funcs_1/t/is_tables_is_embedded.test2
-rw-r--r--mysql-test/suite/maria/ps_maria.result12
-rw-r--r--mysql-test/suite/rpl/r/last_insert_id.result18
-rw-r--r--mysql-test/suite/rpl/t/last_insert_id.cnf20
-rw-r--r--mysql-test/suite/rpl/t/last_insert_id.test30
-rw-r--r--mysql-test/suite/vcol/r/vcol_misc.result8
-rw-r--r--mysql-test/suite/vcol/t/vcol_misc.test11
-rw-r--r--mysql-test/t/bad_frm_crash_5029.test11
-rw-r--r--mysql-test/t/client_xml.test2
-rw-r--r--mysql-test/t/derived.test46
-rw-r--r--mysql-test/t/drop_bad_db_type.test25
-rw-r--r--mysql-test/t/func_group.test20
-rw-r--r--mysql-test/t/func_str.test8
-rw-r--r--mysql-test/t/func_time.test243
-rw-r--r--mysql-test/t/group_min_max.test2
-rw-r--r--mysql-test/t/information_schema.test2
-rw-r--r--mysql-test/t/insert.test2
-rw-r--r--mysql-test/t/join.test16
-rw-r--r--mysql-test/t/join_outer.test90
-rw-r--r--mysql-test/t/myisam_optimize.test47
-rw-r--r--mysql-test/t/mysqlbinlog.test1
-rw-r--r--mysql-test/t/mysqld--help.test2
-rw-r--r--mysql-test/t/mysqldump.test22
-rw-r--r--mysql-test/t/null.test28
-rw-r--r--mysql-test/t/openssl_1.test8
-rw-r--r--mysql-test/t/partition_myisam.test6
-rw-r--r--mysql-test/t/plugin.test52
-rw-r--r--mysql-test/t/range.test38
-rw-r--r--mysql-test/t/select.test91
-rw-r--r--mysql-test/t/sp.test31
-rw-r--r--mysql-test/t/subselect2.test43
-rw-r--r--mysql-test/t/subselect_sj_mat.test26
-rw-r--r--mysql-test/t/table_elim.test17
-rw-r--r--mysql-test/t/type_date.test22
-rw-r--r--mysql-test/t/view_grant.test6
99 files changed, 2623 insertions, 281 deletions
diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt
index c0ee12fbd23..5ffbd78316c 100644
--- a/mysql-test/CMakeLists.txt
+++ b/mysql-test/CMakeLists.txt
@@ -151,13 +151,13 @@ MACRO(PROCESS_COLLECTION_INCLUDE collin collection)
ENDFOREACH()
ENDMACRO()
-FILE(GLOB infiles "collections/*.in")
-FOREACH(collin ${infiles})
- STRING(REPLACE ".in" "" collection ${collin})
- STRING(REPLACE ".in" ".done" colldone ${collin})
- # Only generate file once
- IF(NOT EXISTS ${colldone})
- PROCESS_COLLECTION_INCLUDE(${collin} ${collection})
- FILE(APPEND ${colldone} "${collin}\n")
- ENDIF()
-ENDFOREACH()
+#FILE(GLOB infiles "collections/*.in")
+#FOREACH(collin ${infiles})
+# STRING(REPLACE ".in" "" collection ${collin})
+# STRING(REPLACE ".in" ".done" colldone ${collin})
+# # Only generate file once
+# IF(NOT EXISTS ${colldone})
+# PROCESS_COLLECTION_INCLUDE(${collin} ${collection})
+# FILE(APPEND ${colldone} "${collin}\n")
+# ENDIF()
+#ENDFOREACH()
diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf
index 8f2f96f3320..96848c39f11 100644
--- a/mysql-test/include/default_mysqld.cnf
+++ b/mysql-test/include/default_mysqld.cnf
@@ -1,4 +1,4 @@
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates
+# Copyright (c) 2007, 2013, Oracle and/or its affiliates
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ port-open-timeout=10
log-bin-trust-function-creators=1
key_buffer_size= 1M
-sort_buffer= 256K
+sort_buffer_size= 256K
max_heap_table_size= 1M
loose-aria-pagecache-buffer-size=8M
diff --git a/mysql-test/include/have_pbxt.opt b/mysql-test/include/have_pbxt.opt
deleted file mode 100644
index 54ba9495053..00000000000
--- a/mysql-test/include/have_pbxt.opt
+++ /dev/null
@@ -1 +0,0 @@
---loose-pbxt
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index a82e3ee10b7..1327afdb426 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -117,7 +117,7 @@ sub collect_test_cases ($$$$) {
if ( @$opt_cases )
{
# A list of tests was specified on the command line
- # Check that the tests specified was found
+ # Check that the tests specified were found
# in at least one suite
foreach my $test_name_spec ( @$opt_cases )
{
@@ -189,30 +189,33 @@ sub collect_test_cases ($$$$) {
}
-# Returns (suitename, testname)
+# Returns (suitename, testname, combinations....)
sub split_testname {
my ($test_name)= @_;
# If .test file name is used, get rid of directory part
$test_name= basename($test_name) if $test_name =~ /\.test$/;
+ # Then, get the combinations:
+ my ($test_name, @combs) = split /,/, $test_name;
+
# Now split name on .'s
my @parts= split(/\./, $test_name);
if (@parts == 1){
# Only testname given, ex: alias
- return (undef , $parts[0]);
+ return (undef , $parts[0], @combs);
} elsif (@parts == 2) {
# Either testname.test or suite.testname given
# Ex. main.alias or alias.test
if ($parts[1] eq "test")
{
- return (undef , $parts[0]);
+ return (undef , $parts[0], @combs);
}
else
{
- return ($parts[0], $parts[1]);
+ return ($parts[0], $parts[1], @combs);
}
}
@@ -499,14 +502,14 @@ sub process_suite {
# Collect in specified order
foreach my $test_name_spec ( @$opt_cases )
{
- my ($sname, $tname)= split_testname($test_name_spec);
+ my ($sname, $tname, @combs)= split_testname($test_name_spec);
# Check correct suite if suitename is defined
next if defined $sname and $sname ne $suitename
and $sname ne "$basename-";
next unless $all_cases{$tname};
- push @cases, collect_one_test_case($suite, $all_cases{$tname}, $tname);
+ push @cases, collect_one_test_case($suite, $all_cases{$tname}, $tname, @combs);
}
} else {
for (sort keys %all_cases)
@@ -559,9 +562,9 @@ sub process_opts {
}
}
-sub make_combinations($@)
+sub make_combinations($$@)
{
- my ($test, @combinations) = @_;
+ my ($test, $test_combs, @combinations) = @_;
return ($test) if $test->{'skip'} or not @combinations;
if ($combinations[0]->{skip}) {
@@ -578,11 +581,19 @@ sub make_combinations($@)
if (My::Options::is_set($test->{master_opt}, $comb->{comb_opt}) &&
My::Options::is_set($test->{slave_opt}, $comb->{comb_opt}) ){
+ delete $test_combs->{$comb->{name}};
+
# Add combination name short name
push @{$test->{combinations}}, $comb->{name};
return ($test);
}
+
+ # Skip all other combinations, if this combination is forced
+ if (delete $test_combs->{$comb->{name}}) {
+ @combinations = ($comb); # run the loop below only for this combination
+ last;
+ }
}
my @cases;
@@ -635,6 +646,8 @@ sub collect_one_test_case {
my $suite = shift;
my $tpath = shift;
my $tname = shift;
+ my %test_combs = map { $_ => 1 } @_;
+
my $suitename = $suite->{name};
my $name = "$suitename.$tname";
@@ -829,7 +842,11 @@ sub collect_one_test_case {
my @cases = ($tinfo);
for my $comb ($suite->{combinations}, @{$file_combinations{$filename}})
{
- @cases = map make_combinations($_, @{$comb}), @cases;
+ @cases = map make_combinations($_, \%test_combs, @{$comb}), @cases;
+ }
+ if (keys %test_combs) {
+ mtr_error("Could not run $name with '".(
+ join(',', sort keys %test_combs))."' combination(s)");
}
for $tinfo (@cases) {
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 107b78aa1f9..169aff3f3e9 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -2077,7 +2077,17 @@ sub executable_setup () {
}
else
{
- $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
+ if ( defined $ENV{'MYSQL_TEST'} )
+ {
+ $exe_mysqltest=$ENV{'MYSQL_TEST'};
+ print "===========================================================\n";
+ print "WARNING:The mysqltest binary is fetched from $exe_mysqltest\n";
+ print "===========================================================\n";
+ }
+ else
+ {
+ $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
+ }
}
}
diff --git a/mysql-test/r/bad_frm_crash_5029.result b/mysql-test/r/bad_frm_crash_5029.result
new file mode 100644
index 00000000000..7a829c8f6ba
--- /dev/null
+++ b/mysql-test/r/bad_frm_crash_5029.result
@@ -0,0 +1,2 @@
+show create table t1;
+ERROR 42000: Unknown storage engine 'InnoDB'
diff --git a/mysql-test/r/ctype_binary.result b/mysql-test/r/ctype_binary.result
index c897108f793..4c09fb97e64 100644
--- a/mysql-test/r/ctype_binary.result
+++ b/mysql-test/r/ctype_binary.result
@@ -1421,12 +1421,12 @@ t1 CREATE TABLE `t1` (
drop table t1;
select hex(concat(time_to_sec('10:11:12')));
hex(concat(time_to_sec('10:11:12')))
-33363637322E303030303030
+3336363732
create table t1 as select concat(time_to_sec('10:11:12')) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varbinary(24) DEFAULT NULL
+ `c1` varbinary(17) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(extract(year from 20090702)));
@@ -1533,7 +1533,7 @@ create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varbinary(17) DEFAULT NULL
+ `c1` varbinary(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(maketime(10,11,12)));
@@ -1573,7 +1573,7 @@ create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:0
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varbinary(26) DEFAULT NULL
+ `c1` varbinary(19) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
@@ -1583,7 +1583,7 @@ create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varbinary(26) DEFAULT NULL
+ `c1` varbinary(19) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
c1
@@ -2786,8 +2786,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `field_str1` varchar(26) DEFAULT NULL,
- `field1_str2` varchar(26) DEFAULT NULL,
+ `field_str1` varchar(19) DEFAULT NULL,
+ `field1_str2` varchar(19) DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -2798,8 +2798,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def field_str1 254 26 10 Y 128 31 63
-def field1_str2 254 26 19 Y 128 31 63
+def field_str1 254 19 10 Y 128 0 63
+def field1_str2 254 19 19 Y 128 0 63
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@@ -2854,7 +2854,7 @@ CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
INSERT INTO t1 VALUES ();
SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1;
maketime(`a`,`a`,`a`)
-00:00:00
+00:00:00.000000
DROP TABLE t1;
SET sql_mode=default;
#
diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result
index 5323469dff3..723f7534259 100644
--- a/mysql-test/r/ctype_cp1251.result
+++ b/mysql-test/r/ctype_cp1251.result
@@ -1813,12 +1813,12 @@ t1 CREATE TABLE `t1` (
drop table t1;
select hex(concat(time_to_sec('10:11:12')));
hex(concat(time_to_sec('10:11:12')))
-33363637322E303030303030
+3336363732
create table t1 as select concat(time_to_sec('10:11:12')) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(24) CHARACTER SET cp1251 DEFAULT NULL
+ `c1` varchar(17) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(extract(year from 20090702)));
@@ -1925,7 +1925,7 @@ create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(17) CHARACTER SET cp1251 DEFAULT NULL
+ `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(maketime(10,11,12)));
@@ -1965,7 +1965,7 @@ create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:0
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) CHARACTER SET cp1251 DEFAULT NULL
+ `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
@@ -1975,7 +1975,7 @@ create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) CHARACTER SET cp1251 DEFAULT NULL
+ `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
c1
@@ -3178,8 +3178,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `field_str1` varchar(26) DEFAULT NULL,
- `field1_str2` varchar(26) DEFAULT NULL,
+ `field_str1` varchar(19) DEFAULT NULL,
+ `field1_str2` varchar(19) DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -3190,8 +3190,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def field_str1 254 26 10 Y 128 31 63
-def field1_str2 254 26 19 Y 128 31 63
+def field_str1 254 19 10 Y 128 0 63
+def field1_str2 254 19 19 Y 128 0 63
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@@ -3246,7 +3246,7 @@ CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
INSERT INTO t1 VALUES ();
SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1;
maketime(`a`,`a`,`a`)
-00:00:00
+00:00:00.000000
DROP TABLE t1;
SET sql_mode=default;
#
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result
index ae459fce8eb..5ed8159aae3 100644
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@ -1840,12 +1840,12 @@ t1 CREATE TABLE `t1` (
drop table t1;
select hex(concat(time_to_sec('10:11:12')));
hex(concat(time_to_sec('10:11:12')))
-33363637322E303030303030
+3336363732
create table t1 as select concat(time_to_sec('10:11:12')) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(24) DEFAULT NULL
+ `c1` varchar(17) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(extract(year from 20090702)));
@@ -1952,7 +1952,7 @@ create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(17) DEFAULT NULL
+ `c1` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(maketime(10,11,12)));
@@ -1992,7 +1992,7 @@ create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:0
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) DEFAULT NULL
+ `c1` varchar(19) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
@@ -2002,7 +2002,7 @@ create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) DEFAULT NULL
+ `c1` varchar(19) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
c1
@@ -3205,8 +3205,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `field_str1` varchar(26) DEFAULT NULL,
- `field1_str2` varchar(26) DEFAULT NULL,
+ `field_str1` varchar(19) DEFAULT NULL,
+ `field1_str2` varchar(19) DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -3217,8 +3217,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def field_str1 254 26 10 Y 128 31 63
-def field1_str2 254 26 19 Y 128 31 63
+def field_str1 254 19 10 Y 128 0 63
+def field1_str2 254 19 19 Y 128 0 63
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@@ -3273,7 +3273,7 @@ CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
INSERT INTO t1 VALUES ();
SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1;
maketime(`a`,`a`,`a`)
-00:00:00
+00:00:00.000000
DROP TABLE t1;
SET sql_mode=default;
#
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index cc43dd2d7dc..f73ea4bdbee 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -2749,12 +2749,12 @@ t1 CREATE TABLE `t1` (
drop table t1;
select hex(concat(time_to_sec('10:11:12')));
hex(concat(time_to_sec('10:11:12')))
-00330036003600370032002E003000300030003000300030
+00330036003600370032
create table t1 as select concat(time_to_sec('10:11:12')) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(24) CHARACTER SET ucs2 DEFAULT NULL
+ `c1` varchar(17) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(extract(year from 20090702)));
@@ -2861,7 +2861,7 @@ create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(17) CHARACTER SET ucs2 DEFAULT NULL
+ `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(maketime(10,11,12)));
@@ -2901,7 +2901,7 @@ create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:0
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) CHARACTER SET ucs2 DEFAULT NULL
+ `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
@@ -2911,7 +2911,7 @@ create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) CHARACTER SET ucs2 DEFAULT NULL
+ `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
c1
@@ -4114,8 +4114,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `field_str1` varchar(26) DEFAULT NULL,
- `field1_str2` varchar(26) DEFAULT NULL,
+ `field_str1` varchar(19) DEFAULT NULL,
+ `field1_str2` varchar(19) DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -4126,8 +4126,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def field_str1 254 26 10 Y 128 31 63
-def field1_str2 254 26 19 Y 128 31 63
+def field_str1 254 19 10 Y 128 0 63
+def field1_str2 254 19 19 Y 128 0 63
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@@ -4182,7 +4182,7 @@ CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
INSERT INTO t1 VALUES ();
SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1;
maketime(`a`,`a`,`a`)
-00:00:00
+00:00:00.000000
DROP TABLE t1;
SET sql_mode=default;
SET NAMES latin1;
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index d25c454913d..ad8e852979b 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -3579,12 +3579,12 @@ t1 CREATE TABLE `t1` (
drop table t1;
select hex(concat(time_to_sec('10:11:12')));
hex(concat(time_to_sec('10:11:12')))
-33363637322E303030303030
+3336363732
create table t1 as select concat(time_to_sec('10:11:12')) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(24) CHARACTER SET utf8 DEFAULT NULL
+ `c1` varchar(17) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(extract(year from 20090702)));
@@ -3691,7 +3691,7 @@ create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(17) CHARACTER SET utf8 DEFAULT NULL
+ `c1` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(maketime(10,11,12)));
@@ -3731,7 +3731,7 @@ create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:0
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) CHARACTER SET utf8 DEFAULT NULL
+ `c1` varchar(19) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
@@ -3741,7 +3741,7 @@ create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(26) CHARACTER SET utf8 DEFAULT NULL
+ `c1` varchar(19) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
c1
@@ -4944,8 +4944,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `field_str1` varchar(26) DEFAULT NULL,
- `field1_str2` varchar(26) DEFAULT NULL,
+ `field_str1` varchar(19) DEFAULT NULL,
+ `field1_str2` varchar(19) DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -4956,8 +4956,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def field_str1 254 26 10 Y 128 31 63
-def field1_str2 254 26 19 Y 128 31 63
+def field_str1 254 19 10 Y 128 0 63
+def field1_str2 254 19 19 Y 128 0 63
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@@ -5012,7 +5012,7 @@ CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
INSERT INTO t1 VALUES ();
SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1;
maketime(`a`,`a`,`a`)
-00:00:00
+00:00:00.000000
DROP TABLE t1;
SET sql_mode=default;
#
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result
index 7f69fd1a5a4..ff3f4038447 100644
--- a/mysql-test/r/date_formats.result
+++ b/mysql-test/r/date_formats.result
@@ -192,70 +192,70 @@ Tuesday 52 2001 %W %V %X 2002-01-01
15-2001-1 %d-%Y-%c 2001-01-15
select date,format,TIME(str_to_date(date, format)) as time from t1;
date format time
-2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
-03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
-0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
-03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
-2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000
+0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450
-2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
-10:20:10 %H:%i:%s 10:20:10
-10:20:10 %h:%i:%s.%f 10:20:10
-10:20:10 %T 10:20:10
-10:20:10AM %h:%i:%s%p 10:20:10
-10:20:10AM %r 10:20:10
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000
+10:20:10 %H:%i:%s 10:20:10.000000
+10:20:10 %h:%i:%s.%f 10:20:10.000000
+10:20:10 %T 10:20:10.000000
+10:20:10AM %h:%i:%s%p 10:20:10.000000
+10:20:10AM %r 10:20:10.000000
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000
-15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
-15 September 2001 %d %M %Y 00:00:00
-15 SEPTEMB 2001 %d %M %Y 00:00:00
-15 MAY 2001 %d %b %Y 00:00:00
-15th May 2001 %D %b %Y 00:00:00
-Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
-Sund 15 MAY 2001 %W %d %b %Y 00:00:00
-Tuesday 00 2002 %W %U %Y 00:00:00
-Thursday 53 1998 %W %u %Y 00:00:00
-Sunday 01 2001 %W %v %x 00:00:00
-Tuesday 52 2001 %W %V %X 00:00:00
-060 2004 %j %Y 00:00:00
-4 53 1998 %w %u %Y 00:00:00
-15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
-15-01-20 %d-%m-%y 00:00:00
-15-2001-1 %d-%Y-%c 00:00:00
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000
+15 September 2001 %d %M %Y 00:00:00.000000
+15 SEPTEMB 2001 %d %M %Y 00:00:00.000000
+15 MAY 2001 %d %b %Y 00:00:00.000000
+15th May 2001 %D %b %Y 00:00:00.000000
+Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Tuesday 00 2002 %W %U %Y 00:00:00.000000
+Thursday 53 1998 %W %u %Y 00:00:00.000000
+Sunday 01 2001 %W %v %x 00:00:00.000000
+Tuesday 52 2001 %W %V %X 00:00:00.000000
+060 2004 %j %Y 00:00:00.000000
+4 53 1998 %w %u %Y 00:00:00.000000
+15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000
+15-01-20 %d-%m-%y 00:00:00.000000
+15-2001-1 %d-%Y-%c 00:00:00.000000
select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
date format time2
-2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
-03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
-0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
-03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
-2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000
+0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450
-2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
-10:20:10 %H:%i:%s 10:20:10
-10:20:10 %h:%i:%s.%f 10:20:10
-10:20:10 %T 10:20:10
-10:20:10AM %h:%i:%s%p 10:20:10
-10:20:10AM %r 10:20:10
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000
+10:20:10 %H:%i:%s 10:20:10.000000
+10:20:10 %h:%i:%s.%f 10:20:10.000000
+10:20:10 %T 10:20:10.000000
+10:20:10AM %h:%i:%s%p 10:20:10.000000
+10:20:10AM %r 10:20:10.000000
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000
-15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
-15 September 2001 %d %M %Y 00:00:00
-15 SEPTEMB 2001 %d %M %Y 00:00:00
-15 MAY 2001 %d %b %Y 00:00:00
-15th May 2001 %D %b %Y 00:00:00
-Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
-Sund 15 MAY 2001 %W %d %b %Y 00:00:00
-Tuesday 00 2002 %W %U %Y 00:00:00
-Thursday 53 1998 %W %u %Y 00:00:00
-Sunday 01 2001 %W %v %x 00:00:00
-Tuesday 52 2001 %W %V %X 00:00:00
-060 2004 %j %Y 00:00:00
-4 53 1998 %w %u %Y 00:00:00
-15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
-15-01-20 %d-%m-%y 00:00:00
-15-2001-1 %d-%Y-%c 00:00:00
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000
+15 September 2001 %d %M %Y 00:00:00.000000
+15 SEPTEMB 2001 %d %M %Y 00:00:00.000000
+15 MAY 2001 %d %b %Y 00:00:00.000000
+15th May 2001 %D %b %Y 00:00:00.000000
+Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Tuesday 00 2002 %W %U %Y 00:00:00.000000
+Thursday 53 1998 %W %u %Y 00:00:00.000000
+Sunday 01 2001 %W %v %x 00:00:00.000000
+Tuesday 52 2001 %W %V %X 00:00:00.000000
+060 2004 %j %Y 00:00:00.000000
+4 53 1998 %w %u %Y 00:00:00.000000
+15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000
+15-01-20 %d-%m-%y 00:00:00.000000
+15-2001-1 %d-%Y-%c 00:00:00.000000
select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'));
concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'))
2003-01-02 08:11:02.123456
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 363a4700ee6..685e8ddd6bc 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -417,6 +417,29 @@ MIN(i)
DROP TABLE t1;
# End of 5.0 tests
#
+# MDEV-5005: Subquery in Procedure somehow affecting temporary table
+#
+create temporary table if not exists t1 (id int not null);
+select A.* from ( select tt.* from t1 tt ) A;
+id
+prepare stmt from "select A.* from ( select tt.* from t1 tt ) A ";
+execute stmt;
+id
+deallocate prepare stmt;
+drop temporary table t1;
+CREATE PROCEDURE p ()
+BEGIN
+select A.* from ( select tt.* from t1 tt ) A ;
+END |
+create temporary table if not exists t1 (id int not null);
+CALL p();
+id
+CALL p();
+id
+drop procedure p;
+drop temporary table t1;
+# End of 5.3 tests
+#
# Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
# temptable views
#
@@ -440,7 +463,6 @@ SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2);
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1, t2;
DROP VIEW v1, v2;
-set optimizer_switch=@save_derived_optimizer_switch;
create table t1 (n bigint(20) unsigned, d1 datetime, d2 datetime, key (d1));
insert t1 values (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
insert t1 values (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
@@ -454,3 +476,18 @@ n d1 d2 result
2085 2012-01-01 00:00:00 2013-01-01 00:00:00 0
2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0
drop table t1;
+SET optimizer_switch = 'derived_merge=on,derived_with_keys=on,in_to_exists=on';
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (8);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(7);
+EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1,
+(SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+1 PRIMARY <derived3> ref key0 key0 5 const 0
+3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using temporary
+Warnings:
+Note 1249 Select 4 was reduced during optimization
+DROP TABLE t1, t2;
+set optimizer_switch=@save_derived_optimizer_switch;
diff --git a/mysql-test/r/drop_bad_db_type.result b/mysql-test/r/drop_bad_db_type.result
new file mode 100644
index 00000000000..6a125cdccf5
--- /dev/null
+++ b/mysql-test/r/drop_bad_db_type.result
@@ -0,0 +1,12 @@
+set debug_dbug='+d,unstable_db_type';
+install soname 'ha_archive';
+create table t1 (a int) engine=archive;
+insert t1 values (1),(2),(3);
+flush tables;
+uninstall soname 'ha_archive';
+install soname 'ha_archive';
+t1.ARZ
+t1.frm
+drop table t1;
+uninstall soname 'ha_archive';
+set debug_dbug='-d,unstable_db_type';
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index ba90707ca40..9049589b6db 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -2126,6 +2126,19 @@ select z from (select count(*) as z from t1) v group by 1;
z
4
drop table t1;
+CREATE TABLE t1 (i1 int, INDEX(i1));
+INSERT INTO t1 VALUES (9),(8);
+CREATE TABLE t2 (i2 int);
+INSERT INTO t2 VALUES (8),(4);
+CREATE TABLE t3 (i3 int, INDEX(i3));
+INSERT INTO t3 VALUES (9),(8);
+SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND ( 0 OR t3.i3 = t2.i2 );
+MAX(t3.i3)
+8
+SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND t3.i3 = t2.i2;
+MAX(t3.i3)
+8
+DROP TABLE t1,t2,t3;
# end of 5.3 tests
#
# Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),
diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result
index 72c7a5a128f..66a8b99f7fd 100644
--- a/mysql-test/r/func_sapdb.result
+++ b/mysql-test/r/func_sapdb.result
@@ -156,7 +156,7 @@ timestamp("2001-12-01", "25:01:01")
2001-12-02 01:01:01
select timestamp("2001-12-01 01:01:01.000100");
timestamp("2001-12-01 01:01:01.000100")
-2001-12-01 01:01:01.000100
+2001-12-01 01:01:01.0001
select timestamp("2001-12-01");
timestamp("2001-12-01")
2001-12-01 00:00:00
@@ -200,12 +200,12 @@ f3 time(6) YES NULL
f4 time(6) YES NULL
f5 time(6) YES NULL
f6 time YES NULL
-f7 datetime(6) YES NULL
+f7 datetime YES NULL
f8 date YES NULL
f9 time(6) YES NULL
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8 f9
-1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001
+1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59.000001
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
insert into test values
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index ad5d640b402..a588d89b919 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -2623,13 +2623,13 @@ Warning 1292 Truncated incorrect DECIMAL value: ''
# and other crashes
#
CREATE TABLE t1 ( a TEXT );
-SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt';
+SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug58165.txt';;
SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' );
insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' )
x
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'b'
-LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1;;
SELECT * FROM t1;
a
aaaaaaaaaaaaaa
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index f50458695a7..3a7dfffc228 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -11,17 +11,17 @@ now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(no
0 0 0
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
-1994-03-02 10:11:12.000000 1994-03-02 10:11:12 19940302101112.000000
+1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
sec_to_time(time_to_sec("0:30:47")/6.21);
sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21)
-02:30:01 23001 54742.000000 00:04:57.423510
+02:30:01 23001 54742 00:04:57.4235
select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899);
sec_to_time(9001.1) time_to_sec('15:12:22.123456') time_to_sec(15.5566778899)
02:30:01.1 54742.123456 15.556677
select sec_to_time(time_to_sec('-838:59:59'));
sec_to_time(time_to_sec('-838:59:59'))
--838:59:59.000000
+-838:59:59
select sec_to_time('9001.1'), sec_to_time('1234567890123.123');
sec_to_time('9001.1') sec_to_time('1234567890123.123')
02:30:01.100000 838:59:59.999999
@@ -77,7 +77,7 @@ HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322)
23 3 22
select TIME(230322), TIME(230322.33), TIME("230322.33");
TIME(230322) TIME(230322.33) TIME("230322.33")
-23:03:22 23:03:22.33 23:03:22.330000
+23:03:22 23:03:22.33 23:03:22.33
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
week(19980101) week(19970101) week(19980101,1) week(19970101,1)
0 0 1 1
@@ -569,7 +569,7 @@ select @a:=FROM_UNIXTIME(1);
1970-01-01 03:00:01
select unix_timestamp(@a);
unix_timestamp(@a)
-1.000000
+1
select unix_timestamp('1969-12-01 19:00:01');
unix_timestamp('1969-12-01 19:00:01')
NULL
@@ -611,10 +611,10 @@ unix_timestamp('1969-12-30 01:00:00')
NULL
select unix_timestamp('2038-01-17 12:00:00');
unix_timestamp('2038-01-17 12:00:00')
-2147331600.000000
+2147331600
select unix_timestamp('1970-01-01 03:00:01');
unix_timestamp('1970-01-01 03:00:01')
-1.000000
+1
select unix_timestamp('2038-01-19 07:14:07');
unix_timestamp('2038-01-19 07:14:07')
NULL
@@ -1950,3 +1950,400 @@ NULL
Warnings:
Warning 1411 Incorrect datetime value: '2020' for function str_to_date
SET TIME_ZONE=DEFAULT;
+#
+# MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context
+#
+CREATE TABLE t1 (a TIMESTAMP(3));
+INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999');
+SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
+c1 c2 c2
+20010101102030 20010101102030.999 20010101102031
+DROP TABLE t1;
+CREATE TABLE t1 (a TIME(3));
+INSERT INTO t1 VALUES ('10:20:30.999');
+SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
+c1 c2 c2
+102030 102030.999 102031
+DROP TABLE t1;
+SELECT
+CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+CONCAT(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00
+SELECT
+CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
+CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
+COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
+CONCAT(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
+TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
+DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
+TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30
+SELECT
+CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+CONCAT(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00
+SELECT
+CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
+CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
+IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
+CONCAT(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
+TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
+DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
+TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30
+SELECT
+CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+CONCAT(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00
+SELECT
+CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+CONCAT(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30
+SELECT
+CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
+CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
+CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
+CONCAT(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
+TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
+DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
+TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00
+SELECT
+CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
+CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
+CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
+CONCAT(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
+TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
+DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
+TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
+c1 c2 c3 c4 c5 c6 c7
+20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30
+CREATE TABLE t1 AS SELECT
+CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1,
+CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2,
+CONCAT(IFNULL(TIME(101010),TIME(101010))) AS c3,
+CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` varchar(10) DEFAULT NULL,
+ `c2` varchar(10) DEFAULT NULL,
+ `c3` varchar(10) DEFAULT NULL,
+ `c4` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+#
+# MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
+#
+CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE);
+INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01');
+SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
+CASE WHEN 0 THEN dt2 ELSE t3 END
+0000-00-00 00:00:00.567
+CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
+SELECT * FROM t2;
+CASE WHEN 0 THEN dt2 ELSE t3 END
+0000-00-00 00:00:00.567
+SHOW COLUMNS FROM t2;
+Field Type Null Key Default Extra
+CASE WHEN 0 THEN dt2 ELSE t3 END datetime(3) YES NULL
+DROP TABLE t2;
+SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1;
+CASE WHEN 1 THEN dt2 ELSE t3 END
+2001-01-01 00:00:00.120
+SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1;
+CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END)
+2001-01-01 00:00:00.120
+SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1;
+CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END)
+2001-01-01 00:00:00.120
+SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1;
+CONCAT(CASE WHEN 1 THEN d ELSE t3 END)
+2002-01-01 00:00:00.000
+SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1;
+CASE WHEN 1 THEN t3 ELSE d END
+0000-00-00 00:00:00.567
+SELECT COALESCE(d, t3) FROM t1;
+COALESCE(d, t3)
+2002-01-01 00:00:00.000
+SELECT CONCAT(COALESCE(d, t3)) FROM t1;
+CONCAT(COALESCE(d, t3))
+2002-01-01 00:00:00.000
+SELECT COALESCE(dt2, t3) FROM t1;
+COALESCE(dt2, t3)
+2001-01-01 00:00:00.120
+SELECT CONCAT(COALESCE(dt2, t3)) FROM t1;
+CONCAT(COALESCE(dt2, t3))
+2001-01-01 00:00:00.120
+SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1;
+IFNULL(dt2, t3) CONCAT(IFNULL(dt2, t3))
+2001-01-01 00:00:00.120 2001-01-01 00:00:00.120
+SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1;
+IFNULL(d, t3) CONCAT(IFNULL(d, t3))
+2002-01-01 00:00:00.000 2002-01-01 00:00:00.000
+DROP TABLE t1;
+#
+# MDEV-4724 Some temporal functions do not preserve microseconds
+#
+SELECT MAKETIME(10,10,10.231);
+MAKETIME(10,10,10.231)
+10:10:10.231
+SELECT MAKETIME(0, 0, 59.9);
+MAKETIME(0, 0, 59.9)
+00:00:59.9
+CREATE TABLE t1 AS SELECT
+MAKETIME(10,00,00),
+MAKETIME(10,00,00.1),
+MAKETIME(10,00,00.12),
+MAKETIME(10,00,00.123),
+MAKETIME(10,00,00.1234),
+MAKETIME(10,00,00.12345),
+MAKETIME(10,00,00.123456);
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+MAKETIME(10,00,00) time YES NULL
+MAKETIME(10,00,00.1) time(1) YES NULL
+MAKETIME(10,00,00.12) time(2) YES NULL
+MAKETIME(10,00,00.123) time(3) YES NULL
+MAKETIME(10,00,00.1234) time(4) YES NULL
+MAKETIME(10,00,00.12345) time(5) YES NULL
+MAKETIME(10,00,00.123456) time(6) YES NULL
+DROP TABLE t1;
+CREATE TABLE t1 AS SELECT
+TIME('10:00:00'),
+TIME('10:00:00.1'),
+TIME('10:00:00.12'),
+TIME('10:00:00.123'),
+TIME('10:00:00.1234'),
+TIME('10:00:00.12345'),
+TIME('10:00:00.12346');
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+TIME('10:00:00') time YES NULL
+TIME('10:00:00.1') time(1) YES NULL
+TIME('10:00:00.12') time(2) YES NULL
+TIME('10:00:00.123') time(3) YES NULL
+TIME('10:00:00.1234') time(4) YES NULL
+TIME('10:00:00.12345') time(5) YES NULL
+TIME('10:00:00.12346') time(5) YES NULL
+DROP TABLE t1;
+SET TIME_ZONE='+00:00';
+SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17');
+SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17');
+NOW() UNIX_TIMESTAMP() UNIX_TIMESTAMP(NOW()) UNIX_TIMESTAMP('2012-10-16 22:46:17')
+2012-10-16 22:46:17 1350427577 1350427577 1350427577
+SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456');
+SELECT @@timestamp, FROM_UNIXTIME(@@timestamp);
+@@timestamp FROM_UNIXTIME(@@timestamp)
+97445.123456 1970-01-02 03:04:05.123456
+SET TIME_ZONE=DEFAULT;
+SET TIMESTAMP=DEFAULT;
+SELECT TIME('2012-10-16 15:54:16.12');
+TIME('2012-10-16 15:54:16.12')
+15:54:16.12
+SELECT TIMESTAMP('2012-10-16 15:54:16.12');
+TIMESTAMP('2012-10-16 15:54:16.12')
+2012-10-16 15:54:16.12
+SELECT TIMEDIFF('10:10:10.1','00:00:00');
+TIMEDIFF('10:10:10.1','00:00:00')
+10:10:10.1
+SELECT TIME_TO_SEC('10:10:10');
+TIME_TO_SEC('10:10:10')
+36610
+SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12');
+ADDTIME(TIME('10:10:10.1'),'10:10:10.12')
+20:20:20.22
+SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12');
+ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12')
+2001-01-01 20:20:20.22
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND)
+2001-01-01 00:00:01
+SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND)
+2001-01-01 00:00:01.1
+SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND)
+2001-01-01 00:00:01.12
+SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND)
+2001-01-01 00:00:01.123
+SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND)
+2001-01-01 00:00:01.1234
+SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND)
+2001-01-01 00:00:01.12345
+SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND)
+2001-01-01 00:00:01.123456
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND)
+2001-01-01 00:00:01
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND)
+2001-01-01 00:00:01.1
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND)
+2001-01-01 00:00:01.12
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND)
+2001-01-01 00:00:01.123
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND)
+2001-01-01 00:00:01.1234
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND)
+2001-01-01 00:00:01.12345
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND)
+2001-01-01 00:00:01.123456
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND)
+2000-12-31 23:59:59
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND)
+2000-12-31 23:59:58.9
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND)
+2000-12-31 23:59:58.88
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND)
+2000-12-31 23:59:58.877
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND)
+2000-12-31 23:59:58.8766
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND)
+2000-12-31 23:59:58.87655
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND)
+2000-12-31 23:59:58.876544
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND);
+DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND)
+2001-01-01 00:00:00.000000
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: 'xxx'
+SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00');
+CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00')
+2001-01-01 11:20:30.12
+#
+# MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision
+#
+CREATE TABLE t1 (t0 TIME);
+INSERT INTO t1 VALUES ('00:00:00');
+SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+t0 + INTERVAL 1.1 SECOND
+00:00:01.1
+CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+SHOW COLUMNS FROM t2;
+Field Type Null Key Default Extra
+t0 + INTERVAL 1.1 SECOND time(1) YES NULL
+DROP TABLE t1,t2;
+CREATE TABLE t1 (t0 DATETIME);
+INSERT INTO t1 VALUES ('2001-01-01 00:00:00');
+SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+t0 + INTERVAL 1.1 SECOND
+2001-01-01 00:00:01.1
+CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+SHOW COLUMNS FROM t2;
+Field Type Null Key Default Extra
+t0 + INTERVAL 1.1 SECOND datetime(1) YES NULL
+DROP TABLE t1, t2;
+#
+# MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10')
+#
+CREATE TABLE t1 AS SELECT
+TIMESTAMP('2001-01-01','10:10:10'),
+TIMESTAMP('2001-01-01','10:10:10.1'),
+TIMESTAMP('2001-01-01','10:10:10.12'),
+TIMESTAMP('2001-01-01','10:10:10.123'),
+TIMESTAMP('2001-01-01','10:10:10.1234'),
+TIMESTAMP('2001-01-01','10:10:10.12345'),
+TIMESTAMP('2001-01-01','10:10:10.123456'),
+TIMESTAMP('2001-01-01','10:10:10.1234567');
+Warnings:
+Warning 1292 Truncated incorrect time value: '10:10:10.1234567'
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+TIMESTAMP('2001-01-01','10:10:10') datetime YES NULL
+TIMESTAMP('2001-01-01','10:10:10.1') datetime(1) YES NULL
+TIMESTAMP('2001-01-01','10:10:10.12') datetime(2) YES NULL
+TIMESTAMP('2001-01-01','10:10:10.123') datetime(3) YES NULL
+TIMESTAMP('2001-01-01','10:10:10.1234') datetime(4) YES NULL
+TIMESTAMP('2001-01-01','10:10:10.12345') datetime(5) YES NULL
+TIMESTAMP('2001-01-01','10:10:10.123456') datetime(6) YES NULL
+TIMESTAMP('2001-01-01','10:10:10.1234567') datetime(6) YES NULL
+SELECT * FROM t1;
+TIMESTAMP('2001-01-01','10:10:10') TIMESTAMP('2001-01-01','10:10:10.1') TIMESTAMP('2001-01-01','10:10:10.12') TIMESTAMP('2001-01-01','10:10:10.123') TIMESTAMP('2001-01-01','10:10:10.1234') TIMESTAMP('2001-01-01','10:10:10.12345') TIMESTAMP('2001-01-01','10:10:10.123456') TIMESTAMP('2001-01-01','10:10:10.1234567')
+2001-01-01 10:10:10 2001-01-01 10:10:10.1 2001-01-01 10:10:10.12 2001-01-01 10:10:10.123 2001-01-01 10:10:10.1234 2001-01-01 10:10:10.12345 2001-01-01 10:10:10.123456 2001-01-01 10:10:10.123456
+DROP TABLE t1;
+CREATE TABLE t1 AS SELECT
+TIMESTAMP('2001-01-01 00:00:00','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.1','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.12','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.123','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10'),
+TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10');
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2001-01-01 00:00:00.1234567'
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+TIMESTAMP('2001-01-01 00:00:00','10:10:10') datetime YES NULL
+TIMESTAMP('2001-01-01 00:00:00.1','10:10:10') datetime(1) YES NULL
+TIMESTAMP('2001-01-01 00:00:00.12','10:10:10') datetime(2) YES NULL
+TIMESTAMP('2001-01-01 00:00:00.123','10:10:10') datetime(3) YES NULL
+TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10') datetime(4) YES NULL
+TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10') datetime(5) YES NULL
+TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10') datetime(6) YES NULL
+TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10') datetime(6) YES NULL
+SELECT * FROM t1;
+TIMESTAMP('2001-01-01 00:00:00','10:10:10') TIMESTAMP('2001-01-01 00:00:00.1','10:10:10') TIMESTAMP('2001-01-01 00:00:00.12','10:10:10') TIMESTAMP('2001-01-01 00:00:00.123','10:10:10') TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10') TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10') TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10') TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10')
+2001-01-01 10:10:10 2001-01-01 10:10:10.1 2001-01-01 10:10:10.12 2001-01-01 10:10:10.123 2001-01-01 10:10:10.1234 2001-01-01 10:10:10.12345 2001-01-01 10:10:10.123456 2001-01-01 10:10:10.123456
+DROP TABLE t1;
+CREATE TABLE t1 AS SELECT
+TIMESTAMP('00:00:00','10:10:10'),
+TIMESTAMP(TIME('00:00:00'),'10:10:10');
+SHOW COLUMNS FROM t1;
+Field Type Null Key Default Extra
+TIMESTAMP('00:00:00','10:10:10') datetime YES NULL
+TIMESTAMP(TIME('00:00:00'),'10:10:10') datetime YES NULL
+SELECT * FROM t1;
+TIMESTAMP('00:00:00','10:10:10') TIMESTAMP(TIME('00:00:00'),'10:10:10')
+NULL NULL
+DROP TABLE t1;
+#
+# MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1)
+#
+SELECT MAKETIME(0, 0, -0.1);
+MAKETIME(0, 0, -0.1)
+NULL
diff --git a/mysql-test/r/func_time_hires.result b/mysql-test/r/func_time_hires.result
index 4aa0333c4b4..1a736c89573 100644
--- a/mysql-test/r/func_time_hires.result
+++ b/mysql-test/r/func_time_hires.result
@@ -15,11 +15,11 @@ current_time(3) 01:01:01.123
current_timestamp(4) 2011-01-01 01:01:01.1234
localtime(5) 2011-01-01 01:01:01.12345
localtimestamp(6) 2011-01-01 01:01:01.123456
-time_to_sec('12:34:56') 45296.000000
-time_to_sec('12:34:56.789') 45296.789000
+time_to_sec('12:34:56') 45296
+time_to_sec('12:34:56.789') 45296.789
select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
-sec_to_time(time_to_sec('1:2:3')) 01:02:03.000000
-sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.567890
+sec_to_time(time_to_sec('1:2:3')) 01:02:03
+sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.56789
select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
time_to_sec(sec_to_time(11111)) 11111
time_to_sec(sec_to_time(11111.22222)) 11111.22222
@@ -48,7 +48,7 @@ t1 CREATE TABLE `t1` (
`localtime(5)` datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000',
`localtimestamp(6)` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
`time_to_sec(123456)` bigint(17) DEFAULT NULL,
- `time_to_sec('12:34:56.789')` decimal(22,6) DEFAULT NULL
+ `time_to_sec('12:34:56.789')` decimal(19,3) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
sec_to_time(12345) 03:25:45
@@ -63,15 +63,15 @@ current_timestamp(4) 2011-01-01 01:01:01.1234
localtime(5) 2011-01-01 01:01:01.12345
localtimestamp(6) 2011-01-01 01:01:01.123456
time_to_sec(123456) 45296
-time_to_sec('12:34:56.789') 45296.789000
+time_to_sec('12:34:56.789') 45296.789
drop table t1;
select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));;
-unix_timestamp('2011-01-01 01:01:01') 1293832861.000000
+unix_timestamp('2011-01-01 01:01:01') 1293832861
unix_timestamp('2011-01-01 01:01:01.123456') 1293832861.123456
unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))) 1293832861
unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4))) 1293832861.1234
select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));;
-from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01.000000
+from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01
from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')) 2011-01-01 01:01:01.123456
from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))) 2011-01-01 01:01:01
from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4)))) 2011-01-01 01:01:01.1234
@@ -167,7 +167,7 @@ CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00')
2011-01-02 15:00:00
SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00')
-2011-01-02 15:00:00.123000
+2011-01-02 15:00:00.123
SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00')
2011-01-02 15:00:00.123456
@@ -200,7 +200,7 @@ time(f1)
alter table t1 modify f1 varchar(100);
select time(f1) from t1;
time(f1)
-21:00:00
+21:00:00.000000
select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
time(f1)
21:00:00.000000
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 10caf4cd10f..f3910b67dd3 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -1615,8 +1615,8 @@ ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't
show grants for mysqluser10@localhost;
Grants for mysqluser10@localhost
GRANT USAGE ON *.* TO 'mysqluser10'@'localhost'
-GRANT SELECT ON `mysqltest1`.`t22` TO 'mysqluser10'@'localhost'
GRANT SELECT ON `mysqltest1`.`t11` TO 'mysqluser10'@'localhost'
+GRANT SELECT ON `mysqltest1`.`t22` TO 'mysqluser10'@'localhost'
GRANT EXECUTE ON PROCEDURE `mysqltest1`.`p1` TO 'mysqluser10'@'localhost'
GRANT EXECUTE ON FUNCTION `mysqltest1`.`f1` TO 'mysqluser10'@'localhost'
select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser10' and host='localhost';
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index 283dd8f38ba..43b0f4d56f3 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -3388,9 +3388,10 @@ COUNT(DISTINCT a, b + 0)
16
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL a 10 NULL 9 Using index for group-by
+1 SIMPLE t1 index NULL a 10 NULL 16 Using index
SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
COUNT(DISTINCT a)
+2
EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 16
@@ -3524,7 +3525,7 @@ WHERE b = 13 AND c = 42 GROUP BY a;
a COUNT(DISTINCT a) SUM(DISTINCT a)
EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range NULL a 10 NULL 9 Using where; Using index for group-by
+1 SIMPLE t2 index NULL a 15 NULL 16 Using where; Using index
SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
COUNT(DISTINCT a, b) SUM(DISTINCT a)
0 NULL
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index ce962a96f29..bf25b1c28ee 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -43,7 +43,7 @@ create view v1 (c) as
SELECT table_name FROM information_schema.TABLES
WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
table_name not like 'ndb_%' AND table_name not like 'innodb_%' AND
-table_name not like 'pbxt_%' AND table_name not like 'xtradb_%';
+table_name not like 'xtradb_%';
select * from v1;
c
ALL_PLUGINS
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index 0e5b36acb10..fdd2027990f 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -1460,7 +1460,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE D system PRIMARY NULL NULL NULL 1
1 SIMPLE DSAR system NULL NULL NULL NULL 1
1 SIMPLE DT range t_id t_id 2 NULL 2 Using where
-1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,test.D.birthday 1 Using index
+1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,func 1 Using index
SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR
WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND
DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id;
@@ -1477,6 +1477,25 @@ DROP TABLE t1,t2,t3,t4,t5;
#
SELECT * FROM t5 JOIN (t1 JOIN t2 UNION SELECT * FROM t3 JOIN t4);
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 ')' at line 1
+#
+# MDEV-4959: join of const table with NULL fields
+#
+CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2 (i2 int, a int, b int) ENGINE=MyISAM;
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3);
+SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b;
+i1 i2 a b
+EXPLAIN EXTENDED
+SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00
+Warnings:
+Note 1003 select NULL AS `i1`,`v2`.`i2` AS `i2`,`v2`.`a` AS `a`,`v2`.`b` AS `b` from `test`.`v2` where ((`v2`.`i2` = NULL) and (`v2`.`a` < `v2`.`b`))
+DROP VIEW v2;
+DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
#
# Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index fb4cc58d607..c9b694c9532 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -2138,4 +2138,88 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index
drop table t0, t1;
+#
+# MDEV-4836: Wrong result on <not null date column> IS NULL (old documented hack stopped working)
+# (this is a regression after fix for MDEV-4817)
+#
+CREATE TABLE t1 (id INT, d DATE NOT NULL);
+INSERT INTO t1 VALUES (1,'0000-00-00'),(2,'0000-00-00');
+CREATE TABLE t2 (i INT);
+SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL;
+id d i
+1 0000-00-00 NULL
+2 0000-00-00 NULL
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i1 INT, d1 DATE NOT NULL);
+INSERT INTO t1 VALUES (1,'2012-12-21'),(2,'0000-00-00');
+CREATE TABLE t2 (i2 INT, j2 INT);
+INSERT INTO t2 VALUES (1,10),(2,20);
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2;
+i1 d1 i2 j2
+2 0000-00-00 NULL NULL
+DROP TABLE t1,t2;
+# Another testcase
+CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2 (i2 INT, a INT, b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3);
+SELECT * FROM t1 LEFT JOIN v2 ON i1 = i2 WHERE a < b;
+i1 i2 a b
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE a < b;
+i1 i2 a b
+drop view v2;
+drop table t1,t2;
+#
+# Bug mdev-4942: LEFT JOIN with conjunctive
+# <non-nullable datetime field> IS NULL in WHERE
+# causes an assert failure
+#
+CREATE TABLE t1 ( i1 int, d1 date );
+INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16');
+CREATE TABLE t2 ( i2 int, d2 date NOT NULL );
+INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25');
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL;
+i1 d1 i2 d2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4952: LEFT JOIN with disjunctive
+# <non-nullable datetime field> IS NULL in WHERE
+# causes an assert failure
+#
+CREATE TABLE t1 (a1 int, b1 int NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1, 10), (2, 11);
+CREATE TABLE t2 (dt datetime NOT NULL, a2 int, b2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES
+('2006-10-08 09:34:54', 1, 100), ('2001-01-19 01:04:43', 2, 200);
+SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2
+WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL;
+a1 b1 dt a2 b2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4962: nested outer join with
+# <non-nullable datetime field> IS NULL in WHERE
+# causes an assert failure
+#
+CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (i2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (10),(20);
+CREATE TABLE t3 (i3 int, d3 datetime NOT NULL) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (8,'2008-12-04 17:53:42'),(9,'2012-12-21 12:12:12');
+SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
+WHERE d3 IS NULL;
+i1 i2 i3 d3
+1 NULL NULL NULL
+2 NULL NULL NULL
+EXPLAIN EXTENDED
+SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
+WHERE d3 IS NULL;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`i2` = `test`.`t1`.`i1`) and (`test`.`t3`.`i3` = `test`.`t1`.`i1`))) where ((`test`.`t3`.`d3` = 0) or isnull(`test`.`t3`.`d3`))
+DROP TABLE t1,t2,t3;
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result
index b5460d43e2b..eae21a090c4 100644
--- a/mysql-test/r/join_outer_jcl6.result
+++ b/mysql-test/r/join_outer_jcl6.result
@@ -2149,6 +2149,90 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index
drop table t0, t1;
+#
+# MDEV-4836: Wrong result on <not null date column> IS NULL (old documented hack stopped working)
+# (this is a regression after fix for MDEV-4817)
+#
+CREATE TABLE t1 (id INT, d DATE NOT NULL);
+INSERT INTO t1 VALUES (1,'0000-00-00'),(2,'0000-00-00');
+CREATE TABLE t2 (i INT);
+SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL;
+id d i
+1 0000-00-00 NULL
+2 0000-00-00 NULL
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i1 INT, d1 DATE NOT NULL);
+INSERT INTO t1 VALUES (1,'2012-12-21'),(2,'0000-00-00');
+CREATE TABLE t2 (i2 INT, j2 INT);
+INSERT INTO t2 VALUES (1,10),(2,20);
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2;
+i1 d1 i2 j2
+2 0000-00-00 NULL NULL
+DROP TABLE t1,t2;
+# Another testcase
+CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2 (i2 INT, a INT, b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3);
+SELECT * FROM t1 LEFT JOIN v2 ON i1 = i2 WHERE a < b;
+i1 i2 a b
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE a < b;
+i1 i2 a b
+drop view v2;
+drop table t1,t2;
+#
+# Bug mdev-4942: LEFT JOIN with conjunctive
+# <non-nullable datetime field> IS NULL in WHERE
+# causes an assert failure
+#
+CREATE TABLE t1 ( i1 int, d1 date );
+INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16');
+CREATE TABLE t2 ( i2 int, d2 date NOT NULL );
+INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25');
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL;
+i1 d1 i2 d2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4952: LEFT JOIN with disjunctive
+# <non-nullable datetime field> IS NULL in WHERE
+# causes an assert failure
+#
+CREATE TABLE t1 (a1 int, b1 int NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1, 10), (2, 11);
+CREATE TABLE t2 (dt datetime NOT NULL, a2 int, b2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES
+('2006-10-08 09:34:54', 1, 100), ('2001-01-19 01:04:43', 2, 200);
+SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2
+WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL;
+a1 b1 dt a2 b2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4962: nested outer join with
+# <non-nullable datetime field> IS NULL in WHERE
+# causes an assert failure
+#
+CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (i2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (10),(20);
+CREATE TABLE t3 (i3 int, d3 datetime NOT NULL) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (8,'2008-12-04 17:53:42'),(9,'2012-12-21 12:12:12');
+SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
+WHERE d3 IS NULL;
+i1 i2 i3 d3
+1 NULL NULL NULL
+2 NULL NULL NULL
+EXPLAIN EXTENDED
+SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
+WHERE d3 IS NULL;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`i2` = `test`.`t1`.`i1`) and (`test`.`t3`.`i3` = `test`.`t1`.`i1`))) where ((`test`.`t3`.`d3` = 0) or isnull(`test`.`t3`.`d3`))
+DROP TABLE t1,t2,t3;
SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default;
show variables like 'join_cache_level';
diff --git a/mysql-test/r/myisam_optimize.result b/mysql-test/r/myisam_optimize.result
new file mode 100644
index 00000000000..5c9dee9a9ca
--- /dev/null
+++ b/mysql-test/r/myisam_optimize.result
@@ -0,0 +1,23 @@
+call mtr.add_suppression(" marked as crashed and should be repaired");
+create table t1 (a int auto_increment primary key, b text);
+insert t1 (b) select repeat("A", 100);
+insert t1 (b) select repeat("B", 200) from t1;
+insert t1 (b) select repeat("C", 300) from t1;
+delete from t1 where a < 3;
+explain select a, left(b,10) from t1 order by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using filesort
+select left(b,10), a from t1 order by a;
+left(b,10) a
+CCCCCCCCCC 3
+CCCCCCCCCC 4
+set debug_sync='myisam_before_repair_by_sort wait_for go';
+optimize table t1;
+select a, left(b,10) from t1 order by a;
+set debug_sync='now signal go';
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+a left(b,10)
+3 CCCCCCCCCC
+4 CCCCCCCCCC
+drop table t1;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index da96d843273..131bd6fd593 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -5196,7 +5196,7 @@ CREATE TABLE b12809202_db.t1 (c1 INT);
CREATE TABLE b12809202_db.t2 (c1 INT);
INSERT INTO b12809202_db.t1 VALUES (1), (2), (3);
INSERT INTO b12809202_db.t2 VALUES (1), (2), (3);
-# Starting mysqldump with --single-transaction & --flush-log options..
+# Starting mysqldump with --single-transaction & --flush-logs options..
# Note : In the following dump the transaction
# should start only after the logs are
# flushed, as 'flush logs' causes implicit
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index 916deeee1dd..836de3d5842 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -343,3 +343,33 @@ Field Type Null Key Default Extra
IFNULL(NULL, b) decimal(1,0) YES NULL
DROP TABLE t1, t2;
# End of 5.0 tests
+#
+# MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL
+#
+CREATE TABLE t1 (dt DATETIME NOT NULL);
+INSERT INTO t1 VALUES (NOW()),(NOW());
+EXPLAIN
+SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL;
+dt
+DROP TABLE t1;
+CREATE TABLE t1 (dt INT NOT NULL);
+INSERT INTO t1 VALUES (1),(2);
+EXPLAIN
+SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL;
+dt
+DROP TABLE t1;
+CREATE TABLE t1 (dt INT NOT NULL);
+INSERT INTO t1 VALUES (1),(2);
+EXPLAIN
+SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL);
+dt
+DROP TABLE t1;
diff --git a/mysql-test/r/partition_myisam.result b/mysql-test/r/partition_myisam.result
index 10586ddc548..ad21859a6a6 100644
--- a/mysql-test/r/partition_myisam.result
+++ b/mysql-test/r/partition_myisam.result
@@ -105,10 +105,11 @@ test.t1 check Error Failed to read from the .par file
test.t1 check error Corrupt
SELECT * FROM t1;
ERROR HY000: Failed to read from the .par file
-# Note that it is currently impossible to drop a partitioned table
-# without the .par file
+# Note that we will remove the frm file when we detect that
+# .par file has been deleted.
DROP TABLE t1;
-ERROR 42S02: Unknown table 't1'
+Warnings:
+Warning 155 Table 'test.t1' doesn't exist in engine
#
# Bug#50392: insert_id is not reset for partitioned tables
# auto_increment on duplicate entry
diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result
index fd46100b7ee..6a3d93d1b3f 100644
--- a/mysql-test/r/plugin.result
+++ b/mysql-test/r/plugin.result
@@ -44,9 +44,11 @@ set global example_ulong_var=500;
set global example_enum_var= e1;
show status like 'example%';
Variable_name Value
-Example_func_example enum_var is 0, ulong_var is 500, really
+Example_func_example enum_var is 0, ulong_var is 500, double_var is 8.500000, really
show variables like 'example%';
Variable_name Value
+example_double_thdvar 8.500000
+example_double_var 8.500000
example_enum_var e1
example_ulong_var 500
example_varopt_default 5
@@ -199,6 +201,84 @@ select 1;
1
1
UNINSTALL PLUGIN example;
+#
+# Bug #16194302 SUPPORT FOR FLOATING-POINT SYSTEM
+# VARIABLES USING THE PLUGIN INTERFACE.
+#
+INSTALL PLUGIN example SONAME 'ha_example';
+SET GLOBAL example_double_var = -0.1;
+Warnings:
+Warning 1292 Truncated incorrect example_double_var value: '-0.1'
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+0.500000
+SET GLOBAL example_double_var = 0.000001;
+Warnings:
+Warning 1292 Truncated incorrect example_double_var value: '0.000001'
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+0.500000
+SET GLOBAL example_double_var = 0.4;
+Warnings:
+Warning 1292 Truncated incorrect example_double_var value: '0.4'
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+0.500000
+SET GLOBAL example_double_var = 123.456789;
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+123.456789
+SET GLOBAL example_double_var = 500;
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+500.000000
+SET GLOBAL example_double_var = 999.999999;
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+999.999999
+SET GLOBAL example_double_var = 1000.51;
+Warnings:
+Warning 1292 Truncated incorrect example_double_var value: '1000.51'
+SELECT @@GLOBAL.example_double_var;
+@@GLOBAL.example_double_var
+1000.500000
+SET SESSION example_double_thdvar = -0.1;
+Warnings:
+Warning 1292 Truncated incorrect example_double_thdvar value: '-0.1'
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+0.500000
+SET SESSION example_double_thdvar = 0.000001;
+Warnings:
+Warning 1292 Truncated incorrect example_double_thdvar value: '0.000001'
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+0.500000
+SET SESSION example_double_thdvar = 0.4;
+Warnings:
+Warning 1292 Truncated incorrect example_double_thdvar value: '0.4'
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+0.500000
+SET SESSION example_double_thdvar = 123.456789;
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+123.456789
+SET SESSION example_double_thdvar = 500;
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+500.000000
+SET SESSION example_double_thdvar = 999.999999;
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+999.999999
+SET SESSION example_double_thdvar = 1000.51;
+Warnings:
+Warning 1292 Truncated incorrect example_double_thdvar value: '1000.51'
+SELECT @@SESSION.example_double_thdvar;
+@@SESSION.example_double_thdvar
+1000.500000
+UNINSTALL PLUGIN example;
UNINSTALL PLUGIN MyISAM;
ERROR HY000: Built-in plugins cannot be deleted
select plugin_name from information_schema.plugins where plugin_library like 'ha_example%';
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index d7bc193a15c..1c3c2de764b 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longtext,
- `const10` decimal(22,6) DEFAULT NULL,
- `param10` decimal(65,30) DEFAULT NULL,
+ `const10` bigint(17) DEFAULT NULL,
+ `param10` bigint(20) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
-def test t5 t5 const10 const10 246 24 16 Y 32768 6 63
-def test t5 t5 param10 param10 246 67 40 Y 32768 30 63
+def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
+def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861.000000
-param10 662680861.000000000000000000000000000000
+const10 662680861
+param10 662680861
const11 1991
param11 1991
const12 NULL
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index ce9409762e5..8b4b6daa108 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -1776,8 +1776,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longtext,
- `const10` decimal(22,6) DEFAULT NULL,
- `param10` decimal(65,30) DEFAULT NULL,
+ `const10` bigint(17) DEFAULT NULL,
+ `param10` bigint(20) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1806,8 +1806,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
-def test t5 t5 const10 const10 246 24 16 Y 32768 6 63
-def test t5 t5 param10 param10 246 67 40 Y 32768 30 63
+def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
+def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1833,8 +1833,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861.000000
-param10 662680861.000000000000000000000000000000
+const10 662680861
+param10 662680861
const11 1991
param11 1991
const12 NULL
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index d5fc8f7e8da..0ea54a45afa 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -1777,8 +1777,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longtext,
- `const10` decimal(22,6) DEFAULT NULL,
- `param10` decimal(65,30) DEFAULT NULL,
+ `const10` bigint(17) DEFAULT NULL,
+ `param10` bigint(20) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1807,8 +1807,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
-def test t5 t5 const10 const10 246 24 16 Y 32768 6 63
-def test t5 t5 param10 param10 246 67 40 Y 32768 30 63
+def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
+def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1834,8 +1834,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861.000000
-param10 662680861.000000000000000000000000000000
+const10 662680861
+param10 662680861
const11 1991
param11 1991
const12 NULL
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index bb74363f68c..2fc9475e926 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -1713,8 +1713,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longtext,
- `const10` decimal(22,6) DEFAULT NULL,
- `param10` decimal(65,30) DEFAULT NULL,
+ `const10` bigint(17) DEFAULT NULL,
+ `param10` bigint(20) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1743,8 +1743,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
-def test t5 t5 const10 const10 246 24 16 Y 32768 6 63
-def test t5 t5 param10 param10 246 67 40 Y 32768 30 63
+def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
+def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1770,8 +1770,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861.000000
-param10 662680861.000000000000000000000000000000
+const10 662680861
+param10 662680861
const11 1991
param11 1991
const12 NULL
@@ -5067,8 +5067,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longtext,
- `const10` decimal(22,6) DEFAULT NULL,
- `param10` decimal(65,30) DEFAULT NULL,
+ `const10` bigint(17) DEFAULT NULL,
+ `param10` bigint(20) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -5097,8 +5097,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
-def test t5 t5 const10 const10 246 24 16 Y 32768 6 63
-def test t5 t5 param10 param10 246 67 40 Y 32768 30 63
+def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
+def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -5124,8 +5124,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861.000000
-param10 662680861.000000000000000000000000000000
+const10 662680861
+param10 662680861
const11 1991
param11 1991
const12 NULL
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 86d98fdcc54..d41bfaa2c67 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -712,14 +712,14 @@ INSERT INTO t1 VALUES
'd8c4177d09f8b11f5.52725522');
EXPLAIN
SELECT s.oxid FROM t1 v, t1 s
-WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
+WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using index condition
1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4)
SELECT s.oxid FROM t1 v, t1 s
-WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
+WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
oxid
@@ -728,6 +728,11 @@ d8c4177d206a333d2.74422679
d8c4177d225791924.30714720
d8c4177d2380fc201.39666693
d8c4177d24ccef970.14957924
+d8c4177d151affab2.81582771
+d8c4177d206a333d2.74422678
+d8c4177d225791924.30714721
+d8c4177d2380fc201.39666694
+d8c4177d24ccef970.14957925
DROP TABLE t1;
create table t1 (
c1 char(10), c2 char(10), c3 char(10), c4 char(10),
@@ -1887,6 +1892,46 @@ AAA AAA AAA
AAAA AAAA AAAA
AAAAA AAAAA AAAAA
DROP TABLE t1;
+#
+# mdev-4894: Poor performance with unnecessary
+# (bug#70021) 'Range checked for each record'
+#
+create table t1( key1 int not null, INDEX i1(key1) );
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8);
+insert into t1 select key1+8 from t1;
+insert into t1 select key1+16 from t1;
+insert into t1 select key1+32 from t1;
+insert into t1 select key1+64 from t1;
+insert into t1 select key1+128 from t1;
+insert into t1 select key1+256 from t1;
+insert into t1 select key1+512 from t1;
+alter table t1 add key2 int not null, add index i2(key2);
+update t1 set key2=key1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+create table t2 (a int);
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8);
+insert into t2 select a+16 from t2;
+insert into t2 select a+32 from t2;
+insert into t2 select a+64 from t2;
+explain
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 64
+1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Using join buffer (flat, BNL join)
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
+count(*)
+128
+explain
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 64
+1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Using join buffer (flat, BNL join)
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
+count(*)
+126
+drop table t1,t2;
End of 5.1 tests
#
# LP Bug #533117: Wrong use_count in SEL_ARG trees
diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result
index 0527449fa9b..a5c14d99975 100644
--- a/mysql-test/r/range_mrr_icp.result
+++ b/mysql-test/r/range_mrr_icp.result
@@ -714,14 +714,14 @@ INSERT INTO t1 VALUES
'd8c4177d09f8b11f5.52725522');
EXPLAIN
SELECT s.oxid FROM t1 v, t1 s
-WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
+WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using index condition
1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4)
SELECT s.oxid FROM t1 v, t1 s
-WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
+WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
oxid
@@ -730,6 +730,11 @@ d8c4177d206a333d2.74422679
d8c4177d225791924.30714720
d8c4177d2380fc201.39666693
d8c4177d24ccef970.14957924
+d8c4177d151affab2.81582771
+d8c4177d206a333d2.74422678
+d8c4177d225791924.30714721
+d8c4177d2380fc201.39666694
+d8c4177d24ccef970.14957925
DROP TABLE t1;
create table t1 (
c1 char(10), c2 char(10), c3 char(10), c4 char(10),
@@ -1889,6 +1894,46 @@ AAA AAA AAA
AAAA AAAA AAAA
AAAAA AAAAA AAAAA
DROP TABLE t1;
+#
+# mdev-4894: Poor performance with unnecessary
+# (bug#70021) 'Range checked for each record'
+#
+create table t1( key1 int not null, INDEX i1(key1) );
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8);
+insert into t1 select key1+8 from t1;
+insert into t1 select key1+16 from t1;
+insert into t1 select key1+32 from t1;
+insert into t1 select key1+64 from t1;
+insert into t1 select key1+128 from t1;
+insert into t1 select key1+256 from t1;
+insert into t1 select key1+512 from t1;
+alter table t1 add key2 int not null, add index i2(key2);
+update t1 set key2=key1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+create table t2 (a int);
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8);
+insert into t2 select a+16 from t2;
+insert into t2 select a+32 from t2;
+insert into t2 select a+64 from t2;
+explain
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 64
+1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
+count(*)
+128
+explain
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 64
+1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
+count(*)
+126
+drop table t1,t2;
End of 5.1 tests
#
# LP Bug #533117: Wrong use_count in SEL_ARG trees
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 806afb1c843..55b2ac7bc3a 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -5345,7 +5345,7 @@ a b c
8 8 8
DROP TABLE t1,t2;
#
-# Bug mdev-4413: another manifestations of bug mdev-2474
+# Bug mdev-4413: another manifestations of bug mdev-4274
# (valgrind complains)
#
CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
@@ -5357,6 +5357,118 @@ WHERE c = a AND
( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c );
a b c
DROP TABLE t1, t2;
+#
+# Bug mdev-4355: equalities from the result of simplification of OR
+# are not propagated to lower AND levels
+#
+CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11);
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+a b
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` = 5))
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+a b
+DROP TABLE t1;
+#
+# Bug mdev-4418: impossible multiple equality in OR formula
+# after row substitution
+#
+CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0,'j'), (8,'v');
+CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('k','k');
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS `d` from `test`.`t1` where ((`test`.`t1`.`b` = 'k') and (`test`.`t1`.`a` = 136))
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+a b c d
+DROP TABLE t1,t2;
+#
+# Bug mdev-4944: range conditition in OR formula with fields
+# belonging to multiple equalities
+#
+CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,8);
+CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8), (9);
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select 1 AS `i1`,8 AS `j1`,`test`.`t2`.`i2` AS `i2` from `test`.`t2` where 0
+SELECT * FROM t1, t2
+WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+i1 j1 i2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4971: equality propagation after merging degenerate
+# disjunction into embedding AND level
+#
+CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,10,100), (2,20,200) ;
+CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,1);
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+pk1 a1 b1 pk2 a2
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or 0))
+INSERT INTO t1 VALUES (3,1,6);
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+pk1 a1 b1 pk2 a2
+3 1 6 1 1
+DROP TABLE t1,t2;
End of 5.3 tests
#
# mysql BUG#1271 Undefined variable in PASSWORD()
diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result
index 97ffa8413cb..32a4b0e30a8 100644
--- a/mysql-test/r/select_jcl6.result
+++ b/mysql-test/r/select_jcl6.result
@@ -5356,7 +5356,7 @@ a b c
8 8 8
DROP TABLE t1,t2;
#
-# Bug mdev-4413: another manifestations of bug mdev-2474
+# Bug mdev-4413: another manifestations of bug mdev-4274
# (valgrind complains)
#
CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
@@ -5368,6 +5368,118 @@ WHERE c = a AND
( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c );
a b c
DROP TABLE t1, t2;
+#
+# Bug mdev-4355: equalities from the result of simplification of OR
+# are not propagated to lower AND levels
+#
+CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11);
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+a b
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` = 5))
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+a b
+DROP TABLE t1;
+#
+# Bug mdev-4418: impossible multiple equality in OR formula
+# after row substitution
+#
+CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0,'j'), (8,'v');
+CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('k','k');
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS `d` from `test`.`t1` where ((`test`.`t1`.`b` = 'k') and (`test`.`t1`.`a` = 136))
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+a b c d
+DROP TABLE t1,t2;
+#
+# Bug mdev-4944: range conditition in OR formula with fields
+# belonging to multiple equalities
+#
+CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,8);
+CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8), (9);
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select 1 AS `i1`,8 AS `j1`,`test`.`t2`.`i2` AS `i2` from `test`.`t2` where 0
+SELECT * FROM t1, t2
+WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+i1 j1 i2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4971: equality propagation after merging degenerate
+# disjunction into embedding AND level
+#
+CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,10,100), (2,20,200) ;
+CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,1);
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+pk1 a1 b1 pk2 a2
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or 0))
+INSERT INTO t1 VALUES (3,1,6);
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+pk1 a1 b1 pk2 a2
+3 1 6 1 1
+DROP TABLE t1,t2;
End of 5.3 tests
#
# mysql BUG#1271 Undefined variable in PASSWORD()
diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result
index 806afb1c843..55b2ac7bc3a 100644
--- a/mysql-test/r/select_pkeycache.result
+++ b/mysql-test/r/select_pkeycache.result
@@ -5345,7 +5345,7 @@ a b c
8 8 8
DROP TABLE t1,t2;
#
-# Bug mdev-4413: another manifestations of bug mdev-2474
+# Bug mdev-4413: another manifestations of bug mdev-4274
# (valgrind complains)
#
CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
@@ -5357,6 +5357,118 @@ WHERE c = a AND
( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c );
a b c
DROP TABLE t1, t2;
+#
+# Bug mdev-4355: equalities from the result of simplification of OR
+# are not propagated to lower AND levels
+#
+CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11);
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1))
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+a b
+5 11
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+a b
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` = 5))
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+a b
+DROP TABLE t1;
+#
+# Bug mdev-4418: impossible multiple equality in OR formula
+# after row substitution
+#
+CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0,'j'), (8,'v');
+CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('k','k');
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS `d` from `test`.`t1` where ((`test`.`t1`.`b` = 'k') and (`test`.`t1`.`a` = 136))
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+a b c d
+DROP TABLE t1,t2;
+#
+# Bug mdev-4944: range conditition in OR formula with fields
+# belonging to multiple equalities
+#
+CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,8);
+CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8), (9);
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select 1 AS `i1`,8 AS `j1`,`test`.`t2`.`i2` AS `i2` from `test`.`t2` where 0
+SELECT * FROM t1, t2
+WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+i1 j1 i2
+DROP TABLE t1,t2;
+#
+# Bug mdev-4971: equality propagation after merging degenerate
+# disjunction into embedding AND level
+#
+CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,10,100), (2,20,200) ;
+CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,1);
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+pk1 a1 b1 pk2 a2
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or 0))
+INSERT INTO t1 VALUES (3,1,6);
+SELECT * FROM t1, t2
+WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+pk1 a1 b1 pk2 a2
+3 1 6 1 1
+DROP TABLE t1,t2;
End of 5.3 tests
#
# mysql BUG#1271 Undefined variable in PASSWORD()
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 6e6f05667ed..d17f8c3fbb1 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -7977,4 +7977,43 @@ Warning 1329 No data - zero rows fetched, selected, or processed
drop procedure p1;
drop procedure p2;
drop table t1;
+#
+# MDEV-4978 - Server cursor is broken with blobs in the select list,
+# ORDER BY does not work
+#
+CREATE TABLE t1(a INT, b BLOB);
+INSERT INTO t1 VALUES(1,REPEAT('a',4835)),(2,'b'),(3,'c'),(4,'d'),(5,REPEAT('e',805)),(6,'f');
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE done INT DEFAULT 0;
+DECLARE v1 INT;
+DECLARE v2 BLOB;
+DECLARE c1 CURSOR FOR SELECT * FROM t1 ORDER BY a;
+DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1;
+OPEN c1;
+REPEAT
+FETCH c1 INTO v1, v2;
+IF NOT done THEN
+SELECT v1;
+END IF;
+UNTIL done END REPEAT;
+CLOSE c1;
+END|
+CALL p1;
+v1
+1
+v1
+2
+v1
+3
+v1
+4
+v1
+5
+v1
+6
+Warnings:
+Error 1329 No data - zero rows fetched, selected, or processed
+DROP PROCEDURE p1;
+DROP TABLE t1;
# End of 5.5 test
diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result
index 4fd303dfd44..72ca9d33354 100644
--- a/mysql-test/r/subselect2.result
+++ b/mysql-test/r/subselect2.result
@@ -237,6 +237,34 @@ a b
DROP TABLE t1,t2,t3;
set optimizer_switch=@tmp_mdev567;
#
+# MDEV-4996: degenerate OR formula in WHERE of a subquery
+#
+CREATE TABLE t1 (a int, c1 varchar(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,'x'), (8,'d');
+CREATE TABLE t2 (m int, n int, c2 varchar(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (0, 5, 'x'), (1, 4,'p');
+SELECT * FROM t1 WHERE c1 NOT IN (
+SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c
+WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND
+( t2b.m != a OR t2b.m = t2a.m ));
+a c1
+2 x
+8 d
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE c1 NOT IN (
+SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c
+WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND
+( t2b.m != a OR t2b.m = t2a.m ));
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+2 DEPENDENT SUBQUERY t2a ALL NULL NULL NULL NULL 2 100.00 Using where
+2 DEPENDENT SUBQUERY t2b ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t2c ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`c1`,`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t2a`.`c2` from `test`.`t2` `t2a` join `test`.`t2` `t2b` join `test`.`t2` `t2c` where (((`test`.`t2b`.`m` <> `test`.`t1`.`a`) or (`test`.`t2b`.`m` = `test`.`t2a`.`m`)) and trigcond(((<cache>(`test`.`t1`.`c1`) = `test`.`t2a`.`c2`) or isnull(`test`.`t2a`.`c2`))) and (`test`.`t2c`.`c2` = `test`.`t2b`.`c2`) and (`test`.`t2b`.`n` = `test`.`t2a`.`m`)) having trigcond(<is_not_null_test>(`test`.`t2a`.`c2`)))))))
+DROP TABLE t1,t2;
+#
# MDEV-614, also MDEV-536, also LP:1050806:
# different result for a query using subquery between 5.5.25 and 5.5.27
#
@@ -295,4 +323,29 @@ node_uid date mirror_date result
2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0
set optimizer_switch=@tmp_mdev614;
DROP TABLE t1;
+#
+# MDEV-4420: non-expensive single-value subquery used as
+# used as an access key to join a table
+#
+create table t1 (a varchar(3));
+insert into t1 values ('USA'), ('FRA');
+create table t2 select * from t1;
+insert into t2 values ('RUS');
+create table t3 select * from t2;
+create index idx on t3(a);
+explain extended
+select * from t1, t2 left join t3 on ( t2.a = t3.a )
+where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 );
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 ref idx idx 6 func 2 100.00 Using where; Using index
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where ((`test`.`t1`.`a` = (select min(`test`.`t1`.`a`) from `test`.`t1`)) and (`test`.`t2`.`a` = (select min(`test`.`t1`.`a`) from `test`.`t1`)))
+select * from t1, t2 left join t3 on ( t2.a = t3.a )
+where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 );
+a a a
+FRA FRA FRA
+drop table t1,t2,t3;
set optimizer_switch=@subselect2_test_tmp;
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result
index 0a98efb5c0e..e1c9df3b00b 100644
--- a/mysql-test/r/subselect_mat.result
+++ b/mysql-test/r/subselect_mat.result
@@ -2016,6 +2016,28 @@ drop table t1,t2;
# This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
+#
+# MDEV-4908: Assertion `((Item_cond *) cond)->functype() ==
+# ((Item_cond *) new_item)->functype()' fails on a query with
+# IN and equal conditions, AND/OR, materialization+semijoin
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'materialization=on,semijoin=on';
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+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;
+SET optimizer_switch=@save_optimizer_switch;
+#
+# MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries
+#
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+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;
+# End of 5.3 tests
set @subselect_mat_test_optimizer_switch_value=null;
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result
index 3fc91b452a5..2d229db9ec5 100644
--- a/mysql-test/r/subselect_sj.result
+++ b/mysql-test/r/subselect_sj.result
@@ -2485,7 +2485,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
1 PRIMARY t1 ref a a 5 const 1 Using index
-1 PRIMARY t2 ref a a 5 test.t3.b 1 Using index
+1 PRIMARY t2 ref a a 5 func 1 Using index
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 0
SELECT * FROM t1, t2
WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4);
diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result
index fbe6db4edda..74fea8957a9 100644
--- a/mysql-test/r/subselect_sj2_mat.result
+++ b/mysql-test/r/subselect_sj2_mat.result
@@ -1399,7 +1399,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join)
Warnings:
-Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t2`.`i2` > 0))
+Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t3`.`i3` > 0))
SELECT * FROM t1
WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2);
i1
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result
index f18de3c4d0b..a0ebbb3305d 100644
--- a/mysql-test/r/subselect_sj_jcl6.result
+++ b/mysql-test/r/subselect_sj_jcl6.result
@@ -2499,7 +2499,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
1 PRIMARY t1 ref a a 5 const 1 Using index
-1 PRIMARY t2 ref a a 5 test.t3.b 1 Using index
+1 PRIMARY t2 ref a a 5 func 1 Using index
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 0
SELECT * FROM t1, t2
WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4);
diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result
index 4e8d1697b83..bcdd82b790c 100644
--- a/mysql-test/r/subselect_sj_mat.result
+++ b/mysql-test/r/subselect_sj_mat.result
@@ -2056,3 +2056,25 @@ drop table t1,t2;
# This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
+#
+# MDEV-4908: Assertion `((Item_cond *) cond)->functype() ==
+# ((Item_cond *) new_item)->functype()' fails on a query with
+# IN and equal conditions, AND/OR, materialization+semijoin
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'materialization=on,semijoin=on';
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+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;
+SET optimizer_switch=@save_optimizer_switch;
+#
+# MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries
+#
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+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;
+# End of 5.3 tests
diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result
index 63b3304641b..0b19b6b4eaf 100644
--- a/mysql-test/r/table_elim.result
+++ b/mysql-test/r/table_elim.result
@@ -628,4 +628,24 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select `test`.`t2`.`b` AS `b` from `test`.`t2` where <expr_cache><`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`b`,<exists>(select sum(1) from dual where 1 having (<cache>(`test`.`t2`.`b`) = <ref_null_helper>(sum(1))))))
DROP TABLE t1,t2;
+#
+# MDEV-4840: Wrong result (missing rows) on LEFT JOIN with InnoDB tables
+#
+CREATE TABLE t1 (alpha3 VARCHAR(3));
+INSERT INTO t1 VALUES ('USA'),('CAN');
+CREATE TABLE t2 ( t3_code VARCHAR(3), name VARCHAR(64));
+INSERT INTO t2 VALUES ('USA','Austin'),('USA','Boston');
+CREATE TABLE t3 ( code VARCHAR(3), name VARCHAR(64), PRIMARY KEY (code), UNIQUE KEY (name));
+INSERT INTO t3 VALUES ('CAN','Canada'),('USA','United States');
+SELECT * FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code;
+alpha3 t3_code name code name
+USA USA Austin USA United States
+USA USA Boston USA United States
+CAN NULL NULL NULL NULL
+SELECT t1.alpha3 FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code;
+alpha3
+USA
+USA
+CAN
+DROP TABLE t1, t2, t3;
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/r/timezone.result b/mysql-test/r/timezone.result
index 5ae7e6f8117..d84fe54ba8c 100644
--- a/mysql-test/r/timezone.result
+++ b/mysql-test/r/timezone.result
@@ -7,7 +7,7 @@ select @a:=FROM_UNIXTIME(1);
1970-01-01 01:00:01
select unix_timestamp(@a);
unix_timestamp(@a)
-1.000000
+1
CREATE TABLE t1 (ts int);
INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00'));
INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 02:00'));
@@ -44,7 +44,7 @@ unix_timestamp('1970-01-01 01:00:01'),
unix_timestamp('2038-01-19 04:14:07'),
unix_timestamp('2038-01-19 04:14:08');
unix_timestamp('1970-01-01 01:00:00') unix_timestamp('1970-01-01 01:00:01') unix_timestamp('2038-01-19 04:14:07') unix_timestamp('2038-01-19 04:14:08')
-0.000000 1.000000 2147483647.000000 NULL
+0 1 2147483647 NULL
select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59');
unix_timestamp('1969-12-31 23:59:59') unix_timestamp('1970-01-01 00:00:00') unix_timestamp('1970-01-01 00:59:59')
NULL NULL NULL
diff --git a/mysql-test/r/timezone4.result b/mysql-test/r/timezone4.result
index ad0672890a2..28028bea657 100644
--- a/mysql-test/r/timezone4.result
+++ b/mysql-test/r/timezone4.result
@@ -3,4 +3,4 @@ from_unixtime(0)
1969-12-31 14:00:00
select unix_timestamp('1969-12-31 14:00:01');
unix_timestamp('1969-12-31 14:00:01')
-1.000000
+1
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index af747dca562..4ead8f8d743 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -311,6 +311,44 @@ NULL
Warnings:
Warning 1292 Incorrect datetime value: '2022-00-00 00:00:00'
#
+# MDEV-4804 Date comparing false result
+#
+SET @h0="20111107";
+SET @h1="0";
+SET @@timestamp=UNIX_TIMESTAMP('2013-08-19 20:30:00');
+SELECT
+COALESCE(DATE(@h0),DATE("1901-01-01")) AS h0d,
+COALESCE(DATE(@h1),DATE(NOW())) AS h1d,
+COALESCE(DATE(@h0),DATE("1901-01-01"))>COALESCE(DATE(@h1),DATE(NOW())) AS compare_h0_gt_h1;
+h0d h1d compare_h0_gt_h1
+2011-11-07 2013-08-19 0
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+SELECT
+DATE('20011107'),
+DATE('0'),
+COALESCE(DATE('0'),CURRENT_DATE) AS d1,
+DATE('20011107')>COALESCE(DATE('0'),CURRENT_DATE) AS cmp;
+DATE('20011107') DATE('0') d1 cmp
+2001-11-07 NULL 2013-08-19 0
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+SELECT
+DATE('20011107'),
+DATE('0'),
+IFNULL(DATE('0'),CURRENT_DATE) AS d1,
+DATE('20011107')>IFNULL(DATE('0'),CURRENT_DATE) AS cmp;
+DATE('20011107') DATE('0') d1 cmp
+2001-11-07 NULL 2013-08-19 0
+Warnings:
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+Warning 1292 Incorrect datetime value: '0'
+SET @@timestamp=DEFAULT;
+#
# End of 5.3 tests
#
#
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 1b53f92f82a..ff81029d127 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -657,13 +657,8 @@ create table t1 (d date, t time) engine=myisam;
insert into t1 values ('2000-12-03','22:55:23'),('2008-05-03','10:19:31');
select case when d = '2012-12-12' then d else t end as cond, group_concat( d ) from t1 group by cond;
cond group_concat( d )
-NULL 2000-12-03
-NULL 2008-05-03
-Warnings:
-Warning 1292 Incorrect datetime value: '22:55:23'
-Warning 1292 Incorrect datetime value: '10:19:31'
-Warning 1292 Incorrect datetime value: '22:55:23'
-Warning 1292 Incorrect datetime value: '10:19:31'
+0000-00-00 10:19:31 2008-05-03
+0000-00-00 22:55:23 2000-12-03
drop table t1;
#
# Semantics of the condition <non-nullable datetime field> IS NULL
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index 5a04913553b..32bbb6baa0b 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -187,10 +187,10 @@ Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
#
SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')));
CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00')))
-00:00:01.000000
+00:00:01
SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')));
CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00')))
-768:00:01.000000
+768:00:01
#
# End of 5.3 tests
#
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index d6321cae92b..966b88f0018 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4417,7 +4417,7 @@ WHERE f1<>0 OR f2<>0 AND f4='v' AND (f2<>0 OR f3<>0 AND f5<>0 OR f4 LIKE '%b%');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings:
-Note 1003 select 'r' AS `f4` from dual where ((20 <> 0) or 0)
+Note 1003 select 'r' AS `f4` from dual where (20 <> 0)
DROP VIEW v1;
DROP TABLE t1;
#
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index bfd09bfa9cd..ac09c19a4b4 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -1154,6 +1154,8 @@ drop user olga@localhost;
drop user pjotr@localhost;
drop user quintessa@localhost;
drop database mysqltest1;
+select * from information_schema.table_privileges;
+GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
End of 5.0 tests.
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/std_data/mdev5029.frm b/mysql-test/std_data/mdev5029.frm
new file mode 100644
index 00000000000..de169a20953
--- /dev/null
+++ b/mysql-test/std_data/mdev5029.frm
Binary files differ
diff --git a/mysql-test/std_data/pbxt_load_unique_error1.inc b/mysql-test/std_data/pbxt_load_unique_error1.inc
deleted file mode 100644
index 998daad4144..00000000000
--- a/mysql-test/std_data/pbxt_load_unique_error1.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-1,abc
-2,def
-3,ghi
-3,jkl
-4,opq
diff --git a/mysql-test/suite/binlog/t/binlog_killed_simulate.test b/mysql-test/suite/binlog/t/binlog_killed_simulate.test
index 8640e02d4e5..e1a1c9de3b2 100644
--- a/mysql-test/suite/binlog/t/binlog_killed_simulate.test
+++ b/mysql-test/suite/binlog/t/binlog_killed_simulate.test
@@ -21,9 +21,6 @@ reset master;
update t1 set a=2 /* will be "killed" after work has been done */;
# a proof the query is binlogged with no error
-#todo: introduce a suite private macro that provides numeric values
-# for some constants like the offset of the first real event
-# that is different between severs versions.
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
@@ -48,14 +45,14 @@ reset master;
--error ER_QUERY_INTERRUPTED
load data infile '../../std_data/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */;
-
# a proof the query is binlogged with an error
--let $binlog_load_data= query_get_value(SHOW BINLOG EVENTS, Pos, 5)
--let $binlog_end= query_get_value(SHOW BINLOG EVENTS, Pos, 6)
source include/show_binlog_events.inc;
---exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_load_data --stop-position=$binlog_end $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
+--mkdir $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571
+--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571 --force-if-open --start-position=$binlog_load_data --stop-position=$binlog_end $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
@@ -68,6 +65,8 @@ eval select $error_code /* must return 0 to mean the killed query is in */;
# cleanup for the sub-case
remove_file $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog;
+--remove_files_wildcard $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571 *
+--rmdir $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571
drop table t1,t2;
diff --git a/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc b/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc
index 95bbc35de72..e8e21a6be7b 100644
--- a/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc
+++ b/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc
@@ -104,8 +104,6 @@ if (`SELECT IF($query_count > 1, 1, 0)`)
# Detect extra rows:
# Allow phantoms in some configurations:
# - InnoDB default settings
- # - Falcon's falcon_consistent_read=0 (non-default setting)
- # (TODO: What about PBXT?)
#
###########################
# TODO: Execute a query against tmp1 and tmp2 which selects new rows (rows
diff --git a/mysql-test/suite/engines/rr_trx/include/rr_init.test b/mysql-test/suite/engines/rr_trx/include/rr_init.test
index b98905791b0..05769bf70eb 100644
--- a/mysql-test/suite/engines/rr_trx/include/rr_init.test
+++ b/mysql-test/suite/engines/rr_trx/include/rr_init.test
@@ -13,14 +13,6 @@ if (`SELECT @@storage_engine LIKE 'InnoDB' AND @@version LIKE '%6.%'`)
--enable_query_log
}
-if (`SELECT @@storage_engine LIKE 'PBXT' AND @@version LIKE '%5.1%'`)
-{
- --disable_query_log
- SET SESSION binlog_format = 'MIXED';
- SET GLOBAL binlog_format = 'MIXED';
- --enable_query_log
-}
-
# Verify default storage engine.
SHOW VARIABLES LIKE 'storage_engine';
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
index 43a60e4c57e..7b8074f82f2 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
@@ -1,7 +1,6 @@
SELECT * FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%'
ORDER BY table_schema, table_name, column_name;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
def information_schema ALL_PLUGINS LOAD_OPTION 11 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
@@ -438,7 +437,6 @@ COLLATION_NAME
FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%'
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH = 1
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
@@ -451,7 +449,6 @@ COLLATION_NAME
FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%'
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH <> 1
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
@@ -464,7 +461,6 @@ COLLATION_NAME
FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%'
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH IS NULL
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
@@ -489,7 +485,6 @@ COLUMN_TYPE
FROM information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%'
ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION;
COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE
3.0000 information_schema ALL_PLUGINS PLUGIN_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result
index 6e92285dbaf..5d3770c42de 100644
--- a/mysql-test/suite/funcs_1/r/is_tables_is.result
+++ b/mysql-test/suite/funcs_1/r/is_tables_is.result
@@ -12,7 +12,7 @@ AS "user_comment",
FROM information_schema.tables
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'
+AND table_name not like 'xtradb_%'
ORDER BY table_schema,table_name;
TABLE_CATALOG def
TABLE_SCHEMA information_schema
@@ -835,7 +835,7 @@ AS "user_comment",
FROM information_schema.tables
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'
+AND table_name not like 'xtradb_%'
ORDER BY table_schema,table_name;
TABLE_CATALOG def
TABLE_SCHEMA information_schema
diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
index 6e92285dbaf..5d3770c42de 100644
--- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
@@ -12,7 +12,7 @@ AS "user_comment",
FROM information_schema.tables
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'
+AND table_name not like 'xtradb_%'
ORDER BY table_schema,table_name;
TABLE_CATALOG def
TABLE_SCHEMA information_schema
@@ -835,7 +835,7 @@ AS "user_comment",
FROM information_schema.tables
WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'
+AND table_name not like 'xtradb_%'
ORDER BY table_schema,table_name;
TABLE_CATALOG def
TABLE_SCHEMA information_schema
diff --git a/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test b/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test
index 330dfa20629..c0829ab2636 100644
--- a/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test
+++ b/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test
@@ -21,6 +21,5 @@ if (`SELECT VERSION() NOT LIKE '%embedded%'`)
}
let $my_where = WHERE table_schema = 'information_schema'
-AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%';
+AND table_name <> 'profiling' AND table_name not like 'innodb_%';
--source suite/funcs_1/datadict/columns.inc
diff --git a/mysql-test/suite/funcs_1/t/is_tables_is.test b/mysql-test/suite/funcs_1/t/is_tables_is.test
index 36a47047bb3..09f257ed11e 100644
--- a/mysql-test/suite/funcs_1/t/is_tables_is.test
+++ b/mysql-test/suite/funcs_1/t/is_tables_is.test
@@ -15,5 +15,5 @@
--source include/not_embedded.inc
let $my_where = WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%';
+AND table_name not like 'xtradb_%';
--source suite/funcs_1/datadict/tables1.inc
diff --git a/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test b/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test
index cb828a91f82..1d2a7d67602 100644
--- a/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test
+++ b/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test
@@ -19,5 +19,5 @@ if (`SELECT VERSION() NOT LIKE '%embedded%'`)
}
let $my_where = WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%'
-AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%';
+AND table_name not like 'xtradb_%';
--source suite/funcs_1/datadict/tables1.inc
diff --git a/mysql-test/suite/maria/ps_maria.result b/mysql-test/suite/maria/ps_maria.result
index 6c1b40302ec..e2669b568cf 100644
--- a/mysql-test/suite/maria/ps_maria.result
+++ b/mysql-test/suite/maria/ps_maria.result
@@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` (
`param08` longtext,
`const09` datetime DEFAULT NULL,
`param09` longtext,
- `const10` decimal(22,6) DEFAULT NULL,
- `param10` decimal(65,30) DEFAULT NULL,
+ `const10` bigint(17) DEFAULT NULL,
+ `param10` bigint(20) DEFAULT NULL,
`const11` int(4) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
@@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8
def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8
def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
-def test t5 t5 const10 const10 246 24 16 Y 32768 6 63
-def test t5 t5 param10 param10 246 67 40 Y 32768 30 63
+def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
+def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
@@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01
param08 1991-08-05 01:01:01
const09 1991-08-05 01:01:01
param09 1991-08-05 01:01:01
-const10 662680861.000000
-param10 662680861.000000000000000000000000000000
+const10 662680861
+param10 662680861
const11 1991
param11 1991
const12 NULL
diff --git a/mysql-test/suite/rpl/r/last_insert_id.result b/mysql-test/suite/rpl/r/last_insert_id.result
new file mode 100644
index 00000000000..ce64e9df41e
--- /dev/null
+++ b/mysql-test/suite/rpl/r/last_insert_id.result
@@ -0,0 +1,18 @@
+include/rpl_init.inc [topology=1->2->3]
+create table t1 (id int not null auto_increment primary key, i int) engine=InnoDB;
+insert into t1 (i) values (-1);
+insert into t1 (i) values (LAST_INSERT_ID());
+select * from t1;
+id i
+1 -1
+2 1
+select * from t1;
+id i
+1 -1
+2 1
+select * from t1;
+id i
+1 -1
+2 1
+drop table t1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/last_insert_id.cnf b/mysql-test/suite/rpl/t/last_insert_id.cnf
new file mode 100644
index 00000000000..1c229e4ac94
--- /dev/null
+++ b/mysql-test/suite/rpl/t/last_insert_id.cnf
@@ -0,0 +1,20 @@
+!include suite/rpl/my.cnf
+
+[mysqld.1]
+log-slave-updates
+loose-innodb
+
+[mysqld.2]
+log-slave-updates
+loose-innodb
+replicate-ignore-table=db.t2
+
+[mysqld.3]
+log-slave-updates
+loose-innodb
+
+[ENV]
+SERVER_MYPORT_3= @mysqld.3.port
+SERVER_MYSOCK_3= @mysqld.3.socket
+
+
diff --git a/mysql-test/suite/rpl/t/last_insert_id.test b/mysql-test/suite/rpl/t/last_insert_id.test
new file mode 100644
index 00000000000..f23cca405ac
--- /dev/null
+++ b/mysql-test/suite/rpl/t/last_insert_id.test
@@ -0,0 +1,30 @@
+--source include/have_innodb.inc
+--source include/have_binlog_format_mixed_or_statement.inc
+--let $rpl_topology=1->2->3
+--source include/rpl_init.inc
+
+connection server_1;
+
+create table t1 (id int not null auto_increment primary key, i int) engine=InnoDB;
+insert into t1 (i) values (-1);
+insert into t1 (i) values (LAST_INSERT_ID());
+select * from t1;
+
+save_master_pos;
+
+connection server_2;
+
+sync_with_master;
+select * from t1;
+save_master_pos;
+
+connection server_3;
+
+sync_with_master;
+select * from t1;
+
+connection server_1;
+drop table t1;
+
+--source include/rpl_end.inc
+
diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result
index 4929eabb2e9..4514928e592 100644
--- a/mysql-test/suite/vcol/r/vcol_misc.result
+++ b/mysql-test/suite/vcol/r/vcol_misc.result
@@ -197,6 +197,13 @@ SELECT COUNT(*) FROM t1;
COUNT(*)
2
DROP TABLE t1;
+#
+# MDEV-4823 Server crashes in Item_func_not::fix_fields on
+# creating a table with a virtual column using NOT
+#
+CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL );
+drop table t1;
+# end of 5.2 tests
create table t1 (a int, b int);
insert into t1 values (3, 30), (4, 20), (1, 20);
create table t2 (c int, d int, v int as (d+1), index idx(c));
@@ -309,3 +316,4 @@ ERROR HY000: The value specified for computed column 'd' in table 't1' ignored
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
ERROR HY000: The value specified for computed column 'd' in table 't1' ignored
drop table t1;
+# end of 5.3 tests
diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test
index 3c51ee4b685..9c8443218fa 100644
--- a/mysql-test/suite/vcol/t/vcol_misc.test
+++ b/mysql-test/suite/vcol/t/vcol_misc.test
@@ -197,6 +197,15 @@ SELECT COUNT(*) FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-4823 Server crashes in Item_func_not::fix_fields on
+--echo # creating a table with a virtual column using NOT
+--echo #
+CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL );
+drop table t1;
+
+--echo # end of 5.2 tests
+
#
# SELECT that uses a virtual column and executed with BKA
#
@@ -265,3 +274,5 @@ UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,'a');
drop table t1;
+
+--echo # end of 5.3 tests
diff --git a/mysql-test/t/bad_frm_crash_5029.test b/mysql-test/t/bad_frm_crash_5029.test
new file mode 100644
index 00000000000..b15c37fbc6d
--- /dev/null
+++ b/mysql-test/t/bad_frm_crash_5029.test
@@ -0,0 +1,11 @@
+#
+# MDEV-5029 Crash in MariaDB 5.5.33 with .frm from older MariaDB release
+#
+# a.k.a. fail to open an frm with indexes:
+
+let $datadir=`select @@datadir`;
+copy_file std_data/mdev5029.frm $datadir/test/t1.frm;
+--error ER_UNKNOWN_STORAGE_ENGINE
+show create table t1;
+remove_file $datadir/test/t1.frm;
+
diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test
index 0847e2b366b..86ca0a920ad 100644
--- a/mysql-test/t/client_xml.test
+++ b/mysql-test/t/client_xml.test
@@ -23,7 +23,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
--source include/count_sessions.inc
--exec $MYSQL --xml test -e "select * from t1"
---exec $MYSQL_DUMP --xml --skip-create test
+--exec $MYSQL_DUMP --xml --skip-create-options test
--exec $MYSQL --xml test -e "select count(*) from t1"
--exec $MYSQL --xml test -e "select 1 < 2 from dual"
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 381c87c635c..008af317aec 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -320,6 +320,37 @@ DROP TABLE t1;
--echo # End of 5.0 tests
+--echo #
+--echo # MDEV-5005: Subquery in Procedure somehow affecting temporary table
+--echo #
+
+create temporary table if not exists t1 (id int not null);
+
+select A.* from ( select tt.* from t1 tt ) A;
+
+prepare stmt from "select A.* from ( select tt.* from t1 tt ) A ";
+execute stmt;
+deallocate prepare stmt;
+
+drop temporary table t1;
+
+--delimiter |
+CREATE PROCEDURE p ()
+BEGIN
+ select A.* from ( select tt.* from t1 tt ) A ;
+END |
+--delimiter ;
+
+create temporary table if not exists t1 (id int not null);
+
+CALL p();
+CALL p();
+
+drop procedure p;
+
+drop temporary table t1;
+
+--echo # End of 5.3 tests
--echo #
--echo # Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
@@ -342,7 +373,6 @@ SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2);
DROP TABLE t1, t2;
DROP VIEW v1, v2;
-set optimizer_switch=@save_derived_optimizer_switch;
#
# MDEV-614 lp:1050806 - different result for a query using subquery between 5.5.25 and 5.5.27
@@ -358,3 +388,17 @@ select * from (
where d1 < '2012-12-12 12:12:12' and n in (2085, 2084) order by d2 asc
) as calculated_result;
drop table t1;
+
+#
+# MDEV-5012 Server crashes in Item_ref::real_item on EXPLAIN with select subqueries or views, constant table, derived_merge+derived_with_keys
+#
+SET optimizer_switch = 'derived_merge=on,derived_with_keys=on,in_to_exists=on';
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (8);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(7);
+EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1,
+ (SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9);
+DROP TABLE t1, t2;
+
+set optimizer_switch=@save_derived_optimizer_switch;
diff --git a/mysql-test/t/drop_bad_db_type.test b/mysql-test/t/drop_bad_db_type.test
new file mode 100644
index 00000000000..69e1a889b18
--- /dev/null
+++ b/mysql-test/t/drop_bad_db_type.test
@@ -0,0 +1,25 @@
+
+--source include/have_debug.inc
+
+if (!$HA_ARCHIVE_SO) {
+ skip Needs Archive plugin;
+}
+
+let $mysqld_datadir= `select @@datadir`;
+
+set debug_dbug='+d,unstable_db_type';
+
+install soname 'ha_archive';
+create table t1 (a int) engine=archive;
+insert t1 values (1),(2),(3);
+flush tables;
+uninstall soname 'ha_archive';
+
+install soname 'ha_archive';
+--list_files $mysqld_datadir/test
+drop table t1;
+--list_files $mysqld_datadir/test
+uninstall soname 'ha_archive';
+
+set debug_dbug='-d,unstable_db_type';
+
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index a5c35c0dff2..0c2f28ab25d 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1403,6 +1403,26 @@ select z from (select count(*) as z from t1) v;
select z from (select count(*) as z from t1) v group by 1;
drop table t1;
+#
+# Bug mdev-5015: Degenerate OR condition in an aggregated join
+#
+
+CREATE TABLE t1 (i1 int, INDEX(i1));
+INSERT INTO t1 VALUES (9),(8);
+
+CREATE TABLE t2 (i2 int);
+INSERT INTO t2 VALUES (8),(4);
+
+
+CREATE TABLE t3 (i3 int, INDEX(i3));
+INSERT INTO t3 VALUES (9),(8);
+
+SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND ( 0 OR t3.i3 = t2.i2 );
+
+SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND t3.i3 = t2.i2;
+
+DROP TABLE t1,t2,t3;
+
--echo # end of 5.3 tests
--echo #
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 1a60b0c222a..0715fca7d96 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -6,6 +6,8 @@
drop table if exists t1,t2;
--enable_warnings
+let $mysqld_datadir= `select @@datadir`;
+
set names latin1;
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
@@ -1379,9 +1381,11 @@ SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3));
--echo # and other crashes
--echo #
CREATE TABLE t1 ( a TEXT );
-SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt';
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt';
SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' );
-LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 6f9359e6095..045b91b3e7b 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1194,3 +1194,246 @@ SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12'));
SET TIME_ZONE='+02:00';
SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'));
SET TIME_ZONE=DEFAULT;
+
+
+--echo #
+--echo # MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context
+--echo #
+CREATE TABLE t1 (a TIMESTAMP(3));
+INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999');
+SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a TIME(3));
+INSERT INTO t1 VALUES ('10:20:30.999');
+SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
+DROP TABLE t1;
+
+SELECT
+ CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+ CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+ COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+ CONCAT(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+ TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+ DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+ TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+
+SELECT
+ CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
+ CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
+ COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
+ CONCAT(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
+ TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
+ DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
+ TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
+
+SELECT
+ CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+ CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+ IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+ CONCAT(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+ TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+ DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+ TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+
+SELECT
+ CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
+ CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
+ IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
+ CONCAT(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
+ TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
+ DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
+ TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
+
+SELECT
+ CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+ CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+ IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+ CONCAT(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+ TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+ DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+ TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+
+SELECT
+ CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
+ CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
+ IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
+ CONCAT(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
+ TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
+ DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
+ TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
+
+SELECT
+ CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
+ CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
+ CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
+ CONCAT(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
+ TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
+ DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
+ TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
+
+SELECT
+ CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
+ CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
+ CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
+ CONCAT(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
+ TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
+ DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
+ TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
+
+CREATE TABLE t1 AS SELECT
+ CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1,
+ CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2,
+ CONCAT(IFNULL(TIME(101010),TIME(101010))) AS c3,
+ CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
+--echo #
+CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE);
+INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01');
+SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
+CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
+SELECT * FROM t2;
+SHOW COLUMNS FROM t2;
+DROP TABLE t2;
+SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1;
+SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1;
+SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1;
+SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1;
+SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1;
+SELECT COALESCE(d, t3) FROM t1;
+SELECT CONCAT(COALESCE(d, t3)) FROM t1;
+SELECT COALESCE(dt2, t3) FROM t1;
+SELECT CONCAT(COALESCE(dt2, t3)) FROM t1;
+SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1;
+SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-4724 Some temporal functions do not preserve microseconds
+--echo #
+SELECT MAKETIME(10,10,10.231);
+SELECT MAKETIME(0, 0, 59.9);
+CREATE TABLE t1 AS SELECT
+ MAKETIME(10,00,00),
+ MAKETIME(10,00,00.1),
+ MAKETIME(10,00,00.12),
+ MAKETIME(10,00,00.123),
+ MAKETIME(10,00,00.1234),
+ MAKETIME(10,00,00.12345),
+ MAKETIME(10,00,00.123456);
+SHOW COLUMNS FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT
+ TIME('10:00:00'),
+ TIME('10:00:00.1'),
+ TIME('10:00:00.12'),
+ TIME('10:00:00.123'),
+ TIME('10:00:00.1234'),
+ TIME('10:00:00.12345'),
+ TIME('10:00:00.12346');
+SHOW COLUMNS FROM t1;
+DROP TABLE t1;
+
+SET TIME_ZONE='+00:00';
+SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17');
+SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17');
+SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456');
+SELECT @@timestamp, FROM_UNIXTIME(@@timestamp);
+SET TIME_ZONE=DEFAULT;
+SET TIMESTAMP=DEFAULT;
+
+SELECT TIME('2012-10-16 15:54:16.12');
+SELECT TIMESTAMP('2012-10-16 15:54:16.12');
+SELECT TIMEDIFF('10:10:10.1','00:00:00');
+SELECT TIME_TO_SEC('10:10:10');
+SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12');
+SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12');
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND);
+SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND);
+SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00');
+
+--echo #
+--echo # MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision
+--echo #
+CREATE TABLE t1 (t0 TIME);
+INSERT INTO t1 VALUES ('00:00:00');
+SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+SHOW COLUMNS FROM t2;
+DROP TABLE t1,t2;
+
+CREATE TABLE t1 (t0 DATETIME);
+INSERT INTO t1 VALUES ('2001-01-01 00:00:00');
+SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
+SHOW COLUMNS FROM t2;
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10')
+--echo #
+CREATE TABLE t1 AS SELECT
+ TIMESTAMP('2001-01-01','10:10:10'),
+ TIMESTAMP('2001-01-01','10:10:10.1'),
+ TIMESTAMP('2001-01-01','10:10:10.12'),
+ TIMESTAMP('2001-01-01','10:10:10.123'),
+ TIMESTAMP('2001-01-01','10:10:10.1234'),
+ TIMESTAMP('2001-01-01','10:10:10.12345'),
+ TIMESTAMP('2001-01-01','10:10:10.123456'),
+ TIMESTAMP('2001-01-01','10:10:10.1234567');
+SHOW COLUMNS FROM t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT
+ TIMESTAMP('2001-01-01 00:00:00','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.1','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.12','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.123','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10'),
+ TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10');
+SHOW COLUMNS FROM t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT
+ TIMESTAMP('00:00:00','10:10:10'),
+ TIMESTAMP(TIME('00:00:00'),'10:10:10');
+SHOW COLUMNS FROM t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1)
+--echo #
+SELECT MAKETIME(0, 0, -0.1);
+
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 3c286026726..ef1ee58c97e 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -1379,6 +1379,8 @@ EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
WHERE b = 13 AND c = 42 GROUP BY a;
+# This query could have been resolved using loose index scan since the second
+# part of count(..) is defined by a constant predicate
EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index b6ee712ec28..8c88be5c603 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -51,7 +51,7 @@ create view v1 (c) as
SELECT table_name FROM information_schema.TABLES
WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
table_name not like 'ndb_%' AND table_name not like 'innodb_%' AND
- table_name not like 'pbxt_%' AND table_name not like 'xtradb_%';
+ table_name not like 'xtradb_%';
--sorted_result
select * from v1;
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 22b5ff9127c..f9b9fcf266d 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -518,7 +518,9 @@ set sql_mode='error_for_division_by_zero';
--echo #
--enable_info
insert t1 (data) values ('letter'), (1/0);
+--disable_ps_protocol
update t1 set data='envelope' where 1/0 or 1;
+--enable_ps_protocol
insert t1 (data) values (default), (1/0), ('dead beef');
--disable_info
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 73b40715676..54b2a3c82ea 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -1141,6 +1141,22 @@ DROP TABLE t1,t2,t3,t4,t5;
--error ER_PARSE_ERROR
SELECT * FROM t5 JOIN (t1 JOIN t2 UNION SELECT * FROM t3 JOIN t4);
+--echo #
+--echo # MDEV-4959: join of const table with NULL fields
+--echo #
+
+CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2 (i2 int, a int, b int) ENGINE=MyISAM;
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3);
+
+SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b;
+EXPLAIN EXTENDED
+SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b;
+
+DROP VIEW v2;
+DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index b0000b2b943..7a70c413e8d 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -1686,5 +1686,95 @@ explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or
drop table t0, t1;
+--echo #
+--echo # MDEV-4836: Wrong result on <not null date column> IS NULL (old documented hack stopped working)
+--echo # (this is a regression after fix for MDEV-4817)
+--echo #
+CREATE TABLE t1 (id INT, d DATE NOT NULL);
+INSERT INTO t1 VALUES (1,'0000-00-00'),(2,'0000-00-00');
+CREATE TABLE t2 (i INT);
+SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL;
+DROP TABLE t1,t2;
+
+
+CREATE TABLE t1 (i1 INT, d1 DATE NOT NULL);
+INSERT INTO t1 VALUES (1,'2012-12-21'),(2,'0000-00-00');
+
+CREATE TABLE t2 (i2 INT, j2 INT);
+INSERT INTO t2 VALUES (1,10),(2,20);
+
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2;
+DROP TABLE t1,t2;
+
+--echo # Another testcase
+CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (NULL);
+
+CREATE TABLE t2 (i2 INT, a INT, b INT) ENGINE=MyISAM;
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+
+INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3);
+SELECT * FROM t1 LEFT JOIN v2 ON i1 = i2 WHERE a < b;
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE a < b;
+
+drop view v2;
+drop table t1,t2;
+
+--echo #
+--echo # Bug mdev-4942: LEFT JOIN with conjunctive
+--echo # <non-nullable datetime field> IS NULL in WHERE
+--echo # causes an assert failure
+--echo #
+
+CREATE TABLE t1 ( i1 int, d1 date );
+INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16');
+
+CREATE TABLE t2 ( i2 int, d2 date NOT NULL );
+INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25');
+
+SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL;
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug mdev-4952: LEFT JOIN with disjunctive
+--echo # <non-nullable datetime field> IS NULL in WHERE
+--echo # causes an assert failure
+--echo #
+
+CREATE TABLE t1 (a1 int, b1 int NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1, 10), (2, 11);
+
+CREATE TABLE t2 (dt datetime NOT NULL, a2 int, b2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES
+('2006-10-08 09:34:54', 1, 100), ('2001-01-19 01:04:43', 2, 200);
+
+SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2
+ WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL;
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug mdev-4962: nested outer join with
+--echo # <non-nullable datetime field> IS NULL in WHERE
+--echo # causes an assert failure
+--echo #
+
+CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2 (i2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (10),(20);
+
+CREATE TABLE t3 (i3 int, d3 datetime NOT NULL) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (8,'2008-12-04 17:53:42'),(9,'2012-12-21 12:12:12');
+
+SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
+ WHERE d3 IS NULL;
+EXPLAIN EXTENDED
+SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3
+ WHERE d3 IS NULL;
+
+DROP TABLE t1,t2,t3;
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/t/myisam_optimize.test b/mysql-test/t/myisam_optimize.test
new file mode 100644
index 00000000000..2d630f7dbd0
--- /dev/null
+++ b/mysql-test/t/myisam_optimize.test
@@ -0,0 +1,47 @@
+#
+# test OPTIMIZE and a concurrent SELECT of a MyISAM table
+#
+source include/have_debug_sync.inc;
+
+call mtr.add_suppression(" marked as crashed and should be repaired");
+
+create table t1 (a int auto_increment primary key, b text);
+insert t1 (b) select repeat("A", 100);
+insert t1 (b) select repeat("B", 200) from t1;
+insert t1 (b) select repeat("C", 300) from t1;
+
+delete from t1 where a < 3;
+explain select a, left(b,10) from t1 order by a;
+select left(b,10), a from t1 order by a;
+
+set debug_sync='myisam_before_repair_by_sort wait_for go';
+send optimize table t1;
+
+connect (con1,localhost,root,,);
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state like "%myisam_before_repair_by_sort%";
+--source include/wait_condition.inc
+
+send select a, left(b,10) from t1 order by a;
+
+connect (con2,localhost,root,,);
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock";
+--source include/wait_condition.inc
+
+set debug_sync='now signal go';
+
+connection default;
+reap;
+
+connection con1;
+reap;
+
+disconnect con1;
+disconnect con2;
+connection default;
+
+drop table t1;
+
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index d492af92cb2..c90feb9194d 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -598,6 +598,7 @@ eval SET GLOBAL SERVER_ID = $old_server_id;
--echo # MDEV-4645: Incorrect reads of frozen binlog events;
--echo # FDE corrupted in relay log
--echo #
+--let TZ=Europe/Helsinki
--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_checksum.binlog
--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_group_id.binlog
--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_group_id_checksum.binlog
diff --git a/mysql-test/t/mysqld--help.test b/mysql-test/t/mysqld--help.test
index 571a097c3f7..aacf3affe10 100644
--- a/mysql-test/t/mysqld--help.test
+++ b/mysql-test/t/mysqld--help.test
@@ -26,7 +26,7 @@ perl;
@plugins=qw/innodb ndb archive blackhole federated partition ndbcluster
feedback debug temp-pool ssl des-key-file xtradb sequence
thread-concurrency super-large-pages mutex-deadlock-detector
- null-audit aria pbxt oqgraph sphinx thread-handling
+ null-audit aria oqgraph sphinx thread-handling
test-sql-discovery rpl-semi-sync query-cache-info
query-response-time locales/;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index eaa2e7a8840..5af27607483 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -36,7 +36,7 @@ drop view if exists v1, v2, v3;
CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024;
INSERT INTO t1 VALUES (1), (2);
---exec $MYSQL_DUMP --skip-create --skip-comments -X test t1
+--exec $MYSQL_DUMP --skip-create-options --skip-comments -X test t1
DROP TABLE t1;
--echo #
@@ -79,14 +79,14 @@ SET SQL_MODE=@OLD_SQL_MODE;
# check how mysqldump make quoting
--exec $MYSQL_DUMP --compact test t1
---exec $MYSQL_DUMP --compact --skip-create test t1
---exec $MYSQL_DUMP --skip-create --skip-comments test t1
+--exec $MYSQL_DUMP --compact --skip-create-options test t1
+--exec $MYSQL_DUMP --skip-create-options --skip-comments test t1
--exec $MYSQL_DUMP --skip-opt --extended-insert --skip-comments test t1
DROP TABLE t1;
CREATE TABLE t1(a int, b text, c varchar(3));
INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
---exec $MYSQL_DUMP --skip-create --compact -X test t1
+--exec $MYSQL_DUMP --skip-create-options --compact -X test t1
DROP TABLE t1;
--echo #
@@ -95,7 +95,7 @@ DROP TABLE t1;
CREATE TABLE t1 (`a"b"` char(2));
INSERT INTO t1 VALUES ("1\""), ("\"2");
---exec $MYSQL_DUMP --compact --skip-create -X test t1
+--exec $MYSQL_DUMP --compact --skip-create-options -X test t1
DROP TABLE t1;
--echo #
@@ -582,8 +582,8 @@ INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db
--exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db t1 t2
---exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db
---exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db t1 t2
+--exec $MYSQL_DUMP --skip-comments --skip-create-options --xml --no-data mysqldump_test_db
+--exec $MYSQL_DUMP --skip-comments --skip-create-options --xml --no-data mysqldump_test_db t1 t2
DROP TABLE t1, t2;
DROP DATABASE mysqldump_test_db;
@@ -1634,7 +1634,7 @@ drop database mysqldump_test_db;
CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
---exec $MYSQL_DUMP --skip-create --compact --hex-blob test t1
+--exec $MYSQL_DUMP --skip-create-options --compact --hex-blob test t1
DROP TABLE t1;
--echo #
@@ -2216,7 +2216,7 @@ DROP TABLE t1, t2;
--echo #
CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT';
---exec $MYSQL_DUMP --compact --skip-create --xml test
+--exec $MYSQL_DUMP --compact --skip-create-options --xml test
DROP TABLE `comment_table`;
--echo #
@@ -2385,7 +2385,7 @@ CREATE TABLE b12809202_db.t2 (c1 INT);
INSERT INTO b12809202_db.t1 VALUES (1), (2), (3);
INSERT INTO b12809202_db.t2 VALUES (1), (2), (3);
---echo # Starting mysqldump with --single-transaction & --flush-log options..
+--echo # Starting mysqldump with --single-transaction & --flush-logs options..
--echo # Note : In the following dump the transaction
--echo # should start only after the logs are
--echo # flushed, as 'flush logs' causes implicit
@@ -2397,7 +2397,7 @@ INSERT INTO b12809202_db.t2 VALUES (1), (2), (3);
# mixing of normal (stdout) and --verbose (stderr) output will happen in random
# order depending on stdio internal buffer size.
--replace_regex /-- Server version.*// /-- MySQL dump .*// /-- Dump completed on .*/-- Dump completed/
---exec $MYSQL_DUMP --verbose --single-transaction --flush-log b12809202_db 2>&1 > $MYSQLTEST_VARDIR/tmp/bug61854.sql
+--exec $MYSQL_DUMP --verbose --single-transaction --flush-logs b12809202_db 2>&1 > $MYSQLTEST_VARDIR/tmp/bug61854.sql
--echo
--echo #### Dump ends here ####
diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test
index 2878b54c357..4a45240ec68 100644
--- a/mysql-test/t/null.test
+++ b/mysql-test/t/null.test
@@ -255,3 +255,31 @@ DESCRIBE t2;
DROP TABLE t1, t2;
--echo # End of 5.0 tests
+
+--echo #
+--echo # MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL
+--echo #
+
+CREATE TABLE t1 (dt DATETIME NOT NULL);
+INSERT INTO t1 VALUES (NOW()),(NOW());
+
+EXPLAIN
+SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL;
+SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL;
+
+DROP TABLE t1;
+CREATE TABLE t1 (dt INT NOT NULL);
+INSERT INTO t1 VALUES (1),(2);
+EXPLAIN
+SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL;
+SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL;
+
+DROP TABLE t1;
+CREATE TABLE t1 (dt INT NOT NULL);
+INSERT INTO t1 VALUES (1),(2);
+
+EXPLAIN
+SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL);
+SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL);
+
+DROP TABLE t1;
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 61e0dcc7197..0c8f81e4712 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -196,16 +196,16 @@ CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
# Run mysqldump
---exec $MYSQL_DUMP --skip-create --skip-comments --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test t1
+--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test t1
---exec $MYSQL_DUMP --skip-create --skip-comments --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test
+--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test
---exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test
+--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test
# With wrong parameters
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR mysqldump.exe mysqldump
--error 2
---exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1
+--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1
DROP TABLE t1;
--remove_file $MYSQLTEST_VARDIR/tmp/test.sql
diff --git a/mysql-test/t/partition_myisam.test b/mysql-test/t/partition_myisam.test
index 49c5d793169..db4b07e5b1f 100644
--- a/mysql-test/t/partition_myisam.test
+++ b/mysql-test/t/partition_myisam.test
@@ -87,11 +87,9 @@ FLUSH TABLES;
CHECK TABLE t1;
--error ER_FAILED_READ_FROM_PAR_FILE
SELECT * FROM t1;
---echo # Note that it is currently impossible to drop a partitioned table
---echo # without the .par file
---error ER_BAD_TABLE_ERROR
+--echo # Note that we will remove the frm file when we detect that
+--echo # .par file has been deleted.
DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.frm
--remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI
--remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYD
diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test
index 94030670d9f..40d3c2f2f97 100644
--- a/mysql-test/t/plugin.test
+++ b/mysql-test/t/plugin.test
@@ -175,6 +175,58 @@ SET @@SQL_MODE=@OLD_SQL_MODE;
select 1;
UNINSTALL PLUGIN example;
+--echo #
+--echo # Bug #16194302 SUPPORT FOR FLOATING-POINT SYSTEM
+--echo # VARIABLES USING THE PLUGIN INTERFACE.
+--echo #
+
+--replace_regex /\.dll/.so/
+eval INSTALL PLUGIN example SONAME 'ha_example';
+
+SET GLOBAL example_double_var = -0.1;
+SELECT @@GLOBAL.example_double_var;
+
+SET GLOBAL example_double_var = 0.000001;
+SELECT @@GLOBAL.example_double_var;
+
+SET GLOBAL example_double_var = 0.4;
+SELECT @@GLOBAL.example_double_var;
+
+SET GLOBAL example_double_var = 123.456789;
+SELECT @@GLOBAL.example_double_var;
+
+SET GLOBAL example_double_var = 500;
+SELECT @@GLOBAL.example_double_var;
+
+SET GLOBAL example_double_var = 999.999999;
+SELECT @@GLOBAL.example_double_var;
+
+SET GLOBAL example_double_var = 1000.51;
+SELECT @@GLOBAL.example_double_var;
+
+SET SESSION example_double_thdvar = -0.1;
+SELECT @@SESSION.example_double_thdvar;
+
+SET SESSION example_double_thdvar = 0.000001;
+SELECT @@SESSION.example_double_thdvar;
+
+SET SESSION example_double_thdvar = 0.4;
+SELECT @@SESSION.example_double_thdvar;
+
+SET SESSION example_double_thdvar = 123.456789;
+SELECT @@SESSION.example_double_thdvar;
+
+SET SESSION example_double_thdvar = 500;
+SELECT @@SESSION.example_double_thdvar;
+
+SET SESSION example_double_thdvar = 999.999999;
+SELECT @@SESSION.example_double_thdvar;
+
+SET SESSION example_double_thdvar = 1000.51;
+SELECT @@SESSION.example_double_thdvar;
+
+UNINSTALL PLUGIN example;
+
#
# MDEV-4573 UNINSTALL PLUGIN misleading error message for non-dynamic plugins
#
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index a5ff9cc0096..dc9ca0012fe 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -570,12 +570,12 @@ INSERT INTO t1 VALUES
EXPLAIN
SELECT s.oxid FROM t1 v, t1 s
- WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
+ WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
SELECT s.oxid FROM t1 v, t1 s
- WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
+ WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
@@ -1481,6 +1481,40 @@ SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND
DROP TABLE t1;
+--echo #
+--echo # mdev-4894: Poor performance with unnecessary
+--echo # (bug#70021) 'Range checked for each record'
+--echo #
+
+create table t1( key1 int not null, INDEX i1(key1) );
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8);
+insert into t1 select key1+8 from t1;
+insert into t1 select key1+16 from t1;
+insert into t1 select key1+32 from t1;
+insert into t1 select key1+64 from t1;
+insert into t1 select key1+128 from t1;
+insert into t1 select key1+256 from t1;
+insert into t1 select key1+512 from t1;
+
+alter table t1 add key2 int not null, add index i2(key2);
+update t1 set key2=key1;
+analyze table t1;
+
+create table t2 (a int);
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8);
+insert into t2 select a+16 from t2;
+insert into t2 select a+32 from t2;
+insert into t2 select a+64 from t2;
+
+explain
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000;
+explain
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
+select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a;
+
+drop table t1,t2;
+
--echo End of 5.1 tests
--echo #
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 80ca862b74e..609a27f3d34 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -4500,7 +4500,7 @@ SELECT * FROM t1 INNER JOIN t2 ON ( c = a )
DROP TABLE t1,t2;
--echo #
---echo # Bug mdev-4413: another manifestations of bug mdev-2474
+--echo # Bug mdev-4413: another manifestations of bug mdev-4274
--echo # (valgrind complains)
--echo #
@@ -4516,6 +4516,95 @@ SELECT * FROM t1, t2
DROP TABLE t1, t2;
+--echo #
+--echo # Bug mdev-4355: equalities from the result of simplification of OR
+--echo # are not propagated to lower AND levels
+--echo #
+
+CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1);
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug mdev-4418: impossible multiple equality in OR formula
+--echo # after row substitution
+--echo #
+
+CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0,'j'), (8,'v');
+
+CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('k','k');
+
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b));
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug mdev-4944: range conditition in OR formula with fields
+--echo # belonging to multiple equalities
+--echo #
+
+CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,8);
+
+CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (8), (9);
+
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+ WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+SELECT * FROM t1, t2
+ WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 );
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug mdev-4971: equality propagation after merging degenerate
+--echo # disjunction into embedding AND level
+--echo #
+
+CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,10,100), (2,20,200) ;
+
+CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,1);
+
+SELECT * FROM t1, t2
+ WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+EXPLAIN EXTENDED
+SELECT * FROM t1, t2
+ WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+
+INSERT INTO t1 VALUES (3,1,6);
+SELECT * FROM t1, t2
+ WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
+
+DROP TABLE t1,t2;
+
--echo End of 5.3 tests
--echo #
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 0fb3474f877..b8d87a2cf60 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -9271,4 +9271,35 @@ drop procedure p2;
drop table t1;
+--echo #
+--echo # MDEV-4978 - Server cursor is broken with blobs in the select list,
+--echo # ORDER BY does not work
+--echo #
+CREATE TABLE t1(a INT, b BLOB);
+INSERT INTO t1 VALUES(1,REPEAT('a',4835)),(2,'b'),(3,'c'),(4,'d'),(5,REPEAT('e',805)),(6,'f');
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE done INT DEFAULT 0;
+ DECLARE v1 INT;
+ DECLARE v2 BLOB;
+ DECLARE c1 CURSOR FOR SELECT * FROM t1 ORDER BY a;
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1;
+ OPEN c1;
+ REPEAT
+ FETCH c1 INTO v1, v2;
+ IF NOT done THEN
+ SELECT v1;
+ END IF;
+ UNTIL done END REPEAT;
+ CLOSE c1;
+END|
+DELIMITER ;|
+
+CALL p1;
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
--echo # End of 5.5 test
diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test
index 68894ad18cb..b3c1322184d 100644
--- a/mysql-test/t/subselect2.test
+++ b/mysql-test/t/subselect2.test
@@ -260,6 +260,29 @@ DROP TABLE t1,t2,t3;
set optimizer_switch=@tmp_mdev567;
--echo #
+--echo # MDEV-4996: degenerate OR formula in WHERE of a subquery
+--echo #
+
+CREATE TABLE t1 (a int, c1 varchar(1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (2,'x'), (8,'d');
+
+CREATE TABLE t2 (m int, n int, c2 varchar(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (0, 5, 'x'), (1, 4,'p');
+
+SELECT * FROM t1 WHERE c1 NOT IN (
+ SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c
+ WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND
+ ( t2b.m != a OR t2b.m = t2a.m ));
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE c1 NOT IN (
+ SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c
+ WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND
+ ( t2b.m != a OR t2b.m = t2a.m ));
+
+DROP TABLE t1,t2;
+
+--echo #
--echo # MDEV-614, also MDEV-536, also LP:1050806:
--echo # different result for a query using subquery between 5.5.25 and 5.5.27
--echo #
@@ -315,6 +338,26 @@ set optimizer_switch=@tmp_mdev614;
DROP TABLE t1;
+--echo #
+--echo # MDEV-4420: non-expensive single-value subquery used as
+--echo # used as an access key to join a table
+--echo #
+
+create table t1 (a varchar(3));
+insert into t1 values ('USA'), ('FRA');
+create table t2 select * from t1;
+insert into t2 values ('RUS');
+create table t3 select * from t2;
+create index idx on t3(a);
+
+explain extended
+select * from t1, t2 left join t3 on ( t2.a = t3.a )
+where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 );
+
+select * from t1, t2 left join t3 on ( t2.a = t3.a )
+where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 );
+
+drop table t1,t2,t3;
set optimizer_switch=@subselect2_test_tmp;
diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test
index 711f2f4f9b6..e9226b8884f 100644
--- a/mysql-test/t/subselect_sj_mat.test
+++ b/mysql-test/t/subselect_sj_mat.test
@@ -1700,3 +1700,29 @@ drop table t1,t2;
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
+--echo #
+--echo # MDEV-4908: Assertion `((Item_cond *) cond)->functype() ==
+--echo # ((Item_cond *) new_item)->functype()' fails on a query with
+--echo # IN and equal conditions, AND/OR, materialization+semijoin
+--echo #
+
+
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'materialization=on,semijoin=on';
+
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+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;
+SET optimizer_switch=@save_optimizer_switch;
+
+--echo #
+--echo # MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries
+--echo #
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+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 # End of 5.3 tests
diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test
index 2cca6f501f0..357953290c4 100644
--- a/mysql-test/t/table_elim.test
+++ b/mysql-test/t/table_elim.test
@@ -561,4 +561,21 @@ EXPLAIN EXTENDED
DROP TABLE t1,t2;
+--echo #
+--echo # MDEV-4840: Wrong result (missing rows) on LEFT JOIN with InnoDB tables
+--echo #
+CREATE TABLE t1 (alpha3 VARCHAR(3));
+INSERT INTO t1 VALUES ('USA'),('CAN');
+
+CREATE TABLE t2 ( t3_code VARCHAR(3), name VARCHAR(64));
+INSERT INTO t2 VALUES ('USA','Austin'),('USA','Boston');
+
+CREATE TABLE t3 ( code VARCHAR(3), name VARCHAR(64), PRIMARY KEY (code), UNIQUE KEY (name));
+INSERT INTO t3 VALUES ('CAN','Canada'),('USA','United States');
+
+SELECT * FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code;
+SELECT t1.alpha3 FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code;
+
+DROP TABLE t1, t2, t3;
+
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index af8681abff3..6cfd9711c3e 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -300,6 +300,28 @@ drop table t1;
SELECT CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5');
--echo #
+--echo # MDEV-4804 Date comparing false result
+--echo #
+SET @h0="20111107";
+SET @h1="0";
+SET @@timestamp=UNIX_TIMESTAMP('2013-08-19 20:30:00');
+SELECT
+ COALESCE(DATE(@h0),DATE("1901-01-01")) AS h0d,
+ COALESCE(DATE(@h1),DATE(NOW())) AS h1d,
+ COALESCE(DATE(@h0),DATE("1901-01-01"))>COALESCE(DATE(@h1),DATE(NOW())) AS compare_h0_gt_h1;
+SELECT
+ DATE('20011107'),
+ DATE('0'),
+ COALESCE(DATE('0'),CURRENT_DATE) AS d1,
+ DATE('20011107')>COALESCE(DATE('0'),CURRENT_DATE) AS cmp;
+SELECT
+ DATE('20011107'),
+ DATE('0'),
+ IFNULL(DATE('0'),CURRENT_DATE) AS d1,
+ DATE('20011107')>IFNULL(DATE('0'),CURRENT_DATE) AS cmp;
+SET @@timestamp=DEFAULT;
+
+--echo #
--echo # End of 5.3 tests
--echo #
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 663501a0a88..847153d19f4 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -1595,6 +1595,12 @@ disconnect root;
connection default;
+#
+# MDEV-4951 drop user leaves privileges
+#
+#verify that no privileges were left after the above
+select * from information_schema.table_privileges;
+
--echo End of 5.0 tests.