mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-31279 Crash when lateral derived is guaranteed to return no rows
Consider this query SELECT t1.* FROM t1, (SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq where sq.b = t1.a; If SELECT 1 FROM t3 is expensive, for example t3 has > thd->variables.expensive_subquery_limit, first evaluation is deferred to mysql_derived_fill(). There it is noted that, in the above case NOT EXISTS (SELECT 1 FROM t3) is constant and false. This causes the join variable zero_result_cause to be set to "Impossible WHERE noticed after reading const tables" and the handler for this join is never "opened" via handler::ha_open. When mysql_derived_fill() is called for the next group of results, this unopened handler is not taken into account. reviewed by Igor Babaev (igor@mariadb.com)
This commit is contained in:
@ -1227,6 +1227,9 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
goto err;
|
||||
JOIN *join= unit->first_select()->join;
|
||||
join->first_record= false;
|
||||
if (join->zero_result_cause)
|
||||
goto err;
|
||||
|
||||
for (uint i= join->top_join_tab_count;
|
||||
i < join->top_join_tab_count + join->aggr_tables;
|
||||
i++)
|
||||
|
Reference in New Issue
Block a user