From: Date: April 30 2005 6:23pm Subject: bk commit into 4.1 tree (dlenev:1.2219) BUG#9913 List-Archive: http://lists.mysql.com/internals/24501 X-Bug: 9913 Message-Id: <20050430162348.261F8226FE3@brandersnatch.localdomain> Below is the list of changes that have just been committed into a local 4.1 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 1.2219 05/04/30 20:23:40 dlenev@stripped +5 -0 Fix for Bug #9913 "udf_deinit is not called after execution of PS" (aka "deinit is not called when calling udf from trigger"). We should call udf_deinit() function during cleanup phase after prepared (or ordinary) statement execution instead of calling it from Item's desctructor. No test case is provided since it is hard to test UDF's from our test suite. sql/sql_udf.h 1.8 05/04/30 20:23:35 dlenev@stripped +1 -0 Added udf_handler::cleanup() method declaration which is responsible for cleaning up UDF execution context at the end of execution of statement (using ~udf_handler() for this purprose did not worked for PS). sql/item_sum.h 1.79 05/04/30 20:23:35 dlenev@stripped +1 -0 Added Item_udf_sum::cleanup() method to perform cleanup properly after execution of PS with aggregate UDF function. sql/item_sum.cc 1.134 05/04/30 20:23:35 dlenev@stripped +11 -0 Added Item_udf_sum::cleanup() method to perform cleanup properly after execution of PS with aggregate UDF function. sql/item_func.h 1.122 05/04/30 20:23:35 dlenev@stripped +1 -0 Added Item_udf_func::cleanup() method to perform cleanup properly after execution of PS with UDF function. sql/item_func.cc 1.240 05/04/30 20:23:35 dlenev@stripped +15 -0 udf_handler: Moved all functionality from udf_handler::~udf_handler() to udf_handler::cleanup() method which will be called after each PS execution, thus allowing udf_deinit() to be executed symetrically with udf_init() (which is executed for each execution of PS). Added Item_udf_func::cleanup() which performs proper cleanup after execution of PS with UDF function. # 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: brandersnatch.localdomain # Root: /home/dlenev/src/mysql-4.1-bg9913 --- 1.239/sql/item_func.cc Tue Apr 19 13:44:50 2005 +++ 1.240/sql/item_func.cc Sat Apr 30 20:23:35 2005 @@ -1618,6 +1618,13 @@ udf_handler::~udf_handler() { + /* Everything should be properly cleaned up by this moment. */ + DBUG_ASSERT(not_original || !(initialized || buffers)); +} + + +void udf_handler::cleanup() +{ if (!not_original) { if (initialized) @@ -1629,9 +1636,11 @@ (*deinit)(&initid); } free_udf(u_d); + initialized= FALSE; } if (buffers) // Because of bug in ecc delete [] buffers; + buffers= 0; } } @@ -1870,6 +1879,12 @@ return save_str; } + +void Item_udf_func::cleanup() +{ + udf.cleanup(); + Item_func::cleanup(); +} double Item_func_udf_float::val() --- 1.121/sql/item_func.h Wed Mar 30 11:13:21 2005 +++ 1.122/sql/item_func.h Sat Apr 30 20:23:35 2005 @@ -786,6 +786,7 @@ fixed= 1; return res; } + void cleanup(); Item_result result_type () const { return udf.result_type(); } table_map not_null_tables() const { return 0; } }; --- 1.133/sql/item_sum.cc Thu Feb 24 04:50:33 2005 +++ 1.134/sql/item_sum.cc Sat Apr 30 20:23:35 2005 @@ -1449,6 +1449,17 @@ DBUG_RETURN(0); } +void Item_udf_sum::cleanup() +{ + /* + udf_handler::cleanup() nicely handles case when we have not + original item but one created by copy_or_same() method. + */ + udf.cleanup(); + Item_sum::cleanup(); +} + + Item *Item_sum_udf_float::copy_or_same(THD* thd) { return new (thd->mem_root) Item_sum_udf_float(thd, this); --- 1.78/sql/item_sum.h Tue Feb 22 13:51:20 2005 +++ 1.79/sql/item_sum.h Sat Apr 30 20:23:35 2005 @@ -550,6 +550,7 @@ bool add(); void reset_field() {}; void update_field() {}; + void cleanup(); }; --- 1.7/sql/sql_udf.h Sat Nov 6 08:37:27 2004 +++ 1.8/sql/sql_udf.h Sat Apr 30 20:23:35 2005 @@ -67,6 +67,7 @@ bool get_arguments(); bool fix_fields(THD *thd,struct st_table_list *tlist,Item_result_field *item, uint arg_count,Item **args); + void cleanup(); double val(my_bool *null_value) { if (get_arguments())