Skip to content

Commit 4ebf680

Browse files
kevgsmidenok
authored andcommitted
SQL: VIEW over a JOIN of versioned tables [fixes #153]
1 parent 92c7a87 commit 4ebf680

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

mysql-test/suite/versioning/r/view.result

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ select * from vvvt1 for system_time all;
112112
x
113113
create or replace table t1 (x int) with system versioning;
114114
create or replace view vt1(c) as select x from t1;
115-
drop view vvvt1;
116-
drop view vvt1;
117-
drop view vt1;
118-
drop table t1;
115+
create or replace table t1 (a int) with system versioning;
116+
create or replace table t2 (b int) with system versioning;
117+
insert into t1 values (1);
118+
insert into t2 values (2);
119+
create or replace view vt12 as select * from t1 cross join t2;
120+
select * from vt12;
121+
a b
122+
1 2
123+
create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2;
124+
select * from vt12;
125+
a b
126+
drop view vt1, vvt1, vvvt1, vt12;
127+
drop table t1, t2;

mysql-test/suite/versioning/t/view.test

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ select * from vvvt1 for system_time all;
7373
create or replace table t1 (x int) with system versioning;
7474
create or replace view vt1(c) as select x from t1;
7575

76-
drop view vvvt1;
77-
drop view vvt1;
78-
drop view vt1;
79-
drop table t1;
76+
create or replace table t1 (a int) with system versioning;
77+
create or replace table t2 (b int) with system versioning;
78+
insert into t1 values (1);
79+
insert into t2 values (2);
80+
create or replace view vt12 as select * from t1 cross join t2;
81+
select * from vt12;
82+
create or replace view vt12 as select * from t1 for system_time as of timestamp '0-0-0' cross join t2;
83+
select * from vt12;
84+
85+
drop view vt1, vvt1, vvvt1, vt12;
86+
drop table t1, t2;

sql/sql_view.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
467467
const char *end = s->vers_end_field()->field_name;
468468

469469
select_lex->item_list.push_back(new (thd->mem_root) Item_field(
470-
thd, &select_lex->context, NULL, NULL, start));
470+
thd, &select_lex->context, tables->db, tables->alias, start));
471471
select_lex->item_list.push_back(new (thd->mem_root) Item_field(
472-
thd, &select_lex->context, NULL, NULL, end));
472+
thd, &select_lex->context, tables->db, tables->alias, end));
473473

474474
if (lex->view_list.elements)
475475
{

0 commit comments

Comments
 (0)