summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-10-19 00:32:51 +0200
committerunknown <serg@janus.mylan>2007-10-19 00:32:51 +0200
commitfd4ca26dfc9f7b6783d568d319d61a7fefd21ee4 (patch)
tree7f090641023cec494a31ddd05c2109e96555147a
parent59b0303e8e1f458a9c9f7f125687eeb20a928d38 (diff)
downloadmariadb-git-fd4ca26dfc9f7b6783d568d319d61a7fefd21ee4.tar.gz
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()
-rw-r--r--include/m_string.h1
-rw-r--r--mysql-test/t/variables.test4
-rw-r--r--mysys/my_getopt.c32
-rw-r--r--strings/llstr.c7
4 files changed, 29 insertions, 15 deletions
diff --git a/include/m_string.h b/include/m_string.h
index 036eb8fe4d6..c24bfd7aa6c 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -203,6 +203,7 @@ double my_strtod(const char *str, char **end, int *error);
double my_atof(const char *nptr);
extern char *llstr(longlong value,char *buff);
+extern char *ullstr(longlong value,char *buff);
#ifndef HAVE_STRTOUL
extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base);
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 0952fc6d20c..e1ed89cea4e 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -141,9 +141,9 @@ set GLOBAL myisam_max_sort_file_size=2000000;
show global variables like 'myisam_max_sort_file_size';
select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size';
set GLOBAL myisam_max_sort_file_size=default;
---replace_result 2147482624 FILE_SIZE 9223372036853727232 FILE_SIZE
+--replace_result 2146435072 FILE_SIZE 9223372036853727232 FILE_SIZE
show variables like 'myisam_max_sort_file_size';
---replace_result 2147482624 FILE_SIZE 9223372036853727232 FILE_SIZE
+--replace_result 2146435072 FILE_SIZE 9223372036853727232 FILE_SIZE
select * from information_schema.session_variables where variable_name like 'myisam_max_sort_file_size';
set global net_retry_count=10, session net_retry_count=10;
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 <mysys_err.h>
#include <my_getopt.h>
-#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);
diff --git a/strings/llstr.c b/strings/llstr.c
index 12aea63e014..678f8b05f39 100644
--- a/strings/llstr.c
+++ b/strings/llstr.c
@@ -32,3 +32,10 @@ char *llstr(longlong value,char *buff)
longlong10_to_str(value,buff,-10);
return buff;
}
+
+char *ullstr(longlong value,char *buff)
+{
+ longlong10_to_str(value,buff,10);
+ return buff;
+}
+