diff options
author | unknown <kaa@polly.(none)> | 2007-10-04 12:34:00 +0400 |
---|---|---|
committer | unknown <kaa@polly.(none)> | 2007-10-04 12:34:00 +0400 |
commit | 78348d4ed10a3a77870d956ad861c3fdcadd96a5 (patch) | |
tree | e84ac095560faabf900d89f9cf86b80c1815e1aa /mysys | |
parent | 2b8748ca6e35c95fb9b8a6f0b55227f7c1da3a0f (diff) | |
download | mariadb-git-78348d4ed10a3a77870d956ad861c3fdcadd96a5.tar.gz |
Issue a warning if a user sets an option or a variable to a value that is greater than a defined maximum for the option/variable.
This is for bug #29446 "Specifying a myisam_sort_buffer > 4GB on 64 bit machines not possible". Support for myisam_sort_buffer_size > 4 GB on 64-bit Windows will be looked at later in 5.2.
mysql-test/r/variables.result:
Fixed the test.
mysql-test/t/variables.test:
Fixed the test.
mysys/my_getopt.c:
Print a warning to the error log if a user sets an option to a value greater than the option's maximum value.
sql/set_var.cc:
Issue an SQL warning if a user assignes a value greater than the variable's maximum value.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_getopt.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 623c48b2e55..71630e1b4c2 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -19,6 +19,7 @@ #include <my_sys.h> #include <mysys_err.h> #include <my_getopt.h> +#include <errno.h> static void default_reporter(enum loglevel level, const char *format, ...); 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) longlong num; *error= 0; + errno= 0; 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') num*= 1024L; else if (*endchar == 'm' || *endchar == 'M') @@ -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); if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value && 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= ((num - optp->sub_size) / block_size); num= (longlong) (num * block_size); return max(num, optp->min_value); |