From 61a365e696090f10b46515ff32bf7e293491a99d Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sat, 20 Mar 2004 17:08:01 +0100 Subject: [PATCH] more sys_var_str fixes --- mysql-test/r/variables.result | 9 +++++++++ mysql-test/t/variables.test | 9 +++++++++ sql/set_var.cc | 14 +++++--------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 39d83f8b815..8934cd705b6 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -384,6 +384,15 @@ select @@session.key_buffer_size; ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable set ft_boolean_syntax = @@init_connect; ERROR HY000: Variable 'ft_boolean_syntax' is a GLOBAL variable and should be set with SET GLOBAL +set global ft_boolean_syntax = @@init_connect; +ERROR 42000: Variable 'ft_boolean_syntax' can't be set to the value of '' +set init_connect = NULL; +ERROR HY000: Variable 'init_connect' is a GLOBAL variable and should be set with SET GLOBAL +set global init_connect = NULL; +set ft_boolean_syntax = @@init_connect; +ERROR HY000: Variable 'ft_boolean_syntax' is a GLOBAL variable and should be set with SET GLOBAL +set global ft_boolean_syntax = @@init_connect; +ERROR 42000: Variable 'ft_boolean_syntax' can't be set to the value of '' select @@global.max_user_connections,@@local.max_join_size; @@global.max_user_connections @@session.max_join_size 100 200 diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index c3f7c613005..26eacb86164 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -272,6 +272,15 @@ select @@session.key_buffer_size; --error 1229 set ft_boolean_syntax = @@init_connect; +--error 1231 +set global ft_boolean_syntax = @@init_connect; +--error 1229 +set init_connect = NULL; +set global init_connect = NULL; +--error 1229 +set ft_boolean_syntax = @@init_connect; +--error 1231 +set global ft_boolean_syntax = @@init_connect; # # swap diff --git a/sql/set_var.cc b/sql/set_var.cc index 332a3bdd3d0..8fe15b700f9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -835,15 +835,11 @@ bool sys_var_str::check(THD *thd, set_var *var) bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex, set_var *var) { - char *res= 0, *old_value; - uint new_length= 0; - /* If the string is "", delete old init command */ - if (var && (new_length= var->value->str_value.length())) - { - if (!(res= my_strdup_with_length((byte*) var->value->str_value.ptr(), - new_length, MYF(0)))) - return 1; - } + char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0); + uint new_length= (var ? var->value->str_value.length() : 0); + if (!old_value) old_value=""; + if (!(res= my_strdup_with_length(old_value, new_length, MYF(0)))) + return 1; /* Replace the old value in such a way that the any thread using the value will work.