From 2ae2876a6ce4b1e4d4bb61d8f372feff1cb51339 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Thu, 14 Dec 2017 21:16:31 +0300 Subject: [PATCH] MDEV-14652 NATURAL JOIN crash in mark_common_columns() [fixes #405] SQL: reverted NATURAL JOIN fix #161 (deprecated by #383) --- mysql-test/suite/versioning/r/select.result | 6 ++++++ mysql-test/suite/versioning/t/select.test | 6 ++++++ sql/sql_base.cc | 9 --------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result index a09c4c19ee0..c7dab825c3d 100644 --- a/mysql-test/suite/versioning/r/select.result +++ b/mysql-test/suite/versioning/r/select.result @@ -362,6 +362,12 @@ select * from t1 for system_time as of current_timestamp; x select * from t1 for system_time as of now; ERROR 42S22: Unknown column 'now' in 'where clause' +### Issue #405, NATURAL JOIN failure +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int); +create or replace view v1 as select a, sys_trx_start, sys_trx_end from t1 where a > round(rand()*1000); +select * from v1 natural join t2; +a b drop view v1; drop table t1, t2; call innodb_verify_vtq(32); diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index 7b99cd9d13f..b80be9590c5 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -248,6 +248,12 @@ select * from t1 for system_time as of current_timestamp; --error ER_BAD_FIELD_ERROR select * from t1 for system_time as of now; +--echo ### Issue #405, NATURAL JOIN failure +create or replace table t1 (a int) with system versioning; +create or replace table t2 (b int); +create or replace view v1 as select a, sys_trx_start, sys_trx_end from t1 where a > round(rand()*1000); +select * from v1 natural join t2; + drop view v1; drop table t1, t2; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b69e61ed9ae..4d500b58d56 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6420,15 +6420,6 @@ 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->str, using_fields);