Commit 76c6d9cd authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

Fixed BUG#6857: current_time() in STORED PROCEDURES

  Have to thd->set_time() before each substatement execution, to make
  current_time() et al return different times within the same procedure.
parent 65daa271
......@@ -2158,6 +2158,22 @@ call bug8116(42)|
userid
drop procedure bug8116|
drop table t3|
drop procedure if exists bug6857|
create procedure bug6857(counter int)
begin
declare t0, t1 int;
declare plus bool default 0;
set t0 = current_time();
while counter > 0 do
set counter = counter - 1;
end while;
set t1 = current_time();
if t1 > t0 then
set plus = 1;
end if;
select plus;
end|
drop procedure bug6857|
drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
drop procedure if exists ifac|
......
......@@ -2645,6 +2645,37 @@ call bug8116(42)|
drop procedure bug8116|
drop table t3|
#
# BUG#6857: current_time() in STORED PROCEDURES
#
--disable_warnings
drop procedure if exists bug6857|
--enable_warnings
create procedure bug6857(counter int)
begin
declare t0, t1 int;
declare plus bool default 0;
set t0 = current_time();
while counter > 0 do
set counter = counter - 1;
end while;
set t1 = current_time();
if t1 > t0 then
set plus = 1;
end if;
select plus;
end|
# QQ: This is currently disabled. Not only does it slow down a normal test
# run, it makes running with valgrind (or similar tools) extremely
# painful.
# Make sure this takes at least one second on all machines in all builds.
# 30000 makes it about 3 seconds on an old 1.1GHz linux.
#call bug6857(300000)|
drop procedure bug6857|
#
# Some "real" examples
......
......@@ -503,6 +503,7 @@ sp_head::execute(THD *thd)
if (i == NULL)
break;
DBUG_PRINT("execute", ("Instruction %u", ip));
thd->set_time(); // Make current_time() et al work
ret= i->execute(thd, &ip);
thd->rollback_item_tree_changes();
if (i->free_list)
......
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