List:Commits« Previous MessageNext Message »
From:ahristov Date:January 11 2006 5:09pm
Subject:bk commit into 5.1 tree (andrey:1.2033)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey 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.2033 06/01/11 18:09:05 andrey@lmy004. +8 -0
  WL #1034 (Internal CRON) pre-push updates
  - various fixes of test cases
  (hopefully the last pre-push update before the push)

  sql/event_executor.cc
    1.16 06/01/11 18:08:53 andrey@lmy004. +20 -8
    if asked to stop -> stop.

  scripts/mysql_fix_privilege_tables.sql
    1.32 06/01/11 18:08:53 andrey@lmy004. +2 -2
    don't specify the database. this fixes a failing test case which creates the
    tables not on mysql but on a test database and then tests again mysql.

  scripts/mysql_create_system_tables.sh
    1.27 06/01/11 18:08:53 andrey@lmy004. +31 -0
    add missing create table statement

  mysql-test/t/system_mysql_db_fix.test
    1.20 06/01/11 18:08:53 andrey@lmy004. +1 -1
    drop event table and leave the test database empty

  mysql-test/t/events.test
    1.4 06/01/11 18:08:53 andrey@lmy004. +78 -1
    test case for events (internal CRON)

  mysql-test/r/system_mysql_db.result
    1.32 06/01/11 18:06:26 andrey@lmy004. +20 -0
    more testing - add structure of event system table

  mysql-test/r/events.result
    1.3 06/01/11 18:06:26 andrey@lmy004. +104 -1
    results of events test

  mysql-test/include/system_db_struct.inc
    1.6 06/01/11 18:06:25 andrey@lmy004. +1 -0
    extend test case to include testing for event system table

# 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:	andrey
# Host:	lmy004.
# Root:	/work/mysql-5.1-tt-copy-works

--- 1.2/mysql-test/r/events.result	2006-01-10 19:16:41 +01:00
+++ 1.3/mysql-test/r/events.result	2006-01-11 18:06:26 +01:00
@@ -1,4 +1,5 @@
-use test;
+create database if not exists events_test;
+use events_test;
 drop event if exists event1;
 Warnings:
 Note	1305	Event event1 does not exist
@@ -19,3 +20,105 @@
 0
 drop event event3;
 drop table t_event3;
+set names utf8;
+create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1;
+drop event задачка;
+set event_scheduler=0;
+ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL
+set global event_scheduler=2;
+ERROR 42000: Variable 'event_scheduler' can't be set to the value of '2'
+set global event_scheduler=0;
+select count(*) from mysql.event;
+count(*)
+0
+select get_lock("test_lock1", 20);
+get_lock("test_lock1", 20)
+1
+create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
+select count(*) from mysql.event;
+count(*)
+1
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+select release_lock("test_lock1");
+release_lock("test_lock1")
+1
+drop event закачка;
+select count(*) from mysql.event;
+count(*)
+0
+set global event_scheduler=1;
+select get_lock("test_lock2", 20);
+get_lock("test_lock2", 20)
+1
+create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
+select sleep(2);
+sleep(2)
+0
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+2	event_scheduler		NULL	Connect	1	Sleeping	NULL
+3	root		events_test	Connect	1	User lock	select get_lock("test_lock2", 20)
+select release_lock("test_lock2");
+release_lock("test_lock2")
+1
+drop event закачка;
+set global event_scheduler=1;
+select get_lock("test_lock2_1", 20);
+get_lock("test_lock2_1", 20)
+1
+create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
+select sleep(2);
+sleep(2)
+0
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+2	event_scheduler		NULL	Connect	1	Sleeping	NULL
+4	root		events_test	Connect	1	User lock	select get_lock("test_lock2_1", 20)
+set global event_scheduler=0;
+select sleep(2);
+sleep(2)
+0
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+2	event_scheduler		NULL	Connect	3	Sleeping	NULL
+4	root		events_test	Connect	3	User lock	select get_lock("test_lock2_1", 20)
+select release_lock("test_lock2_1");
+release_lock("test_lock2_1")
+1
+select sleep(2);
+sleep(2)
+0
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+drop event закачка21;
+set global event_scheduler=1;
+select get_lock("test_lock3", 20);
+get_lock("test_lock3", 20)
+1
+create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20);
+select sleep(2);
+sleep(2)
+0
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+5	event_scheduler		NULL	Connect	2	Sleeping	NULL
+6	root		events_test	Connect	2	User lock	select get_lock("test_lock3", 20)
+drop event закачка;
+select release_lock("test_lock3");
+release_lock("test_lock3")
+1
+set global event_scheduler=0;
+select sleep(2);
+sleep(2)
+0
+show processlist;
+Id	User	Host	db	Command	Time	State	Info
+1	root	localhost	events_test	Query	0	NULL	show processlist
+drop database events_test;

--- 1.3/mysql-test/t/events.test	2006-01-10 19:16:42 +01:00
+++ 1.4/mysql-test/t/events.test	2006-01-11 18:08:53 +01:00
@@ -1,4 +1,5 @@
-use test;
+create database if not exists events_test;
+use events_test;
 drop event if exists event1;
 create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end;
 alter event event1 rename to event2;
@@ -15,3 +16,79 @@
 select count(*) from t_event3;
 drop event event3;
 drop table t_event3;
+
+set names utf8;
+create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1;
+drop event задачка;
+
+# event_scheduler is a global var
+--error 1229
+set event_scheduler=0;
+# event_scheduler could be only either 0 or 1
+--error 1231
+set global event_scheduler=2;
+
+set global event_scheduler=0;
+select count(*) from mysql.event;
+select get_lock("test_lock1", 20);
+create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
+select count(*) from mysql.event;
+show processlist;
+select release_lock("test_lock1");
+drop event закачка;
+select count(*) from mysql.event;
+
+set global event_scheduler=1;
+select get_lock("test_lock2", 20);
+create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
+select sleep(2);
+show processlist;
+select release_lock("test_lock2");
+drop event закачка;
+
+#
+# 1. get a lock
+# 2. create an event
+# 3. sleep so it has time to start
+# 4. should appear in processlist
+# 5. kill the scheduler, it will wait for the child to stop
+# 6. both processes should be there on show processlist
+# 7. release the lock and sleep, both scheduler and child should end
+set global event_scheduler=1;
+select get_lock("test_lock2_1", 20);
+create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
+select sleep(2);
+show processlist;
+set global event_scheduler=0;
+select sleep(2);
+show processlist;
+select release_lock("test_lock2_1");
+select sleep(2);
+show processlist;
+drop event закачка21;
+
+set global event_scheduler=1;
+select get_lock("test_lock3", 20);
+create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20);
+select sleep(2);
+show processlist;
+drop event закачка;
+select release_lock("test_lock3");
+
+#
+# test with very often occuring event
+# (disabled for now, locks)
+#select get_lock("test_lock4", 20);
+#create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20);
+#select sleep(3);
+#show processlist;
+#drop event закачка4;
+#select release_lock("test_lock4");
+
+set global event_scheduler=0;
+select sleep(2);
+show processlist;
+#the following locks for some reason and is a bug, commented for now
+#select count(*) from mysql.event;
+
+drop database events_test;

--- 1.15/sql/event_executor.cc	2006-01-10 11:31:35 +01:00
+++ 1.16/sql/event_executor.cc	2006-01-11 18:08:53 +01:00
@@ -234,11 +234,16 @@
     event_timed *et;
     
     cnt++;
-    DBUG_PRINT("info", ("EVEX External Loop %d", cnt));
+    DBUG_PRINT("info", ("EVEX External Loop %d thd->k", cnt));
 
     thd->proc_info = "Sleeping";
-    if (!evex_queue_num_elements(EVEX_EQ_NAME) ||
-        !event_executor_running_global_var)
+    if (!event_executor_running_global_var)
+    {
+      sql_print_information("Scheduler asked to stop.");
+      break;
+    }
+
+    if (!evex_queue_num_elements(EVEX_EQ_NAME))
     {
       my_sleep(1000000);// sleep 1s
       continue;
@@ -279,13 +284,16 @@
           We sleep t2sleep seconds but we check every second whether this thread
           has been killed, or there is a new candidate
         */
-        while (t2sleep-- && !thd->killed &&
+        while (t2sleep-- && !thd->killed && event_executor_running_global_var &&
                evex_queue_num_elements(EVEX_EQ_NAME) &&
                (evex_queue_first_element(&EVEX_EQ_NAME, event_timed*) == et))
           my_sleep(1000000);
       }
       if (!event_executor_running_global_var)
-        continue;
+      {
+        sql_print_information("Scheduler asked to stop.");
+        break;
+      }
     }
 
 
@@ -345,7 +353,7 @@
   evex_main_thread_id= 0;
   VOID(pthread_mutex_unlock(&LOCK_evex_running));
 
