Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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
1.1979 05/08/11 18:58:22 jimw@stripped +7 -0
Add SLEEP(seconds) function, which always returns 0 after the given
number of seconds (which can include microseconds). (Bug #6760)
sql/lex.h
1.139 05/08/11 18:58:18 jimw@stripped +1 -0
Handle SLEEP() function
sql/item_func.h
1.126 05/08/11 18:58:18 jimw@stripped +11 -0
Add class for sleep() function
sql/item_func.cc
1.239 05/08/11 18:58:18 jimw@stripped +11 -0
Add sleep() implementation
sql/item_create.h
1.42 05/08/11 18:58:18 jimw@stripped +1 -0
Add create_func_sleep()
sql/item_create.cc
1.55 05/08/11 18:58:18 jimw@stripped +5 -0
Add create_func_sleep()
mysql-test/t/func_misc.test
1.14 05/08/11 18:58:18 jimw@stripped +9 -0
Add new regression test.
mysql-test/r/func_misc.result
1.19 05/08/11 18:58:18 jimw@stripped +11 -0
Add new results
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jimw
# Host: rama.(none)
# Root: /home/jimw/my/mysql-5.0-6760
--- 1.54/sql/item_create.cc 2005-07-15 14:01:39 -07:00
+++ 1.55/sql/item_create.cc 2005-08-11 18:58:18 -07:00
@@ -354,6 +354,11 @@
return new Item_func_sha(a);
}
+Item *create_func_sleep(Item* a)
+{
+ return new Item_func_sleep(a);
+}
+
Item *create_func_space(Item *a)
{
CHARSET_INFO *cs= current_thd->variables.collation_connection;
--- 1.41/sql/item_create.h 2005-02-08 14:49:33 -08:00
+++ 1.42/sql/item_create.h 2005-08-11 18:58:18 -07:00
@@ -83,6 +83,7 @@
Item *create_func_sign(Item* a);
Item *create_func_sin(Item* a);
Item *create_func_sha(Item* a);
+Item *create_func_sleep(Item* a);
Item *create_func_soundex(Item* a);
Item *create_func_space(Item *);
Item *create_func_sqrt(Item* a);
--- 1.238/sql/item_func.cc 2005-08-02 20:44:29 -07:00
+++ 1.239/sql/item_func.cc 2005-08-11 18:58:18 -07:00
@@ -3259,6 +3259,17 @@
str->append(')');
}
+/* This function is just used to create tests with time gaps */
+
+longlong Item_func_sleep::val_int()
+{
+ DBUG_ASSERT(fixed == 1);
+ double time= args[0]->val_real();
+ my_sleep((ulong)time*1000000L);
+ return 0;
+}
+
+
#define extra_size sizeof(double)
static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
--- 1.125/sql/item_func.h 2005-07-28 18:37:02 -07:00
+++ 1.126/sql/item_func.h 2005-08-11 18:58:18 -07:00
@@ -874,6 +874,7 @@
}
};
+
class Item_func_benchmark :public Item_int_func
{
ulong loop_count;
@@ -886,6 +887,16 @@
void fix_length_and_dec() { max_length=1; maybe_null=0; }
void print(String *str);
};
+
+
+class Item_func_sleep :public Item_int_func
+{
+public:
+ Item_func_sleep(Item *a) :Item_int_func(a) {}
+ const char *func_name() const { return "sleep"; }
+ longlong val_int();
+};
+
#ifdef HAVE_DLOPEN
--- 1.138/sql/lex.h 2005-07-19 09:06:42 -07:00
+++ 1.139/sql/lex.h 2005-08-11 18:58:18 -07:00
@@ -734,6 +734,7 @@
{ "SIN", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_sin)},
{ "SHA", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_sha)},
{ "SHA1", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_sha)},
+ { "SLEEP", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_sleep)},
{ "SOUNDEX", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_soundex)},
{ "SPACE", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_space)},
{ "SQRT", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_sqrt)},
--- 1.18/mysql-test/r/func_misc.result 2005-05-17 00:51:07 -07:00
+++ 1.19/mysql-test/r/func_misc.result 2005-08-11 18:58:18 -07:00
@@ -59,3 +59,14 @@
`length(uuid())` int(10) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+create table t1 (a timestamp default '2005-05-05 01:01:01',
+b timestamp default '2005-05-05 01:01:01');
+insert into t1 set a = now();
+select sleep(3);
+sleep(3)
+0
+update t1 set b = now();
+select timediff(b, a) >= '00:00:03' from t1;
+timediff(b, a) >= '00:00:03'
+1
+drop table t1;
--- 1.13/mysql-test/t/func_misc.test 2005-07-28 07:09:48 -07:00
+++ 1.14/mysql-test/t/func_misc.test 2005-08-11 18:58:18 -07:00
@@ -46,3 +46,12 @@
create table t1 as select uuid(), length(uuid());
show create table t1;
drop table t1;
+
+# Bug #6760: Add SLEEP() function
+create table t1 (a timestamp default '2005-05-05 01:01:01',
+ b timestamp default '2005-05-05 01:01:01');
+insert into t1 set a = now();
+select sleep(3);
+update t1 set b = now();
+select timediff(b, a) >= '00:00:03' from t1;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (jimw:1.1979) BUG#6760 | Jim Winstead | 12 Aug |