From 934ea4d1ead652ea75a31e163e003cdb27b210d4 Mon Sep 17 00:00:00 2001
From: "Tatiana A. Nurnberg" <azundris@mysql.com>
Date: Thu, 25 Nov 2010 03:11:05 +0000
Subject: [PATCH] Assorted post-merge fixes, clean-up, integration, compat with
 5.6. 43233/55794.

mysql-test/r/change_user.result:
  Don't use -1 integer wrap around. It used to work, but now we do what's
  actually in the documentation. In tests, we now use DEFAULT or the
  numeral equivalent (as we do in the 5.6 tests).
mysql-test/r/key_cache.result:
  Can't drop default key case is an error now, not a warning, for compatibility
  with 5.6.
mysql-test/r/variables.result:
  Can't drop default key case is an error now, not a warning, for compatibility
  with 5.6.
mysql-test/t/change_user.test:
  Don't use -1 integer wrap around. It used to work, but now we do what's
  actually in the documentation. In tests, we now use DEFAULT or the
  numeral equivalent (as we do in the 5.6 tests).
mysql-test/t/key_cache.test:
  Can't drop default key case is an error now, not a warning, for compatibility
  with 5.6.
mysql-test/t/variables.test:
  Can't drop default key case is an error now, not a warning, for compatibility
  with 5.6.
sql/mysqld.cc:
  0 is a legal (albeit magic) value: "drop key cache."
sql/set_var.cc:
  bound_unsigned() can go now, it was just a kludge until things are done
  The Right Way, which they are now.

  Can't drop default key case is an error now, not a warning, for compatibility
  with 5.6.
tests/mysql_client_test.c:
  Don't use -1 integer wrap around. It used to work, but now we do what's
  actually in the documentation. In tests, we now use DEFAULT or the
  numeral equivalent (as we do in the 5.6 tests).
---
 mysql-test/r/change_user.result |  2 +-
 mysql-test/r/key_cache.result   |  3 +--
 mysql-test/r/variables.result   |  5 ++--
 mysql-test/t/change_user.test   |  2 +-
 mysql-test/t/key_cache.test     |  1 +
 mysql-test/t/variables.test     |  5 +++-
 sql/mysqld.cc                   |  2 +-
 sql/set_var.cc                  | 43 ++-------------------------------
 tests/mysql_client_test.c       |  4 +--
 9 files changed, 15 insertions(+), 52 deletions(-)

diff --git a/mysql-test/r/change_user.result b/mysql-test/r/change_user.result
index f8d5d900a80..1ed7fcbb8fa 100644
--- a/mysql-test/r/change_user.result
+++ b/mysql-test/r/change_user.result
@@ -18,7 +18,7 @@ change_user
 SELECT @@session.sql_big_selects;
 @@session.sql_big_selects
 0
-SET @@global.max_join_size = -1;
+SET @@global.max_join_size = 18446744073709551615;
 SET @@session.max_join_size = default;
 change_user
 SELECT @@session.sql_big_selects;
diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
index 08d8059f61b..f80fea0fc76 100644
--- a/mysql-test/r/key_cache.result
+++ b/mysql-test/r/key_cache.result
@@ -334,8 +334,7 @@ test.t1	check	status	OK
 DROP TABLE t1,t2;
 set global key_cache_block_size= @my_key_cache_block_size;
 set @@global.key_buffer_size=0;
-Warnings:
-Warning	1438	Cannot drop default keycache
+ERROR HY000: Cannot drop default keycache
 select @@global.key_buffer_size;
 @@global.key_buffer_size
 2097152
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 58f88b78bda..20f41c4a83c 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -1524,7 +1524,7 @@ ERROR 42000: Variable 'max_binlog_cache_size' can't be set to the value of '-1'
 SET @@global.max_join_size=0;
 ERROR 42000: Variable 'max_join_size' can't be set to the value of '0'
 SET @@global.key_buffer_size=0;
-ERROR 42000: Variable 'key_buffer_size' can't be set to the value of '0'
+ERROR HY000: Cannot drop default keycache
 SET @@global.key_cache_block_size=0;
 ERROR 42000: Variable 'key_cache_block_size' can't be set to the value of '0'
 throw warnings in default mode
@@ -1536,8 +1536,7 @@ SET @@global.max_join_size=0;
 Warnings:
 Warning	1292	Truncated incorrect max_join_size value: '0'
 SET @@global.key_buffer_size=0;
-Warnings:
-Warning	1292	Truncated incorrect key_buffer_size value: '0'
+ERROR HY000: Cannot drop default keycache
 SET @@global.key_cache_block_size=0;
 Warnings:
 Warning	1292	Truncated incorrect key_cache_block_size value: '0'
diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test
index 89f35116a2c..3ed798e8d36 100644
--- a/mysql-test/t/change_user.test
+++ b/mysql-test/t/change_user.test
@@ -20,7 +20,7 @@ SET @@session.max_join_size = default;
 SELECT @@session.sql_big_selects;
 # On some machines the following will result into a warning
 --disable_warnings
