summaryrefslogtreecommitdiff
path: root/sql/sql_udf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_udf.cc')
-rw-r--r--sql/sql_udf.cc56
1 files changed, 17 insertions, 39 deletions
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 3f8a4e346f9..69c5388f776 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -38,36 +38,10 @@
#ifdef HAVE_DLOPEN
extern "C"
{
-#if defined(__WIN__)
- void* dlsym(void* lib,const char* name)
- {
- return GetProcAddress((HMODULE)lib,name);
- }
- void* dlopen(const char* libname,int unused)
- {
- return LoadLibraryEx(libname,NULL,0);
- }
- void dlclose(void* lib)
- {
- FreeLibrary((HMODULE)lib);
- }
-
-#elif !defined(OS2)
-#include <dlfcn.h>
-#endif
-
#include <stdarg.h>
#include <hash.h>
}
-#ifndef RTLD_NOW
-#define RTLD_NOW 1 // For FreeBSD 2.2.2
-#endif
-
-#ifndef HAVE_DLERROR
-#define dlerror() ""
-#endif
-
static bool initialized = 0;
static MEM_ROOT mem;
static HASH udf_hash;
@@ -172,7 +146,7 @@ void udf_init()
if (simple_open_n_lock_tables(new_thd, &tables))
{
DBUG_PRINT("error",("Can't open udf table"));
- sql_print_error("Can't open the mysql.func table. Please run the mysql_install_db script to create it.");
+ sql_print_error("Can't open the mysql.func table. Please run the mysql_upgrade script to create it.");
goto end;
}
@@ -195,9 +169,8 @@ void udf_init()
This is done to ensure that only approved dll from the system
directories are used (to make this even remotely secure).
*/
- if (strchr(dl_name, '/') ||
- IF_WIN(strchr(dl_name, '\\'),0) ||
- strlen(name.str) > NAME_LEN)
+ if (my_strchr(files_charset_info, dl_name, dl_name + strlen(dl_name), FN_LIBCHAR) ||
+ strlen(name.str) > NAME_LEN)
{
sql_print_error("Invalid row in mysql.func table for function '%.64s'",
name.str);
@@ -215,10 +188,13 @@ void udf_init()
void *dl = find_udf_dl(tmp->dl);
if (dl == NULL)
{
- if (!(dl = dlopen(tmp->dl, RTLD_NOW)))
+ char dlpath[FN_REFLEN];
+ strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", tmp->dl,
+ NullS);
+ if (!(dl= dlopen(dlpath, RTLD_NOW)))
{
/* Print warning to log */
- sql_print_error(ER(ER_CANT_OPEN_LIBRARY), tmp->dl,errno,dlerror());
+ sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, dlerror());
/* Keep the udf in the hash so that we can remove it later */
continue;
}
@@ -420,7 +396,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
This is done to ensure that only approved dll from the system
directories are used (to make this even remotely secure).
*/
- if (strchr(udf->dl, '/') || IF_WIN(strchr(udf->dl, '\\'),0))
+ if (my_strchr(files_charset_info, udf->dl, udf->dl + strlen(udf->dl), FN_LIBCHAR))
{
my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
DBUG_RETURN(1);
@@ -439,12 +415,14 @@ int mysql_create_function(THD *thd,udf_func *udf)
}
if (!(dl = find_udf_dl(udf->dl)))
{
- if (!(dl = dlopen(udf->dl, RTLD_NOW)))
+ char dlpath[FN_REFLEN];
+ strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", udf->dl, NullS);
+ if (!(dl = dlopen(dlpath, RTLD_NOW)))
{
DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)",
- udf->dl,errno,dlerror()));
+ dlpath, errno, dlerror()));
my_error(ER_CANT_OPEN_LIBRARY, MYF(0),
- udf->dl, errno, dlerror());
+ dlpath, errno, dlerror());
goto err;
}
new_dl=1;
@@ -484,7 +462,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
table->field[2]->store(u_d->dl,(uint) strlen(u_d->dl), system_charset_info);
if (table->s->fields >= 4) // If not old func format
table->field[3]->store((longlong) u_d->type, TRUE);
- error = table->file->write_row(table->record[0]);
+ error = table->file->ha_write_row(table->record[0]);
close_thread_tables(thd);
if (error)
@@ -536,14 +514,14 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
if (!(table = open_ltable(thd,&tables,TL_WRITE)))
goto err;
table->field[0]->store(udf_name->str, udf_name->length, system_charset_info);
- table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
+ table->file->ha_retrieve_all_cols();
if (!table->file->index_read_idx(table->record[0], 0,
(byte*) table->field[0]->ptr,
table->key_info[0].key_length,
HA_READ_KEY_EXACT))
{
int error;
- if ((error = table->file->delete_row(table->record[0])))
+ if ((error = table->file->ha_delete_row(table->record[0])))
table->file->print_error(error, MYF(0));
}
close_thread_tables(thd);