From: Date: November 13 2006 9:10am Subject: bk commit into 5.0 tree (dlenev:1.2285) BUG#23651 List-Archive: http://lists.mysql.com/commits/15202 X-Bug: 23651 Message-Id: <20061113081056.43F6E2042FE@mockturtle.local> Below is the list of changes that have just been committed into a local 5.0 repository of dlenev. When dlenev does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-11-13 11:10:49+03:00, dlenev@stripped +3 -0 Fix for bug bug#23651 "Server crashes when trigger which uses stored function invoked from different connections". Invocation of trigger which was using stored function from different connections caused server crashes (for non-debug server this happened in highly concurrent environment, but debug server failed on assertion in relatively simple scenario). Item_func_sp was not safe to use in triggers (in other words for re-execution from different threads) as artificial TABLE object pointed by Item_func_sp::dummy_table referenced incorrect THD object. To fix the problem we force re-initialization of this object for each re-execution of statement. mysql-test/r/trigger.result@stripped, 2006-11-13 11:10:48+03:00, dlenev@stripped +15 -0 Added test for bug#23651 "Server crashes when trigger which uses stored function invoked from different connections". mysql-test/t/trigger.test@stripped, 2006-11-13 11:10:48+03:00, dlenev@stripped +20 -0 Added test for bug#23651 "Server crashes when trigger which uses stored function invoked from different connections". sql/item_func.cc@stripped, 2006-11-13 11:10:48+03:00, dlenev@stripped +1 -0 To make Item_func_sp safe for usage in triggers (in other words safe for re-execution in different threads) we need to ensure that artificial TABLE object pointed by Item_func_sp::dummy_table references correct THD object. To achieve this we simply force its re-initialization for each re-execution of statement. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: dlenev # Host: mockturtle.local # Root: /home/dlenev/src/mysql-5.0-bg23651 --- 1.310/sql/item_func.cc 2006-11-13 11:10:56 +03:00 +++ 1.311/sql/item_func.cc 2006-11-13 11:10:56 +03:00 @@ -4845,6 +4845,7 @@ result_field= NULL; } m_sp= NULL; + dummy_table->s= NULL; Item_func::cleanup(); } --- 1.48/mysql-test/r/trigger.result 2006-11-13 11:10:56 +03:00 +++ 1.49/mysql-test/r/trigger.result 2006-11-13 11:10:56 +03:00 @@ -1241,4 +1241,19 @@ 2 2 13 13 drop table t1; +drop table if exists t1; +drop function if exists f1; +create table t1 (i int); +create function f1() returns int return 10; +create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10; +insert into t1 values (); +select @a; +@a +20 +insert into t1 values (); +select @a; +@a +20 +drop table t1; +drop function f1; End of 5.0 tests --- 1.54/mysql-test/t/trigger.test 2006-11-13 11:10:56 +03:00 +++ 1.55/mysql-test/t/trigger.test 2006-11-13 11:10:56 +03:00 @@ -1499,4 +1499,24 @@ drop table t1; +# +# Bug #23651 "Server crashes when trigger which uses stored function +# invoked from different connections". +# +--disable_warnings +drop table if exists t1; +drop function if exists f1; +--enable_warnings +create table t1 (i int); +create function f1() returns int return 10; +create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10; +insert into t1 values (); +select @a; +connection addconroot1; +insert into t1 values (); +select @a; +connection default; +drop table t1; +drop function f1; + --echo End of 5.0 tests