summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/join_outer.result12
-rw-r--r--mysql-test/r/join_outer_jcl6.result12
-rw-r--r--mysql-test/t/join_outer.test16
-rw-r--r--sql/sql_select.cc3
4 files changed, 42 insertions, 1 deletions
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 170c6f3eb05..8b426c9a26f 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -2138,4 +2138,16 @@ 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;
+#
+# 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;
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 82805a883b3..7ce7eb2eec7 100644
--- a/mysql-test/r/join_outer_jcl6.result
+++ b/mysql-test/r/join_outer_jcl6.result
@@ -2149,6 +2149,18 @@ 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;
+#
+# 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;
SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default;
show variables like 'join_cache_level';
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index b0000b2b943..f48120bf63b 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -1687,4 +1687,20 @@ explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or
drop table t0, t1;
+--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;
+
SET optimizer_switch=@save_optimizer_switch;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 87ab88ade10..d4062f5e0c9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -13642,7 +13642,8 @@ internal_remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
In these cases the disjunct/conjunct must be merged into the
argument list of cond.
*/
- if (new_item->type() == Item::COND_ITEM)
+ if (new_item->type() == Item::COND_ITEM &&
+ item->type() == Item::COND_ITEM)
{
DBUG_ASSERT(((Item_cond *) cond)->functype() ==
((Item_cond *) new_item)->functype());