-SET @@global.max_join_size = -1;
+SET @@global.max_join_size = 18446744073709551615;
 --enable_warnings
 SET @@session.max_join_size = default;
 --echo change_user
diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test
index 4c14dc96aaa..f12d20e962e 100644
--- a/mysql-test/t/key_cache.test
+++ b/mysql-test/t/key_cache.test
@@ -216,6 +216,7 @@ set global key_cache_block_size= @my_key_cache_block_size;
 # Bug#10473 - Can't set 'key_buffer_size' system variable to ZERO
 # (One cannot drop the default key cache.)
 #
+--error ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
 set @@global.key_buffer_size=0;
 select @@global.key_buffer_size;
 
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 1b411d9420c..74d5c8450a2 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1275,7 +1275,7 @@ SET @@global.max_binlog_cache_size=-1;
 SET @@global.max_join_size=0;
 
 # sys_var_key_buffer_size: "key_buffer_size"
---error ER_WRONG_VALUE_FOR_VAR
+--error ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
 SET @@global.key_buffer_size=0;
 
 # sys_var_key_cache_long: "key_cache_block_size" et al.
@@ -1287,6 +1287,9 @@ SET SQL_MODE=DEFAULT;
 
 SET @@global.max_binlog_cache_size=-1;
 SET @@global.max_join_size=0;
+# this is an exception. since this is a new error/warning, let's stay
+# compatible with the upcoming 5.6.
+--error ER_WARN_CANT_DROP_DEFAULT_KEYCACHE
 SET @@global.key_buffer_size=0;
 SET @@global.key_cache_block_size=0;
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d17ccc47abb..98556e87838 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -6774,7 +6774,7 @@ thread is in the relay logs.",
    "as much as you can afford; 1GB on a 4GB machine that mainly runs MySQL is "
    "quite common.",
    &dflt_key_cache_var.param_buff_size, NULL, NULL, (GET_ULL | GET_ASK_ADDR),
-   REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD,
+   REQUIRED_ARG, KEY_CACHE_SIZE, 0, SIZE_T_MAX, MALLOC_OVERHEAD,
    IO_SIZE, 0},
   {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
    "This characterizes the number of hits a hot block has to be untouched "
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 2621c8457bc..26f97d46d52 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1423,44 +1423,6 @@ bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
 }
 
 
-/**
-  check an unsigned user-supplied value for a systemvariable against bounds.
-
-  TODO: This is a wrapper function to call clipping from within an update()
-        function.  Calling bounds from within update() is fair game in theory,
-        but we can only send warnings from in there, not errors, and besides,
-        it violates our model of separating check from update phase.
-        To avoid breaking out of the server with an ASSERT() in strict mode,
-        we pretend we're not in strict mode when we go through here. Bug#43233
-        was opened to remind us to replace this kludge with The Right Thing,
-        which of course is to do the check in the actual check phase, and then
-        throw an error or warning accordingly.
-
-  @param thd             thread handle
-  @param num             the value to limit
-  @param option_limits   the bounds-record, or NULL if none
- */
-static void bound_unsigned(THD *thd, ulonglong *num,
-                              const struct my_option *option_limits)
-{
-  if (option_limits)
-  {
-    my_bool   fixed     = FALSE;
-    ulonglong unadjusted= *num;
-
-    *num= getopt_ull_limit_value(unadjusted, option_limits, &fixed);
-
-    if (fixed)
-    {
-      ulong ssm= thd->variables.sql_mode;
-      thd->variables.sql_mode&= ~MODE_STRICT_ALL_TABLES;
-      throw_bounds_warning(thd, fixed, TRUE, option_limits->name, unadjusted);
-      thd->variables.sql_mode= ssm;
-    }
-  }
-}
-
-
 /**
   Get unsigned system-variable.
   Negative value does not wrap around, but becomes zero.
@@ -2359,9 +2321,8 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
   {
     if (key_cache == dflt_key_cache)
     {
-      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                          ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
-                          ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
+      error= 1;
+      my_error(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE, MYF(0));
       goto end;					// Ignore default key cache
     }
 
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index ed8031b3fc3..53e2ed1d082 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -17125,7 +17125,7 @@ static void test_bug20023()
 
   /* Set MAX_JOIN_SIZE to the default value (-1). */
 
-  DIE_IF(mysql_query(&con, "SET @@global.max_join_size = -1"));
+  DIE_IF(mysql_query(&con, "SET @@global.max_join_size = 18446744073709551615"));
   DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default"));
 
   /* Issue COM_CHANGE_USER. */
@@ -17156,7 +17156,7 @@ static void test_bug20023()
 
   DIE_IF(mysql_query(&con, query_buffer));
 
-  DIE_IF(mysql_query(&con, "SET @@global.max_join_size = -1"));
+  DIE_IF(mysql_query(&con, "SET @@global.max_join_size = 18446744073709551615"));
   DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default"));
 
   /* Issue COM_CHANGE_USER. */
-- 
2.30.9