From 4ebf680c9bb7fa42656a87024e9d464226b089d4 Mon Sep 17 00:00:00 2001 From: kevg Date: Tue, 14 Mar 2017 13:05:39 +0300 Subject: [PATCH] SQL: VIEW over a JOIN of versioned tables [fixes #153] --- mysql-test/suite/versioning/r/view.result | 17 +++++++++++++---- mysql-test/suite/versioning/t/view.test | 15 +++++++++++---- sql/sql_view.cc | 4 ++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/versioning/r/view.result b/mysql-test/suite/versioning/r/view.result index 4dc6455e7ab..104e2a557e8 100644 --- a/mysql-test/suite/versioning/r/view.result +++ b/mysql-test/suite/versioning/r/view.result @@ -112,7 +112,16 @@ select * from vvvt1 for system_time all; x create or replace table t1 (x int) with system versioning; create or replace view vt1(c) as select x from t1; -drop view vvvt1; -drop view vvt1; -drop view vt1; -drop table t1; +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +create or replace view vt12 as select * from t1 cross join t2; +select * from vt12; +a b +1 2 +create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2; +select * from vt12; +a b +drop view vt1, vvt1, vvvt1, vt12; +drop table t1, t2; diff --git a/mysql-test/suite/versioning/t/view.test b/mysql-test/suite/versioning/t/view.test index 909e55eac82..c284df3ec5e 100644 --- a/mysql-test/suite/versioning/t/view.test +++ b/mysql-test/suite/versioning/t/view.test @@ -73,7 +73,14 @@ select * from vvvt1 for system_time all; create or replace table t1 (x int) with system versioning; create or replace view vt1(c) as select x from t1; -drop view vvvt1; -drop view vvt1; -drop view vt1; -drop table t1; +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int) with system versioning; +insert into t1 values (1); +insert into t2 values (2); +create or replace view vt12 as select * from t1 cross join t2; +select * from vt12; +create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2; +select * from vt12; + +drop view vt1, vvt1, vvvt1, vt12; +drop table t1, t2; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 215d81f5724..d542a5710f6 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -467,9 +467,9 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, const char *end = s->vers_end_field()->field_name; select_lex->item_list.push_back(new (thd->mem_root) Item_field( - thd, &select_lex->context, NULL, NULL, start)); + thd, &select_lex->context, tables->db, tables->alias, start)); select_lex->item_list.push_back(new (thd->mem_root) Item_field( - thd, &select_lex->context, NULL, NULL, end)); + thd, &select_lex->context, tables->db, tables->alias, end)); if (lex->view_list.elements) {