diff options
author | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-06 01:28:01 +0100 |
---|---|---|
committer | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-06 01:28:01 +0100 |
commit | 4618d68d6d85141cd2422c892ed5053c72aa097a (patch) | |
tree | ddef382443551fdd438cec70128ab88a08413381 /sql | |
parent | 53f7db282dc982e48c0a944e9c3f68ebc3d26db3 (diff) | |
download | mariadb-git-4618d68d6d85141cd2422c892ed5053c72aa097a.tar.gz |
Bug#31177: Server variables can't be set to their current values
additional fixes for BDB and correct assignment of both signed
and unsigned 64-bit data to unsigned system variables
mysql-test/r/ps_2myisam.result:
account for UNSIGNED_FLAG
mysql-test/r/ps_3innodb.result:
account for UNSIGNED_FLAG
mysql-test/r/ps_4heap.result:
account for UNSIGNED_FLAG
mysql-test/r/ps_5merge.result:
account for UNSIGNED_FLAG
mysql-test/r/ps_6bdb.result:
account for UNSIGNED_FLAG
mysql-test/r/ps_7ndb.result:
account for UNSIGNED_FLAG
mysys/my_getopt.c:
We have correct signed/unsigned information now, so we no longer
need to err on the side of caution.
sql/item_func.cc:
Copy unsigned info over from entry so the item's data
correctly describe it.
sql/mysqld.cc:
BDB log buffer size: default can't be less than minimum
sql/set_var.cc:
Handle signedness of in-values correctly when assigning to
unsigned types, all the way up to 64-bit. Use handler from
all three unsigned sysvar types.
sql/set_var.h:
thd_ulonglong: Override default check with one for unsigned types
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 | ||||
-rw-r--r-- | sql/set_var.cc | 32 | ||||
-rw-r--r-- | sql/set_var.h | 1 |
4 files changed, 28 insertions, 9 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 2ee9973c785..019df9176c9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4597,6 +4597,8 @@ void Item_func_get_user_var::fix_length_and_dec() if (var_entry) { + unsigned_flag= var_entry->unsigned_flag; + collation.set(var_entry->collation); switch (var_entry->type) { case REAL_RESULT: diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3900f74da7e..23a05485796 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5679,7 +5679,7 @@ log and this option does nothing anymore.", {"bdb_log_buffer_size", OPT_BDB_LOG_BUFFER_SIZE, "The buffer that is allocated to cache index and rows for BDB tables.", (gptr*) &berkeley_log_buffer_size, (gptr*) &berkeley_log_buffer_size, 0, - GET_ULONG, REQUIRED_ARG, 0, 256*1024L, ULONG_MAX, 0, 1024, 0}, + GET_ULONG, REQUIRED_ARG, 256*1024L, 256*1024L, ULONG_MAX, 0, 1024, 0}, {"bdb_max_lock", OPT_BDB_MAX_LOCK, "The maximum number of locks you can have active on a BDB table.", (gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG, diff --git a/sql/set_var.cc b/sql/set_var.cc index 84b3f92c1ca..58b9b93b17f 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -115,6 +115,7 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type); static void fix_server_id(THD *thd, enum_var_type type); static ulonglong fix_unsigned(THD *thd, ulonglong num, const struct my_option *option_limits); +static bool get_unsigned(THD *thd, set_var *var); static void throw_bounds_warning(THD *thd, const char *name, ulonglong num); static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); @@ -1471,6 +1472,18 @@ static ulonglong fix_unsigned(THD *thd, ulonglong num, return out; } +static bool get_unsigned(THD *thd, set_var *var) +{ + if (var->value->unsigned_flag) + var->save_result.ulonglong_value= (ulonglong) var->value->val_int(); + else + { + longlong v= var->value->val_int(); + var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v); + } + return 0; +} + sys_var_long_ptr:: sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg, @@ -1482,9 +1495,7 @@ sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg, bool sys_var_long_ptr_global::check(THD *thd, set_var *var) { - longlong v= var->value->val_int(); - var->save_result.ulonglong_value= v < 0 ? 0 : v; - return 0; + return get_unsigned(thd, var); } bool sys_var_long_ptr_global::update(THD *thd, set_var *var) @@ -1497,9 +1508,9 @@ bool sys_var_long_ptr_global::update(THD *thd, set_var *var) { #if SIZEOF_LONG < SIZEOF_LONG_LONG /* Avoid overflows on 32 bit systems */ - if (tmp > (ulonglong) ~(ulong) 0) + if (tmp > ULONG_MAX) { - tmp= ((ulonglong) ~(ulong) 0); + tmp= ULONG_MAX; throw_bounds_warning(thd, name, var->save_result.ulonglong_value); } #endif @@ -1567,7 +1578,7 @@ byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) bool sys_var_thd_ulong::check(THD *thd, set_var *var) { - return (sys_var_thd::check(thd, var) || + return (get_unsigned(thd, var) || (check_func && (*check_func)(thd, var))); } @@ -1585,9 +1596,9 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var) if (option_limits) tmp= (ulong) fix_unsigned(thd, tmp, option_limits); #if SIZEOF_LONG < SIZEOF_LONG_LONG - else if (tmp > (ulonglong) ~(ulong) 0) + else if (tmp > ULONG_MAX) { - tmp= ((ulonglong) ~(ulong) 0); + tmp= ULONG_MAX; throw_bounds_warning(thd, name, var->save_result.ulonglong_value); } #endif @@ -1667,6 +1678,11 @@ byte *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type, return (byte*) &(thd->variables.*offset); } +bool sys_var_thd_ulonglong::check(THD *thd, set_var *var) +{ + return get_unsigned(thd, var); +} + bool sys_var_thd_ulonglong::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; diff --git a/sql/set_var.h b/sql/set_var.h index 7b3f864f44c..93402e21258 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -365,6 +365,7 @@ public: void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_LONGLONG; } byte *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 type == OPT_GLOBAL && !option_limits; |