-  sql_print_information("Event scheduler stopping");
+  sql_print_information("Event scheduler stopping. Waiting for worker threads to finish.");
 
   /*
     TODO: A better will be with a conditional variable
@@ -392,7 +400,7 @@
   VOID(pthread_mutex_unlock(&LOCK_evex_running));
 
   free_root(&evex_mem_root, MYF(0));
-  sql_print_information("Event scheduler stopped");
+  sql_print_information("Event scheduler stopped.");
 
 #ifndef DBUG_FAULTY_THR
   my_thread_end();
@@ -605,14 +613,18 @@
 bool sys_var_event_executor::update(THD *thd, set_var *var)
 {
   // here start the thread if not running.
+  DBUG_ENTER("sys_var_event_executor::update");
   VOID(pthread_mutex_lock(&LOCK_evex_running));
   *value= var->save_result.ulong_value;
+
+  DBUG_PRINT("new_value", ("%d", *value));
   if ((my_bool) *value && !evex_is_running)
   {
     VOID(pthread_mutex_unlock(&LOCK_evex_running));
     init_events();
   } else 
     VOID(pthread_mutex_unlock(&LOCK_evex_running));
-  return 0;
+
+  DBUG_RETURN(0);
 }
 

--- 1.31/scripts/mysql_fix_privilege_tables.sql	2005-12-16 13:01:40 +01:00
+++ 1.32/scripts/mysql_fix_privilege_tables.sql	2006-01-11 18:08:53 +01:00
@@ -562,6 +562,6 @@
 # EVENT privilege
 #
 
-ALTER TABLE mysql.user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
-ALTER TABLE mysql.db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
+ALTER TABLE user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
+ALTER TABLE db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
 

--- 1.5/mysql-test/include/system_db_struct.inc	2005-10-17 17:08:49 +02:00
+++ 1.6/mysql-test/include/system_db_struct.inc	2006-01-11 18:06:25 +01:00
@@ -12,3 +12,4 @@
 show create table columns_priv;
 show create table procs_priv;
 show create table proc;
+show create table event;

--- 1.31/mysql-test/r/system_mysql_db.result	2006-01-10 19:16:42 +01:00
+++ 1.32/mysql-test/r/system_mysql_db.result	2006-01-11 18:06:26 +01:00
@@ -184,5 +184,25 @@
   `comment` char(64) character set utf8 collate utf8_bin NOT NULL default '',
   PRIMARY KEY  (`db`,`name`,`type`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
+show create table event;
+Table	Create Table
+event	CREATE TABLE `event` (
+  `db` char(64) character set utf8 collate utf8_bin NOT NULL default '',
+  `name` char(64) character set utf8 collate utf8_bin NOT NULL default '',
+  `body` longblob NOT NULL,
+  `definer` char(77) character set utf8 collate utf8_bin NOT NULL default '',
+  `execute_at` datetime default NULL,
+  `interval_value` int(11) default NULL,
+  `interval_field` enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL,
+  `created` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `modified` timestamp NOT NULL default '0000-00-00 00:00:00',
+  `last_executed` datetime default NULL,
+  `starts` datetime default NULL,
+  `ends` datetime default NULL,
+  `status` enum('ENABLED','DISABLED') NOT NULL default 'ENABLED',
+  `on_completion` enum('DROP','PRESERVE') NOT NULL default 'DROP',
+  `comment` varchar(64) character set utf8 collate utf8_bin NOT NULL default '',
+  PRIMARY KEY  (`db`,`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
 show tables;
 Tables_in_test

--- 1.19/mysql-test/t/system_mysql_db_fix.test	2005-11-07 16:24:35 +01:00
+++ 1.20/mysql-test/t/system_mysql_db_fix.test	2006-01-11 18:08:53 +01:00
@@ -85,7 +85,7 @@
 
 -- disable_query_log
 
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, event;
 
 -- enable_query_log
 

--- 1.26/scripts/mysql_create_system_tables.sh	2006-01-04 10:36:34 +01:00
+++ 1.27/scripts/mysql_create_system_tables.sh	2006-01-11 18:08:53 +01:00
@@ -741,6 +741,35 @@
   c_p="$c_p comment='Stored Procedures';"
 fi
 
+
+if test ! -f $mdata/event.frm
+then
+  c_ev="$c_ev CREATE TABLE event ("
+  c_ev="$c_ev   db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '',"
+  c_ev="$c_ev   name char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '',"
+  c_ev="$c_ev   body longblob NOT NULL,"
+  c_ev="$c_ev   definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '',"
+  c_ev="$c_ev   execute_at DATETIME default NULL,"
+  c_ev="$c_ev   interval_value int(11) default NULL,"
+  c_ev="$c_ev   interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK',"
+  c_ev="$c_ev                        'SECOND','MICROSECOND', 'YEAR_MONTH','DAY_HOUR',"
+  c_ev="$c_ev                        'DAY_MINUTE','DAY_SECOND',"
+  c_ev="$c_ev                        'HOUR_MINUTE','HOUR_SECOND',"
+  c_ev="$c_ev                        'MINUTE_SECOND','DAY_MICROSECOND',"
+  c_ev="$c_ev                        'HOUR_MICROSECOND','MINUTE_MICROSECOND',"
+  c_ev="$c_ev                        'SECOND_MICROSECOND') default NULL,"
+  c_ev="$c_ev   created TIMESTAMP NOT NULL,"
+  c_ev="$c_ev   modified TIMESTAMP NOT NULL,"
+  c_ev="$c_ev   last_executed DATETIME default NULL,"
+  c_ev="$c_ev   starts DATETIME default NULL,"
+  c_ev="$c_ev   ends DATETIME default NULL,"
+  c_ev="$c_ev   status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED',"
+  c_ev="$c_ev   on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP',"
+  c_ev="$c_ev   comment varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '',"
+  c_ev="$c_ev   PRIMARY KEY  (db,name)"
+  c_ev="$c_ev ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';"
+fi
+
 cat << END_OF_DATA
 use mysql;
 set storage_engine=myisam;
@@ -780,6 +809,8 @@
 
 $c_p
 $c_pp
+
+$c_ev
 
 END_OF_DATA
 
Thread
bk commit into 5.1 tree (andrey:1.2033)ahristov11 Jan