diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result index 167d1c8ff9a..34ce9e3976e 100644 --- a/mysql-test/suite/versioning/r/select.result +++ b/mysql-test/suite/versioning/r/select.result @@ -413,9 +413,22 @@ a2 a1 2 1 1 2 2 2 +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; +a a +2 1 +3 1 +2 2 +3 2 +2 3 +3 3 +1 NULL drop view v1; drop table t1, t2; -call innodb_verify_vtq(21); +call innodb_verify_vtq(24); No A B C D 1 1 1 1 1 2 1 1 1 1 @@ -438,6 +451,9 @@ No A B C D 19 1 1 1 1 20 1 1 1 1 21 1 1 1 1 +22 1 1 1 1 +23 1 1 1 1 +24 1 1 1 1 drop procedure test_01; drop procedure test_02; drop procedure verify_vtq; diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index 35cbc068070..fb086b0060d 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -184,10 +184,16 @@ select * from v1 natural join t2; select * from v1 natural left join t2; select * from v1 natural right join t2; +create or replace table t1 (a int) with system versioning; +insert into t1 values (1); +insert into t1 values (2); +insert into t1 values (3); +select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; + drop view v1; drop table t1, t2; -call innodb_verify_vtq(21); +call innodb_verify_vtq(24); drop procedure test_01; drop procedure test_02; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c91895ce056..7658bb9e2d0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -834,6 +834,12 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, dst_cond= &table->on_expr; } + if (TABLE_LIST *t= table->embedding) + { + if (t->on_expr) + dst_cond= &t->on_expr; + } + const char *fstart= table->table->vers_start_field()->field_name; const char *fend= table->table->vers_end_field()->field_name;