From 7c1d520ef1a18ad397499de6d70debe5be81dd99 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 May 2005 16:18:27 +0500 Subject: [PATCH] a fix (bug #10339: Incorrect error is displayed if try to set value of internal ' warning_count '). sql/set_var.cc: a fix (bug #10339: Incorrect error is displayed if try to set value of internal ' warning_count '). test for read only variables added. sql/set_var.h: a fix (bug #10339: Incorrect error is displayed if try to set value of internal ' warning_count '). sys_var::is_readonly() method introduced. --- mysql-test/r/variables.result | 4 ++++ mysql-test/t/variables.test | 8 ++++++++ sql/set_var.cc | 5 +++++ sql/set_var.h | 2 ++ 4 files changed, 19 insertions(+) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 3479d209019..33b6d84e892 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -526,3 +526,7 @@ show warnings; Level Code Message Warning 1329 No data to FETCH drop table t1; +set @@warning_count=1; +ERROR HY000: Variable 'warning_count' is a read only variable +set @@global.error_count=1; +ERROR HY000: Variable 'error_count' is a read only variable diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 9931b72599f..f821d88bd96 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -395,3 +395,11 @@ select a into @x from t1; show warnings; drop table t1; +# +# Bug #10339: read only variables. +# + +--error 1238 +set @@warning_count=1; +--error 1238 +set @@global.error_count=1; diff --git a/sql/set_var.cc b/sql/set_var.cc index 4add5d6b39b..56b44d980d2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2964,6 +2964,11 @@ bool not_all_support_one_shot(List *var_list) int set_var::check(THD *thd) { + if (var->is_readonly()) + { + my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->name, "read only"); + return -1; + } if (var->check_type(type)) { int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE; diff --git a/sql/set_var.h b/sql/set_var.h index 32f45187124..37522a0b753 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -75,6 +75,7 @@ public: { return option_limits == 0; } Item *item(THD *thd, enum_var_type type, LEX_STRING *base); virtual bool is_struct() { return 0; } + virtual bool is_readonly() const { return 0; } }; @@ -699,6 +700,7 @@ public: return (*value_ptr_func)(thd); } SHOW_TYPE type() { return show_type; } + bool is_readonly() const { return 1; } }; class sys_var_thd_time_zone :public sys_var_thd