mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +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:
@ -298,6 +298,10 @@ create or replace table t2 (b int) with system versioning;
|
||||
select * from t1
|
||||
where exists (select 1 from t2 where t2.b = t1.a and t2.b = t1.a);
|
||||
a
|
||||
### Issue #365, bug 9 (not a derived subquery)
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
select t1.x in (select x from t1) a from t1, (select x from t1) b;
|
||||
a
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
call innodb_verify_vtq(28);
|
||||
|
@ -195,6 +195,10 @@ create or replace table t2 (b int) with system versioning;
|
||||
select * from t1
|
||||
where exists (select 1 from t2 where t2.b = t1.a and t2.b = t1.a);
|
||||
|
||||
--echo ### Issue #365, bug 9 (not a derived subquery)
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
select t1.x in (select x from t1) a from t1, (select x from t1) b;
|
||||
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user