From f1d92c4397bd848b5c761cfcbf3a1d195934c03d 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 fd4ca26dfc9f7b6783d568d319d61a7fefd21ee4 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 be71f3ccb61d3c4f1ebc096ba4e5e1563f578681 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 efd91dff2cb010e792bea1e812d95513be24504a 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 4140f76f4e50a0497c8d325fef7e255bb5cf4e68 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 6cad02044072403c652e2da9a3cc0dfd9713f1e6 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 f1906c62d563fa1502e68a7d9854313560474be9 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 From ae134314b8cc35531472cf8af999fec464ad8efa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 May 2009 17:34:34 +0200 Subject: Fix accessing ulong enum option as uint, failing on 64-bit big-endian. --- mysys/my_getopt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index da7e997d629..0de80b01c4f 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -647,7 +647,7 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(int*)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0) + if (((*(ulong *)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0) return EXIT_ARGUMENT_INVALID; break; case GET_SET: @@ -983,7 +983,7 @@ static void init_one_value(const struct my_option *option, uchar* *variable, *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL); break; case GET_ENUM: - *((uint*) variable)= (uint) value; + *((ulong*) variable)= (uint) value; break; case GET_UINT: *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL); @@ -1221,7 +1221,7 @@ void my_print_variables(const struct my_option *options) } break; case GET_ENUM: - printf("%s\n", get_type(optp->typelib, *(uint*) value)); + printf("%s\n", get_type(optp->typelib, *(ulong*) value)); break; case GET_STR: case GET_STR_ALLOC: /* fall through */ -- cgit v1.2.1 From 03db11cfdaabc27b57de342eb4974195745f90d6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Sep 2009 15:05:02 +0200 Subject: MBug#423035: error in parsing enum value for plugin variable in mysqld command-line option Fix parsing of invalid plugin enum option value. Previous patch to fix plugin enum option parsing on big-endian introduced another bug due to incorrect comparison of unsigned value. This would cause an incorrect value to be parsed as value 0. See also MySQL Bug#41010 and Bug#32034. mysql-test/mysql-test-run.pl: Add a facility for test case to run the mysqld binary (to test that invalid startup options are rejected correctly). mysql-test/r/mysqld_option_err.result: Add a test case to check that invalid startup options for mysqld are rejected. This is needed to test MBug#423035. Also add a few other similar tests, as this was completely untested before this patch. mysql-test/t/mysqld_option_err.test: Add a test case to check that invalid startup options for mysqld are rejected. This is needed to test MBug#423035. Also add a few other similar tests, as this was completely untested before this patch. mysys/my_getopt.c: Fix parsing of invalid plugin enum option value. --- mysys/my_getopt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0de80b01c4f..d44ec162b93 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -603,6 +603,7 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, my_bool set_maximum_value) { int err= 0; + int pos; if (value && argument) { @@ -647,7 +648,9 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(ulong *)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0) + pos= find_type(argument, opts->typelib, 2) - 1; + (*(ulong *)result_pos)= pos; + if (pos < 0) return EXIT_ARGUMENT_INVALID; break; case GET_SET: -- cgit v1.2.1 From 829c6099b7e0a9eb689456db4160362d1e1c8011 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Sep 2009 15:20:03 +0200 Subject: After-merge fix for MySQL 5.1.38 merge into MariaDB. Due to a bugfix for enum options in MariaDB, my_getopt parses enums into an ulong. However, some new code from MySQL was written to assume enums take an uint. Fix by using the correct type. (The new MySQL code in addition had an implicit assumption that my_bool and uint were compatible; remove this assumption). --- mysys/my_getopt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index e57c1d71a13..ceb99975cdb 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -414,11 +414,17 @@ invalid value '%s'", (optp->var_type & GET_TYPE_MASK) == GET_ENUM)) { if (optend == disabled_my_option) - *((my_bool*) value)= (my_bool) 0; + if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL) + *((my_bool*) value)= (my_bool) 0; + else + *((ulong*) value)= (ulong) 0; else { if (!optend) /* No argument -> enable option */ - *((my_bool*) value)= (my_bool) 1; + if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL) + *((my_bool*) value)= (my_bool) 1; + else + *((ulong*) value)= (ulong) 1; else argument= optend; } -- cgit v1.2.1 From e8d7e27fedf9db7e9143fe8eb2b6560696a1fea8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Sep 2009 14:53:07 +0200 Subject: More after-merge fixes for merging MySQL 5.1.38 into MariaDB. mysql-test/t/mysqldump.test: Make test case work when build directory is not world readable (this is the case for Buildbot checkouts). mysys/my_getopt.c: Restore bugfix which was lost in previous merge. storage/xtradb/buf/buf0flu.c: Fix extranous line caused by bad merge. --- mysys/my_getopt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 46e07fda32e..5a06b18d4b8 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -656,8 +656,9 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(ulong *)result_pos)= - find_type(argument, opts->typelib, 2) - 1) < 0) + pos= find_type(argument, opts->typelib, 2) - 1; + (*(ulong *)result_pos)= pos; + if (pos < 0) { /* Accept an integer representation of the enumerated item. -- cgit v1.2.1 From 165eb1186cb6f8e9a9595ffd7c172c54a6dfb6dc Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 7 Aug 2010 15:27:23 +0300 Subject: Added extra argument to longlong2str() to make it have same prototype is int2str() Changed to use longlong10_to_str() instead of longlong2str() when base is 10 or -10 as former is much faster than later Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit. client/mysqltest.cc: longlong2str() -> longlong10_to_str() include/m_string.h: Added extra argument to longlong2str() to make it have same prototype is int2str() mysys/charset.c: Fixed compiler warning mysys/mf_soundex.c: Fixed compiler warning mysys/my_getopt.c: longlong2str() -> longlong10_to_str() sql/create_options.cc: Fixed compiler warning sql/item_strfunc.cc: Added extra argument to longlong2str sql/opt_range.cc: longlong2str() -> longlong10_to_str() sql/partition_info.cc: longlong2str() -> longlong10_to_str() sql/slave.cc: longlong2str() -> longlong10_to_str() sql/sql_bitmap.h: Added extra argument to longlong2str sql/sql_partition.cc: Added extra argument to longlong2str sql/sql_select.cc: longlong2str() -> longlong10_to_str() sql/sql_show.cc: Added extra argument to longlong2str storage/innodb_plugin/handler/ha_innodb.cc: Update to new parameters for longlong2str() storage/maria/ma_dbug.c: longlong2str() -> longlong10_to_str() storage/maria/maria_chk.c: Added extra argument to longlong2str storage/myisam/mi_dbug.c: longlong2str() -> longlong10_to_str() storage/myisam/myisamchk.c: Added extra argument to longlong2str storage/xtradb/handler/ha_innodb.cc: Update to new parameters for longlong2str() strings/longlong2str.c: Added extra argument to longlong2str() to make it have same prototype is int2str() strings/my_vsnprintf.c: Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit. Added cast to get rid of compiler warnings --- 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 82a691d550a..b8a5c5d14bd 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -1271,7 +1271,7 @@ void my_print_variables(const struct my_option *options) printf("%s\n", llstr(*((longlong*) value), buff)); break; case GET_ULL: - longlong2str(*((ulonglong*) value), buff, 10); + longlong10_to_str(*((ulonglong*) value), buff, 10); printf("%s\n", buff); break; case GET_DOUBLE: -- cgit v1.2.1 From 20acfbf30da2eca66f9e5d602d50ac18e38272b8 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 2 Nov 2010 17:22:57 +0200 Subject: Fix for: LP #634955: Assert in _ma_update_at_original_place() Added locking of lock mutex when updating status in external_unlock() for Aria and MyISAM tables. Fixed that 'source' command doesn't cause mysql command line tool to exit on error. DEBUG_EXECUTE() and DEBUG_EVALUATE_IF() should not execute things based on wildcards. (Allows one to run --debug with mysql-test-run scripts that uses @debug) Fixed several core dump, deadlock and crashed table bugs in handling of LOCK TABLE with MERGE tables: - Added priority of locks to avoid crashes with MERGE tables. - Added thr_lock_merge() to allow one to merge two results of thr_lock(). Fixed 'not found row' bug in REPLACE with Aria tables. Mark MyISAM tables that are part of MERGE with HA_OPEN_MERGE_TABLE and set the locks to have priority THR_LOCK_MERGE_PRIV. - By sorting MERGE tables last in thr_multi_unlock() it's safer to release and relock them many times (can happen when TRIGGERS are created) Avoid printing (null) in debug file (to easier find out wrong NULL pointer usage with %s). client/mysql.cc: Fixed that 'source' command doesn't cause mysql command line tool to exit on error. client/mysqltest.cc: Don't send NULL to fn_format(). (Can cause crash on Solaris when using --debug) dbug/dbug.c: DEBUG_EXECUTE() and DEBUG_EVALUATE_IF() should not execute things based on wildcards. include/my_base.h: Added flag to signal if one opens a MERGE table. Added extra() command to signal that one is not part of a MERGE table anymore. include/thr_lock.h: Added priority for locks (needed to fix bug in thr_lock when using MERGE tables) Added option to thr_unlock() if get_status() should be called. Added prototype for thr_merge_locks(). mysql-test/mysql-test-run.pl: Ignore crashed table warnings for tables named 'crashed'. mysql-test/r/merge.result: Renamed triggers to make debugging easier. Added some CHECK TABLES to catch errors earlier. Additional tests. mysql-test/r/merge_debug.result: Test of error handling when reopening MERGE tables. mysql-test/r/udf_query_cache.result: Added missing flush status mysql-test/suite/parts/r/partition_repair_myisam.result: Update results mysql-test/t/merge.test: Renamed triggers to make debugging easier. Added some CHECK TABLES to catch errors earlier. Additional tests. mysql-test/t/merge_debug.test: Test of error handling when reopening MERGE tables. mysql-test/t/udf_query_cache.test: Added missing flush status mysys/my_getopt.c: Removed not used variable mysys/my_symlink2.c: Changed (null) to (NULL) to make it easier to find NULL arguments to DBUG_PRINT() functions. (On linux, NULL to sprintf is printed 'null') mysys/thr_lock.c: Added priority of locks to avoid crashes with MERGE tables. Added thr_lock_merge() to allow one to merge two results of thr_lock(). - This is needed for MyISAM as all locked table must share the same status. If not, you will not see newly inserted rows in other instances of the table. If calling thr_unlock() with THR_UNLOCK_UPDATE_STATUS, call update_status() and restore_status() for the locks. This is needed in some rare cases where we call thr_unlock() followed by thr_lock() without calling external_unlock/external_lock in between. Simplify loop in thr_multi_lock(). Added 'start_trans', which is called at end of thr_multi_lock() when all locks are taken. - This was needed by Aria to ensure that transaction is started when we got all locks, not at get_status(). Without this, some rows could not be visible when we lock two tables at the same time, causing REPLACE using two tables to fail unexpectedly. sql/handler.cc: Add an assert() in handler::print_error() for "impossible errors" (like table is crashed) when --debug-assert-if-crashed-table is used. sql/lock.cc: Simplify mysql_lock_tables() code if get_lock_data() returns 0 locks. Added new parameter to thr_multi_unlock() In mysql_unlock_read_tables(), call first externa_unlock(), then thr_multi_unlock(); This is same order as we do in mysql_unlock_tables(). Don't abort locks in mysql_lock_abort() for merged tables when a MERGE table is deleted; Would cause a spin lock. Added call to thr_merge_locks() in mysql_lock_merge() to ensure consistency in thr_locks(). - New locks of same type and table is stored after the old lock to ensure that we get the status from the original lock. sql/mysql_priv.h: Added debug_assert_if_crashed_table sql/mysqld.cc: Added --debug-assert-if-crashed-table sql/parse_file.cc: Don't print '(null)' in DBUG_PRINT of no dir given sql/set_var.cc: Increase default size of buffer for @debug variable. sql/sql_base.cc: In case of error from reopen_table() in reopen_tables(), call unlock_open_table() and restart loop. - This fixed bug when we twice deleted same table from open_cache. Don't take name lock for already name locked table in open_unireg_entry(). - Fixed bug when doing repair in reopen_table(). - In detach_merge_children(), always detach if 'clear_refs' is given. We can't trust parent->children_attached as this function can be called twice, first time with clear_refs set to 0. sql/sql_class.cc: Changed printing of (null) to "" in set_thd_proc_info() sql/sql_parse.cc: Added DBUG sql/sql_trigger.cc: Don't call unlink_open_table() if reopen_table() fails as the table may already be freed. storage/maria/ma_bitmap.c: Fixed DBUG_ASSERT() in allocate_tail() storage/maria/ma_blockrec.c: Fixed wrong calculation of row length for very small rows in undo_row_update(). - Fixes ASSERT() when doing undo. storage/maria/ma_blockrec.h: Added _ma_block_start_trans() and _ma_block_start_trans_no_versioning() storage/maria/ma_locking.c: Call _ma_update_status_with_lock() when releasing write locks. - Fixes potential problem with updating status without the proper lock. storage/maria/ma_open.c: Changed to use start_trans() instead of get_status() to ensure that we see all rows in all locked tables when we got the locks. - Fixed 'not found row' bug in REPLACE with Aria tables. storage/maria/ma_state.c: Added _ma_update_status_with_lock() and _ma_block_start_trans(). This is to ensure that we see all rows in all locked tables when we got the locks. storage/maria/ma_state.h: Added _ma_update_status_with_lock() storage/maria/ma_write.c: More DBUG_PRINT storage/myisam/mi_check.c: Fixed error message storage/myisam/mi_extra.c: Added HA_EXTRA_DETACH_CHILD: - Detach MyISAM table to not be part of MERGE table (remove flag & lock priority). storage/myisam/mi_locking.c: Call mi_update_status_with_lock() when releasing write locks. - Fixes potential problem with updating status without the proper lock. Change to use new HA_OPEN_MERGE_TABLE flag to test if MERGE table. Added mi_fix_status(), called by thr_merge(). storage/myisam/mi_open.c: Added marker if part of MERGE table. Call mi_fix_status() in thr_lock() for transactional tables. storage/myisam/myisamdef.h: Change my_once_flag to uint, as it stored different values than just 0/1 Added 'open_flag' to store state given to mi_open() storage/myisammrg/ha_myisammrg.cc: Add THR_LOCK_MERGE_PRIV to THR_LOCK_DATA to get MERGE locks sorted after other types of locks. storage/myisammrg/myrg_locking.c: Remove windows specific code. storage/myisammrg/myrg_open.c: Use HA_OPEN_MERGE_TABLE to mi_open(). Set HA_OPEN_MERGE_TABLE for linked MyISAM tables. storage/xtradb/buf/buf0buf.c: Fixed compiler warning storage/xtradb/buf/buf0lru.c: Initialize variable that could be used not initialized. --- mysys/my_getopt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'mysys/my_getopt.c') diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index f9a2c17ae7c..7281f2e1420 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -614,7 +614,6 @@ static int setval(const struct my_option *opts, void *value, char *argument, my_bool set_maximum_value) { int err= 0; - int pos; if (value && argument) { -- cgit v1.2.1