Commit 1d2d4498 authored by unknown's avatar unknown

Merge polly.(none):/home/kaa/src/maint/bug5731/my50-bug5731

into  polly.(none):/home/kaa/src/maint/mysql-5.0-maint
parents ef9e0788 42816b97
...@@ -218,6 +218,8 @@ show variables like 'net_buffer_length'; ...@@ -218,6 +218,8 @@ show 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 net_buffer_length=2000000000;
Warnings:
Warning 1292 Truncated incorrect net_buffer_length value: '2000000000'
show variables like 'net_buffer_length'; show variables like 'net_buffer_length';
Variable_name Value Variable_name Value
net_buffer_length 1048576 net_buffer_length 1048576
......
...@@ -139,6 +139,7 @@ show global variables like 'net_%'; ...@@ -139,6 +139,7 @@ show global variables like 'net_%';
show session variables like 'net_%'; show session variables like 'net_%';
set net_buffer_length=1; set net_buffer_length=1;
show variables like 'net_buffer_length'; show variables like 'net_buffer_length';
--warning 1292
set net_buffer_length=2000000000; set net_buffer_length=2000000000;
show variables like 'net_buffer_length'; show variables like 'net_buffer_length';
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <my_sys.h> #include <my_sys.h>
#include <mysys_err.h> #include <mysys_err.h>
#include <my_getopt.h> #include <my_getopt.h>
#include <errno.h>
static void default_reporter(enum loglevel level, const char *format, ...); static void default_reporter(enum loglevel level, const char *format, ...);
my_error_reporter my_getopt_error_reporter= &default_reporter; my_error_reporter my_getopt_error_reporter= &default_reporter;
...@@ -693,7 +694,15 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name) ...@@ -693,7 +694,15 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name)
longlong num; longlong num;
*error= 0; *error= 0;
errno= 0;
num= strtoll(argument, &endchar, 10); num= strtoll(argument, &endchar, 10);
if (errno == ERANGE)
{
my_getopt_error_reporter(ERROR_LEVEL,
"Incorrect integer value: '%s'", argument);
*error= 1;
return 0;
}
if (*endchar == 'k' || *endchar == 'K') if (*endchar == 'k' || *endchar == 'K')
num*= 1024L; num*= 1024L;
else if (*endchar == 'm' || *endchar == 'M') else if (*endchar == 'm' || *endchar == 'M')
...@@ -730,7 +739,14 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) ...@@ -730,7 +739,14 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
num= eval_num_suffix(arg, err, (char*) optp->name); num= eval_num_suffix(arg, err, (char*) optp->name);
if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value && if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value &&
optp->max_value) /* if max value is not set -> no upper limit */ optp->max_value) /* if max value is not set -> no upper limit */
{
char buf[22];
my_getopt_error_reporter(WARNING_LEVEL,
"Truncated incorrect %s value: '%s'",
optp->name, llstr(num, buf));
num= (ulonglong) optp->max_value; num= (ulonglong) optp->max_value;
}
num= ((num - optp->sub_size) / block_size); num= ((num - optp->sub_size) / block_size);
num= (longlong) (num * block_size); num= (longlong) (num * block_size);
return max(num, optp->min_value); return max(num, optp->min_value);
......
...@@ -1532,16 +1532,31 @@ bool sys_var_thd_ulong::check(THD *thd, set_var *var) ...@@ -1532,16 +1532,31 @@ bool sys_var_thd_ulong::check(THD *thd, set_var *var)
bool sys_var_thd_ulong::update(THD *thd, set_var *var) bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{ {
ulonglong tmp= var->save_result.ulonglong_value; ulonglong tmp= var->save_result.ulonglong_value;
char buf[22];
bool truncated= false;
/* Don't use bigger value than given with --maximum-variable-name=.. */ /* Don't use bigger value than given with --maximum-variable-name=.. */
if ((ulong) tmp > max_system_variables.*offset) if ((ulong) tmp > max_system_variables.*offset)
{
truncated= true;
llstr(tmp, buf);
tmp= max_system_variables.*offset; tmp= max_system_variables.*offset;
}
#if SIZEOF_LONG == 4 #if SIZEOF_LONG == 4
/* Avoid overflows on 32 bit systems */ /* Avoid overflows on 32 bit systems */
if (tmp > (ulonglong) ~(ulong) 0) if (tmp > (ulonglong) ~(ulong) 0)
{
truncated= true;
llstr(tmp, buf);
tmp= ((ulonglong) ~(ulong) 0); tmp= ((ulonglong) ~(ulong) 0);
}
#endif #endif
if (truncated)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
ER(ER_TRUNCATED_WRONG_VALUE), name,
buf);
if (option_limits) if (option_limits)
tmp= (ulong) getopt_ull_limit_value(tmp, option_limits); tmp= (ulong) getopt_ull_limit_value(tmp, option_limits);
......
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