Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.1-opt

into  mysql.com:/misc/mysql/20752/51-20752
parents 62300827 1ed076e4
...@@ -1431,6 +1431,11 @@ benchmark(100, NULL) ...@@ -1431,6 +1431,11 @@ benchmark(100, NULL)
select benchmark(NULL, 1+1); select benchmark(NULL, 1+1);
benchmark(NULL, 1+1) benchmark(NULL, 1+1)
NULL NULL
select benchmark(-1, 1);
benchmark(-1, 1)
NULL
Warnings:
Error 1411 Incorrect count value: '-1' for function benchmark
set @password="password"; set @password="password";
set @my_data="clear text to encode"; set @my_data="clear text to encode";
select md5(encode(@my_data, "password")); select md5(encode(@my_data, "password"));
......
...@@ -874,6 +874,13 @@ select benchmark(0, NULL); ...@@ -874,6 +874,13 @@ select benchmark(0, NULL);
select benchmark(100, NULL); select benchmark(100, NULL);
select benchmark(NULL, 1+1); 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: # Please note:
# 1) The collation of the password is irrelevant, the encryption uses # 1) The collation of the password is irrelevant, the encryption uses
......
...@@ -3646,18 +3646,28 @@ longlong Item_func_benchmark::val_int() ...@@ -3646,18 +3646,28 @@ longlong Item_func_benchmark::val_int()
String tmp(buff,sizeof(buff), &my_charset_bin); String tmp(buff,sizeof(buff), &my_charset_bin);
my_decimal tmp_decimal; my_decimal tmp_decimal;
THD *thd=current_thd; 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; null_value= 1;
return 0; return 0;
} }
null_value=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()) { switch (args[1]->result_type()) {
case REAL_RESULT: case REAL_RESULT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment