Skip to content

Commit 7a22dd3

Browse files
kevgsmidenok
authored andcommitted
SQL: INNER JOIN USING with versioned tables [fixes #147]
1 parent 9355e3e commit 7a22dd3

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,16 @@ ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME query`: write-locking of hist
409409
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
410410
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
411411
a
412-
drop table t1;
412+
create or replace table t1 (a int) with system versioning;
413+
create or replace table t2 (a int) with system versioning;
414+
insert into t1 values(1);
415+
insert into t2 values(1);
416+
create view v1 as select * from t2 inner join t1 using (a);
417+
select * from v1;
418+
a
419+
1
420+
drop view v1;
421+
drop table t1, t2;
413422
call verify_vtq;
414423
No A B C D
415424
1 1 1 1 1

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ select * from t1 for system_time all for update;
134134
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
135135
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
136136

137-
drop table t1;
137+
create or replace table t1 (a int) with system versioning;
138+
create or replace table t2 (a int) with system versioning;
139+
insert into t1 values(1);
140+
insert into t2 values(1);
141+
create view v1 as select * from t2 inner join t1 using (a);
142+
select * from v1;
143+
drop view v1;
144+
145+
drop table t1, t2;
138146

139147
call verify_vtq;
140148

sql/sql_base.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5350,7 +5350,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
53505350
{
53515351
if (!my_strcasecmp(system_charset_info, curr_nj_col->name(), name))
53525352
{
5353-
if (nj_col)
5353+
if (nj_col && !curr_nj_col->table_field->field->vers_sys_field())
53545354
{
53555355
my_error(ER_NON_UNIQ_ERROR, MYF(0), name, thd->where);
53565356
DBUG_RETURN(NULL);

0 commit comments

Comments
 (0)