mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed the bug mdev-12563.
The bug happened when the specification of a recursive CTE had no recursive references at the top level of the specification. In this case the regular processing of derived table references of the select containing a non-recursive reference to this recursive CTE misses handling the specification unit. At the preparation stage any non-recursive reference to a recursive CTE must be handled after the preparation of the specification unit for this CTE. So we have to force this preparation when regular handling of derived tables does not do it.
This commit is contained in:
@ -646,6 +646,23 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
|
||||
SELECT_LEX *first_select= unit->first_select();
|
||||
|
||||
if (derived->is_recursive_with_table() &&
|
||||
!derived->is_with_table_recursive_reference() &&
|
||||
!derived->with->rec_result && derived->with->get_sq_rec_ref())
|
||||
{
|
||||
/*
|
||||
This is a non-recursive reference to a recursive CTE whose
|
||||
specification unit has not been prepared at the regular processing of
|
||||
derived table references. This can happen only in the case when
|
||||
the specification unit has no recursive references at the top level.
|
||||
Force the preparation of the specification unit. Use a recursive
|
||||
table reference from a subquery for this.
|
||||
*/
|
||||
DBUG_ASSERT(derived->with->get_sq_rec_ref());
|
||||
if (mysql_derived_prepare(lex->thd, lex, derived->with->get_sq_rec_ref()))
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
if (unit->prepared && derived->is_recursive_with_table() &&
|
||||
!derived->table)
|
||||
{
|
||||
|
Reference in New Issue
Block a user