mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
89a208850a
Default values of variables were not subject to upper/lower bounds and step, while setting variables was. Bounds and step are also applied to defaults now; defaults are corrected quietly, values given by the user are corrected, and a correction-warning is thrown as needed. Lastly, very large values could wrap around, starting from 0 again. They are bounded at the maximum value for the respective data-type now if no lower maximum is specified in the variable's definition. client/mysql.cc: correct maxima in options array client/mysqltest.c: adjust minimum for "sleep" option so default value is no longer out of bounds. include/m_string.h: ullstr() - the unsigned brother of llstr() include/my_getopt.h: Flag if we bounded the value (that is, correct anything aside from making value a multiple of block-size) mysql-test/r/delayed.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/index_merge.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/innodb.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/innodb_mysql.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/key_cache.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/packet.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/ps.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/subselect.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/type_bit.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/type_bit_innodb.result: We throw a warning now when we adjust out of range parameters. mysql-test/r/variables.result: correct results: bounds and step apply to variables' default values, too mysql-test/t/variables.test: correct results: bounds and step apply to variables' default values, too mysys/my_getopt.c: - apply bounds/step to default values of variables (based on work by serg) - print complaints about incorrect values for variables (truncation etc., by requestion of consulting) - if no lower maximum is specified in variable definition, bound unsigned values at their maximum to prevent wrap-around - some calls to error_reporter had a \n, some didn't. remove \n from calls, let reporter-function handle it, so the default reporter behaves like that in mysqld sql/mysql_priv.h: correct RANGE_ALLOC_BLOCK_SIZE (cleared with monty) sql/mysqld.cc: correct maxima to correct data-type. correct minima where higher than default. correct range-alloc-block-size. correct inno variables so GET_* corresponds to actual variable's type. sql/set_var.cc: When the new value for a variable is out of bounds, we'll send the client a warning (but not if the value was simply not a multiple of 'blocksize'). sys_var_thd_ulong had this, sys_var_long_ptr_global didn't; broken out and streamlined to avoid duplication of code. strings/llstr.c: ullstr() - the unsigned brother of llstr()
77 lines
2.9 KiB
C
77 lines
2.9 KiB
C
/* Copyright (C) 2002-2004 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifndef _my_getopt_h
|
|
#define _my_getopt_h
|
|
|
|
C_MODE_START
|
|
|
|
#define GET_NO_ARG 1
|
|
#define GET_BOOL 2
|
|
#define GET_INT 3
|
|
#define GET_UINT 4
|
|
#define GET_LONG 5
|
|
#define GET_ULONG 6
|
|
#define GET_LL 7
|
|
#define GET_ULL 8
|
|
#define GET_STR 9
|
|
#define GET_STR_ALLOC 10
|
|
#define GET_DISABLED 11
|
|
|
|
#define GET_ASK_ADDR 128
|
|
#define GET_TYPE_MASK 127
|
|
|
|
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
|
|
|
|
struct my_option
|
|
{
|
|
const char *name; /* Name of the option */
|
|
int id; /* unique id or short option */
|
|
const char *comment; /* option comment, for autom. --help */
|
|
gptr *value; /* The variable value */
|
|
gptr *u_max_value; /* The user def. max variable value */
|
|
const char **str_values; /* Pointer to possible values */
|
|
ulong var_type;
|
|
enum get_opt_arg_type arg_type;
|
|
longlong def_value; /* Default value */
|
|
longlong min_value; /* Min allowed value */
|
|
longlong max_value; /* Max allowed value */
|
|
longlong sub_size; /* Subtract this from given value */
|
|
long block_size; /* Value should be a mult. of this */
|
|
int app_type; /* To be used by an application */
|
|
};
|
|
|
|
typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * );
|
|
typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... );
|
|
|
|
extern char *disabled_my_option;
|
|
extern my_bool my_getopt_print_errors;
|
|
extern my_error_reporter my_getopt_error_reporter;
|
|
|
|
extern int handle_options (int *argc, char ***argv,
|
|
const struct my_option *longopts, my_get_one_option);
|
|
extern void my_print_help(const struct my_option *options);
|
|
extern void my_print_variables(const struct my_option *options);
|
|
extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
|
|
const struct my_option *));
|
|
|
|
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
|
|
bool *fixed);
|
|
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
|
|
|
|
C_MODE_END
|
|
|
|
#endif /* _my_getopt_h */
|
|
|