Commit 37d2019d authored by Staale Smedseng's avatar Staale Smedseng

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.
parent 54414741
...@@ -68,7 +68,7 @@ Warnings: ...@@ -68,7 +68,7 @@ Warnings:
Error 1259 ZLIB: Input data corrupted Error 1259 ZLIB: Input data corrupted
Error 1256 Uncompressed data size too large; the maximum size is 1048576 (probably, length of uncompressed data was corrupted) Error 1256 Uncompressed data size too large; the maximum size is 1048576 (probably, length of uncompressed data was corrupted)
drop table t1; drop table t1;
set @@max_allowed_packet=1048576*100; set @@global.max_allowed_packet=1048576*100;
select compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null; select compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null;
compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null
0 0
......
...@@ -3,32 +3,22 @@ set @net_buffer_length=@@global.net_buffer_length; ...@@ -3,32 +3,22 @@ set @net_buffer_length=@@global.net_buffer_length;
set global max_allowed_packet=100; set global max_allowed_packet=100;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100' Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set global net_buffer_length=100; set global net_buffer_length=100;
Warnings: Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100' Warning 1292 Truncated incorrect net_buffer_length value: '100'
set net_buffer_length=100;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100'
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Warnings:
Warning 1301 Result of repeat() was larger than max_allowed_packet (1024) - truncated
select @@net_buffer_length, @@max_allowed_packet; select @@net_buffer_length, @@max_allowed_packet;
@@net_buffer_length @@max_allowed_packet @@net_buffer_length @@max_allowed_packet
1024 1024 1024 1024
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
ERROR 08S01: Got a packet bigger than 'max_allowed_packet' bytes ERROR 08S01: Got a packet bigger than 'max_allowed_packet' bytes
set global max_allowed_packet=default; set global max_allowed_packet=default;
set max_allowed_packet=default;
set global net_buffer_length=default; set global net_buffer_length=default;
set net_buffer_length=default;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
len len
100 100
......
...@@ -187,7 +187,7 @@ Variable_name Value ...@@ -187,7 +187,7 @@ Variable_name Value
myisam_max_sort_file_size FILE_SIZE myisam_max_sort_file_size FILE_SIZE
set global net_retry_count=10, session net_retry_count=10; set global net_retry_count=10, session net_retry_count=10;
set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300; set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300;
set session net_buffer_length=2048, net_write_timeout=500, net_read_timeout=600; set session net_write_timeout=500, net_read_timeout=600;
show global variables like 'net_%'; show global variables like 'net_%';
Variable_name Value Variable_name Value
net_buffer_length 1024 net_buffer_length 1024
...@@ -196,35 +196,39 @@ net_retry_count 10 ...@@ -196,35 +196,39 @@ net_retry_count 10
net_write_timeout 200 net_write_timeout 200
show session variables like 'net_%'; show session variables like 'net_%';
Variable_name Value Variable_name Value
net_buffer_length 2048 net_buffer_length 16384
net_read_timeout 600 net_read_timeout 600
net_retry_count 10 net_retry_count 10
net_write_timeout 500 net_write_timeout 500
set session net_buffer_length=8000, global net_read_timeout=900, net_write_timeout=1000; set global net_buffer_length=8000, net_read_timeout=900, net_write_timeout=1000;
show global variables like 'net_%'; show global variables like 'net_%';
Variable_name Value Variable_name Value
net_buffer_length 1024 net_buffer_length 7168
net_read_timeout 900 net_read_timeout 900
net_retry_count 10 net_retry_count 10
net_write_timeout 1000 net_write_timeout 1000
show session variables like 'net_%'; show session variables like 'net_%';
Variable_name Value Variable_name Value
net_buffer_length 7168 net_buffer_length 16384
net_read_timeout 600 net_read_timeout 600
net_retry_count 10 net_retry_count 10
net_write_timeout 500 net_write_timeout 500
set net_buffer_length=1; set global net_buffer_length=1;
Warnings: Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '1' Warning 1292 Truncated incorrect net_buffer_length value: '1'
show variables like 'net_buffer_length'; show global variables like 'net_buffer_length';
Variable_name Value Variable_name Value
net_buffer_length 1024 net_buffer_length 1024
set net_buffer_length=2000000000; set global net_buffer_length=2000000000;
Warnings: Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '2000000000' Warning 1292 Truncated incorrect net_buffer_length value: '2000000000'
show variables like 'net_buffer_length'; show global variables like 'net_buffer_length';
Variable_name Value Variable_name Value
net_buffer_length 1048576 net_buffer_length 1048576
set session net_buffer_length=1024;
ERROR HY000: SESSION variable net_buffer_length is read-only. Use SET GLOBAL net_buffer_length to assign the value
set session max_allowed_packet=1024;
ERROR HY000: SESSION variable max_allowed_packet is read-only. Use SET GLOBAL max_allowed_packet to assign the value
set character set cp1251_koi8; set character set cp1251_koi8;
show variables like "character_set_client"; show variables like "character_set_client";
Variable_name Value Variable_name Value
...@@ -393,7 +397,7 @@ set last_insert_id=1; ...@@ -393,7 +397,7 @@ set last_insert_id=1;
set global local_infile=1; set global local_infile=1;
set long_query_time=100; set long_query_time=100;
set low_priority_updates=1; set low_priority_updates=1;
set max_allowed_packet=100; set global max_allowed_packet=100;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100' Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set global max_binlog_cache_size=100; set global max_binlog_cache_size=100;
...@@ -417,7 +421,7 @@ select @@max_user_connections; ...@@ -417,7 +421,7 @@ select @@max_user_connections;
100 100
set global max_write_lock_count=100; set global max_write_lock_count=100;
set myisam_sort_buffer_size=100; set myisam_sort_buffer_size=100;
set net_buffer_length=100; set global net_buffer_length=100;
Warnings: Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100' Warning 1292 Truncated incorrect net_buffer_length value: '100'
set net_read_timeout=100; set net_read_timeout=100;
......
...@@ -43,8 +43,10 @@ drop table t1; ...@@ -43,8 +43,10 @@ drop table t1;
# note that when LOW_MEMORY is set the "test" below is meaningless # note that when LOW_MEMORY is set the "test" below is meaningless
# #
set @@max_allowed_packet=1048576*100; set @@global.max_allowed_packet=1048576*100;
--replace_result "''" XXX "'1'" XXX --replace_result "''" XXX "'1'" XXX
# reconnect to make the new max packet size take effect
--connect (newconn, localhost, root,,)
eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null; eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null;
# #
......
...@@ -15,31 +15,33 @@ ...@@ -15,31 +15,33 @@
set @max_allowed_packet=@@global.max_allowed_packet; set @max_allowed_packet=@@global.max_allowed_packet;
set @net_buffer_length=@@global.net_buffer_length; set @net_buffer_length=@@global.net_buffer_length;
connect (con1,localhost,root,,);
connection con1; # setting values below minimum threshold of 1024 will cause truncating
set global max_allowed_packet=100; set global max_allowed_packet=100;
set max_allowed_packet=100;
set global net_buffer_length=100; set global net_buffer_length=100;
set net_buffer_length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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
# Should return NULL as 2000 is bigger than max_allowed_packet
select repeat('a',2000); select repeat('a',2000);
connection default;
disconnect con1;
# #
# Connection 2 should get error for too big packets # Connection 1 should get error for too big packets
# #
connect (con2,localhost,root,,); connect (con1,localhost,root,,);
connection con2; connection con1;
select @@net_buffer_length, @@max_allowed_packet; select @@net_buffer_length, @@max_allowed_packet;
--error ER_NET_PACKET_TOO_LARGE --error ER_NET_PACKET_TOO_LARGE
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
connection default;
disconnect con1;
#
# Reset to default values and reconnect
#
set global max_allowed_packet=default; set global max_allowed_packet=default;
set max_allowed_packet=default;
set global net_buffer_length=default; set global net_buffer_length=default;
set net_buffer_length=default; connect (con2,localhost,root,,);
connection con2;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
select length(repeat('a',2000)); select length(repeat('a',2000));
connection default; connection default;
......
...@@ -131,17 +131,22 @@ show global variables like 'myisam_max_sort_file_size'; ...@@ -131,17 +131,22 @@ show global variables like 'myisam_max_sort_file_size';
set global net_retry_count=10, session net_retry_count=10; set global net_retry_count=10, session net_retry_count=10;
set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300; set global net_buffer_length=1024, net_write_timeout=200, net_read_timeout=300;
set session net_buffer_length=2048, net_write_timeout=500, net_read_timeout=600; set session net_write_timeout=500, net_read_timeout=600;
show global variables like 'net_%'; show global variables like 'net_%';
show session variables like 'net_%'; show session variables like 'net_%';
set session net_buffer_length=8000, global net_read_timeout=900, net_write_timeout=1000; set global net_buffer_length=8000, net_read_timeout=900, net_write_timeout=1000;
show global variables like 'net_%'; show global variables like 'net_%';
show session variables like 'net_%'; show session variables like 'net_%';
set net_buffer_length=1; set global net_buffer_length=1;
show variables like 'net_buffer_length'; show global variables like 'net_buffer_length';
#warning 1292 #warning 1292
set net_buffer_length=2000000000; set global net_buffer_length=2000000000;
show variables like 'net_buffer_length'; show global variables like 'net_buffer_length';
--error ER_UNKNOWN_ERROR
set session net_buffer_length=1024;
--error ER_UNKNOWN_ERROR
set session max_allowed_packet=1024;
set character set cp1251_koi8; set character set cp1251_koi8;
show variables like "character_set_client"; show variables like "character_set_client";
...@@ -272,7 +277,7 @@ set last_insert_id=1; ...@@ -272,7 +277,7 @@ set last_insert_id=1;
set global local_infile=1; set global local_infile=1;
set long_query_time=100; set long_query_time=100;
set low_priority_updates=1; set low_priority_updates=1;
set max_allowed_packet=100; set global max_allowed_packet=100;
set global max_binlog_cache_size=100; set global max_binlog_cache_size=100;
set global max_binlog_size=100; set global max_binlog_size=100;
set global max_connect_errors=100; set global max_connect_errors=100;
...@@ -286,7 +291,7 @@ set global max_user_connections=100; ...@@ -286,7 +291,7 @@ set global max_user_connections=100;
select @@max_user_connections; select @@max_user_connections;
set global max_write_lock_count=100; set global max_write_lock_count=100;
set myisam_sort_buffer_size=100; set myisam_sort_buffer_size=100;
set net_buffer_length=100; set global net_buffer_length=100;
set net_read_timeout=100; set net_read_timeout=100;
set net_write_timeout=100; set net_write_timeout=100;
set global query_cache_limit=100; set global query_cache_limit=100;
......
...@@ -228,8 +228,8 @@ sys_var_thd_bool sys_sql_low_priority_updates("sql_low_priority_updates", ...@@ -228,8 +228,8 @@ sys_var_thd_bool sys_sql_low_priority_updates("sql_low_priority_updates",
&SV::low_priority_updates, &SV::low_priority_updates,
fix_low_priority_updates); fix_low_priority_updates);
#endif #endif
sys_var_thd_ulong sys_max_allowed_packet("max_allowed_packet", sys_var_thd_ulong_session_readonly sys_max_allowed_packet("max_allowed_packet",
&SV::max_allowed_packet); &SV::max_allowed_packet);
sys_var_long_ptr sys_max_binlog_cache_size("max_binlog_cache_size", sys_var_long_ptr sys_max_binlog_cache_size("max_binlog_cache_size",
&max_binlog_cache_size); &max_binlog_cache_size);
sys_var_long_ptr sys_max_binlog_size("max_binlog_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", ...@@ -296,8 +296,8 @@ sys_var_thd_enum sys_myisam_stats_method("myisam_stats_method",
&myisam_stats_method_typelib, &myisam_stats_method_typelib,
NULL); NULL);
sys_var_thd_ulong sys_net_buffer_length("net_buffer_length", sys_var_thd_ulong_session_readonly sys_net_buffer_length("net_buffer_length",
&SV::net_buffer_length); &SV::net_buffer_length);
sys_var_thd_ulong sys_net_read_timeout("net_read_timeout", sys_var_thd_ulong sys_net_read_timeout("net_read_timeout",
&SV::net_read_timeout, &SV::net_read_timeout,
0, fix_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, ...@@ -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) bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
{ {
MY_LOCALE *locale_match; MY_LOCALE *locale_match;
......
...@@ -873,6 +873,28 @@ class sys_var_max_user_conn : public sys_var_thd ...@@ -873,6 +873,28 @@ class sys_var_max_user_conn : public sys_var_thd
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
}; };
/**
* @brief This is a specialization of sys_var_thd_ulong that implements a
read-only session variable. The class overrides check() and check_default()
to achieve the read-only property for the session part of the variable.
*/
class sys_var_thd_ulong_session_readonly : public sys_var_thd_ulong
{
public:
sys_var_thd_ulong_session_readonly(const char *name_arg, ulong SV::*offset_arg,
sys_check_func c_func= NULL,
sys_after_update_func au_func= NULL):
sys_var_thd_ulong(name_arg, offset_arg, c_func, au_func)
{ }
bool check(THD *thd, set_var *var);
bool check_default(enum_var_type type)
{
return type != OPT_GLOBAL || !option_limits;
}
};
class sys_var_trust_routine_creators :public sys_var_bool_ptr class sys_var_trust_routine_creators :public sys_var_bool_ptr
{ {
/* We need a derived class only to have a warn_deprecated() */ /* We need a derived class only to have a warn_deprecated() */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment