mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
SQL: derived tables improvements [closes #185]
This commit is contained in:
@ -771,6 +771,28 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
|
||||
}
|
||||
}
|
||||
|
||||
SELECT_LEX *outer_slex= slex->next_select_in_list();
|
||||
if (outer_slex)
|
||||
{
|
||||
if (slex->vers_derived_conds)
|
||||
{
|
||||
// Propagate derived conditions to outer SELECT_LEX:
|
||||
if (!outer_slex->vers_conditions)
|
||||
{
|
||||
(outer_slex->vers_conditions= slex->vers_derived_conds).
|
||||
from_inner= true;
|
||||
}
|
||||
}
|
||||
else if (slex->vers_conditions.import_outer)
|
||||
{
|
||||
// Propagate query conditions from nearest outer SELECT_LEX:
|
||||
while (outer_slex && (!outer_slex->vers_conditions || outer_slex->vers_conditions.from_inner))
|
||||
outer_slex= outer_slex->next_select_in_list();
|
||||
if (outer_slex)
|
||||
slex->vers_conditions= outer_slex->vers_conditions;
|
||||
}
|
||||
}
|
||||
|
||||
for (table= tables; table; table= table->next_local)
|
||||
{
|
||||
if (table->table && table->table->versioned())
|
||||
@ -1059,7 +1081,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
|
||||
remove_redundant_subquery_clauses(select_lex);
|
||||
}
|
||||
|
||||
/* Handle FOR SYSTEM_TIME clause. */
|
||||
/* System Versioning: handle FOR SYSTEM_TIME clause. */
|
||||
if (vers_setup_select(thd, tables_list, &conds, select_lex) < 0)
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
|
Reference in New Issue
Block a user