From 10543a4a2eb68ecb618936b57d62c6ca1f7eb6bb Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 16 Jan 2012 12:04:28 +0200 Subject: Bug #11754014: 45549: udf plugin_dir path separator inconsistency and cryptic error 1126 message The problem was that dlopen() related code was using just a subset of the path normalization routines used in other places. Fixed the expansion of the pre-dlopen() behavior for plugins and UDFs to use a platform-dependent consistent encoding of the paths. Fixed the error dlopen() error handling to take the correct error message and strip off the trailing newline character(s). Fixed tests to do a platform independent replace of directories and to account for the traling slash. --- sql/sql_udf.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'sql/sql_udf.cc') diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index bf2de4b39bb..44595ace453 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -221,10 +221,15 @@ void udf_init() char dlpath[FN_REFLEN]; strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", tmp->dl, NullS); + (void) unpack_filename(dlpath, dlpath); if (!(dl= dlopen(dlpath, RTLD_NOW))) { + const char *errmsg; + int error_number= dlopen_errno; + DLERROR_GENERATE(errmsg, error_number); + /* Print warning to log */ - sql_print_error(ER(ER_CANT_OPEN_LIBRARY), tmp->dl, errno, dlerror()); + sql_print_error(ER(ER_CANT_OPEN_LIBRARY), tmp->dl, error_number, errmsg); /* Keep the udf in the hash so that we can remove it later */ continue; } @@ -469,12 +474,18 @@ int mysql_create_function(THD *thd,udf_func *udf) { char dlpath[FN_REFLEN]; strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", udf->dl, NullS); + (void) unpack_filename(dlpath, dlpath); + if (!(dl = dlopen(dlpath, RTLD_NOW))) { + const char *errmsg; + int error_number= dlopen_errno; + DLERROR_GENERATE(errmsg, error_number); + DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)", - udf->dl, errno, dlerror())); + udf->dl, error_number, errmsg)); my_error(ER_CANT_OPEN_LIBRARY, MYF(0), - udf->dl, errno, dlerror()); + udf->dl, error_number, errmsg); goto err; } new_dl=1; -- cgit v1.2.1