List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:November 30 2007 5:32am
Subject:bk commit into 5.0 tree (tnurnberg:1.2557) BUG#31177
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of tnurnberg. When tnurnberg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-30 06:32:04+01:00, tnurnberg@stripped +21 -0
  Bug#31177: Server variables can't be set to their current values
  
  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@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +7 -6
    correct maxima in options array

  client/mysqltest.c@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +1 -1
    adjust minimum for "sleep" option so default value is no longer
    out of bounds.

  include/m_string.h@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +1 -0
    ullstr() - the unsigned brother of llstr()

  include/my_getopt.h@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -1
    Flag if we bounded the value (that is, correct anything aside from
    making value a multiple of block-size)

  mysql-test/r/delayed.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +16 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/index_merge.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/innodb.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +4 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/innodb_mysql.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/key_cache.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/packet.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +8 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/ps.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/subselect.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +4 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/type_bit.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/type_bit_innodb.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +2 -0
    We throw a warning now when we adjust out of range parameters.

  mysql-test/r/variables.result@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +28 -2
    correct results: bounds and step apply to variables' default values, too

  mysql-test/t/variables.test@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +1 -1
    correct results: bounds and step apply to variables' default values, too

  mysys/my_getopt.c@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +127 -48
    - 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@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +1 -1
    correct RANGE_ALLOC_BLOCK_SIZE (cleared with monty)

  sql/mysqld.cc@stripped, 2007-11-30 06:32:02+01:00, tnurnberg@stripped +41 -39
    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@stripped, 2007-11-30 06:32:03+01:00, tnurnberg@stripped +48 -22
    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@stripped, 2007-11-30 06:32:03+01:00, tnurnberg@stripped +6 -0
    ullstr() - the unsigned brother of llstr()

diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc	2007-09-24 11:33:22 +02:00
+++ b/client/mysql.cc	2007-11-30 06:32:02 +01:00
@@ -737,9 +737,9 @@ static struct my_option my_long_options[
    0, 1},
   {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
    "Max packet length to send to, or receive from server",
-   (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG,
-   REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,
-   MALLOC_OVERHEAD, 1024, 0},
+   (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0,
+   GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
+   (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
   {"net_buffer_length", OPT_NET_BUFFER_LENGTH,
    "Buffer for TCP/IP and socket communication",
    (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG,
@@ -747,12 +747,13 @@ static struct my_option my_long_options[
   {"select_limit", OPT_SELECT_LIMIT,
    "Automatic limit for SELECT when using --safe-updates",
    (gptr*) &select_limit,
-   (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
+   (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
+   0, 1, 0},
   {"max_join_size", OPT_MAX_JOIN_SIZE,
    "Automatic limit for rows in a join when using --safe-updates",
    (gptr*) &max_join_size,
-   (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
-   0},
+   (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
+   0, 1, 0},
   {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
     " uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth,
     (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
diff -Nrup a/client/mysqltest.c b/client/mysqltest.c
--- a/client/mysqltest.c	2007-10-05 18:18:47 +02:00
+++ b/client/mysqltest.c	2007-11-30 06:32:02 +01:00
@@ -4986,7 +4986,7 @@ static struct my_option my_long_options[
    "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
    0, 0, 0, 0, 0, 0},
   {"sleep", 'T', "Sleep always this many seconds on sleep commands.",
-   (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0,
+   (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
    0, 0, 0},
   {"socket", 'S', "Socket file to use for connection.",
    (gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
diff -Nrup a/include/m_string.h b/include/m_string.h
--- a/include/m_string.h	2007-05-30 20:47:50 +02:00
+++ b/include/m_string.h	2007-11-30 06:32:02 +01:00
@@ -219,6 +219,7 @@ double my_strtod(const char *str, char *
 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 -Nrup a/include/my_getopt.h b/include/my_getopt.h
--- a/include/my_getopt.h	2006-12-30 21:02:04 +01:00
+++ b/include/my_getopt.h	2007-11-30 06:32:02 +01:00
@@ -67,7 +67,8 @@ extern void my_print_variables(const str
 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);
+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
diff -Nrup a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
--- a/mysql-test/r/delayed.result	2007-03-20 14:53:54 +01:00
+++ b/mysql-test/r/delayed.result	2007-11-30 06:32:02 +01:00
@@ -109,12 +109,20 @@ c1
 DROP TABLE t1;
 SET             @@auto_increment_offset=
 @bug20627_old_auto_increment_offset;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-offset value: '0'
 SET             @@auto_increment_increment=
 @bug20627_old_auto_increment_increment;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-increment value: '0'
 SET             @@session.auto_increment_offset=
 @bug20627_old_session_auto_increment_offset;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-offset value: '0'
 SET             @@session.auto_increment_increment=
 @bug20627_old_session_auto_increment_increment;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-increment value: '0'
 SET @bug20830_old_auto_increment_offset=
 @@auto_increment_offset= 2;
 SET @bug20830_old_auto_increment_increment=
@@ -237,12 +245,20 @@ SUM(c1)
 DROP TABLE t1;
 SET             @@auto_increment_offset=
 @bug20830_old_auto_increment_offset;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-offset value: '0'
 SET             @@auto_increment_increment=
 @bug20830_old_auto_increment_increment;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-increment value: '0'
 SET             @@session.auto_increment_offset=
 @bug20830_old_session_auto_increment_offset;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-offset value: '0'
 SET             @@session.auto_increment_increment=
 @bug20830_old_session_auto_increment_increment;
+Warnings:
+Warning	1292	Truncated incorrect auto-increment-increment value: '0'
 CREATE TABLE t1(a BIT);
 INSERT DELAYED INTO t1 VALUES(1);
 FLUSH TABLE t1;
diff -Nrup a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result
--- a/mysql-test/r/index_merge.result	2007-07-14 20:02:07 +02:00
+++ b/mysql-test/r/index_merge.result	2007-11-30 06:32:02 +01:00
@@ -340,6 +340,8 @@ create table t4 (a int);
 insert into t4 values (1),(4),(3);
 set @save_join_buffer_size=@@join_buffer_size;
 set join_buffer_size= 4000;
+Warnings:
+Warning	1292	Truncated incorrect join_buffer_size value: '4000'
 explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) 
 from t0 as A force index(i1,i2), t0 as B force index (i1,i2) 
 where (A.key1 < 500000 or A.key2 < 3)
diff -Nrup a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
--- a/mysql-test/r/innodb.result	2007-07-18 14:22:00 +02:00
+++ b/mysql-test/r/innodb.result	2007-11-30 06:32:02 +01:00
@@ -1833,6 +1833,8 @@ show variables like "innodb_thread_concu
 Variable_name	Value
 innodb_thread_concurrency	8
 set global innodb_thread_concurrency=1001;
+Warnings:
+Warning	1292	Truncated incorrect innodb_thread_concurrency value: '1001'
 show variables like "innodb_thread_concurrency";
 Variable_name	Value
 innodb_thread_concurrency	1000
@@ -1852,6 +1854,8 @@ show variables like "innodb_concurrency_
 Variable_name	Value
 innodb_concurrency_tickets	1000
 set global innodb_concurrency_tickets=0;
+Warnings:
+Warning	1292	Truncated incorrect innodb_concurrency_tickets value: '0'
 show variables like "innodb_concurrency_tickets";
 Variable_name	Value
 innodb_concurrency_tickets	1
diff -Nrup a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
--- a/mysql-test/r/innodb_mysql.result	2007-10-10 21:15:39 +02:00
+++ b/mysql-test/r/innodb_mysql.result	2007-11-30 06:32:02 +01:00
@@ -712,6 +712,8 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2;
 UPDATE t2 SET c='2007-01-03';
 INSERT INTO t1(b,c) SELECT b,c FROM t2;
 set @@sort_buffer_size=8192;
+Warnings:
+Warning	1292	Truncated incorrect sort_buffer_size value: '8192'
 SELECT COUNT(*) FROM t1;
 COUNT(*)
 3072
diff -Nrup a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
--- a/mysql-test/r/key_cache.result	2007-06-06 01:42:39 +02:00
+++ b/mysql-test/r/key_cache.result	2007-11-30 06:32:02 +01:00
@@ -276,6 +276,8 @@ Variable_name	Value
 Key_blocks_unused	KEY_BLOCKS_UNUSED
 set global keycache2.key_buffer_size=0;
 set global keycache3.key_buffer_size=100;
+Warnings:
+Warning	1292	Truncated incorrect key_buffer_size value: '100'
 set global keycache3.key_buffer_size=0;
 create table t1 (mytext text, FULLTEXT (mytext));
 insert t1 values ('aaabbb');
diff -Nrup a/mysql-test/r/packet.result b/mysql-test/r/packet.result
--- a/mysql-test/r/packet.result	2004-07-21 18:27:42 +02:00
+++ b/mysql-test/r/packet.result	2007-11-30 06:32:02 +01:00
@@ -1,7 +1,15 @@
 set global max_allowed_packet=100;
+Warnings:
+Warning	1292	Truncated incorrect max_allowed_packet value: '100'
 set max_allowed_packet=100;
+Warnings:
+Warning	1292	Truncated incorrect max_allowed_packet value: '100'
 set global net_buffer_length=100;
+Warnings:
+Warning	1292	Truncated incorrect net_buffer_length value: '100'
 set net_buffer_length=100;
+Warnings:
+Warning	1292	Truncated incorrect net_buffer_length value: '100'
 SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
 len
 1024
diff -Nrup a/mysql-test/r/ps.result b/mysql-test/r/ps.result
--- a/mysql-test/r/ps.result	2007-06-07 09:07:38 +02:00
+++ b/mysql-test/r/ps.result	2007-11-30 06:32:02 +01:00
@@ -806,6 +806,8 @@ select @@max_prepared_stmt_count;
 @@max_prepared_stmt_count
 0
 set global max_prepared_stmt_count=10000000000000000;
+Warnings:
+Warning	1292	Truncated incorrect max_prepared_stmt_count value: '10000000000000000'
 select @@max_prepared_stmt_count;
 @@max_prepared_stmt_count
 1048576
diff -Nrup a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
--- a/mysql-test/r/subselect.result	2007-06-29 09:39:15 +02:00
+++ b/mysql-test/r/subselect.result	2007-11-30 06:32:02 +01:00
@@ -3666,6 +3666,8 @@ CREATE TABLE t1 (a int, b int auto_incre
 CREATE TABLE t2 (x int auto_increment, y int, z int,
 PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b));
 SET SESSION sort_buffer_size = 32 * 1024;
+Warnings:
+Warning	1292	Truncated incorrect sort_buffer_size value: '32768'
 SELECT SQL_NO_CACHE COUNT(*) 
 FROM (SELECT  a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
 FROM t1) t;
@@ -4101,6 +4103,8 @@ INSERT INTO `t1` VALUES ('asdf','2007-02
 INSERT INTO `t2` VALUES ('abcdefghijk');
 INSERT INTO `t2` VALUES ('asdf');
 SET session sort_buffer_size=8192;
+Warnings:
+Warning	1292	Truncated incorrect sort_buffer_size value: '8192'
 SELECT (SELECT 1 FROM  t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2;
 d1
 1
diff -Nrup a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
--- a/mysql-test/r/type_bit.result	2007-09-14 12:53:11 +02:00
+++ b/mysql-test/r/type_bit.result	2007-11-30 06:32:02 +01:00
@@ -269,6 +269,8 @@ a+0	b+0
 56	379
 68	454
 set @@max_length_for_sort_data=0;
+Warnings:
+Warning	1292	Truncated incorrect max_length_for_sort_data value: '0'
 select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
 a+0	b+0
 57	135
diff -Nrup a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result
--- a/mysql-test/r/type_bit_innodb.result	2007-01-18 12:28:32 +01:00
+++ b/mysql-test/r/type_bit_innodb.result	2007-11-30 06:32:02 +01:00
@@ -269,6 +269,8 @@ a+0	b+0
 56	379
 68	454
 set @@max_length_for_sort_data=0;
+Warnings:
+Warning	1292	Truncated incorrect max_length_for_sort_data value: '0'
 select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
 a+0	b+0
 57	135
diff -Nrup a/mysql-test/r/variables.result b/mysql-test/r/variables.result
--- a/mysql-test/r/variables.result	2007-10-29 08:25:37 +01:00
+++ b/mysql-test/r/variables.result	2007-11-30 06:32:02 +01:00
@@ -214,6 +214,8 @@ net_read_timeout	600
 net_retry_count	10
 net_write_timeout	500
 set net_buffer_length=1;
+Warnings:
+Warning	1292	Truncated incorrect net_buffer_length value: '1'
 show variables like 'net_buffer_length';
 Variable_name	Value
 net_buffer_length	1024
@@ -238,7 +240,7 @@ show variables like '%alloc%';
 Variable_name	Value
 query_alloc_block_size	8192
 query_prealloc_size	8192
-range_alloc_block_size	2048
+range_alloc_block_size	4096
 transaction_alloc_block_size	8192
 transaction_prealloc_size	4096
 set @@range_alloc_block_size=1024*16;
@@ -263,7 +265,7 @@ show variables like '%alloc%';
 Variable_name	Value
 query_alloc_block_size	8192
 query_prealloc_size	8192
-range_alloc_block_size	2048
+range_alloc_block_size	4096
 transaction_alloc_block_size	8192
 transaction_prealloc_size	4096
 SELECT @@version LIKE 'non-existent';
@@ -321,6 +323,8 @@ select @@autocommit, @@big_tables;
 @@autocommit	@@big_tables
 1	1
 set global binlog_cache_size=100;
+Warnings:
+Warning	1292	Truncated incorrect binlog_cache_size value: '100'
 set bulk_insert_buffer_size=100;
 set character set cp1251_koi8;
 set character set default;
@@ -349,17 +353,27 @@ set global flush_time=100;
 set insert_id=1;
 set interactive_timeout=100;
 set join_buffer_size=100;
+Warnings:
+Warning	1292	Truncated incorrect join_buffer_size value: '100'
 set last_insert_id=1;
 set global local_infile=1;
 set long_query_time=100;
 set low_priority_updates=1;
 set max_allowed_packet=100;
+Warnings:
+Warning	1292	Truncated incorrect max_allowed_packet value: '100'
 set global max_binlog_cache_size=100;
+Warnings:
+Warning	1292	Truncated incorrect max_binlog_cache_size value: '100'
 set global max_binlog_size=100;
+Warnings:
+Warning	1292	Truncated incorrect max_binlog_size value: '100'
 set global max_connect_errors=100;
 set global max_connections=100;
 set global max_delayed_threads=100;
 set max_heap_table_size=100;
+Warnings:
+Warning	1292	Truncated incorrect max_heap_table_size value: '100'
 set max_join_size=100;
 set max_sort_length=100;
 set max_tmp_tables=100;
@@ -370,17 +384,25 @@ select @@max_user_connections;
 set global max_write_lock_count=100;
 set myisam_sort_buffer_size=100;
 set net_buffer_length=100;
+Warnings:
+Warning	1292	Truncated incorrect net_buffer_length value: '100'
 set net_read_timeout=100;
 set net_write_timeout=100;
 set global query_cache_limit=100;
 set global query_cache_size=100;
 set global query_cache_type=demand;
 set read_buffer_size=100;
+Warnings:
+Warning	1292	Truncated incorrect read_buffer_size value: '100'
 set read_rnd_buffer_size=100;
+Warnings:
+Warning	1292	Truncated incorrect read_rnd_buffer_size value: '100'
 set global rpl_recovery_rank=100;
 set global server_id=100;
 set global slow_launch_time=100;
 set sort_buffer_size=100;
+Warnings:
+Warning	1292	Truncated incorrect sort_buffer_size value: '100'
 set @@max_sp_recursion_depth=10;
 select @@max_sp_recursion_depth;
 @@max_sp_recursion_depth
@@ -420,6 +442,8 @@ set storage_engine=myisam;
 set global thread_cache_size=100;
 set timestamp=1, timestamp=default;
 set tmp_table_size=100;
+Warnings:
+Warning	1292	Truncated incorrect tmp_table_size value: '100'
 set tx_isolation="READ-COMMITTED";
 set wait_timeout=100;
 set log_warnings=1;
@@ -570,6 +594,8 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER
 Variable_name	Value
 myisam_data_pointer_size	7
 SET GLOBAL table_cache=-1;
+Warnings:
+Warning	1292	Truncated incorrect table_cache value: '0'
 SHOW VARIABLES LIKE 'table_cache';
 Variable_name	Value
 table_cache	1
diff -Nrup a/mysql-test/t/variables.test b/mysql-test/t/variables.test
--- a/mysql-test/t/variables.test	2007-10-29 08:25:37 +01:00
+++ b/mysql-test/t/variables.test	2007-11-30 06:32:02 +01:00
@@ -126,7 +126,7 @@ set GLOBAL query_cache_size=100000;
 set GLOBAL myisam_max_sort_file_size=2000000;
 show global variables like 'myisam_max_sort_file_size';
 set GLOBAL myisam_max_sort_file_size=default;
---replace_result 2147483647 FILE_SIZE 9223372036854775807 FILE_SIZE
+--replace_result 2147482624 FILE_SIZE 2146435072 FILE_SIZE
 show variables like 'myisam_max_sort_file_size';
 
 set global net_retry_count=10, session net_retry_count=10;
diff -Nrup a/mysys/my_getopt.c b/mysys/my_getopt.c
--- a/mysys/my_getopt.c	2007-10-04 10:33:56 +02:00
+++ b/mysys/my_getopt.c	2007-11-30 06:32:02 +01:00
@@ -31,6 +31,7 @@ my_bool getopt_compare_strings(const cha
 			       const char *t,
 			       uint length);
 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 *arg, const struct my_option *optp,
 			    int *err);
 static void init_variables(const struct my_option *options);
@@ -70,6 +71,7 @@ static void default_reporter(enum loglev
     fprintf(stderr, "%s", "Info: ");
   vfprintf(stderr, format, args);
   va_end(args);
+  fputc('\n', stderr);
   fflush(stderr);
 }
 
@@ -133,7 +135,7 @@ int handle_options(int *argc, char ***ar
 	    {
 	      if (my_getopt_print_errors)
                 my_getopt_error_reporter(ERROR_LEVEL,
-                                         "%s: Option '-O' requires an argument\n",
+                                         "%s: Option '-O' requires an argument",
                                          my_progname);
 	      return EXIT_ARGUMENT_REQUIRED;
 	    }
@@ -151,7 +153,7 @@ int handle_options(int *argc, char ***ar
 	    {
 	      if (my_getopt_print_errors)
                 my_getopt_error_reporter(ERROR_LEVEL,
-                                         "%s: Option '--set-variable' requires an argument\n",
+                                         "%s: Option '--set-variable' requires an argument",
                                          my_progname);
 	      return EXIT_ARGUMENT_REQUIRED;
 	    }
@@ -165,7 +167,7 @@ int handle_options(int *argc, char ***ar
 	    {
 	      if (my_getopt_print_errors)
                 my_getopt_error_reporter(ERROR_LEVEL,
-                                         "%s: Option '--set-variable' requires an argument\n",
+                                         "%s: Option '--set-variable' requires an argument",
                                          my_progname);
 	      return EXIT_ARGUMENT_REQUIRED;
 	    }
@@ -228,7 +230,7 @@ int handle_options(int *argc, char ***ar
 		  {
 		    if (my_getopt_print_errors)
                       my_getopt_error_reporter(ERROR_LEVEL,
-                                               "%s: ambiguous option '--%s-%s' (--%s-%s)\n",
+                                               "%s: ambiguous option '--%s-%s' (--%s-%s)",
                                                my_progname, special_opt_prefix[i],
                                                cur_arg, special_opt_prefix[i],
                                                prev_found);
@@ -265,7 +267,7 @@ int handle_options(int *argc, char ***ar
 	      if (my_getopt_print_errors)
                 my_getopt_error_reporter(option_is_loose ? 
                                            WARNING_LEVEL : ERROR_LEVEL,
-                                         "%s: unknown variable '%s'\n",
+                                         "%s: unknown variable '%s'",
                                          my_progname, cur_arg);
 	      if (!option_is_loose)
 		return EXIT_UNKNOWN_VARIABLE;
@@ -273,9 +275,9 @@ int handle_options(int *argc, char ***ar
 	    else
 	    {
 	      if (my_getopt_print_errors)
-                my_getopt_error_reporter(option_is_loose ? 
+                my_getopt_error_reporter(option_is_loose ?
                                            WARNING_LEVEL : ERROR_LEVEL,
-                                         "%s: unknown option '--%s'\n", 
+                                         "%s: unknown option '--%s'",
                                          my_progname, cur_arg);
 	      if (!option_is_loose)
 		return EXIT_UNKNOWN_OPTION;
@@ -293,7 +295,7 @@ int handle_options(int *argc, char ***ar
 	  {
 	    if (my_getopt_print_errors)
               my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: variable prefix '%s' is not unique\n",
+                                       "%s: variable prefix '%s' is not unique",
                                        my_progname, opt_str);
 	    return EXIT_VAR_PREFIX_NOT_UNIQUE;
 	  }
@@ -301,7 +303,7 @@ int handle_options(int *argc, char ***ar
 	  {
 	    if (my_getopt_print_errors)
               my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: ambiguous option '--%s' (%s, %s)\n",
+                                       "%s: ambiguous option '--%s' (%s, %s)",
                                        my_progname, opt_str, prev_found, 
                                        optp->name);
 	    return EXIT_AMBIGUOUS_OPTION;
@@ -324,7 +326,7 @@ int handle_options(int *argc, char ***ar
 	{
 	  if (my_getopt_print_errors)
             my_getopt_error_reporter(ERROR_LEVEL, 
-                                     "%s: option '%s' cannot take an argument\n",
+                                     "%s: option '%s' cannot take an argument",
                                      my_progname, optp->name);
 	  return EXIT_NO_ARGUMENT_ALLOWED;
 	}
@@ -337,7 +339,7 @@ int handle_options(int *argc, char ***ar
 	  {
 	    if (my_getopt_print_errors)
               my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: option '--%s' cannot take an argument\n",
+                                       "%s: option '--%s' cannot take an argument",
                                        my_progname, optp->name);
 	    return EXIT_NO_ARGUMENT_ALLOWED;
 	  }
@@ -359,7 +361,7 @@ int handle_options(int *argc, char ***ar
 	    {
 	      my_getopt_error_reporter(WARNING_LEVEL,
 				       "%s: ignoring option '--%s' due to \
-invalid value '%s'\n",
+invalid value '%s'",
 				       my_progname, optp->name, optend);
 	      continue;
 	    }
@@ -390,7 +392,7 @@ invalid value '%s'\n",
 	  {
 	    if (my_getopt_print_errors)
               my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: option '--%s' requires an argument\n",
+                                       "%s: option '--%s' requires an argument",
                                        my_progname, optp->name);
 	    return EXIT_ARGUMENT_REQUIRED;
 	  }
@@ -450,7 +452,7 @@ invalid value '%s'\n",
 		  {
                     if (my_getopt_print_errors)
                       my_getopt_error_reporter(ERROR_LEVEL,
-                                               "%s: option '-%c' requires an argument\n",
+                                               "%s: option '-%c' requires an argument",
                                                my_progname, optp->id);
                     return EXIT_ARGUMENT_REQUIRED;
 		  }
@@ -463,7 +465,7 @@ invalid value '%s'\n",
 				 set_maximum_value)))
 	      {
                 my_getopt_error_reporter(ERROR_LEVEL,
-                                         "%s: Error while setting value '%s' to '%s'\n",
+                                         "%s: Error while setting value '%s' to '%s'",
                                          my_progname, argument, optp->name);
 		return error;
 	      }
@@ -475,7 +477,7 @@ invalid value '%s'\n",
 	  {
 	    if (my_getopt_print_errors)
               my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: unknown option '-%c'\n", 
+                                       "%s: unknown option '-%c'",
                                        my_progname, *optend);
 	    return EXIT_UNKNOWN_OPTION;
 	  }
@@ -486,13 +488,13 @@ invalid value '%s'\n",
       if ((error= setval(optp, value, argument, set_maximum_value)))
       {
         my_getopt_error_reporter(ERROR_LEVEL,
-                                 "%s: Error while setting value '%s' to '%s'\n",
+                                 "%s: Error while setting value '%s' to '%s'",
                                  my_progname, argument, optp->name);
 	return error;
       }
       get_one_option(optp->id, optp, argument);
 
+      (*argc)--; /* option handled (short or long), decrease argument count */
     }
     else /* non-option found */
       (*argv)[argvpos++]= cur_arg;
@@ -575,13 +577,17 @@ static int setval(const struct my_option
       *((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:
-    case GET_ULONG:          /* fall through */
       *((long*) result_pos)= (long) getopt_ll(argument, opts, &err);
       break;
+    case GET_ULONG:
+      *((long*) result_pos)= (long) getopt_ull(argument, opts, &err);
+      break;
     case GET_LL:
       *((longlong*) result_pos)= getopt_ll(argument, opts, &err);
       break;
@@ -733,23 +739,46 @@ static longlong eval_num_suffix (char *a
 
 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)
+{
+  longlong old= num;
+  bool trunc= FALSE;
+  char buf1[255], buf2[255];
   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 &&
+
+  if (num > 0 && ((ulonglong) num > (ulonglong) optp->max_value) &&
       optp->max_value) /* if max value is not set -> no upper limit */
   {
-    char buf[22];
-    my_getopt_error_reporter(WARNING_LEVEL,
-                             "Truncated incorrect %s value: '%s'", 
-                             optp->name, llstr(num, buf));
-    
     num= (ulonglong) optp->max_value;
+    trunc= TRUE;
   }
+
   num= ((num - optp->sub_size) / block_size);
   num= (longlong) (num * block_size);
-  return max(num, optp->min_value);
+
+  if (num < optp->min_value)
+  {
+    num= optp->min_value;
+    trunc= TRUE;
+  }
+
+  if (trunc)
+    my_getopt_error_reporter(WARNING_LEVEL,
+                             "option '%s': signed value %s adjusted to %s",
+                             optp->name, llstr(old, buf1), llstr(num, buf2));
+  return num;
 }
 
 /*
@@ -761,25 +790,67 @@ static longlong getopt_ll(char *arg, con
 
 static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err)
 {
-  ulonglong num;
-
-  num= eval_num_suffix(arg, err, (char*) optp->name);  
-  return getopt_ull_limit_value(num, optp);
+  ulonglong num= eval_num_suffix(arg, err, (char*) optp->name);
+  return getopt_ull_limit_value(num, optp, NULL);
 }
 
 
-ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp)
+ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
+                                 bool *fix)
 {
+  bool adjusted= FALSE;
+  ulonglong old= num, mod;
+  char buf1[255], buf2[255];
+
   if ((ulonglong) num > (ulonglong) optp->max_value &&
       optp->max_value) /* if max value is not set -> no upper limit */
+  {
     num= (ulonglong) optp->max_value;
+    adjusted= TRUE;
+  }
+
+  switch ((optp->var_type & GET_TYPE_MASK)) {
+  case GET_UINT:
+    if (num > (ulonglong) UINT_MAX)
+    {
+      num= ((ulonglong) UINT_MAX);
+      adjusted= TRUE;
+    }
+    break;
+  case GET_ULONG:
+#if SIZEOF_LONG < SIZEOF_LONG_LONG
+    if (num > (ulonglong) ULONG_MAX)
+    {
+      num= ((ulonglong) ULONG_MAX);
+      adjusted= TRUE;
+    }
+#endif
+    break;
+  default:
+    DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
+    break;
+  }
+
   if (optp->block_size > 1)
   {
     num/= (ulonglong) optp->block_size;
     num*= (ulonglong) optp->block_size;
   }
+
   if (num < (ulonglong) optp->min_value)
+  {
     num= (ulonglong) optp->min_value;
+    adjusted= TRUE;
+  }
+
+  if (adjusted)
+    my_getopt_error_reporter(WARNING_LEVEL,
+                             "option '%s': unsigned value %s adjusted to %s",
+                             optp->name, ullstr(old, buf1), ullstr(num, buf2));
+
+  if (fix)
+    *fix= adjusted;
+
   return num;
 }
 
@@ -789,38 +860,43 @@ ulonglong getopt_ull_limit_value(ulonglo
 
   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, gptr *variable,
+static void init_one_value(const struct my_option *optp, gptr *variable,
 			   longlong value)
 {
-  switch ((option->var_type & GET_TYPE_MASK)) {
+  DBUG_ENTER("init_one_value");
+
+  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) value;
+    *((uint*) variable)= (uint) getopt_ull_limit_value(value, optp, NULL);
     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_ull_limit_value(value, optp, NULL);
     break;
   case GET_LL:
-    *((longlong*) variable)= (longlong) value;
+    *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp);
     break;
   case GET_ULL:
-    *((ulonglong*) variable)=  (ulonglong) value;
+    *((ulonglong*) variable)=  (ulonglong) getopt_ull_limit_value(value, optp,
+                                                                  NULL);
     break;
   default: /* dummy default to avoid compiler warnings */
     break;
   }
+
+  DBUG_VOID_RETURN;
 }
 
 
@@ -839,9 +915,11 @@ static void init_one_value(const struct 
 
 static void init_variables(const struct my_option *options)
 {
+  DBUG_ENTER("init_variables");
   for (; options->name; options++)
   {
     gptr *variable;
+    DBUG_PRINT("options", ("name: '%s'", options->name));
     /*
       We must set u_max_value first as for some variables
       options->u_max_value == options->value and in this case we want to
@@ -855,6 +933,7 @@ static void init_variables(const struct 
 	(variable= (*getopt_get_addr)("", 0, options)))
       init_one_value(options, variable, options->def_value);
   }
+  DBUG_VOID_RETURN;
 }
 
 
@@ -957,8 +1036,8 @@ void my_print_variables(const struct my_
 		  (*getopt_get_addr)("", 0, optp) : optp->value);
     if (value)
     {
-      printf("%s", optp->name);
-      length= (uint) strlen(optp->name);
+      printf("%s ", optp->name);
+      length= (uint) strlen(optp->name)+1;
       for (; length < name_space; length++)
 	putchar(' ');
       switch ((optp->var_type & GET_TYPE_MASK)) {
@@ -977,7 +1056,7 @@ void my_print_variables(const struct my_
 	printf("%d\n", *((uint*) value));
 	break;
       case GET_LONG:
-	printf("%lu\n", *((long*) value));
+	printf("%ld\n", *((long*) value));
 	break;
       case GET_ULONG:
 	printf("%lu\n", *((ulong*) value));
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h	2007-10-29 08:25:37 +01:00
+++ b/sql/mysql_priv.h	2007-11-30 06:32:02 +01:00
@@ -186,7 +186,7 @@ MY_LOCALE *my_locale_by_number(uint numb
 #define QUERY_ALLOC_PREALLOC_SIZE   	8192
 #define TRANS_ALLOC_BLOCK_SIZE		4096
 #define TRANS_ALLOC_PREALLOC_SIZE	4096
-#define RANGE_ALLOC_BLOCK_SIZE		2048
+#define RANGE_ALLOC_BLOCK_SIZE		4096
 #define ACL_ALLOC_BLOCK_SIZE		1024
 #define UDF_ALLOC_BLOCK_SIZE		1024
 #define TABLE_ALLOC_BLOCK_SIZE		1024
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2007-10-29 09:52:39 +01:00
+++ b/sql/mysqld.cc	2007-11-30 06:32:02 +01:00
@@ -4958,7 +4958,7 @@ Disable with --skip-bdb (will save memor
   {"concurrent-insert", OPT_CONCURRENT_INSERT,
    "Use concurrent insert with MyISAM. Disable with --concurrent-insert=0",
    (gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert,
-   0, GET_LONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
+   0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
   {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.",
    (gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
    0, 0, 0},
@@ -5127,7 +5127,7 @@ Disable with --skip-innodb-doublewrite."
   {"innodb_max_purge_lag", OPT_INNODB_MAX_PURGE_LAG,
    "Desired maximum length of the purge queue (0 = no limit)",
    (gptr*) &srv_max_purge_lag,
-   (gptr*) &srv_max_purge_lag, 0, GET_LONG, REQUIRED_ARG, 0, 0, ~0L,
+   (gptr*) &srv_max_purge_lag, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX,
    0, 1L, 0},
   {"innodb_rollback_on_timeout", OPT_INNODB_ROLLBACK_ON_TIMEOUT,
    "Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
@@ -5237,7 +5237,8 @@ Disable with --skip-innodb-doublewrite."
 #ifdef HAVE_MMAP
   {"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.",
    (gptr*) &opt_tc_log_size, (gptr*) &opt_tc_log_size, 0, GET_ULONG,
-   REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ~0L, 0, TC_LOG_PAGE_SIZE, 0},
+   REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0,
+   TC_LOG_PAGE_SIZE, 0},
 #endif
   {"log-update", OPT_UPDATE_LOG,
    "The update log is deprecated since version 5.0, is replaced by the binary \
@@ -5660,8 +5661,8 @@ log and this option does nothing anymore
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {"warnings", 'W', "Deprecated; use --log-warnings instead.",
    (gptr*) &global_system_variables.log_warnings,
-   (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L,
-   0, 0, 0},
+   (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
+   1, 0, ULONG_MAX, 0, 0, 0},
   { "back_log", OPT_BACK_LOG,
     "The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.",
     (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG,
@@ -5670,29 +5671,29 @@ log and this option does nothing anymore
   { "bdb_cache_size", OPT_BDB_CACHE_SIZE,
     "The buffer that is allocated to cache index and rows for BDB tables.",
     (gptr*) &berkeley_cache_size, (gptr*) &berkeley_cache_size, 0, GET_ULONG,
-    REQUIRED_ARG, KEY_CACHE_SIZE, 20*1024, (long) ~0, 0, IO_SIZE, 0},
+    REQUIRED_ARG, KEY_CACHE_SIZE, 20*1024, ULONG_MAX, 0, IO_SIZE, 0},
   /* QQ: The following should be removed soon! (bdb_max_lock preferred) */
   {"bdb_lock_max", OPT_BDB_MAX_LOCK, "Synonym for bdb_max_lock.",
    (gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG,
-   REQUIRED_ARG, 10000, 0, (long) ~0, 0, 1, 0},
+   REQUIRED_ARG, 10000, 0, ULONG_MAX, 0, 1, 0},
   {"bdb_log_buffer_size", OPT_BDB_LOG_BUFFER_SIZE,
    "The buffer that is allocated to cache index and rows for BDB tables.",
    (gptr*) &berkeley_log_buffer_size, (gptr*) &berkeley_log_buffer_size, 0,
-   GET_ULONG, REQUIRED_ARG, 0, 256*1024L, ~0L, 0, 1024, 0},
+   GET_ULONG, REQUIRED_ARG, 0, 256*1024L, ULONG_MAX, 0, 1024, 0},
   {"bdb_max_lock", OPT_BDB_MAX_LOCK,
    "The maximum number of locks you can have active on a BDB table.",
    (gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG,
-   REQUIRED_ARG, 10000, 0, (long) ~0, 0, 1, 0},
+   REQUIRED_ARG, 10000, 0, ULONG_MAX, 0, 1, 0},
 #endif /* HAVE_BERKELEY_DB */
   {"binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
    "The size of the cache to hold the SQL statements for the binary log during a transaction. If you often use big, multi-statement transactions you can increase this to get more performance.",
    (gptr*) &binlog_cache_size, (gptr*) &binlog_cache_size, 0, GET_ULONG,
-   REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
+   REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
   {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
    "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!",
    (gptr*) &global_system_variables.bulk_insert_buff_size,
    (gptr*) &max_system_variables.bulk_insert_buff_size,
-   0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0},
+   0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
   {"connect_timeout", OPT_CONNECT_TIMEOUT,
    "The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.",
     (gptr*) &connect_timeout, (gptr*) &connect_timeout,
@@ -5715,7 +5716,7 @@ log and this option does nothing anymore
   {"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT,
    "After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing.",
     (gptr*) &delayed_insert_limit, (gptr*) &delayed_insert_limit, 0, GET_ULONG,
-    REQUIRED_ARG, DELAYED_LIMIT, 1, ~0L, 0, 1, 0},
+    REQUIRED_ARG, DELAYED_LIMIT, 1, ULONG_MAX, 0, 1, 0},
   {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT,
    "How long a INSERT DELAYED thread should wait for INSERT statements before terminating.",
    (gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0,
@@ -5723,7 +5724,7 @@ log and this option does nothing anymore
   { "delayed_queue_size", OPT_DELAYED_QUEUE_SIZE,
     "What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again.",
     (gptr*) &delayed_queue_size, (gptr*) &delayed_queue_size, 0, GET_ULONG,
-    REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1, 0},
+    REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ULONG_MAX, 0, 1, 0},
   {"div_precision_increment", OPT_DIV_PRECINCREMENT,
    "Precision of the result of '/' operator will be increased on that value.",
    (gptr*) &global_system_variables.div_precincrement,
@@ -5760,16 +5761,16 @@ log and this option does nothing anymore
     (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR,
     REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
-    "The maximum length of the result of function  group_concat.",
+    "The maximum length of the result of function group_concat.",
     (gptr*) &global_system_variables.group_concat_max_len,
     (gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
-    REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0},
+    REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
 #ifdef HAVE_INNOBASE_DB
   {"innodb_additional_mem_pool_size", OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
    "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
    (gptr*) &innobase_additional_mem_pool_size,
    (gptr*) &innobase_additional_mem_pool_size, 0, GET_LONG, REQUIRED_ARG,
-   1*1024*1024L, 512*1024L, ~0L, 0, 1024, 0},
+   1*1024*1024L, 512*1024L, LONG_MAX, 0, 1024, 0},
   {"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT,
    "Data file autoextend increment in megabytes",
    (gptr*) &srv_auto_extend_increment,
@@ -5793,7 +5794,7 @@ log and this option does nothing anymore
     SQL query after it has once got the ticket",
    (gptr*) &srv_n_free_tickets_to_enter,
    (gptr*) &srv_n_free_tickets_to_enter,
-   0, GET_LONG, REQUIRED_ARG, 500L, 1L, ~0L, 0, 1L, 0},
+   0, GET_ULONG, REQUIRED_ARG, 500L, 1L, ULONG_MAX, 0, 1L, 0},
   {"innodb_file_io_threads", OPT_INNODB_FILE_IO_THREADS,
    "Number of file I/O threads in InnoDB.", (gptr*) &innobase_file_io_threads,
    (gptr*) &innobase_file_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 4, 64, 0,
@@ -5809,7 +5810,7 @@ log and this option does nothing anymore
   {"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE,
    "The size of the buffer which InnoDB uses to write log to the log files on disk.",
    (gptr*) &innobase_log_buffer_size, (gptr*) &innobase_log_buffer_size, 0,
-   GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, ~0L, 0, 1024, 0},
+   GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, LONG_MAX, 0, 1024, 0},
   {"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE,
    "Size of each log file in a log group.",
    (gptr*) &innobase_log_file_size, (gptr*) &innobase_log_file_size, 0,
@@ -5827,24 +5828,24 @@ log and this option does nothing anymore
   {"innodb_open_files", OPT_INNODB_OPEN_FILES,
    "How many files at the maximum InnoDB keeps open at the same time.",
    (gptr*) &innobase_open_files, (gptr*) &innobase_open_files, 0,
-   GET_LONG, REQUIRED_ARG, 300L, 10L, ~0L, 0, 1L, 0},
+   GET_LONG, REQUIRED_ARG, 300L, 10L, LONG_MAX, 0, 1L, 0},
   {"innodb_sync_spin_loops", OPT_INNODB_SYNC_SPIN_LOOPS,
    "Count of spin-loop rounds in InnoDB mutexes",
    (gptr*) &srv_n_spin_wait_rounds,
    (gptr*) &srv_n_spin_wait_rounds,
-   0, GET_LONG, REQUIRED_ARG, 20L, 0L, ~0L, 0, 1L, 0},
+   0, GET_ULONG, REQUIRED_ARG, 20L, 0L, ULONG_MAX, 0, 1L, 0},
   {"innodb_thread_concurrency", OPT_INNODB_THREAD_CONCURRENCY,
    "Helps in performance tuning in heavily concurrent environments. "
    "Sets the maximum number of threads allowed inside InnoDB. Value 0"
    " will disable the thread throttling.",
    (gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency,
-   0, GET_LONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
+   0, GET_ULONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
   {"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY,
    "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0"
     " disable a sleep",
    (gptr*) &srv_thread_sleep_delay,
    (gptr*) &srv_thread_sleep_delay,
-   0, GET_LONG, REQUIRED_ARG, 10000L, 0L, ~0L, 0, 1L, 0},
+   0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
 #endif /* HAVE_INNOBASE_DB */
   {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
    "The number of seconds the server waits for activity on an interactive connection before closing it.",
@@ -5874,7 +5875,7 @@ log and this option does nothing anymore
    (gptr*) &dflt_key_cache_var.param_age_threshold,
    (gptr*) 0,
    0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
-   300, 100, ~0L, 0, 100, 0},
+   300, 100, ULONG_MAX, 0, 100, 0},
   {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
    "The default size of key cache blocks",
    (gptr*) &dflt_key_cache_var.param_block_size,
@@ -5910,7 +5911,7 @@ log and this option does nothing anymore
   {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
    "Can be used to restrict the total size used to cache a multi-transaction query.",
    (gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0,
-   GET_ULONG, REQUIRED_ARG, ~0L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
+   GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
   {"max_binlog_size", OPT_MAX_BINLOG_SIZE,
    "Binary log will be rotated automatically when the size exceeds this \
 value. Will also apply to relay logs if max_relay_log_size is 0. \
@@ -5920,7 +5921,7 @@ The minimum value for this variable is 4
   {"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
    "If there is more than this number of interrupted connections from a host this host will be blocked from further connections.",
    (gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG,
-    REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0},
+    REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
   {"max_connections", OPT_MAX_CONNECTIONS,
    "The number of simultaneous clients allowed.", (gptr*) &max_connections,
    (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
@@ -5963,7 +5964,7 @@ The minimum value for this variable is 4
     "Limit assumed max number of seeks when looking up rows based on a key",
     (gptr*) &global_system_variables.max_seeks_for_key,
     (gptr*) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
-    REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0 },
+    REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
   {"max_sort_length", OPT_MAX_SORT_LENGTH,
    "The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).",
    (gptr*) &global_system_variables.max_sort_length,
@@ -5978,20 +5979,20 @@ The minimum value for this variable is 4
    "Maximum number of temporary tables a client can keep open at a time.",
    (gptr*) &global_system_variables.max_tmp_tables,
    (gptr*) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
-   REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0},
+   REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
   {"max_user_connections", OPT_MAX_USER_CONNECTIONS,
    "The maximum number of active connections for a single user (0 = no limit).",
    (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT,
-   REQUIRED_ARG, 0, 1, ~0, 0, 1, 0},
+   REQUIRED_ARG, 0, 0, (uint) ~0, 0, 1, 0},
   {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
    "After this many write locks, allow some read locks to run in between.",
    (gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG,
-   REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0},
+   REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
   {"multi_range_count", OPT_MULTI_RANGE_COUNT,
    "Number of key ranges to request at once.",
    (gptr*) &global_system_variables.multi_range_count,
    (gptr*) &max_system_variables.multi_range_count, 0,
-   GET_ULONG, REQUIRED_ARG, 256, 1, ~0L, 0, 1, 0},
+   GET_ULONG, REQUIRED_ARG, 256, 1, ULONG_MAX, 0, 1, 0},
   {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
    "Block size to be used for MyISAM index pages.",
    (gptr*) &opt_myisam_block_size,
@@ -6019,7 +6020,7 @@ The minimum value for this variable is 4
    "Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.",
    (gptr*) &global_system_variables.myisam_repair_threads,
    (gptr*) &max_system_variables.myisam_repair_threads, 0,
-   GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0},
+   GET_ULONG, REQUIRED_ARG, 1, 1, ULONG_MAX, 0, 1, 0},
   {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
    "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
    (gptr*) &global_system_variables.myisam_sort_buff_size,
@@ -6045,7 +6046,7 @@ The minimum value for this variable is 4
    "If a read on a communication port is interrupted, retry this many times before giving up.",
    (gptr*) &global_system_variables.net_retry_count,
    (gptr*) &max_system_variables.net_retry_count,0,
-   GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0},
+   GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
   {"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
    "Number of seconds to wait for a block to be written to a connection  before aborting the write.",
    (gptr*) &global_system_variables.net_write_timeout,
@@ -6074,7 +6075,7 @@ The minimum value for this variable is 4
    "Allocation block size for query parsing and execution",
    (gptr*) &global_system_variables.query_alloc_block_size,
    (gptr*) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
-   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
+   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
 #ifdef HAVE_QUERY_CACHE
   {"query_cache_limit", OPT_QUERY_CACHE_LIMIT,
    "Don't cache results that are bigger than this.",
@@ -6107,12 +6108,13 @@ The minimum value for this variable is 4
    (gptr*) &global_system_variables.query_prealloc_size,
    (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
    REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
-   ~0L, 0, 1024, 0},
+   ULONG_MAX, 0, 1024, 0},
   {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
    "Allocation block size for storing ranges during optimization",
    (gptr*) &global_system_variables.range_alloc_block_size,
    (gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
-   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0},
+   REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX,
+   0, 1024, 0},
   {"read_buffer_size", OPT_RECORD_BUFFER,
    "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
    (gptr*) &global_system_variables.read_buff_size,
@@ -6182,7 +6184,7 @@ The minimum value for this variable is 4
    "Synchronously flush binary log to disk after every #th event. "
    "Use 0 (default) to disable synchronous flushing.",
    (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG,
-   REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
+   REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
   {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
    (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
    0, 0, 0, 0},
@@ -6206,7 +6208,7 @@ The minimum value for this variable is 4
   {"thread_stack", OPT_THREAD_STACK,
    "The stack size for each thread.", (gptr*) &thread_stack,
    (gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
-   1024L*128L, ~0L, 0, 1024, 0},
+   1024L*128L, ULONG_MAX, 0, 1024, 0},
   { "time_format", OPT_TIME_FORMAT,
     "The TIME format (for future).",
     (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
@@ -6222,12 +6224,12 @@ The minimum value for this variable is 4
    "Allocation block size for various transaction-related structures",
    (gptr*) &global_system_variables.trans_alloc_block_size,
    (gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
-   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
+   REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
   {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
    "Persistent buffer for various transaction-related structures",
    (gptr*) &global_system_variables.trans_prealloc_size,
    (gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
-   REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
+   REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
   {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT,
    "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).",
    (gptr*) &global_system_variables.updatable_views_with_limit,
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2007-10-29 08:25:38 +01:00
+++ b/sql/set_var.cc	2007-11-30 06:32:03 +01:00
@@ -113,6 +113,9 @@ static int check_max_delayed_threads(THD
 static void fix_thd_mem_root(THD *thd, enum_var_type type);
 static void fix_trans_mem_root(THD *thd, enum_var_type type);
 static void fix_server_id(THD *thd, enum_var_type type);
+static ulonglong fix_unsigned(THD *thd, ulonglong num,
+                              const struct my_option *option_limits);
+static void throw_bounds_warning(THD *thd, const char *name, ulonglong num);
 static KEY_CACHE *create_key_cache(const char *name, uint length);
 void fix_sql_mode_var(THD *thd, enum_var_type type);
 static byte *get_error_count(THD *thd);
@@ -1448,6 +1451,27 @@ static void fix_server_id(THD *thd, enum
 }
 
 
+static void throw_bounds_warning(THD *thd, const char *name, ulonglong num)
+{
+  char buf[22];
+  push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                      ER_TRUNCATED_WRONG_VALUE,
+                      ER(ER_TRUNCATED_WRONG_VALUE), name,
+                      ullstr(num, buf));
+}
+
+static ulonglong fix_unsigned(THD *thd, ulonglong num,
+                              const struct my_option *option_limits)
+{
+  bool fixed= FALSE;
+  ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
+
+  if (fixed)
+    throw_bounds_warning(thd, option_limits->name, num);
+  return out;
+}
+
+
 sys_var_long_ptr::
 sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg,
                  sys_after_update_func after_update_arg)
@@ -1468,9 +1492,20 @@ bool sys_var_long_ptr_global::update(THD
   ulonglong tmp= var->save_result.ulonglong_value;
   pthread_mutex_lock(guard);
   if (option_limits)
-    *value= (ulong) getopt_ull_limit_value(tmp, option_limits);
+    *value= (ulong) fix_unsigned(thd, tmp, option_limits);
   else
+  {
+#if SIZEOF_LONG < SIZEOF_LONG_LONG
+    /* Avoid overflows on 32 bit systems */
+    if (tmp > (ulonglong) ~(ulong) 0)
+    {
+      tmp= ((ulonglong) ~(ulong) 0);
+      throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
+    }
+#endif
     *value= (ulong) tmp;
+  }
+
   pthread_mutex_unlock(guard);
   return 0;
 }
@@ -1489,7 +1524,7 @@ bool sys_var_ulonglong_ptr::update(THD *
   ulonglong tmp= var->save_result.ulonglong_value;
   pthread_mutex_lock(&LOCK_global_system_variables);
   if (option_limits)
-    *value= (ulonglong) getopt_ull_limit_value(tmp, option_limits);
+    *value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
   else
     *value= (ulonglong) tmp;
   pthread_mutex_unlock(&LOCK_global_system_variables);
@@ -1539,38 +1574,29 @@ bool sys_var_thd_ulong::check(THD *thd, 
 bool sys_var_thd_ulong::update(THD *thd, set_var *var)
 {
   ulonglong tmp= var->save_result.ulonglong_value;
-  char buf[22];
-  bool truncated= false;
 
   /* Don't use bigger value than given with --maximum-variable-name=.. */
   if ((ulong) tmp > max_system_variables.*offset)
   {
-    truncated= true;
-    llstr(tmp, buf);
+    throw_bounds_warning(thd, name, tmp);
     tmp= max_system_variables.*offset;
   }
 
-#if SIZEOF_LONG == 4
-  /* Avoid overflows on 32 bit systems */
-  if (tmp > (ulonglong) ~(ulong) 0)
+  if (option_limits)
+    tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
+#if SIZEOF_LONG < SIZEOF_LONG_LONG
+  else if (tmp > (ulonglong) ~(ulong) 0)
   {
-    truncated= true;
-    llstr(tmp, buf);
     tmp= ((ulonglong) ~(ulong) 0);
+    throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
   }
 #endif
-  if (truncated)
-    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                        ER_TRUNCATED_WRONG_VALUE,
-                        ER(ER_TRUNCATED_WRONG_VALUE), name,
-                        buf);
 
-  if (option_limits)
-    tmp= (ulong) getopt_ull_limit_value(tmp, option_limits);
   if (var->type == OPT_GLOBAL)
     global_system_variables.*offset= (ulong) tmp;
   else
     thd->variables.*offset= (ulong) tmp;
+
   return 0;
 }
 
@@ -1605,7 +1631,7 @@ bool sys_var_thd_ha_rows::update(THD *th
     tmp= max_system_variables.*offset;
 
   if (option_limits)
-    tmp= (ha_rows) getopt_ull_limit_value(tmp, option_limits);
+    tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
   if (var->type == OPT_GLOBAL)
   {
     /* Lock is needed to make things safe on 32 bit systems */
@@ -1649,7 +1675,7 @@ bool sys_var_thd_ulonglong::update(THD *
     tmp= max_system_variables.*offset;
 
   if (option_limits)
-    tmp= getopt_ull_limit_value(tmp, option_limits);
+    tmp= fix_unsigned(thd, tmp, option_limits);
   if (var->type == OPT_GLOBAL)
   {
     /* Lock is needed to make things safe on 32 bit systems */
@@ -2493,7 +2519,7 @@ bool sys_var_key_buffer_size::update(THD
   }
 
   key_cache->param_buff_size=
-    (ulonglong) getopt_ull_limit_value(tmp, option_limits);
+    (ulonglong) fix_unsigned(thd, tmp, option_limits);
 
   /* If key cache didn't existed initialize it, else resize it */
   key_cache->in_init= 1;
@@ -2541,7 +2567,7 @@ bool sys_var_key_cache_long::update(THD 
     goto end;
 
   *((ulong*) (((char*) key_cache) + offset))=
-    (ulong) getopt_ull_limit_value(tmp, option_limits);
+    (ulong) fix_unsigned(thd, tmp, option_limits);
 
   /*
     Don't create a new key cache if it didn't exist
diff -Nrup a/strings/llstr.c b/strings/llstr.c
--- a/strings/llstr.c	2006-12-23 20:04:30 +01:00
+++ b/strings/llstr.c	2007-11-30 06:32:03 +01:00
@@ -32,3 +32,9 @@ 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;
+}
Thread
bk commit into 5.0 tree (tnurnberg:1.2557) BUG#31177Tatjana A Nuernberg30 Nov
  • Re: bk commit into 5.0 tree (tnurnberg:1.2557) BUG#31177Sergei Golubchik30 Nov