1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-18679 Server crashes in JOIN::optimize

The bug manifested itself when executing a query with materialized
view/derived/CTE whose specification was a SELECT query contained
another materialized derived and impossible WHERE/HAVING condition
was detected for this SELECT.
As soon as such condition is detected the join structures of all
derived tables used in the SELECT are destroyed. So optimization
of the queries specifying these derived tables is impossible. Besides
it's not needed.

In 10.3 optimization of a materialized derived table is performed before
detection of impossible WHERE/HAVING condition in the embedding SELECT.
This commit is contained in:
Igor Babaev
2019-02-23 14:53:27 -08:00
parent bba4e7f287
commit 9bd47835d0
3 changed files with 54 additions and 0 deletions

View File

@ -1002,6 +1002,15 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
if (unit->optimized)
DBUG_RETURN(FALSE);
unit->optimized= TRUE;
if (!join)
{
/*
This happens when derived is used in SELECT for which
zer_result_cause != 0.
In this case join is already destroyed.
*/
DBUG_RETURN(FALSE);
}
}
if ((res= join->optimize()))
goto err;