-
unknown authored
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.
304c42e7