summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc103
1 files changed, 44 insertions, 59 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index ee0e870cd93..2d199366d5a 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1,4 +1,5 @@
-/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2002, 2010, Oracle and/or its affiliates.
+ 2009-2010 Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1507,44 +1508,6 @@ bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
/**
- check an unsigned user-supplied value for a systemvariable against bounds.
-
- TODO: This is a wrapper function to call clipping from within an update()
- function. Calling bounds from within update() is fair game in theory,
- but we can only send warnings from in there, not errors, and besides,
- it violates our model of separating check from update phase.
- To avoid breaking out of the server with an ASSERT() in strict mode,
- we pretend we're not in strict mode when we go through here. Bug#43233
- was opened to remind us to replace this kludge with The Right Thing,
- which of course is to do the check in the actual check phase, and then
- throw an error or warning accordingly.
-
- @param thd thread handle
- @param num the value to limit
- @param option_limits the bounds-record, or NULL if none
- */
-static void bound_unsigned(THD *thd, ulonglong *num,
- const struct my_option *option_limits)
-{
- if (option_limits)
- {
- my_bool fixed = FALSE;
- ulonglong unadjusted= *num;
-
- *num= getopt_ull_limit_value(unadjusted, option_limits, &fixed);
-
- if (fixed)
- {
- ulong ssm= thd->variables.sql_mode;
- thd->variables.sql_mode&= ~MODE_STRICT_ALL_TABLES;
- throw_bounds_warning(thd, fixed, TRUE, option_limits->name, unadjusted);
- thd->variables.sql_mode= ssm;
- }
- }
-}
-
-
-/**
Get unsigned system-variable.
Negative value does not wrap around, but becomes zero.
Check user-supplied value for a systemvariable against bounds.
@@ -1662,11 +1625,16 @@ void sys_var_long_ptr_global::set_default(THD *thd, enum_var_type type)
}
+bool sys_var_ulonglong_ptr::check(THD *thd, set_var *var)
+{
+ return get_unsigned(thd, var, 0, GET_ULL);
+}
+
+
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(&LOCK_global_system_variables);
- bound_unsigned(thd, &tmp, option_limits);
*value= (ulonglong) tmp;
pthread_mutex_unlock(&LOCK_global_system_variables);
return 0;
@@ -1751,25 +1719,30 @@ uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
}
-bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
+bool sys_var_thd_ha_rows::check(THD *thd, set_var *var)
{
- ulonglong tmp= var->save_result.ulonglong_value;
-
- /* Don't use bigger value than given with --maximum-variable-name=.. */
- if ((ha_rows) tmp > max_system_variables.*offset)
- tmp= max_system_variables.*offset;
+ return get_unsigned(thd, var, max_system_variables.*offset,
+#ifdef BIG_TABLES
+ GET_ULL
+#else
+ GET_ULONG
+#endif
+ );
+}
- bound_unsigned(thd, &tmp, option_limits);
+bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
+{
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
pthread_mutex_lock(&LOCK_global_system_variables);
- global_system_variables.*offset= (ha_rows) tmp;
+ global_system_variables.*offset= (ha_rows)
+ var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
- thd->variables.*offset= (ha_rows) tmp;
+ thd->variables.*offset= (ha_rows) var->save_result.ulonglong_value;
return 0;
}
@@ -2292,7 +2265,7 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
if (!(tmp=get_charset_by_csname(name,MY_CS_PRIMARY,MYF(0))) &&
!(tmp=get_old_charset_by_name(name)))
{
- my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
+ my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), name);
return 1;
}
}
@@ -2441,6 +2414,12 @@ uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
}
+bool sys_var_key_buffer_size::check(THD *thd, set_var *var)
+{
+ return get_unsigned(thd, var, 0, GET_ULL);
+}
+
+
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
@@ -2454,10 +2433,10 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
pthread_mutex_lock(&LOCK_global_system_variables);
key_cache= get_key_cache(base_name);
-
+
if (!key_cache)
{
- /* Key cache didn't exists */
+ /* Key cache didn't exist */
if (!tmp) // Tried to delete cache
goto end; // Ok, nothing to do
if (!(key_cache= create_key_cache(base_name->str, base_name->length)))
@@ -2479,9 +2458,8 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
{
if (key_cache == dflt_key_cache)
{
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
- ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
+ error= 1;
+ my_error(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE, MYF(0));
goto end; // Ignore default key cache
}
@@ -2507,7 +2485,6 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
goto end;
}
- bound_unsigned(thd, &tmp, option_limits);
key_cache->param_buff_size= (ulonglong) tmp;
/* If key cache didn't exist initialize it, else resize it */
@@ -2524,10 +2501,19 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
end:
pthread_mutex_unlock(&LOCK_global_system_variables);
+
+ var->save_result.ulonglong_value = SIZE_T_MAX;
+
return error;
}
+bool sys_var_key_cache_long::check(THD *thd, set_var *var)
+{
+ return get_unsigned(thd, var, 0, GET_ULONG);
+}
+
+
/**
@todo
Abort if some other thread is changing the key cache.
@@ -2536,7 +2522,6 @@ end:
*/
bool sys_var_key_cache_long::update(THD *thd, set_var *var)
{
- ulonglong tmp= var->value->val_int();
LEX_STRING *base_name= &var->base;
bool error= 0;
@@ -2561,8 +2546,8 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
if (key_cache->in_init)
goto end;
- bound_unsigned(thd, &tmp, option_limits);
- *((ulong*) (((char*) key_cache) + offset))= (ulong) tmp;
+ *((ulong*) (((char*) key_cache) + offset))= (ulong)
+ var->save_result.ulonglong_value;
/*
Don't create a new key cache if it didn't exist