From 6c76246e21e54963220517900947c9dad5a786e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 13 Oct 2007 20:25:53 +0200 Subject: my_getopt: enforce "correctness" (min/max/block_size) of default values client/mysqltest.c: fix my_option's with incorrect defaults mysql-test/r/maria.result: update results mysql-test/t/variables.test: update results sql/mysqld.cc: fix my_option's with incorrect defaults --- mysys/my_getopt.c | 73 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 3a5b130e067..6a7386d4126 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -20,22 +20,25 @@ #include #include +#if SIZEOF_LONG < SIZEOF_LONG_LONG +#define getopt_ul getopt_ll +#define getopt_ul_limit_value getopt_ll_limit_value +#else +#define getopt_ul getopt_ull +#define getopt_ul_limit_value getopt_ull_limit_value +#endif + static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; -static int findopt(char *optpat, uint length, - const struct my_option **opt_res, - char **ffname); -my_bool getopt_compare_strings(const char *s, - const char *t, - uint length); +static int findopt(char *, uint, const struct my_option **, char **); +my_bool getopt_compare_strings(const char *, const char *, uint); static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); -static ulonglong getopt_ull(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 *, const struct my_option *, int *); static double getopt_double(char *arg, const struct my_option *optp, int *err); static void init_variables(const struct my_option *options); -static int setval(const struct my_option *opts, uchar* *value, char *argument, - my_bool set_maximum_value); +static int setval(const struct my_option *, uchar **, char *, my_bool); static char *check_struct_option(char *cur_arg, char *key_name); /* @@ -603,9 +606,11 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, *((int*) result_pos)= (int) getopt_ll(argument, opts, &err); break; case GET_LONG: - case GET_ULONG: /* fall through */ *((long*) result_pos)= (long) getopt_ll(argument, opts, &err); break; + case GET_ULONG: + *((long*) result_pos)= (long) getopt_ul(argument, opts, &err); + break; case GET_LL: *((longlong*) result_pos)= getopt_ll(argument, opts, &err); break; @@ -748,7 +753,7 @@ static longlong eval_num_suffix(char *argument, int *error, char *option_name) return num; } -/* +/* function: getopt_ll Evaluates and returns the value that user gave as an argument @@ -761,10 +766,22 @@ 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; + longlong num=eval_num_suffix(arg, err, (char*) optp->name); + return getopt_ll_limit_value(num, optp); +} + +/* + function: getopt_ll_limit_value + + Applies min/max/block_size to a numeric value of an option. + Returns "fixed" value. +*/ + +static longlong getopt_ll_limit_value(longlong num, + const struct my_option *optp) +{ ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L); - - 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 */ num= (ulonglong) optp->max_value; @@ -782,9 +799,7 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err) { - ulonglong num; - - num= eval_num_suffix(arg, err, (char*) optp->name); + ulonglong num= eval_num_suffix(arg, err, (char*) optp->name); return getopt_ull_limit_value(num, optp); } @@ -841,35 +856,39 @@ static double getopt_double(char *arg, const struct my_option *optp, int *err) SYNOPSIS init_one_value() - option Option to initialize - value Pointer to variable + optp Option to initialize + value Pointer to variable */ -static void init_one_value(const struct my_option *option, uchar* *variable, +static void init_one_value(const struct my_option *optp, uchar* *variable, longlong value) { DBUG_ENTER("init_one_value"); - switch ((option->var_type & GET_TYPE_MASK)) { + switch ((optp->var_type & GET_TYPE_MASK)) { case GET_BOOL: *((my_bool*) variable)= (my_bool) value; break; case GET_INT: - *((int*) variable)= (int) value; + *((int*) variable)= (int) getopt_ll_limit_value(value, optp); break; case GET_UINT: + *((uint*) variable)= (uint) getopt_ll_limit_value(value, optp); + break; case GET_ENUM: *((uint*) variable)= (uint) value; break; case GET_LONG: - *((long*) variable)= (long) value; + *((long*) variable)= (long) getopt_ll_limit_value(value, optp); break; case GET_ULONG: - *((ulong*) variable)= (ulong) value; + *((ulong*) variable)= (ulong) getopt_ul_limit_value(value, optp); break; case GET_LL: - *((longlong*) variable)= (longlong) value; + *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp); break; case GET_ULL: + *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value(value, optp); + break; case GET_SET: *((ulonglong*) variable)= (ulonglong) value; break; @@ -906,7 +925,7 @@ static void init_one_value(const struct my_option *option, uchar* *variable, } -/* +/* initialize all variables to their default values SYNOPSIS -- cgit v1.2.1 From 32680d6218f85e3a83bee6f19172641aadd13d11 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Oct 2007 00:32:51 +0200 Subject: mysys/my_getopt.c always process uint/ulong using ulonglong (unsigned) code dbug printout for adjusted option values strings/llstr.c ullstr() - the unsigned brother of llstr() include/m_string.h: ullstr() - the unsigned brother of llstr() mysql-test/t/variables.test: test adjusted for 32bit mysys/my_getopt.c: always process uint/ulong using ulonglong (unsigned) code dbug printout for adjusted option values strings/llstr.c: ullstr() - the unsigned brother of llstr() --- mysys/my_getopt.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 6a7386d4126..218d9dce1f4 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -20,14 +20,6 @@ #include #include -#if SIZEOF_LONG < SIZEOF_LONG_LONG -#define getopt_ul getopt_ll -#define getopt_ul_limit_value getopt_ll_limit_value -#else -#define getopt_ul getopt_ull -#define getopt_ul_limit_value getopt_ull_limit_value -#endif - static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; @@ -602,14 +594,16 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, *((my_bool*) result_pos)= (my_bool) atoi(argument) != 0; break; case GET_INT: - case GET_UINT: /* fall through */ *((int*) result_pos)= (int) getopt_ll(argument, opts, &err); break; + case GET_UINT: + *((uint*) result_pos)= (uint) getopt_ull(argument, opts, &err); + break; case GET_LONG: *((long*) result_pos)= (long) getopt_ll(argument, opts, &err); break; case GET_ULONG: - *((long*) result_pos)= (long) getopt_ul(argument, opts, &err); + *((long*) result_pos)= (long) getopt_ull(argument, opts, &err); break; case GET_LL: *((longlong*) result_pos)= getopt_ll(argument, opts, &err); @@ -781,13 +775,19 @@ static longlong getopt_ll_limit_value(longlong num, const struct my_option *optp) { ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L); + longlong old= num; + char buf1[255] __attribute__((unused)), buf2[255] __attribute__((unused)); if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value && optp->max_value) /* if max value is not set -> no upper limit */ num= (ulonglong) optp->max_value; num= ((num - optp->sub_size) / block_size); num= (longlong) (num * block_size); - return max(num, optp->min_value); + num= max(num, optp->min_value); + if (num != old) + DBUG_PRINT("options", ("option '%s' adjusted %s -> %s", + optp->name, llstr(old, buf1), llstr(num, buf2))); + return num; } /* @@ -806,6 +806,9 @@ static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err) ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp) { + ulonglong old= num; + char buf1[255] __attribute__((unused)), buf2[255] __attribute__((unused)); + if ((ulonglong) num > (ulonglong) optp->max_value && optp->max_value) /* if max value is not set -> no upper limit */ num= (ulonglong) optp->max_value; @@ -816,6 +819,9 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp) } if (num < (ulonglong) optp->min_value) num= (ulonglong) optp->min_value; + if (num != old) + DBUG_PRINT("options", ("option '%s' adjusted %s -> %s", + optp->name, ullstr(old, buf1), ullstr(num, buf2))); return num; } @@ -872,7 +878,7 @@ static void init_one_value(const struct my_option *optp, uchar* *variable, *((int*) variable)= (int) getopt_ll_limit_value(value, optp); break; case GET_UINT: - *((uint*) variable)= (uint) getopt_ll_limit_value(value, optp); + *((uint*) variable)= (uint) getopt_ull_limit_value(value, optp); break; case GET_ENUM: *((uint*) variable)= (uint) value; @@ -881,7 +887,7 @@ static void init_one_value(const struct my_option *optp, uchar* *variable, *((long*) variable)= (long) getopt_ll_limit_value(value, optp); break; case GET_ULONG: - *((ulong*) variable)= (ulong) getopt_ul_limit_value(value, optp); + *((ulong*) variable)= (ulong) getopt_ull_limit_value(value, optp); break; case GET_LL: *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp); -- cgit v1.2.1 From dfe098fec9aa0d2d2f47c2e86ea0cdd8200ed2b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 16 Dec 2007 20:37:22 +0200 Subject: Fixed after-merge problems. --- mysys/my_getopt.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index d7de0d12e08..796062f75b0 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -30,7 +30,6 @@ my_error_reporter my_getopt_error_reporter= &default_reporter; static int findopt(char *, uint, const struct my_option **, char **); my_bool getopt_compare_strings(const char *, const char *, uint); 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 *, const struct my_option *, int *); static double getopt_double(char *arg, const struct my_option *optp, int *err); static void init_variables(const struct my_option *options, @@ -789,8 +788,8 @@ 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, - bool *fix) +longlong getopt_ll_limit_value(longlong num, const struct my_option *optp, + bool *fix) { longlong old= num; bool adjusted= FALSE; @@ -859,7 +858,7 @@ static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err) ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, - bool *fix); + bool *fix) { bool adjusted= FALSE; ulonglong old= num; @@ -965,25 +964,27 @@ static void init_one_value(const struct my_option *optp, uchar* *variable, *((my_bool*) variable)= (my_bool) value; break; case GET_INT: - *((int*) variable)= (int) getopt_ll_limit_value(value, optp); + *((int*) variable)= (int) getopt_ll_limit_value(value, optp, NULL); break; case GET_UINT: - *((uint*) variable)= (uint) getopt_ull_limit_value(value, optp); + *((uint*) variable)= (uint) getopt_ull_limit_value(value, optp, NULL); break; case GET_ENUM: *((uint*) variable)= (uint) value; break; case GET_LONG: - *((long*) variable)= (long) getopt_ll_limit_value(value, optp); + *((long*) variable)= (long) getopt_ll_limit_value(value, optp, NULL); break; case GET_ULONG: - *((ulong*) variable)= (ulong) getopt_ull_limit_value(value, optp); + *((ulong*) variable)= (ulong) getopt_ull_limit_value(value, optp, NULL); break; case GET_LL: - *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp); + *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp, + NULL); break; case GET_ULL: - *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value(value, optp); + *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value(value, optp, + NULL); break; case GET_SET: *((ulonglong*) variable)= (ulonglong) value; -- cgit v1.2.1 From 4dcbe2cbd60a38e6b976676862f05c28f253053c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Dec 2007 14:10:07 +0200 Subject: Fixes to merge. mysql-test/r/maria.result: Fixed result file. The results will be fixed by Sergei's patch. mysql-test/t/variables.test: Fixed result file. The results will be fixed by Sergei's patch. mysys/my_getopt.c: Fixed a problem with manual merge. sql/set_var.cc: Fixed a problem with manual merge. sql/set_var.h: Fixed a problem with manual merge. sql/sql_plugin.cc: Removed unneccessary function call. This was forgotten from a previous patch. --- mysys/my_getopt.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 796062f75b0..63ef57300fa 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -27,10 +27,15 @@ typedef void (*init_func_p)(const struct my_option *option, uchar* *variable, static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; -static int findopt(char *, uint, const struct my_option **, char **); -my_bool getopt_compare_strings(const char *, const char *, uint); +static int findopt(char *optpat, uint length, + const struct my_option **opt_res, + char **ffname); +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 ulonglong getopt_ull(char *, const struct my_option *, int *); +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); static void init_variables(const struct my_option *options, init_func_p init_one_value); @@ -38,7 +43,8 @@ static void init_one_value(const struct my_option *option, uchar* *variable, longlong value); static void fini_one_value(const struct my_option *option, uchar* *variable, longlong value); -static int setval(const struct my_option *, uchar **, char *, my_bool); +static int setval(const struct my_option *opts, uchar **value, char *argument, + my_bool set_maximum_value); static char *check_struct_option(char *cur_arg, char *key_name); /* @@ -861,7 +867,7 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, bool *fix) { bool adjusted= FALSE; - ulonglong old= num; + ulonglong old= num, mod; char buf1[255], buf2[255]; if ((ulonglong) num > (ulonglong) optp->max_value && @@ -886,6 +892,8 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, num= ((ulonglong) ULONG_MAX); adjusted= TRUE; } +#else + num= min(num, LONG_MAX); #endif break; default: @@ -951,41 +959,35 @@ static double getopt_double(char *arg, const struct my_option *optp, int *err) SYNOPSIS init_one_value() - optp Option to initialize + option Option to initialize value Pointer to variable */ -static void init_one_value(const struct my_option *optp, uchar* *variable, +static void init_one_value(const struct my_option *option, uchar* *variable, longlong value) { DBUG_ENTER("init_one_value"); - switch ((optp->var_type & GET_TYPE_MASK)) { + switch ((option->var_type & GET_TYPE_MASK)) { case GET_BOOL: *((my_bool*) variable)= (my_bool) value; break; case GET_INT: - *((int*) variable)= (int) getopt_ll_limit_value(value, optp, NULL); - break; - case GET_UINT: - *((uint*) variable)= (uint) getopt_ull_limit_value(value, optp, NULL); + *((int*) variable)= (int) value; break; + case GET_UINT: /* Fall through */ case GET_ENUM: *((uint*) variable)= (uint) value; break; case GET_LONG: - *((long*) variable)= (long) getopt_ll_limit_value(value, optp, NULL); + *((long*) variable)= (long) value; break; case GET_ULONG: - *((ulong*) variable)= (ulong) getopt_ull_limit_value(value, optp, NULL); + *((ulong*) variable)= (ulong) value; break; case GET_LL: - *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp, - NULL); - break; - case GET_ULL: - *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value(value, optp, - NULL); + *((longlong*) variable)= (longlong) value; break; + case GET_ULL: /* Fall through */ case GET_SET: *((ulonglong*) variable)= (ulonglong) value; break; -- cgit v1.2.1 From e17a9a5b1e4f0282cb5eff847609cd7263780e55 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Dec 2007 00:15:29 +0100 Subject: after merge include/mysql/plugin.h: move declarations after merge mysql-test/r/change_user.result: more tests mysql-test/t/change_user.test: more tests mysys/my_getopt.c: remove wrong code BitKeeper/etc/ignore: Added libmysqld/sql_profile.cc to the ignore list --- mysys/my_getopt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 63ef57300fa..61716eae2c6 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -892,8 +892,6 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, num= ((ulonglong) ULONG_MAX); adjusted= TRUE; } -#else - num= min(num, LONG_MAX); #endif break; default: -- cgit v1.2.1 From 9a036c255164c2cd61ea0646fcaa559325e22ff0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Dec 2007 11:55:46 +0200 Subject: Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type Added --zerofill (-z) option to maria_chk (Mostly code from Jani) Added now table states ZEROFILLED and MOVEABLE Set state.changed with new states when things changes include/maria.h: Added maria_zerofill include/myisamchk.h: Added option for zerofill Extend testflag to be 64 to allow for more flags mysql-test/r/create.result: Updated results after merge mysql-test/r/maria.result: Updated results after merge mysys/my_getopt.c: Removed not used variable sql/sql_show.cc: Fixed wrong page type storage/maria/ma_blockrec.c: Renamed compact_page() to ma_compact_block_page() and made it global Always zerofill half filled blob pages Set share.state.changed on REDO storage/maria/ma_blockrec.h: Added _ma_compact_block_page() storage/maria/ma_check.c: Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type This gives the following benefits: - Table is smaller if compressed - All LSN are removed for transactinal tables and this makes them movable between systems Dont set table states of we are using --quick Changed log entry for repair to use 8 bytes for flag storage/maria/ma_delete.c: Simplify code Update state.changed storage/maria/ma_key_recover.c: Update state.changed storage/maria/ma_locking.c: Set uuid for file on first change if it's not set (table was cleared with zerofill) storage/maria/ma_loghandler.c: Updated log entry for REDO_REPAIR_TABLE storage/maria/ma_recovery.c: Updated log entry for REDO_REPAIR_TABLE (flag is now 8 bytes) Set new bits in state.changed storage/maria/ma_test_all.sh: Nicer output storage/maria/ma_test_recovery.expected: Updated results (now states flags are visible) storage/maria/ma_update.c: Update state.changed storage/maria/ma_write.c: Simplify code Set state.changed storage/maria/maria_chk.c: Added option --zerofill Added printing of states for MOVABLE and ZEROFILLED MYD -> MAD MYI -> MAI storage/maria/maria_def.h: Added states STATE_NOT_MOVABLE and STATE_NOT_ZEROFILLED Added prototype for new functions storage/maria/unittest/ma_test_all-t: More tests, including tests for zerofill Removed some not needed 'print' statements storage/maria/unittest/ma_test_loghandler_multithread-t.c: Smaller buffer to not trash devlopment machines totally --- mysys/my_getopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 61716eae2c6..e0cb771ee01 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -867,7 +867,7 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, bool *fix) { bool adjusted= FALSE; - ulonglong old= num, mod; + ulonglong old= num; char buf1[255], buf2[255]; if ((ulonglong) num > (ulonglong) optp->max_value && -- cgit v1.2.1 From 4ab4afde29e998e5d2b95255b82c0727be8f0a32 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 29 Nov 2008 00:27:13 +0100 Subject: Bug#34374: mysql generates incorrect warning an item was evaluated unnecessary, fix that by checking preconditions before evaluating the item sql/sql_select.cc: an item was evaluated unnecessary, fix that by checking preconditions before evaluating the item --- mysys/my_getopt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index ddb0a4d3ed5..059896f5081 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -39,8 +39,7 @@ static ulonglong getopt_ull(char *arg, const struct my_option *optp, static double getopt_double(char *arg, const struct my_option *optp, int *err); static void init_variables(const struct my_option *options, init_func_p init_one_value); -static void init_one_value(const struct my_option *option, uchar* *variable, - longlong value); +static void init_one_value(const struct my_option *opt, uchar* *, longlong); static void fini_one_value(const struct my_option *option, uchar* *variable, longlong value); static int setval(const struct my_option *opts, uchar **value, char *argument, -- cgit v1.2.1