Commit dbc84ff9 authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-4942.

Made sure that degenerate conjunctions/disjunctions are obtained from
AND/OR conditions.
parent c40de1df
...@@ -1836,4 +1836,16 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id ...@@ -1836,4 +1836,16 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id
WHERE a.modified > b.modified or b.modified IS NULL; WHERE a.modified > b.modified or b.modified IS NULL;
id modified id modified
DROP TABLE t1; DROP TABLE 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 optimizer_switch=@save_optimizer_switch;
...@@ -1847,6 +1847,18 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id ...@@ -1847,6 +1847,18 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id
WHERE a.modified > b.modified or b.modified IS NULL; WHERE a.modified > b.modified or b.modified IS NULL;
id modified id modified
DROP TABLE t1; DROP TABLE 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 optimizer_switch=@save_optimizer_switch;
set join_cache_level=default; set join_cache_level=default;
show variables like 'join_cache_level'; show variables like 'join_cache_level';
......
...@@ -1376,4 +1376,20 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id ...@@ -1376,4 +1376,20 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id
DROP TABLE t1; DROP TABLE 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; SET optimizer_switch=@save_optimizer_switch;
...@@ -13350,7 +13350,8 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) ...@@ -13350,7 +13350,8 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
In these cases the disjunct/conjunct must be merged into the In these cases the disjunct/conjunct must be merged into the
argument list of cond. 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() == DBUG_ASSERT(((Item_cond *) cond)->functype() ==
((Item_cond *) new_item)->functype()); ((Item_cond *) new_item)->functype());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment