diff options
author | Tatiana A. Nurnberg <azundris@mysql.com> | 2009-01-12 06:32:49 +0100 |
---|---|---|
committer | Tatiana A. Nurnberg <azundris@mysql.com> | 2009-01-12 06:32:49 +0100 |
commit | 95e0d3bd061b086e94450b6a028c9d5b48a86376 (patch) | |
tree | 684a2670babd0713bd47397b0ad741e352e2a113 /mysys/my_getopt.c | |
parent | 2291857809e3a45f4286ab2974ebc72829d1772a (diff) | |
download | mariadb-git-95e0d3bd061b086e94450b6a028c9d5b48a86376.tar.gz |
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
mysql-test/r/read_buffer_size_basic.result:
test sets out of bounds value; we now throw a warning for this.
This is a side-effect: before, the maximum was higher than the
value we set here. The value was corrected to block-size, the
maximum was not, hence the value was smaller than the maximum
in this particular case. Now that we align the maxima at startup,
the value in SET is larger than the (corrected) maximum, and we
see a warning in this particular case. "This means we're doing it right."
mysql-test/r/read_rnd_buffer_size_basic.result:
test sets out of bounds value; we now throw a warning for this.
This is a side-effect: before, the maximum was higher than the
value we set here. The value was corrected to block-size, the
maximum was not, hence the value was smaller than the maximum
in this particular case. Now that we align the maxima at startup,
the value in SET is larger than the (corrected) maximum, and we
see a warning in this particular case. "This means we're doing it right."
mysys/my_getopt.c:
Do bounds-checking at start-up time so we'll catch and correct
wonky default values and upper limits.
sql/mysqld.cc:
If 0 is a legal value per the docs, not to mention the default, we shouldn't give 1 as
the lower limit.
storage/innobase/handler/ha_innodb.cc:
We are setting upper bounds here.
~0L gives -1. That is NOT what we want!
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r-- | mysys/my_getopt.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0f8055860d4..f97550d4429 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -976,24 +976,26 @@ static void init_one_value(const struct my_option *option, uchar* *variable, *((my_bool*) variable)= (my_bool) value; break; case GET_INT: - *((int*) variable)= (int) value; + *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL); break; - case GET_UINT: case GET_ENUM: *((uint*) variable)= (uint) value; break; + case GET_UINT: + *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL); + break; case GET_LONG: - *((long*) variable)= (long) value; + *((long*) variable)= (long) getopt_ll_limit_value((long) value, option, NULL); break; case GET_ULONG: - *((ulong*) variable)= (ulong) value; + *((ulong*) variable)= (ulong) getopt_ull_limit_value((ulong) value, option, NULL); break; case GET_LL: - *((longlong*) variable)= (longlong) value; + *((longlong*) variable)= (longlong) getopt_ll_limit_value((longlong) value, option, NULL); break; case GET_ULL: case GET_SET: - *((ulonglong*) variable)= (ulonglong) value; + *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value((ulonglong) value, option, NULL); break; case GET_DOUBLE: *((double*) variable)= (double) value; |