From 102a7a2a763dc5f2da8dd1f9ca9a53664c5aad6a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 26 Mar 2013 19:17:26 +0100 Subject: MDEV-4307 Support at least 48 utf8 characters in username in server and PAM Extend plugin auth api to support up to 512 bytes in the user names. Use the API versioning to support old auth plugins too! --- sql/sql_plugin.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index bf3537c0ed9..f540431b4e9 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -35,6 +35,8 @@ #include #include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT #include +#include "sql_plugin_compat.h" + #define REPORT_TO_LOG 1 #define REPORT_TO_USER 2 @@ -135,7 +137,7 @@ static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]= MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION, MYSQL_AUDIT_INTERFACE_VERSION, MYSQL_REPLICATION_INTERFACE_VERSION, - MYSQL_AUTHENTICATION_INTERFACE_VERSION + MIN_AUTHENTICATION_INTERFACE_VERSION }; static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]= { -- cgit v1.2.1 From daac5b511c7607cefed7579145d29c531e5257f3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2013 14:41:05 +0200 Subject: cleanup --- sql/sql_plugin.cc | 66 +++++++++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 41 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 07b93818bb7..059fc197d22 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -509,7 +509,6 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl, /* Determine interface version */ if (!sym) { - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_FIND_DL_ENTRY, plugin_interface_version_sym); DBUG_RETURN(TRUE); } @@ -519,7 +518,6 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl, if (plugin_dl->mysqlversion < min_plugin_interface_version || (plugin_dl->mysqlversion >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8)) { - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0, "plugin interface version mismatch"); DBUG_RETURN(TRUE); @@ -527,7 +525,6 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl, /* Find plugin declarations */ if (!(sym= dlsym(plugin_dl->handle, plugin_declarations_sym))) { - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_FIND_DL_ENTRY, plugin_declarations_sym); DBUG_RETURN(TRUE); } @@ -558,7 +555,6 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl, MYF(MY_ZEROFILL|MY_WME)); if (!cur) { - free_plugin_mem(plugin_dl); report_error(report, ER_OUTOFMEMORY, static_cast(plugin_dl->dl.length)); DBUG_RETURN(TRUE); @@ -633,7 +629,6 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl, Actually this branch impossible because in case of absence of maria version we try mysql version. */ - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_FIND_DL_ENTRY, maria_plugin_interface_version_sym); DBUG_RETURN(TRUE); @@ -644,7 +639,6 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl, if (plugin_dl->mariaversion < min_maria_plugin_interface_version || (plugin_dl->mariaversion >> 8) > (MARIA_PLUGIN_INTERFACE_VERSION >> 8)) { - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0, "plugin interface version mismatch"); DBUG_RETURN(TRUE); @@ -652,7 +646,6 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl, /* Find plugin declarations */ if (!(sym= dlsym(plugin_dl->handle, maria_plugin_declarations_sym))) { - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_FIND_DL_ENTRY, maria_plugin_declarations_sym); DBUG_RETURN(TRUE); } @@ -666,7 +659,6 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl, sizeof_st_plugin= *(int *)sym; else { - free_plugin_mem(plugin_dl); report_error(report, ER_CANT_FIND_DL_ENTRY, maria_sizeof_st_plugin_sym); DBUG_RETURN(TRUE); } @@ -684,7 +676,6 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl, MYF(MY_ZEROFILL|MY_WME)); if (!cur) { - free_plugin_mem(plugin_dl); report_error(report, ER_OUTOFMEMORY, static_cast(plugin_dl->dl.length)); DBUG_RETURN(TRUE); @@ -714,11 +705,12 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) #ifdef HAVE_DLOPEN char dlpath[FN_REFLEN]; uint plugin_dir_len, dummy_errors, dlpathlen, i; - struct st_plugin_dl *tmp, plugin_dl; + struct st_plugin_dl *tmp= 0, plugin_dl; void *sym; DBUG_ENTER("plugin_dl_add"); DBUG_PRINT("enter", ("dl->str: '%s', dl->length: %d", dl->str, (int) dl->length)); + mysql_mutex_assert_owner(&LOCK_plugin); plugin_dir_len= strlen(opt_plugin_dir); /* Ensure that the dll doesn't have a path. @@ -756,7 +748,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) if (*errmsg == ' ') errmsg++; } report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, errno, errmsg); - DBUG_RETURN(0); + goto ret; } /* Checks which plugin interface present and reads info */ @@ -767,12 +759,12 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) plugin_interface_version_sym), dlpath, report)) - DBUG_RETURN(0); + goto ret; } else { if (read_maria_plugin_info(&plugin_dl, sym, dlpath, report)) - DBUG_RETURN(0); + goto ret; } /* link the services in */ @@ -789,7 +781,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) "service '%s' interface version mismatch", list_of_services[i].name); report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, 0, buf); - DBUG_RETURN(0); + goto ret; } *(void**)sym= list_of_services[i].service; } @@ -799,10 +791,9 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1; if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0)))) { - free_plugin_mem(&plugin_dl); report_error(report, ER_OUTOFMEMORY, static_cast(plugin_dl.dl.length)); - DBUG_RETURN(0); + goto ret; } plugin_dl.dl.length= copy_and_convert(plugin_dl.dl.str, plugin_dl.dl.length, files_charset_info, dl->str, dl->length, system_charset_info, @@ -811,12 +802,17 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) /* Add this dll to array */ if (! (tmp= plugin_dl_insert_or_reuse(&plugin_dl))) { - free_plugin_mem(&plugin_dl); report_error(report, ER_OUTOFMEMORY, static_cast(sizeof(struct st_plugin_dl))); - DBUG_RETURN(0); + goto ret; } + +ret: + if (!tmp) + free_plugin_mem(&plugin_dl); + DBUG_RETURN(tmp); + #else DBUG_ENTER("plugin_dl_add"); report_error(report, ER_FEATURE_DISABLED, "plugin", "HAVE_DLOPEN"); @@ -825,34 +821,23 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) } -static void plugin_dl_del(const LEX_STRING *dl) +static void plugin_dl_del(struct st_plugin_dl *plugin_dl) { -#ifdef HAVE_DLOPEN - uint i; DBUG_ENTER("plugin_dl_del"); + if (!plugin_dl) + DBUG_VOID_RETURN; + mysql_mutex_assert_owner(&LOCK_plugin); - for (i= 0; i < plugin_dl_array.elements; i++) + /* Do not remove this element, unless no other plugin uses this dll. */ + if (! --plugin_dl->ref_count) { - struct st_plugin_dl *tmp= *dynamic_element(&plugin_dl_array, i, - struct st_plugin_dl **); - if (tmp->ref_count && - ! my_strnncoll(files_charset_info, - (const uchar *)dl->str, dl->length, - (const uchar *)tmp->dl.str, tmp->dl.length)) - { - /* Do not remove this element, unless no other plugin uses this dll. */ - if (! --tmp->ref_count) - { - free_plugin_mem(tmp); - bzero(tmp, sizeof(struct st_plugin_dl)); - } - break; - } + free_plugin_mem(plugin_dl); + bzero(plugin_dl, sizeof(struct st_plugin_dl)); } + DBUG_VOID_RETURN; -#endif } @@ -1133,7 +1118,7 @@ err: if (errs == 0 && oks == 0) // no plugin was found report_error(report, ER_CANT_FIND_DL_ENTRY, name->str); - plugin_dl_del(dl); + plugin_dl_del(tmp.plugin_dl); DBUG_RETURN(errs > 0 || oks == 0); } @@ -1210,8 +1195,7 @@ static void plugin_del(struct st_plugin_int *plugin) restore_pluginvar_names(plugin->system_vars); plugin_vars_free_values(plugin->system_vars); my_hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin); - if (plugin->plugin_dl) - plugin_dl_del(&plugin->plugin_dl->dl); + plugin_dl_del(plugin->plugin_dl); plugin->state= PLUGIN_IS_FREED; plugin_array_version++; free_root(&plugin->mem_root, MYF(0)); -- cgit v1.2.1 From 48bb551328b004e91578d3d9e34f3837a3852f1e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2013 14:50:01 +0200 Subject: remove the service for installing the closed-source mysql thread pool plugin --- sql/sql_plugin.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 059fc197d22..78e5b5b3833 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1516,8 +1516,8 @@ int plugin_init(int *argc, char **argv, int flags) } /* prepare debug_sync service */ - DBUG_ASSERT(strcmp(list_of_services[5].name, "debug_sync_service") == 0); - list_of_services[5].service= *(void**)&debug_sync_C_callback_ptr; + DBUG_ASSERT(strcmp(list_of_services[4].name, "debug_sync_service") == 0); + list_of_services[4].service= *(void**)&debug_sync_C_callback_ptr; mysql_mutex_lock(&LOCK_plugin); -- cgit v1.2.1 From 8b4d967798299399d4b81b1cd949080edbafdc5b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2013 15:26:58 +0200 Subject: bugfix: MYSQL_THDVAR_STR plugins with PLUGIN_VAR_MEMALLOC didn't work (PLUGIN_VAR_MEMALLOC ix 0x8000 and cannot be saved in a char as such) --- sql/sql_plugin.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 78e5b5b3833..4b631636db6 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -2354,8 +2354,14 @@ err: #undef MYSQL_SYSVAR_NAME #define MYSQL_SYSVAR_NAME(name) name -#define PLUGIN_VAR_TYPEMASK 0x007f -#define PLUGIN_VAR_BOOKMARK_KEY (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_MEMALLOC) +#define PLUGIN_VAR_TYPEMASK 0x7f +#define BOOKMARK_MEMALLOC 0x80 + +static inline char plugin_var_bookmark_key(uint flags) +{ + return (flags & PLUGIN_VAR_TYPEMASK) | + (flags & PLUGIN_VAR_MEMALLOC ? BOOKMARK_MEMALLOC : 0); +} #define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */ @@ -2709,7 +2715,7 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name, else memcpy(varname + 1, name, namelen + 1); - varname[0]= flags & PLUGIN_VAR_BOOKMARK_KEY; + varname[0]= plugin_var_bookmark_key(flags); result= (st_bookmark*) my_hash_search(&bookmark_hash, (const uchar*) varname, length - 1); @@ -2767,7 +2773,7 @@ static st_bookmark *register_var(const char *plugin, const char *name, { result= (st_bookmark*) alloc_root(&plugin_mem_root, sizeof(struct st_bookmark) + length-1); - varname[0]= flags & PLUGIN_VAR_BOOKMARK_KEY; + varname[0]= plugin_var_bookmark_key(flags); memcpy(result->key, varname, length); result->name_len= length - 2; result->offset= -1; @@ -2889,7 +2895,7 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) if (!(var= intern_find_sys_var(v->key + 1, v->name_len)) || !(pi= var->cast_pluginvar()) || - v->key[0] != (pi->plugin_var->flags & PLUGIN_VAR_BOOKMARK_KEY)) + v->key[0] != plugin_var_bookmark_key(pi->plugin_var->flags)) continue; /* Here we do anything special that may be required of the data types */ @@ -3021,7 +3027,7 @@ static void cleanup_variables(THD *thd, struct system_variables *vars) DBUG_ASSERT((uint)v->offset <= vars->dynamic_variables_head); if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && - v->key[0] & PLUGIN_VAR_MEMALLOC) + v->key[0] & BOOKMARK_MEMALLOC) { char **ptr= (char**)(vars->dynamic_variables_ptr + v->offset); my_free(*ptr); -- cgit v1.2.1 From 73f79ac83f827a1b5227482b2184afc188c707ae Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2013 15:37:47 +0200 Subject: simpler fix for mysql bug #56085, no need to write an error interceptor, when the function has a dedicated flag for this very use case. --- sql/sql_plugin.cc | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 4b631636db6..60474bbfd5b 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1707,9 +1707,6 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) int error; THD *new_thd= new THD; bool result; -#ifdef EMBEDDED_LIBRARY - No_such_table_error_handler error_handler; -#endif /* EMBEDDED_LIBRARY */ DBUG_ENTER("plugin_load"); new_thd->thread_stack= (char*) &tables; @@ -1718,22 +1715,13 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) new_thd->db_length= 5; bzero((char*) &new_thd->net, sizeof(new_thd->net)); tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_READ); - -#ifdef EMBEDDED_LIBRARY - /* - When building an embedded library, if the mysql.plugin table - does not exist, we silently ignore the missing table - */ - new_thd->push_internal_handler(&error_handler); -#endif /* EMBEDDED_LIBRARY */ + tables.open_strategy= TABLE_LIST:: IF_EMBEDDED(OPEN_IF_EXISTS, OPEN_NORMAL); result= open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT); -#ifdef EMBEDDED_LIBRARY - new_thd->pop_internal_handler(); - if (error_handler.safely_trapped_errors()) + table= tables.table; + if (IF_EMBEDDED(!table, false)) goto end; -#endif /* EMBEDDED_LIBRARY */ if (result) { @@ -1745,7 +1733,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) sql_print_warning("Could not open mysql.plugin table. Some options may be missing from the help text"); goto end; } - table= tables.table; + if (init_read_record(&read_record_info, new_thd, table, NULL, 1, 0, FALSE)) { sql_print_error("Could not initialize init_read_record; Plugins not " -- cgit v1.2.1 From 0d405ed02f264945426fab12d50b34976350db35 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2013 15:40:59 +0200 Subject: remove long time obsolete xyz_ci() copies of xyz() macros --- sql/sql_plugin.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 60474bbfd5b..0406f8190a8 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -310,8 +310,6 @@ static void plugin_vars_free_values(sys_var *vars); static void restore_pluginvar_names(sys_var *first); static void plugin_opt_set_limits(struct my_option *, const struct st_mysql_sys_var *); -#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B) -#define my_intern_plugin_lock_ci(A,B) intern_plugin_lock(A,B) static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin); static void intern_plugin_unlock(LEX *lex, plugin_ref plugin); static void reap_plugins(void); @@ -973,7 +971,7 @@ plugin_ref plugin_lock(THD *thd, plugin_ref ptr) #endif mysql_mutex_lock(&LOCK_plugin); plugin_ref_to_int(ptr)->locks_total++; - rc= my_intern_plugin_lock_ci(lex, ptr); + rc= intern_plugin_lock(lex, ptr); mysql_mutex_unlock(&LOCK_plugin); DBUG_RETURN(rc); } @@ -987,7 +985,7 @@ plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type) DBUG_ENTER("plugin_lock_by_name"); mysql_mutex_lock(&LOCK_plugin); if ((plugin= plugin_find_internal(name, type))) - rc= my_intern_plugin_lock_ci(lex, plugin_int_to_ref(plugin)); + rc= intern_plugin_lock(lex, plugin_int_to_ref(plugin)); mysql_mutex_unlock(&LOCK_plugin); DBUG_RETURN(rc); } @@ -1597,7 +1595,7 @@ int plugin_init(int *argc, char **argv, int flags) { DBUG_ASSERT(!global_system_variables.table_plugin); global_system_variables.table_plugin= - my_intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr)); + intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr)); DBUG_ASSERT(plugin_ptr->ref_count == 1); } } @@ -2652,7 +2650,7 @@ sys_var *find_sys_var(THD *thd, const char *str, uint length) { mysql_rwlock_unlock(&LOCK_system_variables_hash); LEX *lex= thd ? thd->lex : 0; - if (!(plugin= my_intern_plugin_lock(lex, plugin_int_to_ref(pi->plugin)))) + if (!(plugin= intern_plugin_lock(lex, plugin_int_to_ref(pi->plugin)))) var= NULL; /* failed to lock it, it must be uninstalling */ else if (!(plugin_state(plugin) & PLUGIN_IS_READY)) @@ -2976,7 +2974,7 @@ void plugin_thdvar_init(THD *thd) mysql_mutex_lock(&LOCK_plugin); thd->variables.table_plugin= - my_intern_plugin_lock(NULL, global_system_variables.table_plugin); + intern_plugin_lock(NULL, global_system_variables.table_plugin); intern_plugin_unlock(NULL, old_table_plugin); mysql_mutex_unlock(&LOCK_plugin); DBUG_VOID_RETURN; -- cgit v1.2.1 From a489ae89b9ffe427963745f13c44e1e4d67494f4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2013 15:47:25 +0200 Subject: fix mysql_rm_table_no_locks() not to use dd_frm_type, because the frm file may not exist (the table exists only in the engine). --- sql/sql_plugin.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 0406f8190a8..d6a64b38446 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -906,7 +906,8 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc) mysql_mutex_assert_owner(&LOCK_plugin); - if (pi->state & (PLUGIN_IS_READY | PLUGIN_IS_UNINITIALIZED)) + if (pi->state & (PLUGIN_IS_READY | PLUGIN_IS_UNINITIALIZED | + PLUGIN_IS_DELETED)) { plugin_ref plugin; #ifdef DBUG_OFF -- cgit v1.2.1 From 3ad01d00f2eaef56ed06041f7ac26328e998155b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2013 23:27:07 +0200 Subject: error messages: name the storage engine explicitly, instead of "used storage engine" and similar changes. --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index d6a64b38446..2f9bcf92f6d 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1764,7 +1764,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) mysql_mutex_unlock(&LOCK_plugin); } if (error > 0) - sql_print_error(ER(ER_GET_ERRNO), my_errno); + sql_print_error(ER(ER_GET_ERRNO), my_errno, table->file->table_type()); end_read_record(&read_record_info); table->m_needs_reopen= TRUE; // Force close to free memory close_mysql_tables(new_thd); -- cgit v1.2.1 From eda4c51241b647094b727643e1aad4153c45d647 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2013 23:27:14 +0200 Subject: cleanup --- sql/sql_plugin.cc | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2f9bcf92f6d..b19d6853164 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3387,17 +3387,6 @@ static void plugin_opt_set_limits(struct my_option *options, options->arg_type= OPT_ARG; } -extern "C" my_bool get_one_plugin_option(int optid, const struct my_option *, - char *); - -my_bool get_one_plugin_option(int optid __attribute__((unused)), - const struct my_option *opt, - char *argument) -{ - return 0; -} - - /** Creates a set of my_option objects associated with a specified plugin- handle. -- cgit v1.2.1 From 5f293dd694f9b1b4a0bdf73bb6ae80cda70f21d4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2013 23:27:24 +0200 Subject: MDEV-4022 table attributes with sysvar as a default value --- sql/sql_plugin.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index b19d6853164..6cf1050998b 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -308,8 +308,6 @@ static void unlock_variables(THD *thd, struct system_variables *vars); static void cleanup_variables(THD *thd, struct system_variables *vars); static void plugin_vars_free_values(sys_var *vars); static void restore_pluginvar_names(sys_var *first); -static void plugin_opt_set_limits(struct my_option *, - const struct st_mysql_sys_var *); static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin); static void intern_plugin_unlock(LEX *lex, plugin_ref plugin); static void reap_plugins(void); @@ -3286,8 +3284,8 @@ bool sys_var_pluginvar::global_update(THD *thd, set_var *var) options->block_size= (long) (opt)->blk_sz -static void plugin_opt_set_limits(struct my_option *options, - const struct st_mysql_sys_var *opt) +void plugin_opt_set_limits(struct my_option *options, + const struct st_mysql_sys_var *opt) { options->sub_size= 0; @@ -3866,3 +3864,18 @@ void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root) } } + +/** + Returns a sys_var corresponding to a particular MYSQL_SYSVAR(...) +*/ +sys_var *find_plugin_sysvar(st_plugin_int *plugin, st_mysql_sys_var *plugin_var) +{ + for (sys_var *var= plugin->system_vars; var; var= var->next) + { + sys_var_pluginvar *pvar=var->cast_pluginvar(); + if (pvar->plugin_var == plugin_var) + return var; + } + return 0; +} + -- cgit v1.2.1 From c7eead7a965b33fbad5099c927d2bb0723725bf3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2013 23:27:29 +0200 Subject: MDEV-3807 show plugins soname 'xxx' and INFORMATION_SCHEMA.ALL_PLUGINS table with condition pushdown for I_S.ALL_PLUGINS and a new status variable to cound successful dlopen's --- sql/sql_plugin.cc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 6cf1050998b..8d2379d7738 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -53,7 +53,6 @@ static TYPELIB global_plugin_typelib= { array_elements(global_plugin_typelib_names)-1, "", global_plugin_typelib_names, NULL }; - char *opt_plugin_load= NULL; char *opt_plugin_dir_ptr; char opt_plugin_dir[FN_REFLEN]; @@ -197,6 +196,8 @@ static bool reap_needed= false; static int plugin_array_version=0; static bool initialized= 0; +ulong dlopen_count; + /* write-lock on LOCK_system_variables_hash is required before modifying @@ -746,6 +747,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, errno, errmsg); goto ret; } + dlopen_count++; /* Checks which plugin interface present and reads info */ if (!(sym= dlsym(plugin_dl.handle, maria_plugin_interface_version_sym))) @@ -1485,6 +1487,8 @@ int plugin_init(int *argc, char **argv, int flags) if (initialized) DBUG_RETURN(0); + dlopen_count =0; + #ifdef HAVE_PSI_INTERFACE init_plugin_psi_keys(); #endif @@ -2333,6 +2337,74 @@ err: } +static bool plugin_dl_foreach_internal(THD *thd, st_plugin_dl *plugin_dl, + st_maria_plugin *plug, + plugin_foreach_func *func, void *arg) +{ + for (; plug->name; plug++) + { + st_plugin_int tmp, *plugin; + + tmp.name.str= const_cast(plug->name); + tmp.name.length= strlen(plug->name); + tmp.plugin= plug; + tmp.plugin_dl= plugin_dl; + + mysql_mutex_lock(&LOCK_plugin); + if ((plugin= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)) && + plugin->plugin == plug) + + { + tmp.state= plugin->state; + tmp.load_option= plugin->load_option; + } + else + { + tmp.state= PLUGIN_IS_FREED; + tmp.load_option= PLUGIN_OFF; + } + mysql_mutex_unlock(&LOCK_plugin); + + plugin= &tmp; + if (func(thd, plugin_int_to_ref(plugin), arg)) + return 1; + } + return 0; +} + +bool plugin_dl_foreach(THD *thd, const LEX_STRING *dl, + plugin_foreach_func *func, void *arg) +{ + bool err= 0; + + if (dl) + { + mysql_mutex_lock(&LOCK_plugin); + st_plugin_dl *plugin_dl= plugin_dl_add(dl, REPORT_TO_USER); + mysql_mutex_unlock(&LOCK_plugin); + + if (!plugin_dl) + return 1; + + err= plugin_dl_foreach_internal(thd, plugin_dl, plugin_dl->plugins, + func, arg); + + mysql_mutex_lock(&LOCK_plugin); + plugin_dl_del(plugin_dl); + mysql_mutex_unlock(&LOCK_plugin); + } + else + { + struct st_maria_plugin **builtins; + for (builtins= mysql_mandatory_plugins; !err && *builtins; builtins++) + err= plugin_dl_foreach_internal(thd, 0, *builtins, func, arg); + for (builtins= mysql_optional_plugins; !err && *builtins; builtins++) + err= plugin_dl_foreach_internal(thd, 0, *builtins, func, arg); + } + return err; +} + + /**************************************************************************** Internal type declarations for variables support ****************************************************************************/ -- cgit v1.2.1 From 775e82638b825747a2a8b7cf7d6d29c872693422 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2013 23:27:33 +0200 Subject: put status variables in the proper pluginname_ scope (but support the scopeless mysql style too). always output status/system variables in the correct lettercase --- sql/sql_plugin.cc | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 8d2379d7738..e04a6f7c1eb 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1133,22 +1133,21 @@ static void plugin_deinitialize(struct st_plugin_int *plugin, bool ref_check) if (plugin->plugin->status_vars) { -#ifdef FIX_LATER - /** - @todo - unfortunately, status variables were introduced without a - pluginname_ namespace, that is pluginname_ was not added automatically - to status variable names. It should be fixed together with the next - incompatible API change. + /* + historical ndb behavior caused MySQL plugins to specify + status var names in full, with the plugin name prefix. + this was never fixed in MySQL. + MariaDB fixes that but support MySQL style too. */ - SHOW_VAR array[2]= { + SHOW_VAR *show_vars= plugin->plugin->status_vars; + SHOW_VAR tmp_array[2]= { {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, {0, 0, SHOW_UNDEF} }; - remove_status_vars(array); -#else - remove_status_vars(plugin->plugin->status_vars); -#endif /* FIX_LATER */ + if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length)) + show_vars= tmp_array; + + remove_status_vars(show_vars); } if (plugin_type_deinitialize[plugin->plugin->type]) @@ -1358,24 +1357,22 @@ static int plugin_initialize(struct st_plugin_int *plugin) if (plugin->plugin->status_vars) { -#ifdef FIX_LATER /* - We have a problem right now where we can not prepend without - breaking backwards compatibility. We will fix this shortly so - that engines have "use names" and we wil use those for - CREATE TABLE, and use the plugin name then for adding automatic - variable names. + historical ndb behavior caused MySQL plugins to specify + status var names in full, with the plugin name prefix. + this was never fixed in MySQL. + MariaDB fixes that, but supports MySQL style too. */ - SHOW_VAR array[2]= { + SHOW_VAR *show_vars= plugin->plugin->status_vars; + SHOW_VAR tmp_array[2]= { {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, {0, 0, SHOW_UNDEF} }; - if (add_status_vars(array)) // add_status_vars makes a copy - goto err; -#else - if (add_status_vars(plugin->plugin->status_vars)) + if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length)) + show_vars= tmp_array; + + if (add_status_vars(show_vars)) goto err; -#endif /* FIX_LATER */ } /* -- cgit v1.2.1