diff options
author | unknown <malff/marcsql@weblab.(none)> | 2007-03-01 19:20:47 -0700 |
---|---|---|
committer | unknown <malff/marcsql@weblab.(none)> | 2007-03-01 19:20:47 -0700 |
commit | 0a93be2869be5eb801d7955ad512504190dd0479 (patch) | |
tree | fb41290501675c692d9aba10ea4b0d9b579b017f /mysql-test/t/func_misc.test | |
parent | a475ed7c6b6607272afb87517ae6ab1f3a397f41 (diff) | |
download | mariadb-git-0a93be2869be5eb801d7955ad512504190dd0479.tar.gz |
Bug#26093 (SELECT BENCHMARK() for SELECT statements does not produce valid
results)
Before this fix, the function BENCHMARK() would fail to evaluate expressions
like "(select avg(a) from t1)" in debug builds (with an assert),
or would report a time of zero in non debug builds.
The root cause is that evaluation of DECIMAL_RESULT expressions was not
supported in Item_func_benchmark::val_int().
This has been fixed by this change.
mysql-test/r/func_misc.result:
Added support for DECIMAL_RESULT in Item_func_benchmark::val_int()
mysql-test/t/func_misc.test:
Added support for DECIMAL_RESULT in Item_func_benchmark::val_int()
sql/item_func.cc:
Added support for DECIMAL_RESULT in Item_func_benchmark::val_int()
Diffstat (limited to 'mysql-test/t/func_misc.test')
-rw-r--r-- | mysql-test/t/func_misc.test | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 5cac6c45f65..8ff62f68e45 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -132,4 +132,61 @@ set global query_cache_size=default; create table t1 select INET_ATON('255.255.0.1') as `a`; show create table t1; drop table t1; + +# +# Bug#26093 (SELECT BENCHMARK() for SELECT statements does not produce +# valid results) +# + +--disable_warnings +drop table if exists table_26093; +drop function if exists func_26093_a; +drop function if exists func_26093_b; +--enable_warnings + +create table table_26093(a int); +insert into table_26093 values +(1), (2), (3), (4), (5), +(6), (7), (8), (9), (10); + +delimiter //; + +create function func_26093_a(x int) returns int +begin + set @invoked := @invoked + 1; + return x; +end// + +create function func_26093_b(x int, y int) returns int +begin + set @invoked := @invoked + 1; + return x; +end// + +delimiter ;// + +select avg(a) from table_26093; + +select benchmark(100, (select avg(a) from table_26093)); + +set @invoked := 0; +select benchmark(100, (select avg(func_26093_a(a)) from table_26093)); +# Returns only 10, since intermediate results are cached. +select @invoked; + +set @invoked := 0; +select benchmark(100, (select avg(func_26093_b(a, rand())) from table_26093)); +# Returns 1000, due to rand() preventing caching. +select @invoked; + +--error ER_SUBQUERY_NO_1_ROW +select benchmark(100, (select (a) from table_26093)); + +--error ER_OPERAND_COLUMNS +select benchmark(100, (select 1, 1)); + +drop table table_26093; +drop function func_26093_a; +drop function func_26093_b; + --echo End of 5.0 tests |