diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result index ef2755460c3..e340f4a39fb 100644 --- a/mysql-test/suite/versioning/r/select.result +++ b/mysql-test/suite/versioning/r/select.result @@ -302,9 +302,21 @@ a create or replace table t1 (x int) with system versioning; select t1.x in (select x from t1) a from t1, (select x from t1) b; a +### Issue #365, bug 10 (WHERE cond freed prematurely for PS) +create or replace table t1 (x int) with system versioning; +insert into t1 values (1); +create or replace view v1 as select x from t1 where x = 1; +prepare stmt from " +select x from t1 where x in (select x from v1);"; +execute stmt; +x +1 +execute stmt; +x +1 drop view v1; drop table t1, t2; -call innodb_verify_vtq(28); +call innodb_verify_vtq(29); No A B C D 1 1 1 1 1 2 1 1 1 1 @@ -334,3 +346,4 @@ No A B C D 26 1 1 1 1 27 1 1 1 1 28 1 1 1 1 +29 1 1 1 1 diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index 8f8698bbfcc..d4dce1dd1aa 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -199,9 +199,18 @@ where exists (select 1 from t2 where t2.b = t1.a and t2.b = t1.a); create or replace table t1 (x int) with system versioning; select t1.x in (select x from t1) a from t1, (select x from t1) b; +--echo ### Issue #365, bug 10 (WHERE cond freed prematurely for PS) +create or replace table t1 (x int) with system versioning; +insert into t1 values (1); +create or replace view v1 as select x from t1 where x = 1; +prepare stmt from " +select x from t1 where x in (select x from v1);"; +execute stmt; +execute stmt; + drop view v1; drop table t1, t2; -call innodb_verify_vtq(28); +call innodb_verify_vtq(29); -- source suite/versioning/common_finish.inc diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index a510ed14f1f..f059ff93ec8 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3775,6 +3775,7 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds, DBUG_ENTER("st_select_lex::fix_prepare_information"); if (!thd->stmt_arena->is_conventional() && first_execution) { + Query_arena_stmt on_stmt_arena(thd); first_execution= 0; if (group_list.first) {