summaryrefslogtreecommitdiff
path: root/mysql-test/main
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-04-21 09:01:01 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-04-21 09:01:01 +0300
commit80ed136e6dd4a021b1fc9b7bd7077bf989c3d247 (patch)
treecc24f0e4e9241920329865a1b66c1d086aaeaa9a /mysql-test/main
parent675c22c065110be03a5fab82442d2c3dc32aefff (diff)
parenta0588d54a20488b17a178244989e1abc5151a88a (diff)
downloadmariadb-git-80ed136e6dd4a021b1fc9b7bd7077bf989c3d247.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'mysql-test/main')
-rw-r--r--mysql-test/main/alter_table.result17
-rw-r--r--mysql-test/main/alter_table.test12
-rw-r--r--mysql-test/main/join_outer.result103
-rw-r--r--mysql-test/main/join_outer.test122
-rw-r--r--mysql-test/main/join_outer_jcl6.result103
-rw-r--r--mysql-test/main/mysqld--help.test1
-rw-r--r--mysql-test/main/subselect_exists2in.result18
-rw-r--r--mysql-test/main/subselect_exists2in.test23
8 files changed, 302 insertions, 97 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result
index a27b54d4b48..a43d9845947 100644
--- a/mysql-test/main/alter_table.result
+++ b/mysql-test/main/alter_table.result
@@ -2532,6 +2532,23 @@ ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `k1`
DROP TABLE t1,t2;
#
+# MDEV-25403 ALTER TABLE wrongly checks for field's default value if AFTER is used
+#
+create table t1(t int, d date not null);
+insert into t1 values (1,'2001-1-1');
+set sql_mode = "no_zero_date";
+alter table t1 change d d date not null after t, add i int;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` int(11) DEFAULT NULL,
+ `d` date NOT NULL,
+ `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t1 add x date not null;
+ERROR 22007: Incorrect date value: '0000-00-00' for column `test`.`t1`.`x` at row 1
+drop table t1;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test
index 5fd1358e9a9..e65a4edf13e 100644
--- a/mysql-test/main/alter_table.test
+++ b/mysql-test/main/alter_table.test
@@ -2051,6 +2051,18 @@ ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
DROP TABLE t1,t2;
--echo #
+--echo # MDEV-25403 ALTER TABLE wrongly checks for field's default value if AFTER is used
+--echo #
+create table t1(t int, d date not null);
+insert into t1 values (1,'2001-1-1');
+set sql_mode = "no_zero_date";
+alter table t1 change d d date not null after t, add i int;
+show create table t1;
+--error ER_TRUNCATED_WRONG_VALUE
+alter table t1 add x date not null;
+drop table t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result
index e882973043e..fcffeb6d161 100644
--- a/mysql-test/main/join_outer.result
+++ b/mysql-test/main/join_outer.result
@@ -2687,6 +2687,77 @@ id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
DROP TABLE t1,t2,t3,t4;
# end of 10.1 tests
#
+# MDEV-25362: name resolution for subqueries in ON expressions
+#
+create table t1 (a int, b int);
+create table t2 (c int, d int);
+create table t3 (e int, f int);
+create table t4 (g int, h int);
+explain
+select *
+from
+t1 left join
+(t2
+join
+t3 on
+(t3.f=t1.a)
+) on (t2.c=t1.a );
+ERROR 42S22: Unknown column 't1.a' in 'on clause'
+explain
+select *
+from
+t1 left join
+(t2
+join
+t3 on
+(t3.f=(select max(g) from t4 where t4.h=t1.a))
+) on (t2.c=t1.a );
+ERROR 42S22: Unknown column 't1.a' in 'where clause'
+drop table t1,t2,t3,t4;
+create table t1 (a int);
+insert into t1 values (1),(2);
+create table t2 (b int);
+insert into t2 values (1),(2);
+create table t3 (c int);
+insert into t3 values (1),(2);
+select * from ( select * from t1 left join t2
+on b in (select x from t3 as sq1)
+) as sq2;
+ERROR 42S22: Unknown column 'x' in 'field list'
+drop table t1,t2,t3;
+# end of 10.2 tests
+#
+# MDEV-22866: Crash in join optimizer with constant outer join nest
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4);
+CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
+CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (5),(6);
+CREATE TABLE t5 (e INT) ENGINE=MyISAM;
+INSERT INTO t5 VALUES (7),(8);
+CREATE TABLE t6 (f INT) ENGINE=MyISAM;
+INSERT INTO t6 VALUES (9),(10);
+SELECT *
+FROM
+t1
+LEFT JOIN (
+t2 LEFT JOIN (
+t3 JOIN
+t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
+) ON t2.b >= t4.d
+) ON t1.a <= t2.b
+LEFT JOIN t5 ON t2.b = t5.e
+LEFT JOIN t6 ON t3.c = t6.f;
+a b c d e f
+1 3 NULL NULL NULL NULL
+1 4 NULL NULL NULL NULL
+2 3 NULL NULL NULL NULL
+2 4 NULL NULL NULL NULL
+drop table t1,t2,t3,t4,t5,t6;
+#
# MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
#
create table t1(a int);
@@ -2754,35 +2825,5 @@ WHERE t3.pk IN (2);
1
drop view v4;
drop table t1,t2,t3,t4;
+# end of 10.3 tests
SET optimizer_switch=@org_optimizer_switch;
-#
-# MDEV-22866: Crash in join optimizer with constant outer join nest
-#
-CREATE TABLE t1 (a INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(2);
-CREATE TABLE t2 (b INT) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3),(4);
-CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
-CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
-INSERT INTO t4 VALUES (5),(6);
-CREATE TABLE t5 (e INT) ENGINE=MyISAM;
-INSERT INTO t5 VALUES (7),(8);
-CREATE TABLE t6 (f INT) ENGINE=MyISAM;
-INSERT INTO t6 VALUES (9),(10);
-SELECT *
-FROM
-t1
-LEFT JOIN (
-t2 LEFT JOIN (
-t3 JOIN
-t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
-) ON t2.b >= t4.d
-) ON t1.a <= t2.b
-LEFT JOIN t5 ON t2.b = t5.e
-LEFT JOIN t6 ON t3.c = t6.f;
-a b c d e f
-1 3 NULL NULL NULL NULL
-2 3 NULL NULL NULL NULL
-1 4 NULL NULL NULL NULL
-2 4 NULL NULL NULL NULL
-drop table t1,t2,t3,t4,t5,t6;
diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test
index f835d8af5a8..82c7b265b56 100644
--- a/mysql-test/main/join_outer.test
+++ b/mysql-test/main/join_outer.test
@@ -2192,6 +2192,91 @@ DROP TABLE t1,t2,t3,t4;
--echo # end of 10.1 tests
--echo #
+--echo # MDEV-25362: name resolution for subqueries in ON expressions
+--echo #
+
+create table t1 (a int, b int);
+create table t2 (c int, d int);
+create table t3 (e int, f int);
+create table t4 (g int, h int);
+
+--error ER_BAD_FIELD_ERROR
+explain
+select *
+from
+ t1 left join
+ (t2
+ join
+ t3 on
+ (t3.f=t1.a)
+ ) on (t2.c=t1.a );
+
+# This must produce an error:
+--error ER_BAD_FIELD_ERROR
+explain
+select *
+from
+ t1 left join
+ (t2
+ join
+ t3 on
+ (t3.f=(select max(g) from t4 where t4.h=t1.a))
+ ) on (t2.c=t1.a );
+
+drop table t1,t2,t3,t4;
+
+create table t1 (a int);
+insert into t1 values (1),(2);
+create table t2 (b int);
+insert into t2 values (1),(2);
+create table t3 (c int);
+insert into t3 values (1),(2);
+
+--error ER_BAD_FIELD_ERROR
+select * from ( select * from t1 left join t2
+ on b in (select x from t3 as sq1)
+ ) as sq2;
+
+drop table t1,t2,t3;
+
+--echo # end of 10.2 tests
+
+--echo #
+--echo # MDEV-22866: Crash in join optimizer with constant outer join nest
+--echo #
+
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4);
+
+CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
+
+CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (5),(6);
+
+CREATE TABLE t5 (e INT) ENGINE=MyISAM;
+INSERT INTO t5 VALUES (7),(8);
+
+CREATE TABLE t6 (f INT) ENGINE=MyISAM;
+INSERT INTO t6 VALUES (9),(10);
+
+SELECT *
+FROM
+ t1
+ LEFT JOIN (
+ t2 LEFT JOIN (
+ t3 JOIN
+ t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
+ ) ON t2.b >= t4.d
+ ) ON t1.a <= t2.b
+ LEFT JOIN t5 ON t2.b = t5.e
+ LEFT JOIN t6 ON t3.c = t6.f;
+
+drop table t1,t2,t3,t4,t5,t6;
+
+--echo #
--echo # MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
--echo #
create table t1(a int);
@@ -2251,39 +2336,6 @@ WHERE t3.pk IN (2);
drop view v4;
drop table t1,t2,t3,t4;
-SET optimizer_switch=@org_optimizer_switch;
-
---echo #
---echo # MDEV-22866: Crash in join optimizer with constant outer join nest
---echo #
-
-CREATE TABLE t1 (a INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(2);
+--echo # end of 10.3 tests
-CREATE TABLE t2 (b INT) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3),(4);
-
-CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
-
-CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
-INSERT INTO t4 VALUES (5),(6);
-
-CREATE TABLE t5 (e INT) ENGINE=MyISAM;
-INSERT INTO t5 VALUES (7),(8);
-
-CREATE TABLE t6 (f INT) ENGINE=MyISAM;
-INSERT INTO t6 VALUES (9),(10);
-
-SELECT *
-FROM
- t1
- LEFT JOIN (
- t2 LEFT JOIN (
- t3 JOIN
- t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
- ) ON t2.b >= t4.d
- ) ON t1.a <= t2.b
- LEFT JOIN t5 ON t2.b = t5.e
- LEFT JOIN t6 ON t3.c = t6.f;
-
-drop table t1,t2,t3,t4,t5,t6;
+SET optimizer_switch=@org_optimizer_switch;
diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result
index 9cbfa5d0fe5..721989c3368 100644
--- a/mysql-test/main/join_outer_jcl6.result
+++ b/mysql-test/main/join_outer_jcl6.result
@@ -2694,6 +2694,77 @@ id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
DROP TABLE t1,t2,t3,t4;
# end of 10.1 tests
#
+# MDEV-25362: name resolution for subqueries in ON expressions
+#
+create table t1 (a int, b int);
+create table t2 (c int, d int);
+create table t3 (e int, f int);
+create table t4 (g int, h int);
+explain
+select *
+from
+t1 left join
+(t2
+join
+t3 on
+(t3.f=t1.a)
+) on (t2.c=t1.a );
+ERROR 42S22: Unknown column 't1.a' in 'on clause'
+explain
+select *
+from
+t1 left join
+(t2
+join
+t3 on
+(t3.f=(select max(g) from t4 where t4.h=t1.a))
+) on (t2.c=t1.a );
+ERROR 42S22: Unknown column 't1.a' in 'where clause'
+drop table t1,t2,t3,t4;
+create table t1 (a int);
+insert into t1 values (1),(2);
+create table t2 (b int);
+insert into t2 values (1),(2);
+create table t3 (c int);
+insert into t3 values (1),(2);
+select * from ( select * from t1 left join t2
+on b in (select x from t3 as sq1)
+) as sq2;
+ERROR 42S22: Unknown column 'x' in 'field list'
+drop table t1,t2,t3;
+# end of 10.2 tests
+#
+# MDEV-22866: Crash in join optimizer with constant outer join nest
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4);
+CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
+CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (5),(6);
+CREATE TABLE t5 (e INT) ENGINE=MyISAM;
+INSERT INTO t5 VALUES (7),(8);
+CREATE TABLE t6 (f INT) ENGINE=MyISAM;
+INSERT INTO t6 VALUES (9),(10);
+SELECT *
+FROM
+t1
+LEFT JOIN (
+t2 LEFT JOIN (
+t3 JOIN
+t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
+) ON t2.b >= t4.d
+) ON t1.a <= t2.b
+LEFT JOIN t5 ON t2.b = t5.e
+LEFT JOIN t6 ON t3.c = t6.f;
+a b c d e f
+1 3 NULL NULL NULL NULL
+2 3 NULL NULL NULL NULL
+1 4 NULL NULL NULL NULL
+2 4 NULL NULL NULL NULL
+drop table t1,t2,t3,t4,t5,t6;
+#
# MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
#
create table t1(a int);
@@ -2761,35 +2832,5 @@ WHERE t3.pk IN (2);
1
drop view v4;
drop table t1,t2,t3,t4;
+# end of 10.3 tests
SET optimizer_switch=@org_optimizer_switch;
-#
-# MDEV-22866: Crash in join optimizer with constant outer join nest
-#
-CREATE TABLE t1 (a INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(2);
-CREATE TABLE t2 (b INT) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3),(4);
-CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
-CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
-INSERT INTO t4 VALUES (5),(6);
-CREATE TABLE t5 (e INT) ENGINE=MyISAM;
-INSERT INTO t5 VALUES (7),(8);
-CREATE TABLE t6 (f INT) ENGINE=MyISAM;
-INSERT INTO t6 VALUES (9),(10);
-SELECT *
-FROM
-t1
-LEFT JOIN (
-t2 LEFT JOIN (
-t3 JOIN
-t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
-) ON t2.b >= t4.d
-) ON t1.a <= t2.b
-LEFT JOIN t5 ON t2.b = t5.e
-LEFT JOIN t6 ON t3.c = t6.f;
-a b c d e f
-1 3 NULL NULL NULL NULL
-2 3 NULL NULL NULL NULL
-1 4 NULL NULL NULL NULL
-2 4 NULL NULL NULL NULL
-drop table t1,t2,t3,t4,t5,t6;
diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test
index f7eb038a6f3..4405b198951 100644
--- a/mysql-test/main/mysqld--help.test
+++ b/mysql-test/main/mysqld--help.test
@@ -3,6 +3,7 @@
#
--source include/not_embedded.inc
--source include/not_asan.inc
+--source include/not_ubsan.inc
--source include/have_perfschema.inc
--source include/have_profiling.inc
--source include/platform.inc
diff --git a/mysql-test/main/subselect_exists2in.result b/mysql-test/main/subselect_exists2in.result
index e8ef7081b09..6ff518b5a29 100644
--- a/mysql-test/main/subselect_exists2in.result
+++ b/mysql-test/main/subselect_exists2in.result
@@ -1102,4 +1102,22 @@ U5.`storage_target_id` = V0.`id`
);
id
drop table t1,t2,t3;
+#
+# MDEV-25407: EXISTS subquery with correlation in ON expression crashes
+#
+create table t10(a int primary key);
+insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t11(a int primary key);
+insert into t11 select a.a + b.a* 10 + c.a * 100 from t10 a, t10 b, t10 c;
+create table t1 (a int, b int);
+insert into t1 select a,a from t10;
+create table t2 (a int, b int);
+insert into t2 select a,a from t11;
+create table t3 as select * from t2;
+explain select * from t1 where exists (select t2.a from t2 left join t3 on (t3.b=t1.b) where t2.a=t1.a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+1 PRIMARY t2 ALL NULL NULL NULL NULL 1000 Using where; Start temporary; Using join buffer (flat, BNL join)
+1 PRIMARY t3 ALL NULL NULL NULL NULL 1000 Using where; End temporary; Using join buffer (incremental, BNL join)
+drop table t1, t2, t3, t10, t11;
set optimizer_switch=default;
diff --git a/mysql-test/main/subselect_exists2in.test b/mysql-test/main/subselect_exists2in.test
index e27ce57038b..e70d643138b 100644
--- a/mysql-test/main/subselect_exists2in.test
+++ b/mysql-test/main/subselect_exists2in.test
@@ -941,5 +941,28 @@ WHERE (
drop table t1,t2,t3;
+--echo #
+--echo # MDEV-25407: EXISTS subquery with correlation in ON expression crashes
+--echo #
+create table t10(a int primary key);
+insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t11(a int primary key);
+insert into t11 select a.a + b.a* 10 + c.a * 100 from t10 a, t10 b, t10 c;
+
+create table t1 (a int, b int);
+insert into t1 select a,a from t10;
+
+create table t2 (a int, b int);
+insert into t2 select a,a from t11;
+
+create table t3 as select * from t2;
+
+
+explain select * from t1 where exists (select t2.a from t2 left join t3 on (t3.b=t1.b) where t2.a=t1.a);
+
+drop table t1, t2, t3, t10, t11;
+
+
#restore defaults
set optimizer_switch=default;