Commit 0507f40b authored by Igor Babaev's avatar Igor Babaev

MDEV-29360 Crash when pushing condition with always false IS NULL into derived

Variant 2. Preliminary patch.
parent e886c2ba
......@@ -19051,4 +19051,27 @@ EXPLAIN
}
}
drop table t1, t2;
#
# MDEV-29360: Pushed condition contains always false IS NULL
#
CREATE TABLE t1 (a int NOT NULL);
INSERT INTO t1 VALUES (0),(1),(3);
CREATE TABLE t2 SELECT a as b FROM t1;
CREATE TABLE t3 SELECT a as c FROM t1;
SELECT * FROM (SELECT a FROM t1 GROUP BY a) dt1, (SELECT b FROM t2) dt2, t3
WHERE dt2.b = t3.c AND dt1.a BETWEEN 0 AND (dt2.b IS NULL);
a b c
0 0 0
0 1 1
0 3 3
SELECT * FROM (SELECT a FROM t1 GROUP BY a) dt1, (SELECT b FROM t2) dt2, t3
WHERE dt2.b = t3.c AND dt1.a BETWEEN 0 AND (1+(dt2.b IS NULL));
a b c
0 0 0
1 0 0
0 1 1
1 1 1
0 3 3
1 3 3
DROP TABLE t1,t2,t3;
# End of 10.5 tests
......@@ -4188,4 +4188,20 @@ execute stmt;
drop table t1, t2;
--echo #
--echo # MDEV-29360: Pushed condition contains always false IS NULL
--echo #
CREATE TABLE t1 (a int NOT NULL);
INSERT INTO t1 VALUES (0),(1),(3);
CREATE TABLE t2 SELECT a as b FROM t1;
CREATE TABLE t3 SELECT a as c FROM t1;
SELECT * FROM (SELECT a FROM t1 GROUP BY a) dt1, (SELECT b FROM t2) dt2, t3
WHERE dt2.b = t3.c AND dt1.a BETWEEN 0 AND (dt2.b IS NULL);
SELECT * FROM (SELECT a FROM t1 GROUP BY a) dt1, (SELECT b FROM t2) dt2, t3
WHERE dt2.b = t3.c AND dt1.a BETWEEN 0 AND (1+(dt2.b IS NULL));
DROP TABLE t1,t2,t3;
--echo # End of 10.5 tests
......@@ -7963,6 +7963,8 @@ Item_direct_view_ref::grouping_field_transformer_for_where(THD *thd,
st_select_lex *sel= (st_select_lex *)arg;
Field_pair *gr_field= find_matching_field_pair(this,
sel->grouping_tmp_fields);
if (!gr_field)
return this;
return gr_field->corresponding_item->build_clone(thd);
}
......
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