diff options
author | dlenev@mysql.com <> | 2005-05-09 17:01:23 +0400 |
---|---|---|
committer | dlenev@mysql.com <> | 2005-05-09 17:01:23 +0400 |
commit | feb8a43c4d1ef577402d37939893c35b269213cf (patch) | |
tree | bb82405378321f4a4994e10cd0ff587ebd060a1e /sql | |
parent | 8d12a8b124292a9d48b4caea5cbf362ed9980a94 (diff) | |
parent | e7f29e190426d938ae459eb3251127304c872602 (diff) | |
download | mariadb-git-feb8a43c4d1ef577402d37939893c35b269213cf.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/dlenev/src/mysql-5.0-merges
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 46 | ||||
-rw-r--r-- | sql/item_func.h | 1 | ||||
-rw-r--r-- | sql/item_sum.cc | 11 | ||||
-rw-r--r-- | sql/item_sum.h | 1 | ||||
-rw-r--r-- | sql/sql_udf.h | 1 |
5 files changed, 45 insertions, 15 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 283d7463293..3c87b6ef920 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2533,6 +2533,28 @@ longlong Item_func_bit_count::val_int() #ifdef HAVE_DLOPEN +void udf_handler::cleanup() +{ + if (!not_original) + { + if (initialized) + { + if (u_d->func_deinit != NULL) + { + void (*deinit)(UDF_INIT *) = (void (*)(UDF_INIT*)) + u_d->func_deinit; + (*deinit)(&initid); + } + free_udf(u_d); + initialized= FALSE; + } + if (buffers) // Because of bug in ecc + delete [] buffers; + buffers= 0; + } +} + + bool udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, uint arg_count, Item **arguments) @@ -2805,6 +2827,13 @@ my_decimal *udf_handler::val_decimal(my_bool *null_value, my_decimal *dec_buf) } +void Item_udf_func::cleanup() +{ + udf.cleanup(); + Item_func::cleanup(); +} + + double Item_func_udf_float::val_real() { DBUG_ASSERT(fixed == 1); @@ -2930,21 +2959,8 @@ String *Item_func_udf_str::val_str(String *str) udf_handler::~udf_handler() { - if (!not_original) - { - if (initialized) - { - if (u_d->func_deinit != NULL) - { - void (*deinit)(UDF_INIT *) = (void (*)(UDF_INIT*)) - u_d->func_deinit; - (*deinit)(&initid); - } - free_udf(u_d); - } - if (buffers) // Because of bug in ecc - delete [] buffers; - } + /* Everything should be properly cleaned up by this moment. */ + DBUG_ASSERT(not_original || !(initialized || buffers)); } #else diff --git a/sql/item_func.h b/sql/item_func.h index cdc03a166c5..b53f2a0b9c6 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -879,6 +879,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 76bf8189a0e..a5694189976 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2456,6 +2456,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 b263cbfa0a7..bb5d31b4b4f 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -667,6 +667,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 2a7c06e1891..4df3fe0949d 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()) |