MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:February 23 2008 11:45pm
Subject:bk commit into 5.1 tree (tnurnberg:1.2669) BUG#20752
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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, 2008-02-24 00:45:09+01:00, tnurnberg@stripped +3 -0
  Bug#20752: BENCHMARK with many iterations returns too quickly
  
  In BENCHMARK(count, expr), count could overflow/wrap-around.
  Patch changes to a sufficiently large data-type. Adds a warning
  for negative count values.

  mysql-test/r/func_str.result@stripped, 2008-02-24 00:45:07+01:00, tnurnberg@stripped +5 -0
    show that a negative 'count' for BENCHMARK(count, expr)
    throws a warning and returns NULL.

  mysql-test/t/func_str.test@stripped, 2008-02-24 00:45:07+01:00, tnurnberg@stripped +7 -0
    show that a negative 'count' for BENCHMARK(count, expr)
    throws a warning and returns NULL.

  sql/item_func.cc@stripped, 2008-02-24 00:45:07+01:00, tnurnberg@stripped +14 -4
    use ulonglong rather than ulong in BENCHMARK(count, expr)
    throw warning on negative 'count'; return SQL-NULL.

diff -Nrup a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
--- a/mysql-test/r/func_str.result	2007-11-05 15:43:11 +01:00
+++ b/mysql-test/r/func_str.result	2008-02-24 00:45:07 +01:00
@@ -1431,6 +1431,11 @@ benchmark(100, NULL)
 select benchmark(NULL, 1+1);
 benchmark(NULL, 1+1)
 NULL
+select benchmark(-1, 1);
+benchmark(-1, 1)
+NULL
+Warnings:
+Error	1411	Incorrect count value: '-1' for function benchmark
 set @password="password";
 set @my_data="clear text to encode";
 select md5(encode(@my_data, "password"));
diff -Nrup a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
--- a/mysql-test/t/func_str.test	2007-11-05 15:24:50 +01:00
+++ b/mysql-test/t/func_str.test	2008-02-24 00:45:07 +01:00
@@ -875,6 +875,13 @@ select benchmark(100, NULL);
 select benchmark(NULL, 1+1);
 
 #
+# Bug #20752: BENCHMARK with many iterations returns too quickly
+#
+
+# not a string, but belongs with the above Bug#22684
+select benchmark(-1, 1);
+
+#
 # Please note:
 # 1) The collation of the password is irrelevant, the encryption uses
 # the binary representation of the string without charset/collation.
diff -Nrup a/sql/item_func.cc b/sql/item_func.cc
--- a/sql/item_func.cc	2008-02-13 10:04:12 +01:00
+++ b/sql/item_func.cc	2008-02-24 00:45:07 +01:00
@@ -3651,18 +3651,28 @@ longlong Item_func_benchmark::val_int()
   String tmp(buff,sizeof(buff), &my_charset_bin);
   my_decimal tmp_decimal;
   THD *thd=current_thd;
-  ulong loop_count;
+  ulonglong loop_count;
 
-  loop_count= (ulong) args[0]->val_int();
+  loop_count= (ulonglong) args[0]->val_int();
 
-  if (args[0]->null_value)
+  if (args[0]->null_value ||
+      (!args[0]->unsigned_flag && (((longlong) loop_count) < 0)))
   {
+    if (!args[0]->null_value)
+    {
+      char buff[22];
+      llstr(((longlong) loop_count), buff);
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                          ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+                          "count", buff, "benchmark");
+    }
+
     null_value= 1;
     return 0;
   }
 
   null_value=0;
-  for (ulong loop=0 ; loop < loop_count && !thd->killed; loop++)
+  for (ulonglong loop=0 ; loop < loop_count && !thd->killed; loop++)
   {
     switch (args[1]->result_type()) {
     case REAL_RESULT:
Thread
bk commit into 5.1 tree (tnurnberg:1.2669) BUG#20752Tatjana A Nuernberg24 Feb