summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
authorStaale Smedseng <staale.smedseng@sun.com>2009-06-19 11:27:19 +0200
committerStaale Smedseng <staale.smedseng@sun.com>2009-06-19 11:27:19 +0200
commit37d2019d1756d630d48ab23ca41f7c595862c7f4 (patch)
tree5e93e031147ed30778696a93de12bcf06f5d00f2 /sql/set_var.cc
parent544147417a567c2a40e8cf01e25c7785e26887a1 (diff)
downloadmariadb-git-37d2019d1756d630d48ab23ca41f7c595862c7f4.tar.gz
Bug #32223 SETting max_allowed_packet variable
Inconsistent behavior of session variable max_allowed_packet (and net_buffer_length); only assignment to the global variable has any effect, without this being obvious to the user. The patch for Bug#22891 is backported to 5.0, making the two session variables read-only. As this is a backport to GA software, the error used when trying to assign to the read- only variable is ER_UNKNOWN_ERROR. The error message is the same as in 5.1+. mysql-test/t/variables.test: Tests are changed to account for the new semantics, and assignment to the read-only variables is added to test the emission of the correct error message. sql/set_var.cc: Both max_allowed_packet and net_buffer_length are changed to be of type sys_var_thd_ulong_session_readonly. ER_UNKNOWN_ERROR is used to indicate an attempt to assign to an instance of a read-only variable. sql/set_var.h: Class sys_var_thd_ulong_session_readonly is added.
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 7a85c1c0fa3..aebebb3b465 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -228,8 +228,8 @@ sys_var_thd_bool sys_sql_low_priority_updates("sql_low_priority_updates",
&SV::low_priority_updates,
fix_low_priority_updates);
#endif
-sys_var_thd_ulong sys_max_allowed_packet("max_allowed_packet",
- &SV::max_allowed_packet);
+sys_var_thd_ulong_session_readonly sys_max_allowed_packet("max_allowed_packet",
+ &SV::max_allowed_packet);
sys_var_long_ptr sys_max_binlog_cache_size("max_binlog_cache_size",
&max_binlog_cache_size);
sys_var_long_ptr sys_max_binlog_size("max_binlog_size",
@@ -296,8 +296,8 @@ sys_var_thd_enum sys_myisam_stats_method("myisam_stats_method",
&myisam_stats_method_typelib,
NULL);
-sys_var_thd_ulong sys_net_buffer_length("net_buffer_length",
- &SV::net_buffer_length);
+sys_var_thd_ulong_session_readonly sys_net_buffer_length("net_buffer_length",
+ &SV::net_buffer_length);
sys_var_thd_ulong sys_net_read_timeout("net_read_timeout",
&SV::net_read_timeout,
0, fix_net_read_timeout);
@@ -2948,6 +2948,21 @@ byte *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
}
+bool sys_var_thd_ulong_session_readonly::check(THD *thd, set_var *var)
+{
+ if (var->type != OPT_GLOBAL)
+ {
+ /* Due to backporting, this is actually ER_VARIABLE_IS_READONLY in 5.1+ */
+ my_printf_error(ER_UNKNOWN_ERROR,
+ "SESSION variable %s is read-only. Use SET GLOBAL %s "
+ "to assign the value", MYF(0), name, name);
+ return TRUE;
+ }
+
+ return sys_var_thd_ulong::check(thd, var);
+}
+
+
bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
{
MY_LOCALE *locale_match;