Skip to content
/ server Public
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mysql-test/main/derived_cond_pushdown.result
Original file line number Diff line number Diff line change
Expand Up @@ -21784,4 +21784,19 @@ select * from v2 where greatest(a, default(a));
a count(*)
drop view v2, v1;
drop table t1;
#
# MDEV-29360 Crash when pushing condition with always false IS NULL
# into derived contains constant TRUE/FALSE as subformula
#
CREATE TABLE t1 (id int NOT NULL);
INSERT INTO t1 VALUES (0),(1),(3);
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t3 SELECT * FROM t1;
SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt1, (SELECT id FROM t2) dt2, t3
WHERE dt2.id = t3.id AND dt1.id BETWEEN 0 AND (dt2.id IS NULL);
id id id
0 0 0
0 1 1
0 3 3
DROP TABLE t1,t2,t3;
# End of 10.11 tests
15 changes: 15 additions & 0 deletions mysql-test/main/derived_cond_pushdown.test
Original file line number Diff line number Diff line change
Expand Up @@ -4351,4 +4351,19 @@ select * from v2 where greatest(a, default(a));
drop view v2, v1;
drop table t1;

--echo #
--echo # MDEV-29360 Crash when pushing condition with always false IS NULL
--echo # into derived contains constant TRUE/FALSE as subformula
--echo #

CREATE TABLE t1 (id int NOT NULL);
INSERT INTO t1 VALUES (0),(1),(3);
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t3 SELECT * FROM t1;

SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt1, (SELECT id FROM t2) dt2, t3
WHERE dt2.id = t3.id AND dt1.id BETWEEN 0 AND (dt2.id IS NULL);

DROP TABLE t1,t2,t3;

--echo # End of 10.11 tests
7 changes: 4 additions & 3 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8169,9 +8169,10 @@ Item_direct_view_ref::grouping_field_transformer_for_where(THD *thd,
if (!item_equal)
return this;
st_select_lex *sel= (st_select_lex *)arg;
Field_pair *gr_field= find_matching_field_pair(this,
sel->grouping_tmp_fields);
return gr_field->corresponding_item->deep_copy_with_checks(thd);
if (Field_pair *gr_field= find_matching_field_pair(this,
sel->grouping_tmp_fields))
return gr_field->corresponding_item->deep_copy_with_checks(thd);
return this;
}

void Item_field::print(String *str, enum_query_type query_type)
Expand Down