Commit 365ba070 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-5814: MySQL Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY

- Adopt MySQL's fix: don't run index_merge optimizer if the table statistics 
  reports that the table has 0 rows.
parent 43a43b82
......@@ -9,3 +9,11 @@ SELECT 1 FROM t1 WHERE a = ANY (SELECT a FROM t2);
1
DROP TABLE t1, t2;
End of 5.5 tests
#
# Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY
#
CREATE TABLE t1(a INT, b INT, c INT, KEY(c), UNIQUE(a)) ENGINE = BLACKHOLE;
SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0;
0
DROP TABLE t1;
End of 5.6 tests
......@@ -19,3 +19,12 @@ DROP TABLE t1, t2;
--echo End of 5.5 tests
--echo #
--echo # Bug#13948247 DIVISION BY 0 IN GET_BEST_DISJUNCT_QUICK WITH FORCE INDEX GROUP BY
--echo #
CREATE TABLE t1(a INT, b INT, c INT, KEY(c), UNIQUE(a)) ENGINE = BLACKHOLE;
SELECT 0 FROM t1 FORCE INDEX FOR GROUP BY(a) WHERE a = 0 OR b = 0 AND c = 0;
DROP TABLE t1;
--echo End of 5.6 tests
......@@ -3168,7 +3168,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
}
}
if (optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE))
if (optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE) &&
head->stat_records() != 0)
{
/* Try creating index_merge/ROR-union scan. */
SEL_IMERGE *imerge;
......
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