diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result index 38f9de1d848..7ffff3b3bdc 100644 --- a/mysql-test/suite/versioning/r/select.result +++ b/mysql-test/suite/versioning/r/select.result @@ -313,6 +313,11 @@ x execute stmt; x 1 +### Issue #365, bug 11 (WHERE cond not top level item) +create or replace table t1 (a int, b int, key idx(a)) with system versioning; +insert into t1 values (1, 1), (2, 2); +select * from t1 where (a, 2) in ((1, 1), (2, 2)) and b = 1; +a b drop view v1; drop table t1, t2; call innodb_verify_vtq(29); @@ -346,3 +351,4 @@ No A B C D 27 1 1 1 1 28 1 1 1 1 29 1 1 1 1 +30 1 1 1 1 diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index ecbe89b223e..2bf0e1d7f0f 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -208,6 +208,11 @@ select x from t1 where x in (select x from v1);"; execute stmt; execute stmt; +--echo ### Issue #365, bug 11 (WHERE cond not top level item) +create or replace table t1 (a int, b int, key idx(a)) with system versioning; +insert into t1 values (1, 1), (2, 2); +select * from t1 where (a, 2) in ((1, 1), (2, 2)) and b = 1; + drop view v1; drop table t1, t2; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 675064067fc..f261c5731cf 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7347,6 +7347,7 @@ SEL_TREE *Item_func_in::get_func_row_mm_tree(RANGE_OPT_PARAM *param, key_col->bring_value(); key_col_info.comparator= row_cmp_item->get_comparator(i); + DBUG_ASSERT(key_col_info.comparator); key_col_info.comparator->store_value(key_col); col_comparators++; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 86bdeda8af7..36d9d01e1ec 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -986,6 +986,7 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, thd->change_item_tree(dst_cond, cond1); slex->where= *dst_cond; + slex->where->top_level_item(); } } // if (... table->table->versioned()) } // for (table= tables; ...)