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-11 10:06:52+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-11 10:06:51+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-11 10:06:51+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-11 10:06:51+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-06-18 14:08:52 +02:00
+++ b/mysql-test/r/func_str.result 2008-02-11 10:06:51 +01:00
@@ -1419,6 +1419,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-06-18 14:08:52 +02:00
+++ b/mysql-test/t/func_str.test 2008-02-11 10:06:51 +01:00
@@ -862,6 +862,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 2007-10-04 14:10:54 +02:00
+++ b/sql/item_func.cc 2008-02-11 10:06:51 +01:00
@@ -3637,18 +3637,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.2588) BUG#20752 | Tatjana A Nuernberg | 11 Feb |