1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

SQL: VIEW NATURAL JOIN TABLE [fixes #161]

This commit is contained in:
kevg
2017-03-23 16:14:19 +03:00
committed by Aleksey Midenkov
parent 21e8b22f53
commit e8ae9f1ae9
3 changed files with 49 additions and 2 deletions

View File

@ -390,8 +390,32 @@ a1 a2
2 1
1 2
2 2
create or replace table t1(a1 int) with system versioning;
create or replace table t2(a2 int) with system versioning;
insert into t1 values(1),(2);
insert into t2 values(1),(2);
create or replace view v1 as select a1 from t1;
select * from v1 natural join t2;
a1 a2
1 1
2 1
1 2
2 2
select * from v1 natural left join t2;
a1 a2
1 1
2 1
1 2
2 2
select * from v1 natural right join t2;
a2 a1
1 1
2 1
1 2
2 2
drop view v1;
drop table t1, t2;
call innodb_verify_vtq(19);
call innodb_verify_vtq(21);
No A B C D
1 1 1 1 1
2 1 1 1 1
@ -412,6 +436,8 @@ No A B C D
17 1 1 1 1
18 1 1 1 1
19 1 1 1 1
20 1 1 1 1
21 1 1 1 1
drop procedure test_01;
drop procedure test_02;
drop procedure verify_vtq;

View File

@ -173,9 +173,21 @@ insert into t1 values(1),(2);
insert into t2 values(1),(2);
select * from t1 for system_time all natural left join t2 for system_time all;
# natural join of a view and table
create or replace table t1(a1 int) with system versioning;
create or replace table t2(a2 int) with system versioning;
insert into t1 values(1),(2);
insert into t2 values(1),(2);
create or replace view v1 as select a1 from t1;
select * from v1 natural join t2;
select * from v1 natural left join t2;
select * from v1 natural right join t2;
drop view v1;
drop table t1, t2;
call innodb_verify_vtq(19);
call innodb_verify_vtq(21);
drop procedure test_01;
drop procedure test_02;

View File

@ -6383,6 +6383,15 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
if (nj_col_1->field() && nj_col_1->field()->vers_sys_field())
continue;
if (table_ref_1->is_view() && table_ref_1->table->versioned())
{
Item *item= nj_col_1->view_field->item;
DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
Item_field *item_field= (Item_field *)item;
if (item_field->field->vers_sys_field())
continue;
}
field_name_1= nj_col_1->name();
is_using_column_1= using_fields &&
test_if_string_in_list(field_name_1, using_fields);