summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-08-20 09:15:28 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-08-20 09:15:28 +0300
commit48c67038b9173887254a25ae05eb232d95ff8bc8 (patch)
tree253e371658c99a6f940e8ac1c74a64a5885d3311
parent12e3ac04febe16dd3ee15cd99f9196a60261f1b4 (diff)
parentbc89b1c5582ac4044317a84e8a73d97fd1db9041 (diff)
downloadmariadb-git-48c67038b9173887254a25ae05eb232d95ff8bc8.tar.gz
Merge 10.1 into 10.2
For MDEV-15955, the fix in create_tmp_field_from_item() would cause a compilation error. After a discussion with Alexander Barkov, the fix was omitted and only the test case was kept. In 10.3 and later, MDEV-15955 is fixed properly by overriding create_tmp_field() in Item_func_user_var.
-rw-r--r--mysql-test/r/join.result326
-rw-r--r--mysql-test/r/mysql_tzinfo_to_sql_symlink.result104
-rw-r--r--mysql-test/r/selectivity.result34
-rw-r--r--mysql-test/r/selectivity_innodb.result34
-rw-r--r--mysql-test/r/type_datetime.result11
-rw-r--r--mysql-test/r/type_int.result24
-rw-r--r--mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result82
-rw-r--r--mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result74
-rw-r--r--mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test40
-rw-r--r--mysql-test/t/join.test59
-rw-r--r--mysql-test/t/selectivity.test24
-rw-r--r--mysql-test/t/type_datetime.test14
-rw-r--r--mysql-test/t/type_int.test21
-rw-r--r--sql-common/my_time.c2
-rw-r--r--sql/sql_parse.cc103
-rw-r--r--sql/sql_select.cc20
-rw-r--r--sql/sql_statistics.cc7
-rw-r--r--sql/tztime.cc64
-rw-r--r--sql/wsrep_sst.cc6
19 files changed, 962 insertions, 87 deletions
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index 305615c20f2..7d00536cbde 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -2928,6 +2928,332 @@ NULL NULL NULL 9
NULL NULL NULL 5
drop table t1,t2,t3,t4,s1,s2;
#
+# MDEV-20265: Mix of comma joins with JOIN expressions
+# (correction of the fix for MDEV-19421)
+# MDEV-20330: duplicate
+#
+create table t1 (a int);
+insert into t1 values (7), (5), (3);
+create table t2 (a int);
+insert into t2 values (5), (1), (7);
+create table t3 (a int);
+insert into t3 values (2), (7), (3);
+create table t4 (a int);
+insert into t4 values (4), (7), (9), (5);
+create table t5 (a int);
+insert into t5 values (3), (7), (9), (2);
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1, t2 join t3 left join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1, t2 join t3 left join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 2 NULL
+5 5 2 NULL
+3 5 2 NULL
+7 1 2 NULL
+5 1 2 NULL
+3 1 2 NULL
+7 7 2 NULL
+5 7 2 NULL
+3 7 2 NULL
+7 5 3 NULL
+5 5 3 NULL
+3 5 3 NULL
+7 1 3 NULL
+5 1 3 NULL
+3 1 3 NULL
+7 7 3 NULL
+5 7 3 NULL
+3 7 3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1, t2 join t3 right join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t4` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1, t2 join t3 right join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 NULL NULL 4
+5 NULL NULL 4
+3 NULL NULL 4
+7 NULL NULL 9
+5 NULL NULL 9
+3 NULL NULL 9
+7 NULL NULL 5
+5 NULL NULL 5
+3 NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` left join `test`.`t5` on(`test`.`t5`.`a` = `test`.`t4`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a;
+t1_a t2_a t3_a t4_a t5_a
+7 5 2 7 7
+5 5 2 7 7
+3 5 2 7 7
+7 1 2 7 7
+5 1 2 7 7
+3 1 2 7 7
+7 7 2 7 7
+5 7 2 7 7
+3 7 2 7 7
+7 5 7 7 7
+5 5 7 7 7
+3 5 7 7 7
+7 1 7 7 7
+5 1 7 7 7
+3 1 7 7 7
+7 7 7 7 7
+5 7 7 7 7
+3 7 7 7 7
+7 5 3 7 7
+5 5 3 7 7
+3 5 3 7 7
+7 1 3 7 7
+5 1 3 7 7
+3 1 3 7 7
+7 7 3 7 7
+5 7 3 7 7
+3 7 3 7 7
+7 5 2 9 9
+5 5 2 9 9
+3 5 2 9 9
+7 1 2 9 9
+5 1 2 9 9
+3 1 2 9 9
+7 7 2 9 9
+5 7 2 9 9
+3 7 2 9 9
+7 5 7 9 9
+5 5 7 9 9
+3 5 7 9 9
+7 1 7 9 9
+5 1 7 9 9
+3 1 7 9 9
+7 7 7 9 9
+5 7 7 9 9
+3 7 7 9 9
+7 5 3 9 9
+5 5 3 9 9
+3 5 3 9 9
+7 1 3 9 9
+5 1 3 9 9
+3 1 3 9 9
+7 7 3 9 9
+5 7 3 9 9
+3 7 3 9 9
+7 5 2 4 NULL
+5 5 2 4 NULL
+3 5 2 4 NULL
+7 1 2 4 NULL
+5 1 2 4 NULL
+3 1 2 4 NULL
+7 7 2 4 NULL
+5 7 2 4 NULL
+3 7 2 4 NULL
+7 5 7 4 NULL
+5 5 7 4 NULL
+3 5 7 4 NULL
+7 1 7 4 NULL
+5 1 7 4 NULL
+3 1 7 4 NULL
+7 7 7 4 NULL
+5 7 7 4 NULL
+3 7 7 4 NULL
+7 5 3 4 NULL
+5 5 3 4 NULL
+3 5 3 4 NULL
+7 1 3 4 NULL
+5 1 3 4 NULL
+3 1 3 4 NULL
+7 7 3 4 NULL
+5 7 3 4 NULL
+3 7 3 4 NULL
+7 5 2 5 NULL
+5 5 2 5 NULL
+3 5 2 5 NULL
+7 1 2 5 NULL
+5 1 2 5 NULL
+3 1 2 5 NULL
+7 7 2 5 NULL
+5 7 2 5 NULL
+3 7 2 5 NULL
+7 5 7 5 NULL
+5 5 7 5 NULL
+3 5 7 5 NULL
+7 1 7 5 NULL
+5 1 7 5 NULL
+3 1 7 5 NULL
+7 7 7 5 NULL
+5 7 7 5 NULL
+3 7 7 5 NULL
+7 5 3 5 NULL
+5 5 3 5 NULL
+3 5 3 5 NULL
+7 1 3 5 NULL
+5 1 3 5 NULL
+3 1 3 5 NULL
+7 7 3 5 NULL
+5 7 3 5 NULL
+3 7 3 5 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` join `test`.`t5` left join (`test`.`t2` join `test`.`t3` join `test`.`t4`) on(`test`.`t4`.`a` = `test`.`t5`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a;
+t1_a t2_a t3_a t4_a t5_a
+7 5 2 7 7
+5 5 2 7 7
+3 5 2 7 7
+7 1 2 7 7
+5 1 2 7 7
+3 1 2 7 7
+7 7 2 7 7
+5 7 2 7 7
+3 7 2 7 7
+7 5 7 7 7
+5 5 7 7 7
+3 5 7 7 7
+7 1 7 7 7
+5 1 7 7 7
+3 1 7 7 7
+7 7 7 7 7
+5 7 7 7 7
+3 7 7 7 7
+7 5 3 7 7
+5 5 3 7 7
+3 5 3 7 7
+7 1 3 7 7
+5 1 3 7 7
+3 1 3 7 7
+7 7 3 7 7
+5 7 3 7 7
+3 7 3 7 7
+7 5 2 9 9
+5 5 2 9 9
+3 5 2 9 9
+7 1 2 9 9
+5 1 2 9 9
+3 1 2 9 9
+7 7 2 9 9
+5 7 2 9 9
+3 7 2 9 9
+7 5 7 9 9
+5 5 7 9 9
+3 5 7 9 9
+7 1 7 9 9
+5 1 7 9 9
+3 1 7 9 9
+7 7 7 9 9
+5 7 7 9 9
+3 7 7 9 9
+7 5 3 9 9
+5 5 3 9 9
+3 5 3 9 9
+7 1 3 9 9
+5 1 3 9 9
+3 1 3 9 9
+7 7 3 9 9
+5 7 3 9 9
+3 7 3 9 9
+7 NULL NULL NULL 3
+5 NULL NULL NULL 3
+3 NULL NULL NULL 3
+7 NULL NULL NULL 2
+5 NULL NULL NULL 2
+3 NULL NULL NULL 2
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) join `test`.`t5` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t4`.`a` = `test`.`t5`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a;
+t1_a t2_a t3_a t4_a t5_a
+5 5 2 7 7
+7 7 2 7 7
+3 NULL 2 7 7
+5 5 7 7 7
+7 7 7 7 7
+3 NULL 7 7 7
+5 5 3 7 7
+7 7 3 7 7
+3 NULL 3 7 7
+5 5 2 9 9
+7 7 2 9 9
+3 NULL 2 9 9
+5 5 7 9 9
+7 7 7 9 9
+3 NULL 7 9 9
+5 5 3 9 9
+7 7 3 9 9
+3 NULL 3 9 9
+5 5 NULL NULL 3
+7 7 NULL NULL 3
+3 NULL NULL NULL 3
+5 5 NULL NULL 2
+7 7 NULL NULL 2
+3 NULL NULL NULL 2
+drop table t1,t2,t3,t4,t5;
+select a.a
+from (select 1 as a) a,
+(select 2 as b) b
+cross join
+(select 3 as c) c
+left join
+(select 4 as d) d
+on 1;
+a
+1
+#
# End of MariaDB 5.5 tests
#
#
diff --git a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
index 03543244105..e33a519e897 100644
--- a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
+++ b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result
@@ -2,9 +2,15 @@
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
#
# Verbose run
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=InnoDB;
+ALTER TABLE time_zone_name ENGINE=InnoDB;
+ALTER TABLE time_zone_transition ENGINE=InnoDB;
+ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -28,11 +34,25 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
# Silent run
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=InnoDB;
+ALTER TABLE time_zone_name ENGINE=InnoDB;
+ALTER TABLE time_zone_transition ENGINE=InnoDB;
+ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -53,39 +73,83 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
#
# Testing with explicit timezonefile
#
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
#
# Testing --leap
#
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone_leap_second ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone_leap_second;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone_leap_second ENGINE=MyISAM;
+END IF|
+\d ;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
#
# MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL
#
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=InnoDB;
+ALTER TABLE time_zone_name ENGINE=InnoDB;
+ALTER TABLE time_zone_transition ENGINE=InnoDB;
+ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
diff --git a/mysql-test/r/selectivity.result b/mysql-test/r/selectivity.result
index 7d13adb5286..47efc8ba868 100644
--- a/mysql-test/r/selectivity.result
+++ b/mysql-test/r/selectivity.result
@@ -1635,3 +1635,37 @@ set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;
+#
+# MDEV-19834 Selectivity of an equality condition discounted twice
+#
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables='preferably';
+create table t1 (a int, b int, key (b), key (a));
+insert into t1
+select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
+analyze table t1 ;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status Table is already up to date
+# Check what info the optimizer has about selectivities
+explain extended select * from t1 use index () where a in (17,51,5);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.97 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5)
+explain extended select * from t1 use index () where b=2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 4.76 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2
+# Now, the equality is used for ref access, while the range condition
+# gives selectivity data
+explain extended select * from t1 where a in (17,51,5) and b=2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ref b,a b 5 const 58 2.90 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5)
+drop table t1;
+set use_stat_tables= @save_use_stat_tables;
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+# End of 10.1 tests
diff --git a/mysql-test/r/selectivity_innodb.result b/mysql-test/r/selectivity_innodb.result
index 371661433d2..38c1883c729 100644
--- a/mysql-test/r/selectivity_innodb.result
+++ b/mysql-test/r/selectivity_innodb.result
@@ -1645,6 +1645,40 @@ set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;
+#
+# MDEV-19834 Selectivity of an equality condition discounted twice
+#
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables='preferably';
+create table t1 (a int, b int, key (b), key (a));
+insert into t1
+select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
+analyze table t1 ;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+# Check what info the optimizer has about selectivities
+explain extended select * from t1 use index () where a in (17,51,5);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.97 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where (`test`.`t1`.`a` in (17,51,5))
+explain extended select * from t1 use index () where b=2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 4.76 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where (`test`.`t1`.`b` = 2)
+# Now, the equality is used for ref access, while the range condition
+# gives selectivity data
+explain extended select * from t1 where a in (17,51,5) and b=2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ref b,a b 5 const 59 2.80 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` in (17,51,5)))
+drop table t1;
+set use_stat_tables= @save_use_stat_tables;
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+# End of 10.1 tests
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
set @tmp_ust= @@use_stat_tables;
set @tmp_oucs= @@optimizer_use_condition_selectivity;
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index ef312aad92e..f4b9a8b71b6 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -1156,6 +1156,17 @@ ExtractValue('foo','bar') i MIN(d)
3 1976-12-14 13:21:07
DROP TABLE t1;
#
+# MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
+#
+SET SQL_MODE=DEFAULT;
+CREATE OR REPLACE TABLE t1 (a CHAR(11));
+CREATE OR REPLACE TABLE t2 (b DATETIME);
+INSERT INTO t1 VALUES ('2010-02-19') ;
+SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+SET SQL_MODE=DEFAULT;
+#
# End of 10.1 tests
#
#
diff --git a/mysql-test/r/type_int.result b/mysql-test/r/type_int.result
index 77e6ee14c25..5530cb26cee 100644
--- a/mysql-test/r/type_int.result
+++ b/mysql-test/r/type_int.result
@@ -1,4 +1,28 @@
#
+# Start of 5.5 tests
+#
+#
+# MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+@a := 1
+1
+SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+COALESCE(1)
+1
+SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+COALESCE(@a:=1)
+1
+SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+COALESCE(@a)
+1
+DROP TABLE t1;
+#
+# End of 5.5 tests
+#
+#
# Start of 10.1 tests
#
#
diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result
index c00a0c73ce3..9a0abd4460a 100644
--- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result
+++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result
@@ -2,9 +2,15 @@
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
#
# Verbose run
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=InnoDB;
+ALTER TABLE time_zone_name ENGINE=InnoDB;
+ALTER TABLE time_zone_transition ENGINE=InnoDB;
+ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -28,11 +34,25 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
# Silent run
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=InnoDB;
+ALTER TABLE time_zone_name ENGINE=InnoDB;
+ALTER TABLE time_zone_transition ENGINE=InnoDB;
+ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -53,26 +73,56 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
#
# Testing with explicit timezonefile
#
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
#
# Testing --leap
#
-set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
-prepare set_wsrep_myisam from @prep;
-set @toggle=1; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone_leap_second ENGINE=InnoDB;
+END IF|
+\d ;
TRUNCATE TABLE time_zone_leap_second;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone_leap_second ENGINE=MyISAM;
+END IF|
+\d ;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
-set @toggle=0; execute set_wsrep_myisam using @toggle;
+\d |
+IF (select count(*) from information_schema.global_variables where
+variable_name='wsrep_on') = 1 THEN
+ALTER TABLE time_zone ENGINE=MyISAM;
+ALTER TABLE time_zone_name ENGINE=MyISAM;
+ALTER TABLE time_zone_transition ENGINE=MyISAM;
+ALTER TABLE time_zone_transition_type ENGINE=MyISAM;
+END IF|
+\d ;
diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result
new file mode 100644
index 00000000000..4ce57c641b3
--- /dev/null
+++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result
@@ -0,0 +1,74 @@
+#
+# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
+#
+# Verbose run
+set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
+prepare set_wsrep_write_binlog from @prep1;
+set @toggle=0; execute set_wsrep_write_binlog using @toggle;
+TRUNCATE TABLE time_zone;
+TRUNCATE TABLE time_zone_name;
+TRUNCATE TABLE time_zone_transition;
+TRUNCATE TABLE time_zone_transition_type;
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it.
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
+Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
+ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
+ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
+# Silent run
+set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
+prepare set_wsrep_write_binlog from @prep1;
+set @toggle=0; execute set_wsrep_write_binlog using @toggle;
+TRUNCATE TABLE time_zone;
+TRUNCATE TABLE time_zone_name;
+TRUNCATE TABLE time_zone_transition;
+TRUNCATE TABLE time_zone_transition_type;
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
+ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
+ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
+#
+# Testing with explicit timezonefile
+#
+set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
+prepare set_wsrep_write_binlog from @prep1;
+set @toggle=0; execute set_wsrep_write_binlog using @toggle;
+INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
+SET @time_zone_id= LAST_INSERT_ID();
+INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
+INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
+ (@time_zone_id, 0, 0, 0, 'GMT')
+;
+#
+# Testing --leap
+#
+set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
+prepare set_wsrep_write_binlog from @prep1;
+set @toggle=0; execute set_wsrep_write_binlog using @toggle;
+TRUNCATE TABLE time_zone_leap_second;
+ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test
new file mode 100644
index 00000000000..bb3009bd432
--- /dev/null
+++ b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test
@@ -0,0 +1,40 @@
+--source include/have_wsrep.inc
+--source include/have_symlink.inc
+--source include/not_windows.inc
+
+--echo #
+--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
+--echo #
+
+--exec mkdir $MYSQLTEST_VARDIR/zoneinfo
+--exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix
+--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT
+--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage
+--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab
+
+--echo # Verbose run
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_TZINFO_TO_SQL --verbose --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1
+
+--echo # Silent run
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1
+
+--echo #
+--echo # Testing with explicit timezonefile
+--echo #
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
+
+--echo #
+--echo # Testing --leap
+--echo #
+
+--exec $MYSQL_TZINFO_TO_SQL --leap --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
+
+#
+# Cleanup
+#
+
+--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 632ee947940..4ea6b56bc0b 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -1614,6 +1614,65 @@ eval $q;
drop table t1,t2,t3,t4,s1,s2;
--echo #
+--echo # MDEV-20265: Mix of comma joins with JOIN expressions
+--echo # (correction of the fix for MDEV-19421)
+--echo # MDEV-20330: duplicate
+--echo #
+
+create table t1 (a int);
+insert into t1 values (7), (5), (3);
+create table t2 (a int);
+insert into t2 values (5), (1), (7);
+create table t3 (a int);
+insert into t3 values (2), (7), (3);
+create table t4 (a int);
+insert into t4 values (4), (7), (9), (5);
+create table t5 (a int);
+insert into t5 values (3), (7), (9), (2);
+
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1, t2 join t3 left join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1, t2 join t3 right join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
+from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a;
+eval explain extended $q;
+eval $q;
+
+drop table t1,t2,t3,t4,t5;
+
+select a.a
+from (select 1 as a) a,
+ (select 2 as b) b
+ cross join
+ (select 3 as c) c
+ left join
+ (select 4 as d) d
+ on 1;
+
+--echo #
--echo # End of MariaDB 5.5 tests
--echo #
diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test
index 3df49456332..f1c9d6b31b8 100644
--- a/mysql-test/t/selectivity.test
+++ b/mysql-test/t/selectivity.test
@@ -1,4 +1,5 @@
--source include/have_stat_tables.inc
+--source include/have_sequence.inc
--disable_warnings
drop table if exists t0,t1,t2,t3;
@@ -1102,3 +1103,26 @@ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectiv
drop table t1;
drop function f1;
+--echo #
+--echo # MDEV-19834 Selectivity of an equality condition discounted twice
+--echo #
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables='preferably';
+create table t1 (a int, b int, key (b), key (a));
+insert into t1
+select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
+analyze table t1 ;
+
+--echo # Check what info the optimizer has about selectivities
+explain extended select * from t1 use index () where a in (17,51,5);
+explain extended select * from t1 use index () where b=2;
+
+--echo # Now, the equality is used for ref access, while the range condition
+--echo # gives selectivity data
+explain extended select * from t1 where a in (17,51,5) and b=2;
+drop table t1;
+
+set use_stat_tables= @save_use_stat_tables;
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+--echo # End of 10.1 tests
+
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index b975608076f..fd8b2391fcb 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -711,6 +711,20 @@ SELECT ExtractValue('foo','bar'), i, MIN(d) FROM t1 GROUP BY i;
DROP TABLE t1;
--echo #
+--echo # MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
+--echo #
+
+SET SQL_MODE=DEFAULT;
+CREATE OR REPLACE TABLE t1 (a CHAR(11));
+CREATE OR REPLACE TABLE t2 (b DATETIME);
+INSERT INTO t1 VALUES ('2010-02-19') ;
+SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+SET SQL_MODE=DEFAULT;
+
+
+--echo #
--echo # End of 10.1 tests
--echo #
diff --git a/mysql-test/t/type_int.test b/mysql-test/t/type_int.test
index 76ed7eee824..830b175fb5d 100644
--- a/mysql-test/t/type_int.test
+++ b/mysql-test/t/type_int.test
@@ -1,4 +1,25 @@
--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
+--echo #
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
+
+
+--echo #
--echo # Start of 10.1 tests
--echo #
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 7017f7a39a9..90ce0b11c1e 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -184,7 +184,7 @@ static int get_date_time_separator(uint *number_of_fields, ulonglong flags,
do
{
s++;
- } while (my_isspace(&my_charset_latin1, *s));
+ } while (s < end && my_isspace(&my_charset_latin1, *s));
*str= s;
return 0;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 461c4a419be..181041f4dd6 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8168,10 +8168,6 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd)
TABLE_LIST *head= join_list->head();
if (head->nested_join && head->nested_join->nest_type & REBALANCED_NEST)
{
- List_iterator<TABLE_LIST> li(*join_list);
- li++;
- while (li++)
- li.remove();
DBUG_RETURN(head);
}
@@ -8255,13 +8251,13 @@ void st_select_lex::add_joined_table(TABLE_LIST *table)
context and right-associative in another context.
In this query
- SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a (Q1)
+ SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a (Q1)
JOIN is left-associative and the query Q1 is interpreted as
- SELECT * FROM (t1 JOIN t2) LEFT JOIN t3 ON t2.a=t3.a.
+ SELECT * FROM (t1 JOIN t2) LEFT JOIN t3 ON t2.a=t3.a.
While in this query
- SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.b=t2.b (Q2)
+ SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.b=t2.b (Q2)
JOIN is right-associative and the query Q2 is interpreted as
- SELECT * FROM t1 JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.b=t2.b
+ SELECT * FROM t1 JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.b=t2.b
JOIN is right-associative if it is used with ON clause or with USING clause.
Otherwise it is left-associative.
@@ -8307,9 +8303,9 @@ void st_select_lex::add_joined_table(TABLE_LIST *table)
J LJ - ON
/ \ / \
- t1 LJ - ON (TQ3*) => J t2
- / \ / \
- t3 t2 t1 t3
+ t1 LJ - ON (TQ3*) => t3 J
+ / \ / \
+ t3 t2 t1 t2
With several left associative JOINs
SELECT * FROM t1 JOIN t2 JOIN t3 LEFT JOIN t4 ON t3.a=t4.a (Q4)
@@ -8317,15 +8313,15 @@ void st_select_lex::add_joined_table(TABLE_LIST *table)
J1 LJ - ON
/ \ / \
- t1 LJ - ON J2 t4
+ t1 J2 J2 t4
/ \ => / \
- J2 t4 J1 t3
- / \ / \
- t2 t3 t1 t2
+ t2 LJ - ON J1 t3
+ / \ / \
+ t3 t4 t1 t2
- Here's another example:
- SELECT *
- FROM t1 JOIN t2 LEFT JOIN t3 JOIN t4 ON t3.a=t4.a ON t2.b=t3.b (Q5)
+ Here's another example:
+ SELECT *
+ FROM t1 JOIN t2 LEFT JOIN t3 JOIN t4 ON t3.a=t4.a ON t2.b=t3.b (Q5)
J LJ - ON
/ \ / \
@@ -8335,15 +8331,58 @@ void st_select_lex::add_joined_table(TABLE_LIST *table)
/ \
t3 t4
- If the transformed nested join node node is a natural join node like in
- the following query
- SELECT * FROM t1 JOIN t2 LEFT JOIN t3 USING(a) (Q6)
- the transformation additionally has to take care about setting proper
- references in the field natural_join for both operands of the natural
- join operation.
- The function also has to change the name resolution context for ON
- expressions used in the transformed join expression to take into
- account the tables of the left_op node.
+ If the transformed nested join node node is a natural join node like in
+ the following query
+ SELECT * FROM t1 JOIN t2 LEFT JOIN t3 USING(a) (Q6)
+ the transformation additionally has to take care about setting proper
+ references in the field natural_join for both operands of the natural
+ join operation.
+
+ The queries that combine comma syntax for join operation with
+ JOIN expression require a special care. Consider the query
+ SELECT * FROM t1, t2 JOIN t3 LEFT JOIN t4 ON t3.a=t4.a (Q7)
+ This query is equivalent to the query
+ SELECT * FROM (t1, t2) JOIN t3 LEFT JOIN t4 ON t3.a=t4.a
+ The latter is transformed in the same way as query Q1
+
+ J LJ - ON
+ / \ / \
+ (t1,t2) LJ - ON => J t4
+ / \ / \
+ t3 t4 (t1,t2) t3
+
+ A transformation similar to the transformation for Q3 is done for
+ the following query with RIGHT JOIN
+ SELECT * FROM t1, t2 JOIN t3 RIGHT JOIN t4 ON t3.a=t4.a (Q8)
+
+ J LJ - ON
+ / \ / \
+ t3 LJ - ON => t4 J
+ / \ / \
+ t4 (t1,t2) (t1,t2) t3
+
+ The function also has to change the name resolution context for ON
+ expressions used in the transformed join expression to take into
+ account the tables of the left_op node.
+
+ TODO:
+ A more elegant solution would be to implement the transformation that
+ eliminates nests for cross join operations. For Q7 it would work like this:
+
+ J LJ - ON
+ / \ / \
+ (t1,t2) LJ - ON => (t1,t2,t3) t4
+ / \
+ t3 t4
+
+ For Q8 with RIGHT JOIN the transformation would work similarly:
+
+ J LJ - ON
+ / \ / \
+ t3 LJ - ON => t4 (t1,t2,t3)
+ / \
+ t4 (t1,t2)
+
*/
bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op,
@@ -8366,7 +8405,11 @@ bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op,
}
TABLE_LIST *tbl;
- List<TABLE_LIST> *jl= &right_op->nested_join->join_list;
+ List<TABLE_LIST> *right_op_jl= right_op->join_list;
+ TABLE_LIST *r_tbl= right_op_jl->pop();
+ DBUG_ASSERT(right_op == r_tbl);
+ TABLE_LIST *l_tbl= right_op_jl->pop();
+ DBUG_ASSERT(left_op == l_tbl);
TABLE_LIST *cj_nest;
/*
@@ -8383,6 +8426,8 @@ bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op,
List<TABLE_LIST> *cjl= &cj_nest->nested_join->join_list;
cjl->empty();
+ List<TABLE_LIST> *jl= &right_op->nested_join->join_list;
+ DBUG_ASSERT(jl->elements == 2);
/* Look for the left most node tbl of the right_op tree */
for ( ; ; )
{
@@ -8454,6 +8499,8 @@ bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op,
create a new top level nested join node.
*/
right_op->nested_join->nest_type|= REBALANCED_NEST;
+ if (unlikely(right_op_jl->push_front(right_op)))
+ DBUG_RETURN(true);
DBUG_RETURN(false);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index bdab9cf76cf..1b82b11fce6 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7961,6 +7961,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
KEYUSE *keyuse= pos->key;
KEYUSE *prev_ref_keyuse= keyuse;
uint key= keyuse->key;
+ bool used_range_selectivity= false;
/*
Check if we have a prefix of key=const that matches a quick select.
@@ -7986,6 +7987,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
keyparts++;
}
sel /= (double)table->quick_rows[key] / (double) table->stat_records();
+ used_range_selectivity= true;
}
}
@@ -8021,13 +8023,14 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if (keyparts > keyuse->keypart)
{
/* Ok this is the keyuse that will be used for ref access */
- uint fldno;
- if (is_hash_join_key_no(key))
- fldno= keyuse->keypart;
- else
- fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1;
- if (keyuse->val->const_item())
+ if (!used_range_selectivity && keyuse->val->const_item())
{
+ uint fldno;
+ if (is_hash_join_key_no(key))
+ fldno= keyuse->keypart;
+ else
+ fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1;
+
if (table->field[fldno]->cond_selectivity > 0)
{
sel /= table->field[fldno]->cond_selectivity;
@@ -16344,10 +16347,9 @@ Field *Item::create_tmp_field(bool group, TABLE *table, uint convert_int_length)
static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
Item ***copy_func, bool modify_item)
{
- Field *UNINIT_VAR(new_field);
DBUG_ASSERT(thd == table->in_use);
- new_field= item->Item::create_tmp_field(false, table);
-
+ Field *new_field= item->Item::create_tmp_field(false, table);
+
if (copy_func &&
(item->is_result_field() ||
(item->real_item()->is_result_field())))
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 2f325701b81..26032d8d535 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2119,7 +2119,12 @@ int alloc_statistics_for_table(THD* thd, TABLE *table)
Histogram_type hist_type= (Histogram_type) (thd->variables.histogram_type);
uchar *histogram= NULL;
if (hist_size > 0)
- histogram= (uchar *) alloc_root(&table->mem_root, hist_size * columns);
+ {
+ if ((histogram= (uchar *) alloc_root(&table->mem_root,
+ hist_size * columns)))
+ bzero(histogram, hist_size * columns);
+
+ }
if (!table_stats || !column_stats || !index_stats || !idx_avg_frequency ||
(hist_size && !histogram))
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 8a87985e901..f3d178c59a2 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -148,6 +148,7 @@ typedef struct st_time_zone_info
static my_bool prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage);
+my_bool opt_leap, opt_verbose, opt_skip_write_binlog;
#if defined(TZINFO2SQL) || defined(TESTTIME)
@@ -2437,6 +2438,14 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
We are assuming that there are only one list of leap seconds
For all timezones.
*/
+ if (!opt_skip_write_binlog)
+ printf("\\d |\n"
+ "IF (select count(*) from information_schema.global_variables where\n"
+ "variable_name='wsrep_on') = 1 THEN\n"
+ "ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n"
+ "END IF|\n"
+ "\\d ;\n");
+
printf("TRUNCATE TABLE time_zone_leap_second;\n");
if (sp->leapcnt)
@@ -2449,6 +2458,14 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
printf(";\n");
}
+ if (!opt_skip_write_binlog)
+ printf("\\d |\n"
+ "IF (select count(*) from information_schema.global_variables where\n"
+ "variable_name='wsrep_on') = 1 THEN\n"
+ "ALTER TABLE time_zone_leap_second ENGINE=MyISAM;\n"
+ "END IF|\n"
+ "\\d ;\n");
+
printf("ALTER TABLE time_zone_leap_second ORDER BY Transition_time;\n");
}
@@ -2605,8 +2622,6 @@ scan_tz_dir(char * name_end, uint symlink_recursion_level, uint verbose)
}
-my_bool opt_leap, opt_verbose;
-
static const char *load_default_groups[]=
{ "mysql_tzinfo_to_sql", 0};
@@ -2627,6 +2642,8 @@ static struct my_option my_long_options[] =
&opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to other nodes in a Galera cluster",
+ &opt_skip_write_binlog,&opt_skip_write_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -2695,11 +2712,14 @@ main(int argc, char **argv)
return 1;
}
- // Replicate MyISAM DDL for this session, cf. lp:1161432
- // timezone info unfixable in XtraDB Cluster
- printf("set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');\n"
- "prepare set_wsrep_myisam from @prep;\n"
- "set @toggle=1; execute set_wsrep_myisam using @toggle;\n");
+ if (opt_skip_write_binlog)
+ /* If skip_write_binlog is set and wsrep is compiled in we disable
+ sql_log_bin and wsrep_on to avoid Galera replicating below
+ truncate table clauses. This will allow user to set different
+ time zones to nodes in Galera cluster. */
+ printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n"
+ "prepare set_wsrep_write_binlog from @prep1;\n"
+ "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n");
if (argc == 1 && !opt_leap)
{
@@ -2707,6 +2727,21 @@ main(int argc, char **argv)
root_name_end= strmake_buf(fullname, argv[0]);
+ if(!opt_skip_write_binlog)
+ {
+ // Alter time zone tables to InnoDB if wsrep_on is enabled
+ // to allow changes to them to replicate with Galera
+ printf("\\d |\n"
+ "IF (select count(*) from information_schema.global_variables where\n"
+ "variable_name='wsrep_on') = 1 THEN\n"
+ "ALTER TABLE time_zone ENGINE=InnoDB;\n"
+ "ALTER TABLE time_zone_name ENGINE=InnoDB;\n"
+ "ALTER TABLE time_zone_transition ENGINE=InnoDB;\n"
+ "ALTER TABLE time_zone_transition_type ENGINE=InnoDB;\n"
+ "END IF|\n"
+ "\\d ;\n");
+ }
+
printf("TRUNCATE TABLE time_zone;\n");
printf("TRUNCATE TABLE time_zone_name;\n");
printf("TRUNCATE TABLE time_zone_transition;\n");
@@ -2748,8 +2783,19 @@ main(int argc, char **argv)
free_root(&tz_storage, MYF(0));
}
- // Reset wsrep_replicate_myisam. lp:1161432
- printf("set @toggle=0; execute set_wsrep_myisam using @toggle;\n");
+ if(!opt_skip_write_binlog)
+ {
+ // Fall back to MyISAM
+ printf("\\d |\n"
+ "IF (select count(*) from information_schema.global_variables where\n"
+ "variable_name='wsrep_on') = 1 THEN\n"
+ "ALTER TABLE time_zone ENGINE=MyISAM;\n"
+ "ALTER TABLE time_zone_name ENGINE=MyISAM;\n"
+ "ALTER TABLE time_zone_transition ENGINE=MyISAM;\n"
+ "ALTER TABLE time_zone_transition_type ENGINE=MyISAM;\n"
+ "END IF|\n"
+ "\\d ;\n");
+ }
free_defaults(default_argv);
my_end(0);
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index fe9f5650b4f..f1b0033fc94 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -762,7 +762,7 @@ static ssize_t sst_prepare_other (const char* method,
my_free(binlog_opt_val);
my_free(binlog_index_opt_val);
- if (ret < 0 || ret >= cmd_len)
+ if (ret < 0 || size_t(ret) >= cmd_len)
{
WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE);
@@ -1064,7 +1064,7 @@ static int sst_donate_mysqldump (const char* addr,
(long long)seqno, wsrep_gtid_domain_id,
bypass ? " " WSREP_SST_OPT_BYPASS : "");
- if (ret < 0 || ret >= cmd_len)
+ if (ret < 0 || size_t(ret) >= cmd_len)
{
WSREP_ERROR("sst_donate_mysqldump(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE);
@@ -1434,7 +1434,7 @@ static int sst_donate_other (const char* method,
bypass ? " " WSREP_SST_OPT_BYPASS : "");
my_free(binlog_opt_val);
- if (ret < 0 || ret >= cmd_len)
+ if (ret < 0 || size_t(ret) >= cmd_len)
{
WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE);