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

SQL: fix subquery not a derived table [#365 bug 9]

Tests affected (forced mode):

main.ps \
main.user_var \
main.myisam_explain_non_select_all \
main.opt_tvc \
main.subselect \
main.subselect_no_exists_to_in \
main.derived \
main.derived_opt \
main.update
This commit is contained in:
Aleksey Midenkov
2017-12-05 03:25:34 +03:00
parent 56adced376
commit 3d88a72f76
3 changed files with 11 additions and 3 deletions

View File

@ -791,14 +791,14 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
if (!vers_conditions && outer_slex && slex->vers_import_outer)
{
TABLE_LIST* derived= slex->master_unit()->derived;
while (outer_slex && (!derived->vers_conditions || derived->vers_conditions.from_inner))
// inner SELECT may not be a derived table (derived == NULL)
while (derived && outer_slex && (!derived->vers_conditions || derived->vers_conditions.from_inner))
{
derived= outer_slex->master_unit()->derived;
outer_slex= outer_slex->next_select_in_list();
}
if (outer_slex)
if (derived && outer_slex && !derived->vers_conditions.from_inner)
{
DBUG_ASSERT(derived);
DBUG_ASSERT(derived->vers_conditions);
vers_conditions= derived->vers_conditions;
}