summaryrefslogtreecommitdiff
path: root/sql/sql_plugin.cc
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-12-20 22:11:37 +0100
committerunknown <serg@janus.mylan>2007-12-20 22:11:37 +0100
commiteae52b1cfe579b32c9559db9cd01630013f89adf (patch)
tree8e1c37da4cf89e91d901badb1c2e5f100be39ec1 /sql/sql_plugin.cc
parentb6e564a0d442a3110192170616ef8170d4a40b29 (diff)
parent837d6d2dd92cd2f7f418413df7bb678acc33d39c (diff)
downloadmariadb-git-eae52b1cfe579b32c9559db9cd01630013f89adf.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into janus.mylan:/usr/home/serg/Abk/mysql-5.1 configure.in: Auto merged libmysql/CMakeLists.txt: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/information_schema.result: Auto merged mysql-test/t/information_schema.test: Auto merged sql/Makefile.am: Auto merged sql/field.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_geofunc.cc: Auto merged sql/item_subselect.cc: Auto merged sql/key.cc: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/net_serv.cc: Auto merged sql/opt_sum.cc: Auto merged sql/protocol.h: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/sp_head.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged storage/archive/ha_archive.cc: Auto merged storage/innobase/buf/buf0buf.c: Auto merged storage/innobase/buf/buf0flu.c: Auto merged storage/innobase/buf/buf0lru.c: Auto merged storage/innobase/include/buf0buf.h: Auto merged storage/innobase/include/buf0buf.ic: Auto merged storage/innobase/include/sync0arr.h: Auto merged storage/innobase/include/sync0rw.h: Auto merged storage/innobase/include/sync0rw.ic: Auto merged storage/innobase/include/sync0sync.h: Auto merged storage/innobase/os/os0sync.c: Auto merged storage/innobase/sync/sync0arr.c: Auto merged storage/innobase/sync/sync0rw.c: Auto merged storage/innobase/sync/sync0sync.c: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/mi_open.c: Auto merged storage/myisammrg/ha_myisammrg.cc: Auto merged sql/ha_ndbcluster.cc: merged sql/item_cmpfunc.cc: merged sql/protocol.cc: merged sql/slave.cc: merged sql/sql_class.h: merged sql/sql_parse.cc: merged
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r--sql/sql_plugin.cc66
1 files changed, 60 insertions, 6 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index ef4c63381e2..2a86844c8c6 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -181,6 +181,7 @@ public:
TYPELIB* plugin_var_typelib(void);
uchar* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
bool check(THD *thd, set_var *var);
+ bool check_default(enum_var_type type) { return is_readonly(); }
void set_default(THD *thd, enum_var_type type);
bool update(THD *thd, set_var *var);
};
@@ -1875,11 +1876,26 @@ err:
static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
void *save, st_mysql_value *value)
{
+ bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
plugin_opt_set_limits(&options, var);
- *(int *)save= (int) getopt_ull_limit_value(tmp, &options);
+
+ if (var->flags & PLUGIN_VAR_UNSIGNED)
+ *(uint *)save= (uint) getopt_ull_limit_value((ulonglong) tmp, &options,
+ &fixed);
+ else
+ *(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed);
+
+ if (fixed)
+ {
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), var->name,
+ ullstr(tmp, buf));
+ }
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
(*(int *)save != (int) tmp);
}
@@ -1888,24 +1904,55 @@ static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
void *save, st_mysql_value *value)
{
+ bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
plugin_opt_set_limits(&options, var);
- *(long *)save= (long) getopt_ull_limit_value(tmp, &options);
+
+ if (var->flags & PLUGIN_VAR_UNSIGNED)
+ *(ulong *)save= (ulong) getopt_ull_limit_value((ulonglong) tmp, &options,
+ &fixed);
+ else
+ *(long *)save= (long) getopt_ll_limit_value(tmp, &options, &fixed);
+
+ if (fixed)
+ {
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), var->name,
+ ullstr(tmp, buf));
+ }
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
(*(long *)save != (long) tmp);
}
static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,
- void *save, st_mysql_value *value)
+ void *save, st_mysql_value *value)
{
+ bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
plugin_opt_set_limits(&options, var);
- *(ulonglong *)save= getopt_ull_limit_value(tmp, &options);
+ *(ulonglong *)save= getopt_ull_limit_value(tmp, &options, &fixed);
+
+ if (var->flags & PLUGIN_VAR_UNSIGNED)
+ *(ulonglong *)save= getopt_ull_limit_value((ulonglong) tmp, &options,
+ &fixed);
+ else
+ *(longlong *)save= getopt_ll_limit_value(tmp, &options, &fixed);
+
+ if (fixed)
+ {
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), var->name,
+ ullstr(tmp, buf));
+ }
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
(*(long long *)save != tmp);
}
@@ -2169,9 +2216,11 @@ static st_bookmark *register_var(const char *plugin, const char *name,
size= sizeof(int);
break;
case PLUGIN_VAR_LONG:
+ case PLUGIN_VAR_ENUM:
size= sizeof(long);
break;
case PLUGIN_VAR_LONGLONG:
+ case PLUGIN_VAR_SET:
size= sizeof(ulonglong);
break;
case PLUGIN_VAR_STR:
@@ -2612,6 +2661,7 @@ void sys_var_pluginvar::set_default(THD *thd, enum_var_type type)
if (is_readonly())
return;
+ pthread_mutex_lock(&LOCK_global_system_variables);
tgt= real_value_ptr(thd, type);
src= ((void **) (plugin_var + 1) + 1);
@@ -2628,12 +2678,14 @@ void sys_var_pluginvar::set_default(THD *thd, enum_var_type type)
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_plugin);
plugin_var->update(thd, plugin_var, tgt, src);
- pthread_mutex_unlock(&LOCK_plugin);
+ pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
+ {
+ pthread_mutex_unlock(&LOCK_global_system_variables);
plugin_var->update(thd, plugin_var, tgt, src);
+ }
}
@@ -2679,6 +2731,8 @@ bool sys_var_pluginvar::update(THD *thd, set_var *var)
static void plugin_opt_set_limits(struct my_option *options,
const struct st_mysql_sys_var *opt)
{
+ options->sub_size= 0;
+
switch (opt->flags & (PLUGIN_VAR_TYPEMASK |
PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL)) {
/* global system variables */