Commit c7b83484 authored by Georgi Kodinov's avatar Georgi Kodinov

Bug #11766769: 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET

ARE NOT BEING HONORED

max_allowed_packet works in conjunction with net_buffer_length.
max_allowed_packet is an upper bound of net_buffer_length.
So it doesn't make sense to set the upper limit lower than the value.
Added a warning (using ER_UNKNOWN_ERRROR and a specific message)
when this is done (in the log at startup and when setting either 
max_allowed_packet or the net_buffer_length variables)
Added a test case.
Fixed several tests that broke the above rule.
parent 67319231
......@@ -3,6 +3,7 @@ set @net_buffer_length=@@global.net_buffer_length;
set global max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
set global net_buffer_length=100;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '100'
......
......@@ -280,6 +280,7 @@ NET_BUFFER_LENGTH 1024
set global net_buffer_length=2000000000;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '2000000000'
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
show global variables like 'net_buffer_length';
Variable_name Value
net_buffer_length 1048576
......@@ -502,6 +503,7 @@ set low_priority_updates=1;
set global max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
set global max_binlog_cache_size=100;
Warnings:
Warning 1292 Truncated incorrect max_binlog_cache_size value: '100'
......@@ -1059,6 +1061,8 @@ set global max_write_lock_count =default;
set global myisam_data_pointer_size =@my_myisam_data_pointer_size;
set global myisam_max_sort_file_size =@my_myisam_max_sort_file_size;
set global net_buffer_length =@my_net_buffer_length;
Warnings:
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
set global net_write_timeout =@my_net_write_timeout;
set global net_read_timeout =@my_net_read_timeout;
set global query_cache_limit =@my_query_cache_limit;
......@@ -1547,4 +1551,27 @@ SET @@global.max_binlog_cache_size=DEFAULT;
SET @@global.max_join_size=DEFAULT;
SET @@global.key_buffer_size=@kbs;
SET @@global.key_cache_block_size=@kcbs;
#
# Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET
# ARE NOT BEING HONORED
#
CREATE TABLE t1 (a MEDIUMTEXT);
SET GLOBAL max_allowed_packet=2048;
Warnings:
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SET GLOBAL net_buffer_length=4096;
Warnings:
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
Variable_name Value
max_allowed_packet 2048
SHOW SESSION VARIABLES LIKE 'net_buffer_length';
Variable_name Value
net_buffer_length 4096
ERROR 08S01: Got a packet bigger than 'max_allowed_packet' bytes
SELECT LENGTH(a) FROM t1;
LENGTH(a)
SET GLOBAL max_allowed_packet=default;
SET GLOBAL net_buffer_length=default;
DROP TABLE t1;
End of 5.1 tests
......@@ -49,6 +49,8 @@ SET @max_allowed_packet_2= @@session.max_allowed_packet;
==== clean up ====
DROP TABLE t1;
SET @@global.max_allowed_packet= 1024;
Warnings:
Warning 1105 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SET @@global.net_buffer_length= 1024;
DROP TABLE t1;
RESET SLAVE;
......
--read_buffer_size=12K --max_allowed_packet=8K
--read_buffer_size=12K --max_allowed_packet=8K --net-buffer-length=8K
--max_allowed_packet=8K
--max_allowed_packet=8K --net-buffer-length=8K
......@@ -1304,4 +1304,30 @@ SET @@global.max_join_size=DEFAULT;
SET @@global.key_buffer_size=@kbs;
SET @@global.key_cache_block_size=@kcbs;
--echo #
--echo # Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET
--echo # ARE NOT BEING HONORED
--echo #
CREATE TABLE t1 (a MEDIUMTEXT);
SET GLOBAL max_allowed_packet=2048;
SET GLOBAL net_buffer_length=4096;
CONNECT (con1,localhost,root,,test);
SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
SHOW SESSION VARIABLES LIKE 'net_buffer_length';
--disable_query_log
--error ER_NET_PACKET_TOO_LARGE
INSERT INTO t1 VALUES ('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
--enable_query_log
SELECT LENGTH(a) FROM t1;
CONNECTION default;
DISCONNECT con1;
SET GLOBAL max_allowed_packet=default;
SET GLOBAL net_buffer_length=default;
DROP TABLE t1;
--echo End of 5.1 tests
......@@ -8795,6 +8795,14 @@ static int get_options(int *argc,char **argv)
opt_log_slow_slave_statements) &&
!opt_slow_log)
sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set");
if (global_system_variables.net_buffer_length >
global_system_variables.max_allowed_packet)
{
sql_print_warning("net_buffer_length (%lu) is set to be larger "
"than max_allowed_packet (%lu). Please rectify.",
global_system_variables.net_buffer_length,
global_system_variables.max_allowed_packet);
}
#if defined(HAVE_BROKEN_REALPATH)
my_use_symdir=0;
......
......@@ -147,6 +147,8 @@ static void sys_default_general_log_path(THD *thd, enum_var_type type);
static bool sys_update_slow_log_path(THD *thd, set_var * var);
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
static uchar *get_myisam_mmap_size(THD *thd);
static int check_max_allowed_packet(THD *thd, set_var *var);
static int check_net_buffer_length(THD *thd, set_var *var);
/*
Variable definition list
......@@ -360,7 +362,8 @@ static sys_var_const sys_lower_case_table_names(&vars,
(uchar*)
&lower_case_table_names);
static sys_var_thd_ulong_session_readonly sys_max_allowed_packet(&vars, "max_allowed_packet",
&SV::max_allowed_packet);
&SV::max_allowed_packet,
check_max_allowed_packet);
static sys_var_ulonglong_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
&max_binlog_cache_size);
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size",
......@@ -450,7 +453,8 @@ static sys_var_const sys_named_pipe(&vars, "named_pipe",
/* purecov: end */
#endif
static sys_var_thd_ulong_session_readonly sys_net_buffer_length(&vars, "net_buffer_length",
&SV::net_buffer_length);
&SV::net_buffer_length,
check_net_buffer_length);
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
&SV::net_read_timeout,
0, fix_net_read_timeout);
......@@ -4312,6 +4316,36 @@ uchar *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
}
#endif
int
check_max_allowed_packet(THD *thd, set_var *var)
{
longlong val= var->value->val_int();
if (val < (longlong) global_system_variables.net_buffer_length)
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR,
"The value of 'max_allowed_packet' should be no less than "
"the value of 'net_buffer_length'");
}
return 0;
}
int
check_net_buffer_length(THD *thd, set_var *var)
{
longlong val= var->value->val_int();
if (val > (longlong) global_system_variables.max_allowed_packet)
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR,
"The value of 'max_allowed_packet' should be no less than "
"the value of 'net_buffer_length'");
}
return 0;
}
/****************************************************************************
Used templates
****************************************************************************/
......
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