Skip to content

Commit

Permalink
SQL: VIEW over a JOIN of versioned tables [fixes #153]
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgs authored and midenok committed May 5, 2017
1 parent 92c7a87 commit 4ebf680
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
17 changes: 13 additions & 4 deletions mysql-test/suite/versioning/r/view.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
15 changes: 11 additions & 4 deletions mysql-test/suite/versioning/t/view.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions sql/sql_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 4ebf680

Please sign in to comment.