From fdb6225390afdbfe7c6ede76b736e1b1ba9f419d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Jan 2005 17:04:24 +0200 Subject: [PATCH] fixed using in SP sentences which use Item tree temporary changes rollback (BUG#7992) mysql-test/r/sp.result: rolling back temporary Item tree changes in SP mysql-test/t/sp.test: rolling back temporary Item tree changes in SP sql/sp_head.cc: if PS instruction made some temporary changes in Item tree we have to roll it back --- mysql-test/r/sp.result | 13 +++++++++++++ mysql-test/t/sp.test | 21 +++++++++++++++++++++ sql/sp_head.cc | 1 + 3 files changed, 35 insertions(+) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 1fd519bc729..5640057bf35 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2321,3 +2321,16 @@ select `foo` (); `foo` () 5 drop function `foo`; +drop procedure if exists p1; +create table t1(id int); +insert into t1 values(1); +create procedure p1() +begin +declare i int; +select max(id)+1 into i from t1; +end +// +call p1()// +call p1()// +drop procedure p1; +drop table t1; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 4f556e34d51..4c5665aae62 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2739,3 +2739,24 @@ drop function if exists foo; create function `foo` () returns int return 5; select `foo` (); drop function `foo`; + +# +# rolling back temporary Item tree changes in SP +# +--disable_warnings +drop procedure if exists p1; +--enable_warnings +create table t1(id int); +insert into t1 values(1); +delimiter //; +create procedure p1() +begin + declare i int; + select max(id)+1 into i from t1; +end +// +call p1()// +call p1()// +delimiter ;// +drop procedure p1; +drop table t1; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 3f2969768c5..dc3b2857993 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -482,6 +482,7 @@ sp_head::execute(THD *thd) break; DBUG_PRINT("execute", ("Instruction %u", ip)); ret= i->execute(thd, &ip); + thd->rollback_item_tree_changes(); if (i->free_list) cleanup_items(i->free_list); // Check if an exception has occurred and a handler has been found