Commit d1fb6bbc authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg

Bug#40657: assertion with out of range variables and traditional sql_mode

In STRICT mode, out-of-bounds values caused an error message
to be queued (rather than just a warning), without any further
error-like processing happening. (The error is queued during
update, at which time it's too late. For it to be processed
properly, it would need to be queued during check-stage.)
The assertion rightfully complains that we're trying to send
an OK while having an error queued.

Changeset breaks a lot of tests out into check-stage. This also
allows us to send more correct warnings/error messages.

mysql-test/r/auto_increment_increment_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/auto_increment_increment_func.result:
  update test results reflecting more correct warnings
mysql-test/r/auto_increment_offset_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/auto_increment_offset_func.result:
  update test results reflecting more correct warnings
mysql-test/r/concurrent_insert_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/connect_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/default_week_format_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/delayed_insert_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/div_precision_increment_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/expire_logs_days_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/group_concat_max_len_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/interactive_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_allowed_packet_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_binlog_size_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_connections_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_delayed_threads_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_error_count_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_insert_delayed_threads_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_length_for_sort_data_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_prepared_stmt_count_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_relay_log_size_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_sort_length_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/max_sp_recursion_depth_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/myisam_data_pointer_size_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/net_buffer_length_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/net_read_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/net_write_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/optimizer_prune_level_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/optimizer_search_depth_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/preload_buffer_size_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/ps.result:
  update test results reflecting more correct warnings
mysql-test/r/read_buffer_size_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/read_rnd_buffer_size_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/slave_net_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/slow_launch_time_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/table_definition_cache_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/table_lock_wait_timeout_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/table_open_cache_basic.result:
  update test results reflecting more correct warnings
mysql-test/r/variables.result:
  add test case that throws error (rather than warning)
  in the middle of trying to set a system-variable.
mysql-test/t/variables.test:
  add test case that throws error (rather than warning)
  in the middle of trying to set a system-variable.
sql/set_var.cc:
  Add comments.
  Prevent double-warnings.
  Through warnings for negative values given to unsigned
  system-variables.
  Process errors and warnings at check() stage rather than
  update() stage, since we may only issue warnings at the latter.
