diff options
author | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-01 19:55:06 +0100 |
---|---|---|
committer | unknown <tnurnberg@mysql.com/white.intern.koehntopp.de> | 2007-12-01 19:55:06 +0100 |
commit | 58f10e554aa2ce340e853be1006e1f411f89f09d (patch) | |
tree | aaa884036bc8a904f4d1b5f375f6d3c7376393e3 /mysys | |
parent | 54ad7d88d03c940330510e0870e4bce17327a952 (diff) | |
download | mariadb-git-58f10e554aa2ce340e853be1006e1f411f89f09d.tar.gz |
Bug#31177: Server variables can't be set to their current values
5.1+ specific fixes (plugins etc.)
include/my_getopt.h:
make both ull and ll global
mysql-test/r/index_merge_myisam.result:
we throw warnings to the client, yea, verily
mysql-test/r/innodb.result:
we throw warnings to the client, yea, verily
mysql-test/r/variables.result:
we throw warnings to the client, yea, verily
mysql-test/t/variables.test:
correct result, is multiple of variable's block_size now
mysys/my_getopt.c:
export getopt_ll_limit_value(), check for integer wrap-around
in it, same as in ull variant. Only print warnings to reporter
when caller didn't ask for diagnostics, otherwise assume caller
will handle any warnings (id est, throw them client-wards)
sql/mysqld.cc:
correct signedness of "concurrent-insert"
sql/sql_plugin.cc:
Throw sys-var out-of-range warnings client-wards for
plugins, too.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_getopt.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index af48e9cb0df..3c0faf0c0af 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -34,7 +34,6 @@ my_bool getopt_compare_strings(const char *s, const char *t, uint length); static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); -static longlong getopt_ll_limit_value(longlong, const struct my_option *); static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err); static double getopt_double(char *arg, const struct my_option *optp, int *err); @@ -87,7 +86,7 @@ static void default_reporter(enum loglevel level, fprintf(stderr, "%s", "Info: "); vfprintf(stderr, format, args); va_end(args); - fputs('\n', stderr); + fputc('\n', stderr); fflush(stderr); } @@ -785,7 +784,7 @@ static longlong eval_num_suffix(char *argument, int *error, char *option_name) static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) { longlong num=eval_num_suffix(arg, err, (char*) optp->name); - return getopt_ll_limit_value(num, optp); + return getopt_ll_limit_value(num, optp, NULL); } /* @@ -795,11 +794,11 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) Returns "fixed" value. */ -static longlong getopt_ll_limit_value(longlong num, - const struct my_option *optp) +longlong getopt_ll_limit_value(longlong num, const struct my_option *optp, + bool *fix) { longlong old= num; - bool trunc= FALSE; + bool adjusted= FALSE; char buf1[255], buf2[255]; ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L); @@ -807,7 +806,29 @@ static longlong getopt_ll_limit_value(longlong num, optp->max_value) /* if max value is not set -> no upper limit */ { num= (ulonglong) optp->max_value; - trunc= TRUE; + adjusted= TRUE; + } + + switch ((optp->var_type & GET_TYPE_MASK)) { + case GET_INT: + if (num > (longlong) INT_MAX) + { + num= ((longlong) INT_MAX); + adjusted= TRUE; + } + break; + case GET_LONG: +#if SIZEOF_LONG < SIZEOF_LONG_LONG + if (num > (longlong) LONG_MAX) + { + num= ((longlong) LONG_MAX); + adjusted= TRUE; + } +#endif + break; + default: + DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_LL); + break; } num= ((num - optp->sub_size) / block_size); @@ -816,10 +837,12 @@ static longlong getopt_ll_limit_value(longlong num, if (num < optp->min_value) { num= optp->min_value; - trunc= TRUE; + adjusted= TRUE; } - if (trunc) + if (fix) + *fix= adjusted; + else if (adjusted) my_getopt_error_reporter(WARNING_LEVEL, "option '%s': signed value %s adjusted to %s", optp->name, llstr(old, buf1), llstr(num, buf2)); @@ -888,14 +911,13 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, adjusted= TRUE; } - if (adjusted) + if (fix) + *fix= adjusted; + else if (adjusted) my_getopt_error_reporter(WARNING_LEVEL, "option '%s': unsigned value %s adjusted to %s", optp->name, ullstr(old, buf1), ullstr(num, buf2)); - if (fix) - *fix= adjusted; - return num; } |