From e6ce543f051a2d9dc3ddfaecc4397cdd526701bd Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 30 Apr 2005 20:23:40 +0400 Subject: [PATCH 1/5] 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/item_func.cc: 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. sql/item_func.h: Added Item_udf_func::cleanup() method to perform cleanup properly after execution of PS with UDF function. sql/item_sum.cc: Added Item_udf_sum::cleanup() method to perform cleanup properly after execution of PS with aggregate UDF function. sql/item_sum.h: Added Item_udf_sum::cleanup() method to perform cleanup properly after execution of PS with aggregate UDF function. sql/sql_udf.h: 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_func.cc | 15 +++++++++++++++ sql/item_func.h | 1 + sql/item_sum.cc | 11 +++++++++++ sql/item_sum.h | 1 + sql/sql_udf.h | 1 + 5 files changed, 29 insertions(+) diff --git a/sql/item_func.cc b/sql/item_func.cc index 2b38584fe23..d1d89b70d10 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1617,6 +1617,13 @@ longlong Item_func_bit_count::val_int() #ifdef HAVE_DLOPEN 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) { @@ -1629,9 +1636,11 @@ udf_handler::~udf_handler() (*deinit)(&initid); } free_udf(u_d); + initialized= FALSE; } if (buffers) // Because of bug in ecc delete [] buffers; + buffers= 0; } } @@ -1871,6 +1880,12 @@ String *udf_handler::val_str(String *str,String *save_str) } +void Item_udf_func::cleanup() +{ + udf.cleanup(); + Item_func::cleanup(); +} + double Item_func_udf_float::val() { diff --git a/sql/item_func.h b/sql/item_func.h index 3a309f4ae99..7244fc73a42 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -786,6 +786,7 @@ public: fixed= 1; return res; } + void cleanup(); Item_result result_type () const { return udf.result_type(); } table_map not_null_tables() const { return 0; } }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 7e9c5d09136..dd4cda4ff91 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1449,6 +1449,17 @@ bool Item_udf_sum::add() 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); diff --git a/sql/item_sum.h b/sql/item_sum.h index dab136e4716..040d9395e3a 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -550,6 +550,7 @@ public: bool add(); void reset_field() {}; void update_field() {}; + void cleanup(); }; diff --git a/sql/sql_udf.h b/sql/sql_udf.h index d1f99a6d232..acb04e949a3 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -67,6 +67,7 @@ class udf_handler :public Sql_alloc 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()) From 39dfdcffcb21e0d08b0d6ac0aaa8a2bc1cd22235 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 May 2005 00:35:48 +0200 Subject: [PATCH 2/5] - added cmd-line-utils/libedit/vis.h to the source distribution cmd-line-utils/libedit/Makefile.am: - added vis.h to the source distribution --- cmd-line-utils/libedit/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am index 9ff005c7156..03f3eb65fbc 100644 --- a/cmd-line-utils/libedit/Makefile.am +++ b/cmd-line-utils/libedit/Makefile.am @@ -24,7 +24,7 @@ pkginclude_HEADERS = readline/readline.h noinst_HEADERS = chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.h \ sys.h tokenizer.h config.h hist.h map.h prompt.h read.h \ - search.h tty.h libedit_term.h + search.h tty.h libedit_term.h vis.h EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/vis.h np/strlcat.c np/fgetln.c From 6706b9fac95d46abdc7523c3f052d6972248d829 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 May 2005 00:47:47 +0200 Subject: [PATCH 3/5] - fix the range test to pass when InnoDB is note enabled (e.g. in the "-classic" build) --- mysql-test/t/range.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 3d3d4748fe3..b8412b6624e 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -1,3 +1,5 @@ +-- source include/have_innodb.inc + # # Problem with range optimizer # From 1898bd9586c860042a6a43c125064a1bcbcd4740 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 May 2005 09:24:05 +0200 Subject: [PATCH 4/5] don't use tmp file for such a triviality --- scripts/mysql_install_db.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 0b82e02761e..8dd95da11e3 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -11,7 +11,6 @@ in_rpm=0 windows=0 defaults="" user="" -tmp_file=/tmp/mysql_install_db.$$ case "$1" in --no-defaults|--defaults-file=*|--defaults-extra-file=*) @@ -223,10 +222,8 @@ then then echo "Fill help tables" fi - echo "use mysql;" > $tmp_file - cat $tmp_file $fill_help_tables | eval "$mysqld_install_cmd_line" + (echo "use mysql;"; cat $fill_help_tables) | eval "$mysqld_install_cmd_line" res=$? - rm $tmp_file if test $res != 0 then echo "" From cb4b456bc6d7faec3a22c06cab6e238f5c79d6d2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 May 2005 09:25:47 +0200 Subject: [PATCH 5/5] - added "--skip-comments" to the "mysqldump" test to avoid printing comments that include version-dependent information (which causes test failures when running the test with a different version string) mysql-test/r/mysqldump.result: - fixed the results (removed the version-dependent comments to avoid a test failure) mysql-test/t/mysqldump.test: - added "--skip-comments" to avoid printing comments that include version-dependent information (which causes test failures when running the test with a different version string) --- mysql-test/r/mysqldump.result | 28 ---------------------------- mysql-test/t/mysqldump.test | 4 ++-- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index bcd690bf681..80c6cad5bbf 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -563,11 +563,6 @@ DROP TABLE t1; CREATE TABLE t1 (a decimal(240, 20)); INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), ("0987654321098765432109876543210987654321"); --- MySQL dump 10.9 --- --- Host: localhost Database: test --- ------------------------------------------------------ --- Server version 4.1.12-debug-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -577,20 +572,11 @@ INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `t1` --- - DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` decimal(240,20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; --- --- Dumping data for table `t1` --- - /*!40000 ALTER TABLE `t1` DISABLE KEYS */; LOCK TABLES `t1` WRITE; @@ -606,11 +592,6 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- MySQL dump 10.9 --- --- Host: localhost Database: test --- ------------------------------------------------------ --- Server version 4.1.12-debug-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -620,20 +601,11 @@ UNLOCK TABLES; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `t1` --- - DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `a` decimal(240,20) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; --- --- Dumping data for table `t1` --- - /*!40000 ALTER TABLE `t1` DISABLE KEYS */; INSERT DELAYED IGNORE INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('0987654321098765432109876543210987654321.00000000000000000000'); diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 98ed45f98f6..b89b482a0f9 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -192,6 +192,6 @@ DROP TABLE t1; CREATE TABLE t1 (a decimal(240, 20)); INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), ("0987654321098765432109876543210987654321"); ---exec $MYSQL_DUMP --insert-ignore test t1 ---exec $MYSQL_DUMP --insert-ignore --delayed-insert test t1 +--exec $MYSQL_DUMP --insert-ignore --skip-comments test t1 +--exec $MYSQL_DUMP --insert-ignore --skip-comments --delayed-insert test t1 DROP TABLE t1;