diff options
author | unknown <msvensson@neptunus.(none)> | 2006-03-21 10:54:26 +0100 |
---|---|---|
committer | unknown <msvensson@neptunus.(none)> | 2006-03-21 10:54:26 +0100 |
commit | ae7974b112f668f749951a6e6825951e6a01ded8 (patch) | |
tree | 9ab08d577a0241130d460fe61c9e0550cf8bc163 | |
parent | b16a2fef983d21b0839bc74d2e5a079e872f2fe7 (diff) | |
download | mariadb-git-ae7974b112f668f749951a6e6825951e6a01ded8.tar.gz |
Bug#11835 CREATE FUNCTION crashes server
- Update for 5.1
- Add "have_dlopen"
- Remove requirement to load udf's only in "opt_plugin_dir"
include/my_global.h:
Remove duplicate defines
mysql-test/include/have_udf.inc:
Use "have_dlopen" to check if we "have udf"
mysql-test/r/have_udf.require:
Use "have_dlopen" to check if we "have udf"
mysql-test/r/udf.result:
Update for new error message "function"->"symbol"
sql/item_func.cc:
Remove "evil" dbug printour that checks args[0] even if arg_count is 0
sql/mysql_priv.h:
Add "have_dlopen"
sql/mysqld.cc:
Add "have_dlopen"
Move HAVE_DLOPEN defined to only surround "udf_free" and "udf_init"
sql/set_var.cc:
Add "have_dlopen"
sql/sql_plugin.cc:
Surround 'dlclose' with HAVE_DLOPEN
sql/sql_udf.cc:
Remove the requirement to load udf's only from "opt_plugin_dir".
Fix spelling error
-rw-r--r-- | include/my_global.h | 9 | ||||
-rw-r--r-- | mysql-test/include/have_udf.inc | 14 | ||||
-rw-r--r-- | mysql-test/r/have_udf.require | 3 | ||||
-rw-r--r-- | mysql-test/r/udf.result | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 3 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 13 | ||||
-rw-r--r-- | sql/set_var.cc | 2 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 2 | ||||
-rw-r--r-- | sql/sql_udf.cc | 18 |
10 files changed, 28 insertions, 40 deletions
diff --git a/include/my_global.h b/include/my_global.h index 56aeb84d9ba..1f53804affe 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1443,13 +1443,4 @@ do { doubleget_union _tmp; \ #define dlerror() "" #endif -/* FreeBSD 2.2.2 does not define RTLD_NOW) */ -#ifndef RTLD_NOW -#define RTLD_NOW 1 -#endif - -#ifndef HAVE_DLERROR -#define dlerror() "" -#endif - #endif /* my_global_h */ diff --git a/mysql-test/include/have_udf.inc b/mysql-test/include/have_udf.inc index a22b2a52e61..edb38d50487 100644 --- a/mysql-test/include/have_udf.inc +++ b/mysql-test/include/have_udf.inc @@ -1,12 +1,8 @@ # -# To check if the udf_example.so is available, -# try to load one function from it. -# +# Check if server has support for loading udf's +# i.e it will support dlopen # --require r/have_udf.require ---disable_abort_on_error -CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so'; ---disable_query_log -DROP FUNCTION metaphon; ---enable_query_log ---enable_abort_on_error +disable_query_log; +show variables like "have_dlopen"; +enable_query_log; diff --git a/mysql-test/r/have_udf.require b/mysql-test/r/have_udf.require index 869d1b254fd..6204435c17a 100644 --- a/mysql-test/r/have_udf.require +++ b/mysql-test/r/have_udf.require @@ -1 +1,2 @@ -CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so'; +Variable_name Value +have_dlopen YES diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index ce9271224dc..1b5f59c038a 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -2,7 +2,7 @@ drop table if exists t1; CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so'; CREATE FUNCTION myfunc_double RETURNS REAL SONAME 'udf_example.so'; CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME 'udf_example.so'; -ERROR HY000: Can't find function 'myfunc_nonexist' in library +ERROR HY000: Can't find symbol 'myfunc_nonexist' in library CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME 'udf_example.so'; CREATE FUNCTION sequence RETURNS INTEGER SONAME "udf_example.so"; CREATE FUNCTION lookup RETURNS STRING SONAME 'udf_example.so'; diff --git a/sql/item_func.cc b/sql/item_func.cc index 7937f4093f2..30b2c44c453 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2807,9 +2807,6 @@ longlong Item_func_udf_int::val_int() { DBUG_ASSERT(fixed == 1); DBUG_ENTER("Item_func_udf_int::val_int"); - DBUG_PRINT("info",("result_type: %d arg_count: %d", - args[0]->result_type(), arg_count)); - DBUG_RETURN(udf.val_int(&null_value)); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2eea891d51f..8f4943697a0 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1444,7 +1444,7 @@ extern handlerton myisammrg_hton; extern handlerton heap_hton; extern SHOW_COMP_OPTION have_row_based_replication; -extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink; +extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_dlopen; extern SHOW_COMP_OPTION have_query_cache; extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; extern SHOW_COMP_OPTION have_crypt; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 097ecff6169..3c2c912a61c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -564,7 +564,7 @@ CHARSET_INFO *national_charset_info, *table_alias_charset; CHARSET_INFO *character_set_filesystem; SHOW_COMP_OPTION have_row_based_replication; -SHOW_COMP_OPTION have_openssl, have_symlink, have_query_cache; +SHOW_COMP_OPTION have_openssl, have_symlink, have_dlopen, have_query_cache; SHOW_COMP_OPTION have_geometry, have_rtree_keys; SHOW_COMP_OPTION have_crypt, have_compress; @@ -1163,13 +1163,13 @@ void clean_up(bool print_message) set_var_free(); free_charsets(); (void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */ -#ifdef HAVE_DLOPEN if (!opt_noacl) { +#ifdef HAVE_DLOPEN udf_free(); - } #endif - plugin_free(); + plugin_free(); + } if (tc_log) tc_log->close(); xid_cache_free(); @@ -7078,6 +7078,11 @@ static void mysql_init_variables(void) #else have_symlink=SHOW_OPTION_YES; #endif +#ifdef HAVE_DLOPEN + have_dlopen=SHOW_OPTION_YES; +#else + have_dlopen=SHOW_OPTION_NO; +#endif #ifdef HAVE_QUERY_CACHE have_query_cache=SHOW_OPTION_YES; #else diff --git a/sql/set_var.cc b/sql/set_var.cc index 899bb8543df..213b52cc20c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -630,6 +630,7 @@ sys_var_have_variable sys_have_blackhole_db("have_blackhole_engine", sys_var_have_variable sys_have_compress("have_compress", &have_compress); sys_var_have_variable sys_have_crypt("have_crypt", &have_crypt); sys_var_have_variable sys_have_csv_db("have_csv", &have_csv_db); +sys_var_have_variable sys_have_dlopen("have_dlopen", &have_dlopen); sys_var_have_variable sys_have_example_db("have_example_engine", &have_example_db); sys_var_have_variable sys_have_federated_db("have_federated_engine", @@ -754,6 +755,7 @@ SHOW_VAR init_vars[]= { {sys_have_compress.name, (char*) &have_compress, SHOW_HAVE}, {sys_have_crypt.name, (char*) &have_crypt, SHOW_HAVE}, {sys_have_csv_db.name, (char*) &have_csv_db, SHOW_HAVE}, + {sys_have_dlopen.name, (char*) &have_dlopen, SHOW_HAVE}, {sys_have_example_db.name, (char*) &have_example_db, SHOW_HAVE}, {sys_have_federated_db.name,(char*) &have_federated_db, SHOW_HAVE}, {sys_have_geometry.name, (char*) &have_geometry, SHOW_HAVE}, diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index ad99d81d7b4..74852716f74 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -94,8 +94,10 @@ static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl) static inline void free_plugin_mem(struct st_plugin_dl *p) { +#ifdef HAVE_DLOPEN if (p->handle) dlclose(p->handle); +#endif my_free(p->dl.str, MYF(MY_ALLOW_ZERO_PTR)); if (p->version != MYSQL_PLUGIN_INTERFACE_VERSION) my_free((gptr)p->plugins, MYF(MY_ALLOW_ZERO_PTR)); diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 69c5388f776..495ffe9f5d5 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -114,7 +114,7 @@ void udf_init() READ_RECORD read_record_info; TABLE *table; int error; - DBUG_ENTER("ufd_init"); + DBUG_ENTER("udf_init"); if (initialized) DBUG_VOID_RETURN; @@ -177,7 +177,6 @@ void udf_init() continue; } - if (!(tmp= add_udf(&name,(Item_result) table->field[1]->val_int(), dl_name, udftype))) { @@ -188,13 +187,10 @@ void udf_init() void *dl = find_udf_dl(tmp->dl); if (dl == NULL) { - char dlpath[FN_REFLEN]; - strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", tmp->dl, - NullS); - if (!(dl= dlopen(dlpath, RTLD_NOW))) + if (!(dl= dlopen(tmp->dl, RTLD_NOW))) { /* Print warning to log */ - sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, dlerror()); + sql_print_error(ER(ER_CANT_OPEN_LIBRARY), tmp->dl, errno, dlerror()); /* Keep the udf in the hash so that we can remove it later */ continue; } @@ -415,14 +411,12 @@ int mysql_create_function(THD *thd,udf_func *udf) } if (!(dl = find_udf_dl(udf->dl))) { - char dlpath[FN_REFLEN]; - strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", udf->dl, NullS); - if (!(dl = dlopen(dlpath, RTLD_NOW))) + if (!(dl = dlopen(udf->dl, RTLD_NOW))) { DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)", - dlpath, errno, dlerror())); + udf->dl, errno, dlerror())); my_error(ER_CANT_OPEN_LIBRARY, MYF(0), - dlpath, errno, dlerror()); + udf->dl, errno, dlerror()); goto err; } new_dl=1; |