summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorkaa@polly.(none) <>2007-10-04 12:34:00 +0400
committerkaa@polly.(none) <>2007-10-04 12:34:00 +0400
commit1ba3f4f56b57bcf6266beae20da6a06eda436964 (patch)
treee84ac095560faabf900d89f9cf86b80c1815e1aa /mysys
parentb794e5f212c7be40ad7be58f7b87319cdcd4c8e3 (diff)
downloadmariadb-git-1ba3f4f56b57bcf6266beae20da6a06eda436964.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.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_getopt.c16
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);