parent 622db260
......@@ -61,7 +61,7 @@ SELECT @@global.auto_increment_increment;
1
SET @@global.auto_increment_increment = -1024;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
Warning 1292 Truncated incorrect auto_increment_increment value: '-1024'
SELECT @@global.auto_increment_increment;
@@global.auto_increment_increment
1
......@@ -89,7 +89,7 @@ SELECT @@session.auto_increment_increment;
1
SET @@session.auto_increment_increment = -2;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
Warning 1292 Truncated incorrect auto_increment_increment value: '-2'
SELECT @@session.auto_increment_increment;
@@session.auto_increment_increment
1
......
......@@ -169,7 +169,7 @@ id name
## Verifying behavior of variable with negative value ##
SET @@auto_increment_increment = -10;
Warnings:
Warning 1292 Truncated incorrect auto-increment-increment value: '0'
Warning 1292 Truncated incorrect auto_increment_increment value: '-10'
INSERT into t1(name) values('Record_17');
INSERT into t1(name) values('Record_18');
SELECT * from t1;
......
......@@ -61,7 +61,7 @@ SELECT @@global.auto_increment_offset;
1
SET @@global.auto_increment_offset = -1024;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
Warning 1292 Truncated incorrect auto_increment_offset value: '-1024'
SELECT @@global.auto_increment_offset;
@@global.auto_increment_offset
1
......@@ -94,7 +94,7 @@ SELECT @@session.auto_increment_offset;
1
SET @@session.auto_increment_offset = -2;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
Warning 1292 Truncated incorrect auto_increment_offset value: '-2'
SELECT @@session.auto_increment_offset;
@@session.auto_increment_offset
1
......
......@@ -178,7 +178,7 @@ id name
## Assigning -ve value to variable ##
SET @@auto_increment_offset = -10;
Warnings:
Warning 1292 Truncated incorrect auto-increment-offset value: '0'
Warning 1292 Truncated incorrect auto_increment_offset value: '-10'
SELECT @@auto_increment_offset = -10;
@@auto_increment_offset = -10
0
......
......@@ -28,6 +28,8 @@ SELECT @@global.concurrent_insert;
2
'#--------------------FN_DYNVARS_018_04-------------------------#'
SET @@global.concurrent_insert = -1;
Warnings:
Warning 1292 Truncated incorrect concurrent_insert value: '-1'
Select @@global.concurrent_insert;
@@global.concurrent_insert
0
......
......@@ -35,7 +35,7 @@ SELECT @@global.connect_timeout;
2
SET @@global.connect_timeout = -1024;
Warnings:
Warning 1292 Truncated incorrect connect_timeout value: '0'
Warning 1292 Truncated incorrect connect_timeout value: '-1024'
SELECT @@global.connect_timeout;
@@global.connect_timeout
2
......
......@@ -64,6 +64,8 @@ SELECT @@global.default_week_format;
@@global.default_week_format
7
SET @@global.default_week_format = -1024;
Warnings:
Warning 1292 Truncated incorrect default_week_format value: '-1024'
SELECT @@global.default_week_format;
@@global.default_week_format
0
......@@ -100,6 +102,8 @@ SELECT @@session.default_week_format;
@@session.default_week_format
7
SET @@session.default_week_format = -2;
Warnings:
Warning 1292 Truncated incorrect default_week_format value: '-2'
SELECT @@session.default_week_format;
@@session.default_week_format
0
......
......@@ -35,7 +35,7 @@ SELECT @@global.delayed_insert_timeout;
1
SET @@global.delayed_insert_timeout = -1024;
Warnings:
Warning 1292 Truncated incorrect delayed_insert_timeout value: '0'
Warning 1292 Truncated incorrect delayed_insert_timeout value: '-1024'
SELECT @@global.delayed_insert_timeout;
@@global.delayed_insert_timeout
1
......
......@@ -78,6 +78,8 @@ SELECT @@global.div_precision_increment;
@@global.div_precision_increment
30
SET @@global.div_precision_increment = -1024;
Warnings:
Warning 1292 Truncated incorrect div_precision_increment value: '-1024'
SELECT @@global.div_precision_increment;
@@global.div_precision_increment
0
......@@ -100,6 +102,8 @@ SELECT @@session.div_precision_increment;
@@session.div_precision_increment
30
SET @@session.div_precision_increment = -2;
Warnings:
Warning 1292 Truncated incorrect div_precision_increment value: '-2'
SELECT @@session.div_precision_increment;
@@session.div_precision_increment
0
......
......@@ -32,6 +32,8 @@ SELECT @@global.expire_logs_days;
21
'#--------------------FN_DYNVARS_029_04-------------------------#'
SET @@global.expire_logs_days = -1;
Warnings:
Warning 1292 Truncated incorrect expire_logs_days value: '-1'
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
0
......@@ -53,6 +55,8 @@ SELECT @@global.expire_logs_days;
@@global.expire_logs_days
99
SET @@global.expire_logs_days = -1024;
Warnings:
Warning 1292 Truncated incorrect expire_logs_days value: '-1024'
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
0
......
......@@ -65,7 +65,7 @@ SELECT @@global.group_concat_max_len;
4
SET @@global.group_concat_max_len = -1024;
Warnings:
Warning 1292 Truncated incorrect group_concat_max_len value: '0'
Warning 1292 Truncated incorrect group_concat_max_len value: '-1024'
SELECT @@global.group_concat_max_len;
@@global.group_concat_max_len
4
......@@ -91,7 +91,7 @@ SELECT @@session.group_concat_max_len;
4
SET @@session.group_concat_max_len = -2;
Warnings:
Warning 1292 Truncated incorrect group_concat_max_len value: '0'
Warning 1292 Truncated incorrect group_concat_max_len value: '-2'
SELECT @@session.group_concat_max_len;
@@session.group_concat_max_len
4
......
......@@ -61,7 +61,7 @@ SELECT @@global.interactive_timeout;
1
SET @@global.interactive_timeout = -1024;
Warnings:
Warning 1292 Truncated incorrect interactive_timeout value: '0'
Warning 1292 Truncated incorrect interactive_timeout value: '-1024'
SELECT @@global.interactive_timeout;
@@global.interactive_timeout
1
......@@ -89,7 +89,7 @@ SELECT @@session.interactive_timeout;
1
SET @@session.interactive_timeout = -2;
Warnings:
Warning 1292 Truncated incorrect interactive_timeout value: '0'
Warning 1292 Truncated incorrect interactive_timeout value: '-2'
SELECT @@session.interactive_timeout;
@@session.interactive_timeout
1
......
......@@ -76,7 +76,7 @@ SELECT @@global.max_allowed_packet;
1024
SET @@global.max_allowed_packet = -1024;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '0'
Warning 1292 Truncated incorrect max_allowed_packet value: '-1024'
SELECT @@global.max_allowed_packet;
@@global.max_allowed_packet
1024
......
......@@ -39,7 +39,7 @@ SELECT @@global.max_binlog_size;
'#--------------------FN_DYNVARS_072_04-------------------------#'
SET @@global.max_binlog_size = -1;
Warnings:
Warning 1292 Truncated incorrect max_binlog_size value: '0'
Warning 1292 Truncated incorrect max_binlog_size value: '-1'
SELECT @@global.max_binlog_size;
@@global.max_binlog_size
4096
......@@ -56,7 +56,7 @@ SELECT @@global.max_binlog_size;
1073741824
SET @@global.max_binlog_size = -1024;
Warnings:
Warning 1292 Truncated incorrect max_binlog_size value: '0'
Warning 1292 Truncated incorrect max_binlog_size value: '-1024'
SELECT @@global.max_binlog_size;
@@global.max_binlog_size
4096
......
......@@ -39,7 +39,7 @@ SELECT @@global.max_connections;
'#--------------------FN_DYNVARS_074_04-------------------------#'
SET @@global.max_connections = -1;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '0'
Warning 1292 Truncated incorrect max_connections value: '-1'
SELECT @@global.max_connections;
@@global.max_connections
1
......@@ -56,7 +56,7 @@ SELECT @@global.max_connections;
100000
SET @@global.max_connections = -1024;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '0'
Warning 1292 Truncated incorrect max_connections value: '-1024'
SELECT @@global.max_connections;
@@global.max_connections
1
......
......@@ -76,10 +76,14 @@ SELECT @@session.max_delayed_threads;
16383
'#------------------FN_DYNVARS_075_05-----------------------#'
SET @@global.max_delayed_threads = -1024;
Warnings:
Warning 1292 Truncated incorrect max_delayed_threads value: '-1024'
SELECT @@global.max_delayed_threads;
@@global.max_delayed_threads
0
SET @@global.max_delayed_threads = -1;
Warnings:
Warning 1292 Truncated incorrect max_delayed_threads value: '-1'
SELECT @@global.max_delayed_threads;
@@global.max_delayed_threads
0
......
......@@ -63,10 +63,14 @@ SELECT @@session.max_error_count;
65534
'#------------------FN_DYNVARS_076_05-----------------------#'
SET @@global.max_error_count = -1;
Warnings:
Warning 1292 Truncated incorrect max_error_count value: '-1'
SELECT @@global.max_error_count;
@@global.max_error_count
0
SET @@global.max_error_count = -1024;
Warnings:
Warning 1292 Truncated incorrect max_error_count value: '-1024'
SELECT @@global.max_error_count;
@@global.max_error_count
0
......@@ -93,6 +97,8 @@ SELECT @@global.max_error_count;
@@global.max_error_count
65535
SET @@session.max_error_count = -1;
Warnings:
Warning 1292 Truncated incorrect max_error_count value: '-1'
SELECT @@session.max_error_count;
@@session.max_error_count
0
......@@ -102,6 +108,8 @@ SELECT @@session.max_error_count;
@@session.max_error_count
65535
SET @@session.max_error_count = -2;
Warnings:
Warning 1292 Truncated incorrect max_error_count value: '-2'
SELECT @@session.max_error_count;
@@session.max_error_count
0
......
......@@ -77,10 +77,14 @@ SELECT @@session.max_insert_delayed_threads;
16383
'#------------------FN_DYNVARS_078_05-----------------------#'
SET @@global.max_insert_delayed_threads = -1024;
Warnings:
Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1024'
SELECT @@global.max_insert_delayed_threads;
@@global.max_insert_delayed_threads
0
SET @@global.max_insert_delayed_threads = -1;
Warnings:
Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1'
SELECT @@global.max_insert_delayed_threads;
@@global.max_insert_delayed_threads
0
......
......@@ -71,7 +71,7 @@ SELECT @@session.max_length_for_sort_data;
'#------------------FN_DYNVARS_080_05-----------------------#'
SET @@global.max_length_for_sort_data = -1024;
Warnings:
Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
Warning 1292 Truncated incorrect max_length_for_sort_data value: '-1024'
SELECT @@global.max_length_for_sort_data;
@@global.max_length_for_sort_data
4
......@@ -111,7 +111,7 @@ SELECT @@session.max_length_for_sort_data;
8388608
SET @@session.max_length_for_sort_data = -1;
Warnings:
Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
Warning 1292 Truncated incorrect max_length_for_sort_data value: '-1'
SELECT @@session.max_length_for_sort_data;
@@session.max_length_for_sort_data
4
......
......@@ -36,6 +36,8 @@ SELECT @@global.max_prepared_stmt_count;
65535
'#--------------------FN_DYNVARS_081_04-------------------------#'
SET @@global.max_prepared_stmt_count = -1;
Warnings:
Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1'
SELECT @@global.max_prepared_stmt_count;
@@global.max_prepared_stmt_count
0
......@@ -51,6 +53,8 @@ SELECT @@global.max_prepared_stmt_count;
@@global.max_prepared_stmt_count
1048576
SET @@global.max_prepared_stmt_count = -1024;
Warnings:
Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1024'
SELECT @@global.max_prepared_stmt_count;
@@global.max_prepared_stmt_count
0
......
......@@ -38,6 +38,8 @@ SELECT @@global.max_relay_log_size;
'Bug# 34877: Invalid Values are coming in variable on assigning valid values';
'#--------------------FN_DYNVARS_082_04-------------------------#'
SET @@global.max_relay_log_size = -1;
Warnings:
Warning 1292 Truncated incorrect max_relay_log_size value: '-1'
SELECT @@global.max_relay_log_size;
@@global.max_relay_log_size
0
......@@ -53,6 +55,8 @@ SELECT @@global.max_relay_log_size;
@@global.max_relay_log_size
1073741824
SET @@global.max_relay_log_size = -1024;
Warnings:
Warning 1292 Truncated incorrect max_relay_log_size value: '-1024'
SELECT @@global.max_relay_log_size;
@@global.max_relay_log_size
0
......
......@@ -71,7 +71,7 @@ SELECT @@session.max_sort_length;
'#------------------FN_DYNVARS_084_05-----------------------#'
SET @@global.max_sort_length = -1024;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '0'
Warning 1292 Truncated incorrect max_sort_length value: '-1024'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
......@@ -111,7 +111,7 @@ SELECT @@session.max_sort_length;
8388608
SET @@session.max_sort_length = -1;
Warnings:
Warning 1292 Truncated incorrect max_sort_length value: '0'
Warning 1292 Truncated incorrect max_sort_length value: '-1'
SELECT @@session.max_sort_length;
@@session.max_sort_length
4
......
......@@ -74,6 +74,8 @@ SELECT @@session.max_sp_recursion_depth;
150
'#------------------FN_DYNVARS_085_05-----------------------#'
SET @@global.max_sp_recursion_depth = -1024;
Warnings:
Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1024'
SELECT @@global.max_sp_recursion_depth;
@@global.max_sp_recursion_depth
0
......@@ -84,6 +86,8 @@ SELECT @@global.max_sp_recursion_depth;
@@global.max_sp_recursion_depth
255
SET @@global.max_sp_recursion_depth = -1;
Warnings:
Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1'
SELECT @@global.max_sp_recursion_depth;
@@global.max_sp_recursion_depth
0
......@@ -110,6 +114,8 @@ SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
255
SET @@session.max_sp_recursion_depth = -1;
Warnings:
Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1'
SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
0
......@@ -120,6 +126,8 @@ SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
255
SET @@session.max_sp_recursion_depth = -001;
Warnings:
Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1'
SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
0
......
......@@ -48,7 +48,7 @@ ERROR HY000: Variable 'myisam_data_pointer_size' is a GLOBAL variable and should
'#------------------FN_DYNVARS_093_05-----------------------#'
SET @@global.myisam_data_pointer_size = -1;
Warnings:
Warning 1292 Truncated incorrect myisam_data_pointer_size value: '0'
Warning 1292 Truncated incorrect myisam_data_pointer_size value: '-1'
SELECT @@global.myisam_data_pointer_size;
@@global.myisam_data_pointer_size
2
......
......@@ -50,7 +50,7 @@ SELECT @@global.net_buffer_length;
1024
SET @@global.net_buffer_length = -1024;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '0'
Warning 1292 Truncated incorrect net_buffer_length value: '-1024'
SELECT @@global.net_buffer_length;
@@global.net_buffer_length
1024
......
......@@ -61,7 +61,7 @@ SELECT @@global.net_read_timeout;
1
SET @@global.net_read_timeout = -1024;
Warnings:
Warning 1292 Truncated incorrect net_read_timeout value: '0'
Warning 1292 Truncated incorrect net_read_timeout value: '-1024'
SELECT @@global.net_read_timeout;
@@global.net_read_timeout
1
......@@ -89,7 +89,7 @@ SELECT @@session.net_read_timeout;
1
SET @@session.net_read_timeout = -2;
Warnings:
Warning 1292 Truncated incorrect net_read_timeout value: '0'
Warning 1292 Truncated incorrect net_read_timeout value: '-2'
SELECT @@session.net_read_timeout;
@@session.net_read_timeout
1
......
......@@ -61,7 +61,7 @@ SELECT @@global.net_write_timeout;
1
SET @@global.net_write_timeout = -1024;
Warnings:
Warning 1292 Truncated incorrect net_write_timeout value: '0'
Warning 1292 Truncated incorrect net_write_timeout value: '-1024'
SELECT @@global.net_write_timeout;
@@global.net_write_timeout
1
......@@ -89,7 +89,7 @@ SELECT @@session.net_write_timeout;
1
SET @@session.net_write_timeout = -2;
Warnings:
Warning 1292 Truncated incorrect net_write_timeout value: '0'
Warning 1292 Truncated incorrect net_write_timeout value: '-2'
SELECT @@session.net_write_timeout;
@@session.net_write_timeout
1
......
......@@ -81,6 +81,8 @@ ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@global.optimizer_prune_level = FELSE;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@global.optimizer_prune_level = -1024;
Warnings:
Warning 1292 Truncated incorrect optimizer_prune_level value: '-1024'
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
0
......@@ -107,6 +109,8 @@ ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@session.optimizer_prune_level = 'OFN';
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@session.optimizer_prune_level = -2;
Warnings:
Warning 1292 Truncated incorrect optimizer_prune_level value: '-2'
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
0
......
......@@ -72,6 +72,8 @@ SELECT @@global.optimizer_search_depth;
@@global.optimizer_search_depth
63
SET @@global.optimizer_search_depth = -1;
Warnings:
Warning 1292 Truncated incorrect optimizer_search_depth value: '-1'
SELECT @@global.optimizer_search_depth;
@@global.optimizer_search_depth
0
......@@ -98,6 +100,8 @@ SELECT @@session.optimizer_search_depth;
@@session.optimizer_search_depth
63
SET @@session.optimizer_search_depth = -2;
Warnings:
Warning 1292 Truncated incorrect optimizer_search_depth value: '-2'
SELECT @@session.optimizer_search_depth;
@@session.optimizer_search_depth
0
......
......@@ -77,7 +77,7 @@ SELECT @@global.preload_buffer_size;
1024
SET @@global.preload_buffer_size = -1;
Warnings:
Warning 1292 Truncated incorrect preload_buffer_size value: '0'
Warning 1292 Truncated incorrect preload_buffer_size value: '-1'
SELECT @@global.preload_buffer_size;
@@global.preload_buffer_size
1024
......@@ -111,7 +111,7 @@ SELECT @@session.preload_buffer_size;
1024
SET @@session.preload_buffer_size = -2;
Warnings:
Warning 1292 Truncated incorrect preload_buffer_size value: '0'
Warning 1292 Truncated incorrect preload_buffer_size value: '-2'
SELECT @@session.preload_buffer_size;
@@session.preload_buffer_size
1024
......
......@@ -803,6 +803,8 @@ select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
16382
set global max_prepared_stmt_count=-1;
Warnings:
Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1'
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
0
......
......@@ -81,7 +81,7 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ;
1
SET @@global.read_buffer_size = -1024;
Warnings:
Warning 1292 Truncated incorrect read_buffer_size value: '0'
Warning 1292 Truncated incorrect read_buffer_size value: '-1024'
SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ;
@@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228
1
......@@ -107,7 +107,7 @@ SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ;
1
SET @@session.read_buffer_size = -2;
Warnings:
Warning 1292 Truncated incorrect read_buffer_size value: '0'
Warning 1292 Truncated incorrect read_buffer_size value: '-2'
SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ;
@@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228
1
......
......@@ -83,7 +83,7 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822
1
SET @@global.read_rnd_buffer_size = -1024;
Warnings:
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '0'
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '-1024'
SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228;
@@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228
1
......@@ -109,7 +109,7 @@ SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8
1
SET @@session.read_rnd_buffer_size = -2;
Warnings:
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '0'
Warning 1292 Truncated incorrect read_rnd_buffer_size value: '-2'
SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8228;
@@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8228
1
......
......@@ -58,13 +58,13 @@ ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set
'#------------------FN_DYNVARS_146_05-----------------------#'
SET @@global.slave_net_timeout = -1;
Warnings:
Warning 1292 Truncated incorrect slave_net_timeout value: '0'
Warning 1292 Truncated incorrect slave_net_timeout value: '-1'
SELECT @@global.slave_net_timeout;
@@global.slave_net_timeout
1
SET @@global.slave_net_timeout = -2147483648;
Warnings:
Warning 1292 Truncated incorrect slave_net_timeout value: '0'
Warning 1292 Truncated incorrect slave_net_timeout value: '-2147483648'
SELECT @@global.slave_net_timeout;
@@global.slave_net_timeout
1
......
......@@ -36,6 +36,8 @@ SELECT @@global.slow_launch_time;
65536
'#--------------------FN_DYNVARS_150_04-------------------------#'
SET @@global.slow_launch_time = -1;
Warnings:
Warning 1292 Truncated incorrect slow_launch_time value: '-1'
SELECT @@global.slow_launch_time;
@@global.slow_launch_time
0
......@@ -57,6 +59,8 @@ SELECT @@global.slow_launch_time;
@@global.slow_launch_time
31536000
SET @@global.slow_launch_time = -1024;
Warnings:
Warning 1292 Truncated incorrect slow_launch_time value: '-1024'
SELECT @@global.slow_launch_time;
@@global.slow_launch_time
0
......
......@@ -45,7 +45,7 @@ SELECT @@global.table_definition_cache;
256
SET @@global.table_definition_cache = -1024;
Warnings:
Warning 1292 Truncated incorrect table_definition_cache value: '0'
Warning 1292 Truncated incorrect table_definition_cache value: '-1024'
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
256
......
......@@ -37,13 +37,13 @@ SELECT @@global.table_lock_wait_timeout ;
'#--------------------FN_DYNVARS_001_04-------------------------#'
SET @@global.table_lock_wait_timeout = -1;
Warnings:
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '0'
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '-1'
SET @@global.table_lock_wait_timeout= 100000000000;
Warnings:
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '100000000000'
SET @@global.table_lock_wait_timeout= -1024;
Warnings:
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '0'
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '-1024'
SET @@global.table_lock_wait_timeout= 0;
Warnings:
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '0'
......
......@@ -39,7 +39,7 @@ SELECT @@global.table_open_cache ;
'#--------------------FN_DYNVARS_001_04-------------------------#'
SET @@global.table_open_cache = -1;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0'
Warning 1292 Truncated incorrect table_open_cache value: '-1'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
......@@ -51,7 +51,7 @@ SELECT @@global.table_open_cache ;
524288
SET @@global.table_open_cache = -1024;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0'
Warning 1292 Truncated incorrect table_open_cache value: '-1024'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
......
......@@ -703,7 +703,7 @@ VARIABLE_NAME VARIABLE_VALUE
MYISAM_DATA_POINTER_SIZE 7
SET GLOBAL table_open_cache=-1;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0'
Warning 1292 Truncated incorrect table_open_cache value: '-1'
SHOW VARIABLES LIKE 'table_open_cache';
Variable_name Value
table_open_cache 1
......@@ -1337,3 +1337,36 @@ SET @@session.thread_stack= 7;
ERROR HY000: Variable 'thread_stack' is a read only variable
SET @@global.thread_stack= 7;
ERROR HY000: Variable 'thread_stack' is a read only variable
SELECT @@global.expire_logs_days INTO @old_eld;
SET GLOBAL expire_logs_days = -1;
Warnings:
Warning 1292 Truncated incorrect expire_logs_days value: '-1'
needs to've been adjusted (0)
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
0
SET GLOBAL expire_logs_days = 11;
SET @old_mode=@@sql_mode;
SET SESSION sql_mode = 'TRADITIONAL';
SET GLOBAL expire_logs_days = 100;
ERROR 42000: Variable 'expire_logs_days' can't be set to the value of '100'
needs to be unchanged (11)
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
11
SET SESSION sql_mode = @old_mode;
SET GLOBAL expire_logs_days = 100;
Warnings:
Warning 1292 Truncated incorrect expire_logs_days value: '100'
needs to've been adjusted (99)
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
99
SET GLOBAL expire_logs_days = 11;
SET GLOBAL expire_logs_days = 99;
needs to pass with no warnings (99)
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
99
SET GLOBAL expire_logs_days = @old_eld;
End of 5.1 tests
......@@ -1077,3 +1077,38 @@ SET @@session.thread_stack= 7;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@global.thread_stack= 7;
#
#
# Bug #40657 - assertion with out of range variables and traditional sql_mode
#
SELECT @@global.expire_logs_days INTO @old_eld;
SET GLOBAL expire_logs_days = -1;
--echo needs to've been adjusted (0)
SELECT @@global.expire_logs_days;
SET GLOBAL expire_logs_days = 11;
SET @old_mode=@@sql_mode;
SET SESSION sql_mode = 'TRADITIONAL';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL expire_logs_days = 100;
--echo needs to be unchanged (11)
SELECT @@global.expire_logs_days;
SET SESSION sql_mode = @old_mode;
SET GLOBAL expire_logs_days = 100;
--echo needs to've been adjusted (99)
SELECT @@global.expire_logs_days;
SET GLOBAL expire_logs_days = 11;
SET GLOBAL expire_logs_days = 99;
--echo needs to pass with no warnings (99)
SELECT @@global.expire_logs_days;
# cleanup
SET GLOBAL expire_logs_days = @old_eld;
--echo End of 5.1 tests
......@@ -134,8 +134,8 @@ static int check_max_delayed_threads(THD *thd, set_var *var);
static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
static bool get_unsigned(THD *thd, set_var *var);
static int get_unsigned(THD *thd, set_var *var);
static bool fix_unsigned(THD *, ulonglong *, bool, const struct my_option *);
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
const char *name, longlong val);
static KEY_CACHE *create_key_cache(const char *name, uint length);
......@@ -1365,6 +1365,19 @@ static void fix_server_id(THD *thd, enum_var_type type)
}
/**
Throw warning (error in STRICT mode) if value for variable needed bounding.
Only call from check(), not update(), because an error in update() would be
bad mojo. Plug-in interface also uses this.
@param thd thread handle
@param fixed did we have to correct the value? (throw warn/err if so)
@param unsignd is value's type unsigned?
@param name variable's name
@param val variable's value
@retval TRUE on error, FALSE otherwise (warning or OK)
*/
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
const char *name, longlong val)
{
......@@ -1390,17 +1403,44 @@ bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
return FALSE;
}
static ulonglong fix_unsigned(THD *thd, ulonglong num,
const struct my_option *option_limits)
/**
check an unsigned user-supplied value for a systemvariable against bounds.
if we needed to adjust the value, throw a warning/error.
@param thd thread handle
@param num the value the user gave
@param warn throw warning/error (FALSE if we get here from
get_unsigned(), so we don't throw two warnings if
user supplies negative value to an unsigned variable)
@param option_limits the bounds-record
@retval TRUE on error, FALSE otherwise (warning or OK)
*/
static bool fix_unsigned(THD *thd, ulonglong *num, bool warn,
const struct my_option *option_limits)
{
my_bool fixed= FALSE;
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
my_bool fixed = FALSE;
ulonglong unadjusted= *num;
*num= getopt_ull_limit_value(unadjusted, option_limits, &fixed);
return warn && throw_bounds_warning(thd, fixed, TRUE, option_limits->name,
(longlong) unadjusted);
throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
return out;
}
static bool get_unsigned(THD *thd, set_var *var)
/**
Get unsigned system-variable.
Negative value does not wrap around, but becomes zero.
@param thd thread handle
@param var the system-variable to get
@retval 0 - OK, 1 - warning, 2 - error
*/
static int get_unsigned(THD *thd, set_var *var)
{
if (var->value->unsigned_flag)
var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
......@@ -1408,6 +1448,8 @@ static bool get_unsigned(THD *thd, set_var *var)
{
longlong v= var->value->val_int();
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
if (v < 0)
return throw_bounds_warning(thd, TRUE, FALSE, var->var->name, v) ? 2 : 1;
}
return 0;
}
......@@ -1423,29 +1465,33 @@ sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_ar
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
{
return get_unsigned(thd, var);
}
bool ret = FALSE;
int got_warnings= get_unsigned(thd, var);
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(guard);
if (option_limits)
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
if (got_warnings == 2)
ret= TRUE;
else if (option_limits)
ret= fix_unsigned(thd, &var->save_result.ulonglong_value,
(got_warnings == 0), option_limits);
else
{
#if SIZEOF_LONG < SIZEOF_LONG_LONG
/* Avoid overflows on 32 bit systems */
if (tmp > ULONG_MAX)
if (var->save_result.ulonglong_value > ULONG_MAX)
{
tmp= ULONG_MAX;
throw_bounds_warning(thd, TRUE, TRUE, name,
(longlong) var->save_result.ulonglong_value);
ret= throw_bounds_warning(thd, TRUE, TRUE, name,
(longlong) var->save_result.ulonglong_value);
var->save_result.ulonglong_value= ULONG_MAX;
}
#endif
*value= (ulong) tmp;
}
return ret;
}
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
{
pthread_mutex_lock(guard);
*value= (ulong) var->save_result.ulonglong_value;
pthread_mutex_unlock(guard);
return 0;
}
......@@ -1466,9 +1512,8 @@ bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(&LOCK_global_system_variables);
if (option_limits)
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
else
*value= (ulonglong) tmp;
fix_unsigned(thd, &tmp, FALSE, option_limits);
*value= (ulonglong) tmp;
pthread_mutex_unlock(&LOCK_global_system_variables);
return 0;
}
......@@ -1518,35 +1563,47 @@ uchar *sys_var_enum_const::value_ptr(THD *thd, enum_var_type type,
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
{
return (get_unsigned(thd, var) ||
(check_func && (*check_func)(thd, var)));
}
ulonglong tmp;
int got_warnings= get_unsigned(thd, var);
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
if (got_warnings == 2)
return TRUE;
tmp= var->save_result.ulonglong_value;
/* Don't use bigger value than given with --maximum-variable-name=.. */
if ((ulong) tmp > max_system_variables.*offset)
{
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
if (throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp))
return TRUE;
tmp= max_system_variables.*offset;
}
if (option_limits)
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
{
if (fix_unsigned(thd, &tmp, (got_warnings == 0), option_limits))
return TRUE;
}
#if SIZEOF_LONG < SIZEOF_LONG_LONG
else if (tmp > ULONG_MAX)
{
if (throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp))
return TRUE;
tmp= ULONG_MAX;
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) var->save_result.ulonglong_value);
}
#endif
var->save_result.ulonglong_value= (ulong) tmp;
return ((check_func && (*check_func)(thd, var)));
}
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
global_system_variables.*offset= (ulong) tmp;
global_system_variables.*offset= (ulong) var->save_result.ulonglong_value;
else
thd->variables.*offset= (ulong) tmp;
thd->variables.*offset= (ulong) var->save_result.ulonglong_value;
return 0;
}
......@@ -1585,7 +1642,8 @@ bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
tmp= max_system_variables.*offset;
if (option_limits)
tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
fix_unsigned(thd, &tmp, FALSE, option_limits);
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
......@@ -1626,27 +1684,44 @@ uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
{
return get_unsigned(thd, var);
}
ulonglong tmp;
int got_warnings= get_unsigned(thd, var);
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
if (got_warnings == 2)
return TRUE;
tmp= var->save_result.ulonglong_value;
if (tmp > max_system_variables.*offset)
{
if (throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp))
return TRUE;
tmp= max_system_variables.*offset;
}
if (option_limits)
tmp= fix_unsigned(thd, tmp, option_limits);
{
if (fix_unsigned(thd, &tmp, (got_warnings == 0), option_limits))
return TRUE;
}
var->save_result.ulonglong_value= tmp;
return FALSE;
}
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
pthread_mutex_lock(&LOCK_global_system_variables);
global_system_variables.*offset= (ulonglong) tmp;
global_system_variables.*offset= (ulonglong)
var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
thd->variables.*offset= (ulonglong) tmp;
thd->variables.*offset= (ulonglong) var->save_result.ulonglong_value;
return 0;
}
......@@ -2278,8 +2353,8 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
goto end;
}
key_cache->param_buff_size=
(ulonglong) fix_unsigned(thd, tmp, option_limits);
fix_unsigned(thd, &tmp, FALSE, option_limits);
key_cache->param_buff_size= (ulonglong) tmp;
/* If key cache didn't existed initialize it, else resize it */
key_cache->in_init= 1;
......@@ -2307,7 +2382,7 @@ end:
*/
bool sys_var_key_cache_long::update(THD *thd, set_var *var)
{
ulong tmp= (ulong) var->value->val_int();
ulonglong tmp= (ulonglong) (ulong) var->value->val_int();
LEX_STRING *base_name= &var->base;
bool error= 0;
......@@ -2332,8 +2407,8 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
if (key_cache->in_init)
goto end;
*((ulong*) (((char*) key_cache) + offset))=
(ulong) fix_unsigned(thd, tmp, option_limits);
fix_unsigned(thd, &tmp, FALSE, option_limits);
*((ulong*) (((char*) key_cache) + offset))= (ulong) tmp;
/*
Don't create a new key cache if it didn't exist
......
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