mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Fixed bug lp:800679
Analysis: The failed assert ensured that the choice of subquery strategy is performed only for queries with at least one table. If there is a LIMIT 0 clause all tables are removed, and the subquery is neither optimized, nor executed during actual optimization. However, if the query is EXPLAIN-ed, the EXPLAIN execution path doesn't remove the query tables if there is a LIMIT 0 clause. As a result, the subquery optimization code is called, which violates the ASSERT condition. Solution: Transform the assert into a condition, and if the outer query has no tables assume that there will be at most one subquery execution. There is potentially a better solution by reengineering the EXPLAIN/optimize code, so that subquery optimization is not done if not needed. Such a solution would be a lot bigger and more complex than a bug fix.
This commit is contained in:
parent
95cba1043e
commit
78fa331eaa
3 changed files with 45 additions and 2 deletions
|
|
@ -326,3 +326,26 @@ select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or
|
|||
select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#800679: Assertion `outer_join->table_count > 0' failed in
|
||||
--echo # JOIN::choose_subquery_plan() with materialization=on,semijoin=off
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( f1 int);
|
||||
insert into t1 values (1),(2);
|
||||
CREATE TABLE t2 ( f1 int);
|
||||
insert into t2 values (1),(2);
|
||||
|
||||
SET @@optimizer_switch='materialization=on,semijoin=off';
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE (f1) IN (SELECT f1 FROM t2)
|
||||
LIMIT 0;
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE (f1) IN (SELECT f1 FROM t2)
|
||||
LIMIT 0;
|
||||
|
||||
drop table t1, t2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue