mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
SQL: NATURAL LEFT JOIN for versioned tables [fixes #156]
This commit is contained in:
@ -456,6 +456,16 @@ a b
|
|||||||
1 2
|
1 2
|
||||||
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
||||||
a b
|
a b
|
||||||
|
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);
|
||||||
|
select * from t1 for system_time all natural left join t2 for system_time all;
|
||||||
|
a1 a2
|
||||||
|
1 1
|
||||||
|
2 1
|
||||||
|
1 2
|
||||||
|
2 2
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
call verify_vtq;
|
call verify_vtq;
|
||||||
No A B C D
|
No A B C D
|
||||||
|
@ -175,6 +175,12 @@ select * from (select * from t1 cross join t2) as tmp;
|
|||||||
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
|
||||||
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
select * from (select * from t1 cross join t2 for system_time as of timestamp '0-0-0') as tmp;
|
||||||
|
|
||||||
|
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);
|
||||||
|
select * from t1 for system_time all natural left join t2 for system_time all;
|
||||||
|
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
|
|
||||||
call verify_vtq;
|
call verify_vtq;
|
||||||
|
@ -5350,7 +5350,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
|
|||||||
{
|
{
|
||||||
if (!my_strcasecmp(system_charset_info, curr_nj_col->name(), name))
|
if (!my_strcasecmp(system_charset_info, curr_nj_col->name(), name))
|
||||||
{
|
{
|
||||||
if (nj_col && !curr_nj_col->table_field->field->vers_sys_field())
|
if (nj_col)
|
||||||
{
|
{
|
||||||
my_error(ER_NON_UNIQ_ERROR, MYF(0), name, thd->where);
|
my_error(ER_NON_UNIQ_ERROR, MYF(0), name, thd->where);
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
@ -6379,6 +6379,10 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
|||||||
bool is_using_column_1;
|
bool is_using_column_1;
|
||||||
if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1)))
|
if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
if (nj_col_1->field() && nj_col_1->field()->vers_sys_field())
|
||||||
|
continue;
|
||||||
|
|
||||||
field_name_1= nj_col_1->name();
|
field_name_1= nj_col_1->name();
|
||||||
is_using_column_1= using_fields &&
|
is_using_column_1= using_fields &&
|
||||||
test_if_string_in_list(field_name_1, using_fields);
|
test_if_string_in_list(field_name_1, using_fields);
|
||||||
@ -6420,9 +6424,8 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
|||||||
if (!my_strcasecmp(system_charset_info, field_name_1, cur_field_name_2))
|
if (!my_strcasecmp(system_charset_info, field_name_1, cur_field_name_2))
|
||||||
{
|
{
|
||||||
DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common));
|
DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common));
|
||||||
if ((!it_1.field() || !it_1.field()->vers_sys_field()) &&
|
if (cur_nj_col_2->is_common ||
|
||||||
(cur_nj_col_2->is_common ||
|
(found && (!using_fields || is_using_column_1)))
|
||||||
(found && (!using_fields || is_using_column_1))))
|
|
||||||
{
|
{
|
||||||
my_error(ER_NON_UNIQ_ERROR, MYF(0), field_name_1, thd->where);
|
my_error(ER_NON_UNIQ_ERROR, MYF(0), field_name_1, thd->where);
|
||||||
goto err;
|
goto err;
|
||||||
|
Reference in New Issue
Block a user