Commit 8d29fddb authored by Sergey Petrunya's avatar Sergey Petrunya

BUG#780359: Crash with get_fanout_with_deps in maria-5.3-mwl90

- Handle the case of degenerate joins. When join has impossible WHERE clause,
  a number of its members, including JOIN::map2table, are not initialized. 
  Do not try accessing them, detect degenerate joins early.
parent 34a5646d
......@@ -81,3 +81,21 @@ id select_type table type possible_keys key key_len ref rows Extra
2 SUBQUERY t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
drop table t1,t2,t3,t4;
drop table t0;
#
# BUG#780359: Crash with get_fanout_with_deps in maria-5.3-mwl90
#
CREATE TABLE t1 (f1 int);
INSERT INTO t1 VALUES (2),(2);
CREATE TABLE t2 (f3 int);
INSERT INTO t2 VALUES (2),(2);
SELECT *
FROM t1
WHERE ( f1 ) IN (
SELECT t2.f3
FROM t2
WHERE t2.f3 = 97
AND t2.f3 = 50
GROUP BY 1
);
f1
DROP TABLE t1, t2;
......@@ -74,3 +74,24 @@ drop table t1,t2,t3,t4;
drop table t0;
--echo #
--echo # BUG#780359: Crash with get_fanout_with_deps in maria-5.3-mwl90
--echo #
CREATE TABLE t1 (f1 int);
INSERT INTO t1 VALUES (2),(2);
CREATE TABLE t2 (f3 int);
INSERT INTO t2 VALUES (2),(2);
SELECT *
FROM t1
WHERE ( f1 ) IN (
SELECT t2.f3
FROM t2
WHERE t2.f3 = 97
AND t2.f3 = 50
GROUP BY 1
);
DROP TABLE t1, t2;
......@@ -4094,6 +4094,10 @@ JOIN_TAB *next_top_level_tab(JOIN *join, JOIN_TAB *tab);
double get_fanout_with_deps(JOIN *join, table_map tset)
{
/* Handle the case of "Impossible WHERE" */
if (join->table_count == 0)
return 0.0;
/* First, recursively get all tables we depend on */
table_map deps_to_check= tset;
table_map checked_deps= 0;
......
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