diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-06-17 17:31:51 +0400 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-06-17 17:31:51 +0400 |
commit | 484351d108b923038421b003f39770d3c96aeae0 (patch) | |
tree | 9413ba739bc0dbf1e647293756a3503f17dcde07 /sql/sql_plugin.cc | |
parent | db0ee68b38a3506e6d6e74a976f2e2b9a6fb1772 (diff) | |
parent | 71377f189fd9d6ac59d66773168cfd2bd75a052a (diff) | |
download | mariadb-git-484351d108b923038421b003f39770d3c96aeae0.tar.gz |
Merge trunk-bugfixing -> trunk-runtime
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r-- | sql/sql_plugin.cc | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index bd6ff3a951d..97c480ea0bd 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1994,10 +1994,6 @@ typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_uint_t, uint); typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulong_t, ulong); 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 uchar *(*mysql_sys_var_ptr_p)(void* a_thd, int offset); - /**************************************************************************** default variable data check and update functions @@ -2532,11 +2528,49 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) return (uchar*)thd->variables.dynamic_variables_ptr + offset; } -static uchar *mysql_sys_var_ptr(void* a_thd, int offset) + +/** + For correctness and simplicity's sake, a pointer to a function + must be compatible with pointed-to type, that is, the return and + parameters types must be the same. Thus, a callback function is + defined for each scalar type. The functions are assigned in + construct_options to their respective types. +*/ + +static char *mysql_sys_var_char(THD* thd, int offset) +{ + return (char *) intern_sys_var_ptr(thd, offset, true); +} + +static int *mysql_sys_var_int(THD* thd, int offset) +{ + return (int *) intern_sys_var_ptr(thd, offset, true); +} + +static long *mysql_sys_var_long(THD* thd, int offset) { - return intern_sys_var_ptr((THD *)a_thd, offset, true); + return (long *) intern_sys_var_ptr(thd, offset, true); } +static unsigned long *mysql_sys_var_ulong(THD* thd, int offset) +{ + return (unsigned long *) intern_sys_var_ptr(thd, offset, true); +} + +static long long *mysql_sys_var_longlong(THD* thd, int offset) +{ + return (long long *) intern_sys_var_ptr(thd, offset, true); +} + +static unsigned long long *mysql_sys_var_ulonglong(THD* thd, int offset) +{ + return (unsigned long long *) intern_sys_var_ptr(thd, offset, true); +} + +static char **mysql_sys_var_str(THD* thd, int offset) +{ + return (char **) intern_sys_var_ptr(thd, offset, true); +} void plugin_thdvar_init(THD *thd) { @@ -3081,25 +3115,25 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, continue; switch (opt->flags & PLUGIN_VAR_TYPEMASK) { case PLUGIN_VAR_BOOL: - SET_PLUGIN_VAR_RESOLVE((thdvar_bool_t *) opt); + ((thdvar_bool_t *) opt)->resolve= mysql_sys_var_char; break; case PLUGIN_VAR_INT: - SET_PLUGIN_VAR_RESOLVE((thdvar_int_t *) opt); + ((thdvar_int_t *) opt)->resolve= mysql_sys_var_int; break; case PLUGIN_VAR_LONG: - SET_PLUGIN_VAR_RESOLVE((thdvar_long_t *) opt); + ((thdvar_long_t *) opt)->resolve= mysql_sys_var_long; break; case PLUGIN_VAR_LONGLONG: - SET_PLUGIN_VAR_RESOLVE((thdvar_longlong_t *) opt); + ((thdvar_longlong_t *) opt)->resolve= mysql_sys_var_longlong; break; case PLUGIN_VAR_STR: - SET_PLUGIN_VAR_RESOLVE((thdvar_str_t *) opt); + ((thdvar_str_t *) opt)->resolve= mysql_sys_var_str; break; case PLUGIN_VAR_ENUM: - SET_PLUGIN_VAR_RESOLVE((thdvar_enum_t *) opt); + ((thdvar_enum_t *) opt)->resolve= mysql_sys_var_ulong; break; case PLUGIN_VAR_SET: - SET_PLUGIN_VAR_RESOLVE((thdvar_set_t *) opt); + ((thdvar_set_t *) opt)->resolve= mysql_sys_var_ulonglong; break; default: sql_print_error("Unknown variable type code 0x%x in plugin '%s'.", |