summaryrefslogtreecommitdiff
path: root/sql/sql_plugin.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r--sql/sql_plugin.cc97
1 files changed, 49 insertions, 48 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 5f8513a4a9e..37301751d03 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -177,9 +177,9 @@ public:
{ return !(plugin_var->flags & PLUGIN_VAR_THDLOCAL) && type != OPT_GLOBAL; }
bool check_update_type(Item_result type);
SHOW_TYPE show_type();
- byte* real_value_ptr(THD *thd, enum_var_type type);
+ uchar* real_value_ptr(THD *thd, enum_var_type type);
TYPELIB* plugin_var_typelib(void);
- byte* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+ uchar* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
bool check(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
bool update(THD *thd, set_var *var);
@@ -303,7 +303,7 @@ static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl)
DBUG_RETURN(tmp);
}
}
- if (insert_dynamic(&plugin_dl_array, (gptr)plugin_dl))
+ if (insert_dynamic(&plugin_dl_array, (uchar*)plugin_dl))
DBUG_RETURN(0);
DBUG_RETURN(dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1,
struct st_plugin_dl *));
@@ -319,7 +319,7 @@ static inline void free_plugin_mem(struct st_plugin_dl *p)
#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));
+ my_free((uchar*)p->plugins, MYF(MY_ALLOW_ZERO_PTR));
}
@@ -471,7 +471,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
/* Duplicate and convert dll name */
plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1;
- if (! (plugin_dl.dl.str= my_malloc(plugin_dl.dl.length, MYF(0))))
+ if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0))))
{
free_plugin_mem(&plugin_dl);
if (report & REPORT_TO_USER)
@@ -551,14 +551,14 @@ static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int ty
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
{
struct st_plugin_int *plugin= (st_plugin_int *)
- hash_search(&plugin_hash[i], (const byte *)name->str, name->length);
+ hash_search(&plugin_hash[i], (const uchar *)name->str, name->length);
if (plugin)
DBUG_RETURN(plugin);
}
}
else
DBUG_RETURN((st_plugin_int *)
- hash_search(&plugin_hash[type], (const byte *)name->str, name->length));
+ hash_search(&plugin_hash[type], (const uchar *)name->str, name->length));
DBUG_RETURN(0);
}
@@ -628,7 +628,7 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO)
(long) current_thd, pi->name.str, pi->ref_count));
if (lex)
- insert_dynamic(&lex->plugins, (gptr)&plugin);
+ insert_dynamic(&lex->plugins, (uchar*)&plugin);
DBUG_RETURN(plugin);
}
DBUG_RETURN(NULL);
@@ -676,7 +676,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
DBUG_RETURN(tmp);
}
}
- if (insert_dynamic(&plugin_array, (gptr)plugin))
+ if (insert_dynamic(&plugin_array, (uchar*)plugin))
DBUG_RETURN(0);
DBUG_RETURN(dynamic_element(&plugin_array, plugin_array.elements - 1,
struct st_plugin_int *));
@@ -737,13 +737,12 @@ static bool plugin_add(MEM_ROOT *tmp_root,
tmp.name.length= name_len;
tmp.ref_count= 0;
tmp.state= PLUGIN_IS_UNINITIALIZED;
-
if (!test_plugin_options(tmp_root, &tmp, argc, argv, true))
{
if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))
{
plugin_array_version++;
- if (!my_hash_insert(&plugin_hash[plugin->type], (byte*)tmp_plugin_ptr))
+ if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
{
init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096);
DBUG_RETURN(FALSE);
@@ -832,7 +831,7 @@ static void plugin_del(struct st_plugin_int *plugin)
safe_mutex_assert_owner(&LOCK_plugin);
/* Free allocated strings before deleting the plugin. */
plugin_vars_free_values(plugin->system_vars);
- hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin);
+ hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin);
if (plugin->plugin_dl)
plugin_dl_del(&plugin->plugin_dl->dl);
plugin->state= PLUGIN_IS_FREED;
@@ -914,7 +913,7 @@ static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
if (!pi->plugin_dl)
DBUG_VOID_RETURN;
#else
- my_free((gptr) plugin, MYF(MY_WME));
+ my_free((uchar*) plugin, MYF(MY_WME));
#endif
DBUG_PRINT("info",("unlocking plugin, name= %s, ref_count= %d",
@@ -1048,21 +1047,21 @@ err:
}
-static byte *get_hash_key(const byte *buff, uint *length,
+static uchar *get_hash_key(const uchar *buff, size_t *length,
my_bool not_used __attribute__((unused)))
{
struct st_plugin_int *plugin= (st_plugin_int *)buff;
*length= (uint)plugin->name.length;
- return((byte *)plugin->name.str);
+ return((uchar *)plugin->name.str);
}
-static byte *get_bookmark_hash_key(const byte *buff, uint *length,
+static uchar *get_bookmark_hash_key(const uchar *buff, size_t *length,
my_bool not_used __attribute__((unused)))
{
struct st_bookmark *var= (st_bookmark *)buff;
*length= var->name_len + 1;
- return (byte*) var->key;
+ return (uchar*) var->key;
}
@@ -1179,6 +1178,7 @@ int plugin_init(int *argc, char **argv, int flags)
/*
Now we initialize all remaining plugins
*/
+
pthread_mutex_lock(&LOCK_plugin);
reap= (st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*));
*(reap++)= NULL;
@@ -1212,6 +1212,7 @@ int plugin_init(int *argc, char **argv, int flags)
end:
free_root(&tmp_root, MYF(0));
+
DBUG_RETURN(0);
err_unlock:
@@ -1232,13 +1233,13 @@ static bool register_builtin(struct st_mysql_plugin *plugin,
tmp->ref_count= 0;
tmp->plugin_dl= 0;
- if (insert_dynamic(&plugin_array, (gptr)tmp))
+ if (insert_dynamic(&plugin_array, (uchar*)tmp))
DBUG_RETURN(1);
*ptr= dynamic_element(&plugin_array, plugin_array.elements - 1,
struct st_plugin_int *);
- if (my_hash_insert(&plugin_hash[plugin->type],(byte*) *ptr))
+ if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr))
DBUG_RETURN(1);
DBUG_RETURN(0);
@@ -1310,7 +1311,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
new_thd->store_globals();
new_thd->db= my_strdup("mysql", MYF(0));
new_thd->db_length= 5;
- bzero((gptr)&tables, sizeof(tables));
+ bzero((uchar*)&tables, sizeof(tables));
tables.alias= tables.table_name= (char*)"plugin";
tables.lock_type= TL_READ;
tables.db= new_thd->db;
@@ -1672,7 +1673,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
table->use_all_columns();
table->field[0]->store(name->str, name->length, system_charset_info);
if (! table->file->index_read_idx(table->record[0], 0,
- (byte *)table->field[0]->ptr, HA_WHOLE_KEY,
+ (uchar *)table->field[0]->ptr, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))
{
int error;
@@ -1789,7 +1790,7 @@ typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulonglong_t, ulonglong);
#define SET_PLUGIN_VAR_RESOLVE(opt)\
*(mysql_sys_var_ptr_p*)&((opt)->resolve)= mysql_sys_var_ptr
-typedef byte *(*mysql_sys_var_ptr_p)(void* a_thd, int offset);
+typedef uchar *(*mysql_sys_var_ptr_p)(void* a_thd, int offset);
/****************************************************************************
@@ -2102,7 +2103,7 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name,
varname[0]= flags & PLUGIN_VAR_TYPEMASK;
result= (st_bookmark*) hash_search(&bookmark_hash,
- (const byte*) varname, length - 1);
+ (const uchar*) varname, length - 1);
my_afree(varname);
return result;
@@ -2170,10 +2171,10 @@ static st_bookmark *register_var(const char *plugin, const char *name,
if (new_size > global_variables_dynamic_size)
{
- global_system_variables.dynamic_variables_ptr=
+ global_system_variables.dynamic_variables_ptr= (char*)
my_realloc(global_system_variables.dynamic_variables_ptr, new_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
- max_system_variables.dynamic_variables_ptr=
+ max_system_variables.dynamic_variables_ptr= (char*)
my_realloc(max_system_variables.dynamic_variables_ptr, new_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
/*
@@ -2200,7 +2201,7 @@ static st_bookmark *register_var(const char *plugin, const char *name,
result->version= global_system_variables.dynamic_variables_version;
/* this should succeed because we have already checked if a dup exists */
- if (my_hash_insert(&bookmark_hash, (byte*) result))
+ if (my_hash_insert(&bookmark_hash, (uchar*) result))
{
fprintf(stderr, "failed to add placeholder to hash");
DBUG_ASSERT(0);
@@ -2217,13 +2218,13 @@ static st_bookmark *register_var(const char *plugin, const char *name,
If required, will sync with global variables if the requested variable
has not yet been allocated in the current thread.
*/
-static byte *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
+static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
{
DBUG_ASSERT(offset >= 0);
DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head);
if (!thd)
- return (byte*) global_system_variables.dynamic_variables_ptr + offset;
+ return (uchar*) global_system_variables.dynamic_variables_ptr + offset;
/*
dynamic_variables_head points to the largest valid offset
@@ -2235,7 +2236,7 @@ static byte *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
rw_rdlock(&LOCK_system_variables_hash);
- thd->variables.dynamic_variables_ptr=
+ thd->variables.dynamic_variables_ptr= (char*)
my_realloc(thd->variables.dynamic_variables_ptr,
global_variables_dynamic_size,
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
@@ -2293,10 +2294,10 @@ static byte *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
rw_unlock(&LOCK_system_variables_hash);
}
- return (byte*)thd->variables.dynamic_variables_ptr + offset;
+ return (uchar*)thd->variables.dynamic_variables_ptr + offset;
}
-static byte *mysql_sys_var_ptr(void* a_thd, int offset)
+static uchar *mysql_sys_var_ptr(void* a_thd, int offset)
{
return intern_sys_var_ptr((THD *)a_thd, offset, true);
}
@@ -2397,7 +2398,7 @@ void plugin_thdvar_cleanup(THD *thd)
{
list= ((plugin_ref*) thd->lex->plugins.buffer) + idx - 1;
DBUG_PRINT("info",("unlocking %d plugins", idx));
- while ((char*) list >= thd->lex->plugins.buffer)
+ while ((uchar*) list >= thd->lex->plugins.buffer)
intern_plugin_unlock(NULL, *list--);
}
@@ -2484,7 +2485,7 @@ SHOW_TYPE sys_var_pluginvar::show_type()
}
-byte* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
+uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
{
DBUG_ASSERT(thd || (type == OPT_GLOBAL));
if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
@@ -2494,7 +2495,7 @@ byte* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
return intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false);
}
- return *(byte**) (plugin_var+1);
+ return *(uchar**) (plugin_var+1);
}
@@ -2516,15 +2517,15 @@ TYPELIB* sys_var_pluginvar::plugin_var_typelib(void)
}
-byte* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
+uchar* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
- byte* result;
+ uchar* result;
result= real_value_ptr(thd, type);
if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_ENUM)
- result= (byte*) get_type(plugin_var_typelib(), *(ulong*)result);
+ result= (uchar*) get_type(plugin_var_typelib(), *(ulong*)result);
else if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_SET)
{
char buffer[STRING_BUFFER_USUAL_SIZE];
@@ -2542,9 +2543,9 @@ byte* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
str.append(',');
}
- result= (byte*) "";
+ result= (uchar*) "";
if (str.length())
- result= (byte*) thd->strmake(str.ptr(), str.length()-1);
+ result= (uchar*) thd->strmake(str.ptr(), str.length()-1);
}
return result;
}
@@ -2799,7 +2800,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
options[0].arg_type= options[1].arg_type= NO_ARG;
options[0].def_value= options[1].def_value= **enabled;
options[0].value= options[0].u_max_value=
- options[1].value= options[1].u_max_value= (gptr*) (name - 1);
+ options[1].value= options[1].u_max_value= (uchar**) (name - 1);
options+= 2;
/*
@@ -2878,9 +2879,9 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
if (!opt->update)
{
opt->update= update_func_str;
- if (!(opt->flags & PLUGIN_VAR_MEMALLOC))
+ if (!(opt->flags & PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY))
{
- opt->flags |= PLUGIN_VAR_READONLY;
+ opt->flags|= PLUGIN_VAR_READONLY;
sql_print_warning("Server variable %s of plugin %s was forced "
"to be read-only: string variable without "
"update_func and PLUGIN_VAR_MEMALLOC flag",
@@ -2924,7 +2925,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
optnamelen= namelen + optnamelen + 1;
}
else
- optname= memdup_root(mem_root, v->key + 1, (optnamelen= v->name_len) + 1);
+ optname= (char*) memdup_root(mem_root, v->key + 1, (optnamelen= v->name_len) + 1);
/* convert '_' to '-' */
for (p= optname; *p; p++)
@@ -2945,10 +2946,10 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
(opt->flags & PLUGIN_VAR_TYPEMASK) != PLUGIN_VAR_SET)
{
if (opt->flags & PLUGIN_VAR_THDLOCAL)
- options->value= options->u_max_value= (gptr*)
+ options->value= options->u_max_value= (uchar**)
(global_system_variables.dynamic_variables_ptr + offset);
else
- options->value= options->u_max_value= *(gptr**) (opt + 1);
+ options->value= options->u_max_value= *(uchar***) (opt + 1);
}
options[1]= options[0];
@@ -3148,16 +3149,16 @@ void my_print_help_inc_plugins(my_option *main_options, uint size)
/* Only options with a non-NULL comment are displayed in help text */
for (;opt->id; opt++)
if (opt->comment)
- insert_dynamic(&all_options, (gptr) opt);
+ insert_dynamic(&all_options, (uchar*) opt);
}
for (;main_options->id; main_options++)
- insert_dynamic(&all_options, (gptr) main_options);
+ insert_dynamic(&all_options, (uchar*) main_options);
sort_dynamic(&all_options, (qsort_cmp) option_cmp);
/* main_options now points to the empty option terminator */
- insert_dynamic(&all_options, (gptr) main_options);
+ insert_dynamic(&all_options, (uchar*) main_options);
my_print_help((my_option*) all_options.buffer);
my_print_variables((my_option*) all_options.buffer);