MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:ahristov Date:August 30 2006 12:12pm
Subject:bk commit into 5.1 tree (andrey:1.2285)
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@stripped, 2006-08-30 14:12:20+02:00, andrey@stripped +19 -0
  WL#3337 (Event scheduler new architecture)
  This is a post-review patch.
  
  Fixes the typelib implementation, available only in 5.1.11.
  
  Implement two different TYPELIBs for --event-scheduler cmd line
  option and for GLOBAL variable event_scheduler
  
  --event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
  DISABLED - makes the scheduler unavailable during the server run
  (ON|1)-  When the server is started the scheduler will be started. It can
           be stopped and restarted by setting appropriate values to
           GLOBAL event_scheduler
  (OFF|0)- When the server is started, the scheduler won't be started. It
           can be started and again stopped by setting appropriate values to
           GLOBAL event_scheduler. _DEFAULT_ value
  
  The GLOBAL variable event_scheduler can have the following values:
  OFF | ON | 0 | 1
  DISABLED is not possible and every attempt will end with an error that
  it's not a valid value for the variable.
  OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
            already stopped, and can be started again  by setting
            the value of the variable to ON|1.
  ON | 1  - This is the pre-5.1.11 behavior - The scheduler starts, if not
            already started, and can be stopped again by setting the value
            of the variable to OFF|0.

  mysql-test/r/events.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +10 -8
    update result

  mysql-test/r/events_bugs.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +7 -7
    update result

  mysql-test/r/events_logs_tests.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +4 -4
    update result

  mysql-test/r/events_restart_phase1.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +3 -1
    update result

  mysql-test/r/events_restart_phase3.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +3 -0
    update result

  mysql-test/r/events_scheduling.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +1 -1
    update result

  mysql-test/r/events_stress.result@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +5 -5
    update result

  mysql-test/t/events.test@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +11 -9
    update test:
    2 -> off
    1 -> on

  mysql-test/t/events_bugs.test@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +7 -7
    update test:
    2 -> off
    1 -> on

  mysql-test/t/events_logs_tests.test@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +3 -3
    update test:
    2 -> off
    1 -> on

  mysql-test/t/events_restart_phase1.test@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +3 -1
    update test:
    2 -> off
    1 -> on

  mysql-test/t/events_restart_phase2-master.opt@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +1 -1
    update master file : 1 => on

  mysql-test/t/events_scheduling.test@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +1 -1
    update test:
    2 -> off
    1 -> on

  mysql-test/t/events_stress.test@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +5 -5
    update test:
    2 -> off
    1 -> on

  sql/events.cc@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +29 -12
    Implement two different TYPELIBs for --event-scheduler cmd line
    option and for GLOBAL variable event_scheduler
    
    --event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
    DISABLED - makes the scheduler unavailable during the server run
    (ON|1)-  When the server is started the scheduler will be started. It can
             be stopped and restarted by setting appropriate values to
             GLOBAL event_scheduler
    (OFF|0)- When the server is started, the scheduler won't be started. It
             can be started and again stopped by setting appropriate values to
             GLOBAL event_scheduler. _DEFAULT_ value
    
    The GLOBAL variable event_scheduler can have the following values:
    OFF | ON | 0 | 1
    DISABLED is not possible and every attempt will end with an error that
    it's not a valid value for the variable.
    OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
              already stopped, and can be started again  by setting
              the value of the variable to ON|1.
    ON | 1  - This is the pre-5.1.11 behavior - The scheduler starts, if not
              already started, and can be stopped again by setting the value
              of the variable to OFF|0.

  sql/events.h@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +1 -0
    additional TYPELIB for GLOBAL event_scheduler

  sql/mysqld.cc@stripped, 2006-08-30 14:12:14+02:00, andrey@stripped +9 -6
    --event-scheduler should be checked against a TYPELIB and
    therefore should be GET_STR, as well as we make the parameter optional.
    When not provided OFF|0 is used.

  sql/set_var.cc@stripped, 2006-08-30 14:12:15+02:00, andrey@stripped +22 -16
    Implement typelib for event_scheduler variable.
    If allows both INT_RESULT -> 0 | 1 
    and STRING_RESULT -> OFF | ON
    The variable is shown as DISABLED | ON | OFF

  sql/set_var.h@stripped, 2006-08-30 14:12:15+02:00, andrey@stripped +6 -0
    Implement typelib, which expects both STRING and INT,
    for event_scheduler.

# 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:	fifo.mysql.com
# Root:	/work/mysql-5.1-runtime-wl3337

--- 1.569/sql/mysqld.cc	2006-08-30 14:12:34 +02:00
+++ 1.570/sql/mysqld.cc	2006-08-30 14:12:34 +02:00
@@ -5072,9 +5072,9 @@ Disable with --skip-bdb (will save memor
    (gptr*) &global_system_variables.engine_condition_pushdown,
    (gptr*) &global_system_variables.engine_condition_pushdown,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  /* See how it's handled in get_one_option() */
   {"event-scheduler", OPT_EVENT_SCHEDULER, "Enable/disable the event scheduler.",
-   (gptr*) &Events::opt_event_scheduler, (gptr*) &Events::opt_event_scheduler, 0, GET_ULONG,
-    REQUIRED_ARG, 2/*default*/, 0/*min-value*/, 2/*max-value*/, 0, 0, 0},
+   NULL,  NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"exit-info", 'T', "Used for debugging;  Use at your own risk!", 0, 0, 0,
    GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"external-locking", OPT_USE_LOCKING, "Use system (external) locking (disabled by default).  With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running. Disable with --skip-external-locking.",
@@ -7429,14 +7429,17 @@ get_one_option(int optid, const struct m
       int type;
       if ((type=find_type(argument, &Events::opt_typelib, 1)) <= 0)
       {
-	fprintf(stderr,"Unknown option to event-scheduler: %s\n",argument);
+	fprintf(stderr, "Unknown option to event-scheduler: %s\n",argument);
 	exit(1);
       }
       /* 
-        type=  1     2      3   4     5    6
-             (OFF |  0) - (ON | 1) - (2 | SUSPEND)
+        type=     1          2   3      4   5
+             (DISABLE ) - (ON | OFF) - (1 | 0)
       */
-      Events::opt_event_scheduler= (type-1) / 2;
+      if (type == 1)     // DISABLED
+        Events::opt_event_scheduler= 0;
+      else      
+        Events::opt_event_scheduler= (type - 2) % 2 + 1;
     }
     break;
   case (int) OPT_SKIP_NEW:

--- 1.41/mysql-test/r/events.result	2006-08-30 14:12:34 +02:00
+++ 1.42/mysql-test/r/events.result	2006-08-30 14:12:34 +02:00
@@ -17,13 +17,13 @@ db_x
 SHOW TABLES FROM db_x;
 Tables_in_db_x
 x_table
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 DROP EVENT e_x1;
 DROP EVENT e_x2;
 DROP DATABASE db_x;
 DROP USER pauline@localhost;
 USE events_test;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 drop event if exists event1;
 Warnings:
 Note	1305	Event event1 does not exist
@@ -94,7 +94,7 @@ begin
 alter event e_43 on schedule every 5 minute;
 insert into test_nested values(1);
 end|
-set global event_scheduler = 1;
+set global event_scheduler = on;
 select db, name, body, status, interval_field, interval_value from mysql.event;
 db	name	body	status	interval_field	interval_value
 events_test	e_43	begin
@@ -113,7 +113,7 @@ drop event non_qualif_ev;
 drop table non_qualif;
 alter event non_existant rename to non_existant_too;
 ERROR HY000: Unknown event 'non_existant'
-set global event_scheduler = 2;
+set global event_scheduler = off;
 create event existant on schedule at now() + interval 1 year do select 12;
 alter event non_existant rename to existant;
 ERROR HY000: Event 'existant' already exists
@@ -315,12 +315,14 @@ ERROR HY000: Incorrect AT value: 'defini
 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=2;
+set event_scheduler=off;
 ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL
 set global event_scheduler=3;
 ERROR 42000: Variable 'event_scheduler' can't be set to the value of '3'
+set global event_scheduler=disabled;
+ERROR 42000: Variable 'event_scheduler' can't be set to the value of 'disabled'
 "DISABLE the scheduler. Testing that it does not work when the variable is 0"
-set global event_scheduler=2;
+set global event_scheduler=off;
 select definer, name, db from mysql.event;
 definer	name	db
 select get_lock("test_lock1", 20);
@@ -343,7 +345,7 @@ select count(*) from mysql.event;
 count(*)
 0
 "ENABLE the scheduler and get a lock"
-set global event_scheduler=1;
+set global event_scheduler=on;
 select get_lock("test_lock2", 20);
 get_lock("test_lock2", 20)
 1
@@ -371,7 +373,7 @@ select /*3*/ user, host, db, command, st
 user	host	db	command	state	info
 event_scheduler	localhost	NULL	Daemon	Waiting for next activation	NULL
 root	localhost	events_test	Connect	User lock	select get_lock("test_lock2_1", 20)
-set global event_scheduler=2;
+set global event_scheduler=off;
 "Should have only our process now:"
 select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
 user	host	db	command	state	info

--- 1.18/mysql-test/r/events_bugs.result	2006-08-30 14:12:34 +02:00
+++ 1.19/mysql-test/r/events_bugs.result	2006-08-30 14:12:34 +02:00
@@ -36,9 +36,9 @@ create event e_55 on schedule at 2020010
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'starts 10000101000000 ends 10000101000000 do drop table t' at line 1
 create event e_55 on schedule every 10 hour starts 10000101000000 do drop table t;
 ERROR HY000: Incorrect STARTS value: '10000101000000'
-set global event_scheduler=2;
+set global event_scheduler=off;
 delete from mysql.event;
-set global event_scheduler= 1;
+set global event_scheduler= on;
 set @old_sql_mode:=@@sql_mode;
 set sql_mode=ansi;
 select get_lock('test_bug16407', 60);
@@ -57,7 +57,7 @@ root	localhost	events_test	select get_lo
 select release_lock('test_bug16407');
 release_lock('test_bug16407')
 1
-set global event_scheduler= 2;
+set global event_scheduler= off;
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
 event_schema	event_name	sql_mode
 events_test	e_16407	REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
@@ -118,7 +118,7 @@ release_lock('ee_16407_2')
 select /*3*/ user, host, db, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
 user	host	db	info
 event_scheduler	localhost	NULL	NULL
-set global event_scheduler= 2;
+set global event_scheduler= off;
 select * from events_smode_test order by ev_name, a;
 ev_name	a
 ee_16407_3	1980-02-19
@@ -139,7 +139,7 @@ set sql_mode='ansi';
 select get_lock('ee_16407_5', 60);
 get_lock('ee_16407_5', 60)
 1
-set global event_scheduler= 1;
+set global event_scheduler= on;
 set sql_mode='traditional';
 create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end|
 create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end|
@@ -180,10 +180,10 @@ drop event ee_16407_5;
 drop event ee_16407_6;
 drop procedure ee_16407_5_pendant;
 drop procedure ee_16407_6_pendant;
-set global event_scheduler= 2;
+set global event_scheduler= off;
 drop table events_smode_test;
 set sql_mode=@old_sql_mode;
-set global event_scheduler=2;
+set global event_scheduler=off;
 delete from mysql.user where User like 'mysqltest_%';
 delete from mysql.db where User like 'mysqltest_%';
 flush privileges;

--- 1.1/mysql-test/r/events_restart_phase1.result	2006-08-30 14:12:34 +02:00
+++ 1.2/mysql-test/r/events_restart_phase1.result	2006-08-30 14:12:34 +02:00
@@ -1,10 +1,12 @@
 create database if not exists mysqltest_events_test;
 use mysqltest_events_test;
-set global event_scheduler=2;
+set global event_scheduler=off;
 create table execution_log(name char(10));
 create event abc1 on schedule every 1 second do insert into execution_log value('abc1');
 create event abc2 on schedule every 1 second do insert into execution_log value('abc2');
 create event abc3 on schedule every 1 second do insert into execution_log value('abc3');
+select name from execution_log;
+name
 insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment1');
 insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment2');
 "Now we restart the server"

--- 1.1/mysql-test/r/events_restart_phase3.result	2006-08-30 14:12:34 +02:00
+++ 1.2/mysql-test/r/events_restart_phase3.result	2006-08-30 14:12:34 +02:00
@@ -2,6 +2,9 @@ use mysqltest_events_test;
 "Should get 3 rows : abc1, abc2, abc3
 select distinct name from execution_log order by name;
 name
+abc1
+abc2
+abc3
 drop event abc1;
 drop event abc2;
 drop event abc3;

--- 1.6/mysql-test/r/events_scheduling.result	2006-08-30 14:12:34 +02:00
+++ 1.7/mysql-test/r/events_scheduling.result	2006-08-30 14:12:34 +02:00
@@ -5,7 +5,7 @@ CREATE TABLE table_2(a int);
 CREATE TABLE table_3(a int);
 CREATE TABLE table_4(a int);
 CREATE TABLE T19170(s1 TIMESTAMP);
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
 CREATE EVENT start_n_end
 ON SCHEDULE EVERY 1 SECOND

--- 1.13/mysql-test/r/events_logs_tests.result	2006-08-30 14:12:34 +02:00
+++ 1.14/mysql-test/r/events_logs_tests.result	2006-08-30 14:12:34 +02:00
@@ -14,7 +14,7 @@ USER_HOST	CREATE procedure select_genera
 BEGIN
 SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
 END
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 TRUNCATE mysql.general_log;
 CREATE EVENT log_general ON SCHEDULE EVERY 1 MINUTE DO SELECT 'alabala', SLEEP(1) FROM DUAL;
 "Wait the scheduler to start"
@@ -25,7 +25,7 @@ USER_HOST	CREATE EVENT log_general ON SC
 USER_HOST	SELECT 'alabala', SLEEP(1) FROM DUAL
 DROP PROCEDURE select_general_log;
 DROP EVENT log_general;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 "Check slow query log"
 "Save the values"
 SET @old_global_long_query_time:=(select get_value());
@@ -58,12 +58,12 @@ SET SESSION long_query_time=1;
 SELECT * FROM slow_event_test;
 slo_val	val
 SET SESSION long_query_time=1;
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(1.5);
 "Sleep some more time than the actual event run will take"
 SHOW VARIABLES LIKE 'event_scheduler';
 Variable_name	Value
-event_scheduler	1
+event_scheduler	ON
 "Check our table. Should see 1 row"
 SELECT * FROM slow_event_test;
 slo_val	val

--- 1.5/mysql-test/r/events_stress.result	2006-08-30 14:12:34 +02:00
+++ 1.6/mysql-test/r/events_stress.result	2006-08-30 14:12:34 +02:00
@@ -32,15 +32,15 @@ USE events_conn1_test2;
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
 COUNT(*)
 50
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 DROP DATABASE events_conn1_test2;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
 COUNT(*)
 0
 CREATE DATABASE events_conn1_test3;
 USE events_conn1_test3;
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3';
 COUNT(*)
 50
@@ -55,9 +55,9 @@ DROP DATABASE events_conn2_db;
 DROP DATABASE events_conn3_db;
 DROP DATABASE events_conn1_test2;
 DROP DATABASE events_conn1_test3;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 DROP DATABASE events_conn1_test4;
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 USE events_test;
 DROP TABLE fill_it1;
 DROP TABLE fill_it2;

--- 1.38/mysql-test/t/events.test	2006-08-30 14:12:34 +02:00
+++ 1.39/mysql-test/t/events.test	2006-08-30 14:12:34 +02:00
@@ -21,7 +21,7 @@ SET GLOBAL event_scheduler=1;
 --sleep 1.2
 SHOW DATABASES LIKE 'db_x';
 SHOW TABLES FROM db_x;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 connection priv_conn;
 DROP EVENT e_x1;
 DROP EVENT e_x2;
@@ -33,7 +33,7 @@ USE events_test;
 #
 # END:    BUG #17289 Events: missing privilege check for drop database
 #
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 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 enable;
@@ -92,7 +92,7 @@ begin
   insert into test_nested values(1);
 end|
 delimiter ;|
-set global event_scheduler = 1;
+set global event_scheduler = on;
 --sleep 3
 select db, name, body, status, interval_field, interval_value from mysql.event;
 drop event e_43;
@@ -109,7 +109,7 @@ drop table non_qualif;
 --error ER_EVENT_DOES_NOT_EXIST
 alter event non_existant rename to non_existant_too;
 
-set global event_scheduler = 2;
+set global event_scheduler = off;
 create event existant on schedule at now() + interval 1 year do select 12;
 --error ER_EVENT_ALREADY_EXISTS
 alter event non_existant rename to existant;
@@ -279,13 +279,15 @@ drop event задачка;
 
 # event_scheduler is a global var
 --error ER_GLOBAL_VARIABLE
-set event_scheduler=2;
+set event_scheduler=off;
 # event_scheduler could be only either 1 or 2
 --error ER_WRONG_VALUE_FOR_VAR
 set global event_scheduler=3;
+--error ER_WRONG_VALUE_FOR_VAR
+set global event_scheduler=disabled;
 
 --echo "DISABLE the scheduler. Testing that it does not work when the variable is 0"
-set global event_scheduler=2;
+set global event_scheduler=off;
 select definer, name, db from mysql.event;
 select get_lock("test_lock1", 20);
 create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
@@ -303,7 +305,7 @@ select count(*) from mysql.event;
 #
 #
 --echo "ENABLE the scheduler and get a lock"
-set global event_scheduler=1;
+set global event_scheduler=on;
 select get_lock("test_lock2", 20);
 --echo "Create an event which tries to acquire a mutex. The event locks on the mutex"
 create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
@@ -329,7 +331,7 @@ create event закачка21 on schedul
 --sleep 1
 --echo "Should have only 3 processes: the scheduler, our conn and the locked event"
 select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
-set global event_scheduler=2;
+set global event_scheduler=off;
 --sleep 0.8
 --echo "Should have only our process now:"
 select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
@@ -396,7 +398,7 @@ drop event e1;
 ##drop event закачка4;
 ##select release_lock("test_lock4");
 
-##set global event_scheduler=2;
+##set global event_scheduler=off;
 ##select sleep(2);
 ##--replace_column 1 # 6 #
 ##show processlist;

--- 1.14/mysql-test/t/events_bugs.test	2006-08-30 14:12:34 +02:00
+++ 1.15/mysql-test/t/events_bugs.test	2006-08-30 14:12:34 +02:00
@@ -65,9 +65,9 @@ create event e_55 on schedule every 10 h
 #
 # Start - 16407: Events: Changes in sql_mode won't be taken into account
 #
-set global event_scheduler=2;
+set global event_scheduler=off;
 delete from mysql.event;
-set global event_scheduler= 1;
+set global event_scheduler= on;
 set @old_sql_mode:=@@sql_mode;
 set sql_mode=ansi;
 select get_lock('test_bug16407', 60);
@@ -83,7 +83,7 @@ delimiter ;|
 select /*1*/ user, host, db, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
 select release_lock('test_bug16407');
 
-set global event_scheduler= 2;
+set global event_scheduler= off;
 
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
 --echo "Let's check whether we change the sql_mode on ALTER EVENT"
@@ -132,7 +132,7 @@ select /*2*/ user, host, db, info from i
 select release_lock('ee_16407_2');
 --sleep 1.2
 select /*3*/ user, host, db, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
-set global event_scheduler= 2;
+set global event_scheduler= off;
 select * from events_smode_test order by ev_name, a;
 --echo "OK, last check before we drop them"
 select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
@@ -146,7 +146,7 @@ delete from events_smode_test;
 set sql_mode='ansi';
 select get_lock('ee_16407_5', 60);
 
-set global event_scheduler= 1;
+set global event_scheduler= on;
 
 set sql_mode='traditional';
 delimiter |;
@@ -179,7 +179,7 @@ drop event ee_16407_5;
 drop event ee_16407_6;
 drop procedure ee_16407_5_pendant;
 drop procedure ee_16407_6_pendant;
-set global event_scheduler= 2;
+set global event_scheduler= off;
 drop table events_smode_test;
 set sql_mode=@old_sql_mode;
 #
@@ -189,7 +189,7 @@ set sql_mode=@old_sql_mode;
 #
 # START - 18897: Events: unauthorized action possible with alter event rename
 #
-set global event_scheduler=2;
+set global event_scheduler=off;
 --disable_warnings
 delete from mysql.user where User like 'mysqltest_%';
 delete from mysql.db where User like 'mysqltest_%';

--- 1.1/mysql-test/t/events_restart_phase1.test	2006-08-30 14:12:34 +02:00
+++ 1.2/mysql-test/t/events_restart_phase1.test	2006-08-30 14:12:34 +02:00
@@ -6,11 +6,13 @@ create database if not exists mysqltest_
 --enable_warnings
 
 use mysqltest_events_test;
-set global event_scheduler=2;
+set global event_scheduler=off;
 create table execution_log(name char(10));
 create event abc1 on schedule every 1 second do insert into execution_log value('abc1');
 create event abc2 on schedule every 1 second do insert into execution_log value('abc2');
 create event abc3 on schedule every 1 second do insert into execution_log value('abc3');
+--sleep 1.5
+select name from execution_log;
 
 insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment1');
 insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment2');

--- 1.1/mysql-test/t/events_restart_phase2-master.opt	2006-08-30 14:12:34 +02:00
+++ 1.2/mysql-test/t/events_restart_phase2-master.opt	2006-08-30 14:12:34 +02:00
@@ -1 +1 @@
---event-scheduler=1
+--event-scheduler=on

--- 1.8/mysql-test/t/events_scheduling.test	2006-08-30 14:12:34 +02:00
+++ 1.9/mysql-test/t/events_scheduling.test	2006-08-30 14:12:34 +02:00
@@ -9,7 +9,7 @@ CREATE TABLE table_2(a int);
 CREATE TABLE table_3(a int);
 CREATE TABLE table_4(a int);
 CREATE TABLE T19170(s1 TIMESTAMP);
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 # We need to have 2 to make it safe with valgrind. This is probably because
 # of when we calculate the timestamp value
 CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);

--- 1.13/mysql-test/t/events_logs_tests.test	2006-08-30 14:12:34 +02:00
+++ 1.14/mysql-test/t/events_logs_tests.test	2006-08-30 14:12:34 +02:00
@@ -15,7 +15,7 @@ delimiter ;|
 --echo "Check General Query Log"
 --replace_column 1 USER_HOST
 CALL select_general_log();
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 TRUNCATE mysql.general_log;
 CREATE EVENT log_general ON SCHEDULE EVERY 1 MINUTE DO SELECT 'alabala', SLEEP(1) FROM DUAL;
 --echo "Wait the scheduler to start"
@@ -25,7 +25,7 @@ CREATE EVENT log_general ON SCHEDULE EVE
 CALL select_general_log();
 DROP PROCEDURE select_general_log;
 DROP EVENT log_general;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 
 --echo "Check slow query log"
 --disable_query_log
@@ -71,7 +71,7 @@ SET SESSION long_query_time=1;
 --echo "This won't go to the slow log"
 SELECT * FROM slow_event_test;
 SET SESSION long_query_time=1;
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(1.5);
 --echo "Sleep some more time than the actual event run will take"
 --sleep 2

--- 1.8/mysql-test/t/events_stress.test	2006-08-30 14:12:34 +02:00
+++ 1.9/mysql-test/t/events_stress.test	2006-08-30 14:12:34 +02:00
@@ -61,11 +61,11 @@ while ($1)
 }
 --enable_query_log
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 --sleep 2.5
 DROP DATABASE events_conn1_test2;
 
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
 CREATE DATABASE events_conn1_test3;
 USE events_conn1_test3;
@@ -77,7 +77,7 @@ while ($1)
   dec $1;
 }
 --enable_query_log
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3';
 CREATE DATABASE events_conn1_test4;
 USE events_conn1_test4;
@@ -112,9 +112,9 @@ connection default;
 --send
 DROP DATABASE events_conn1_test2;
 DROP DATABASE events_conn1_test3;
-SET GLOBAL event_scheduler=2;
+SET GLOBAL event_scheduler=off;
 DROP DATABASE events_conn1_test4;
-SET GLOBAL event_scheduler=1;
+SET GLOBAL event_scheduler=on;
 connection conn2;
 reap;
 disconnect conn2;

--- 1.60/sql/events.cc	2006-08-30 14:12:34 +02:00
+++ 1.61/sql/events.cc	2006-08-30 14:12:34 +02:00
@@ -59,17 +59,33 @@
   eligible for execution.
 */
 
-const char *event_scheduler_state_names[]=
-    { "OFF", "0", "ON", "1", "SUSPEND", "2", NullS };
+
+/* This is the typelib for the startup option
+
+*/
+static const char *opt_event_scheduler_state_names[]=
+    { "DISABLED", "ON", "OFF", "1", "0", NullS };
 
 TYPELIB Events::opt_typelib=
 {
-  array_elements(event_scheduler_state_names)-1,
+  array_elements(opt_event_scheduler_state_names)-1,
+  "",
+  opt_event_scheduler_state_names,
+  NULL
+};
+
+static const char *var_event_scheduler_state_names[]=
+    { "OFF", "ON", NullS };
+
+TYPELIB Events::var_typelib=
+{
+  array_elements(var_event_scheduler_state_names)-1,
   "",
-  event_scheduler_state_names,
+  var_event_scheduler_state_names,
   NULL
 };
 
+
 static
 Event_queue events_event_queue;
 
@@ -607,6 +623,9 @@ Events::init()
   bool res= FALSE;
   DBUG_ENTER("Events::init");
 
+  if (!opt_event_scheduler)
+    DBUG_RETURN(FALSE);
+
   /* We need a temporary THD during boot */
   if (!(thd= new THD()))
   {
@@ -637,12 +656,9 @@ Events::init()
   }
   scheduler->init_scheduler(event_queue);
 
-  if (opt_event_scheduler)
-  {
-    DBUG_ASSERT(opt_event_scheduler == 1 || opt_event_scheduler == 2);
-    if (opt_event_scheduler == 1)
-      res= scheduler->start();
-  }
+  DBUG_ASSERT(opt_event_scheduler == 1 || opt_event_scheduler == 2);
+  if (opt_event_scheduler == 1)
+    res= scheduler->start();
 
 end:
   delete thd;
@@ -667,10 +683,11 @@ void
 Events::deinit()
 {
   DBUG_ENTER("Events::deinit");
-
-  if (likely(!check_system_tables_error))
+  if (likely(!check_system_tables_error) &&
+      scheduler->get_state() > Event_scheduler::UNINITIALIZED)
   {
     scheduler->stop();
+    DBUG_ASSERT(scheduler->get_state() == Event_scheduler::INITIALIZED);  
     scheduler->deinit_scheduler();
 
     event_queue->deinit_queue();

--- 1.45/sql/events.h	2006-08-30 14:12:34 +02:00
+++ 1.46/sql/events.h	2006-08-30 14:12:34 +02:00
@@ -51,6 +51,7 @@ public:
 
   static ulong opt_event_scheduler;
   static TYPELIB opt_typelib;
+  static TYPELIB var_typelib;
 
   bool
   init();

--- 1.184/sql/set_var.cc	2006-08-30 14:12:34 +02:00
+++ 1.185/sql/set_var.cc	2006-08-30 14:12:34 +02:00
@@ -3914,6 +3914,7 @@ bool sys_var_thd_dbug::update(THD *thd, 
   return 0;
 }
 
+
 byte *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
 {
   char buf[256];
@@ -3925,6 +3926,12 @@ byte *sys_var_thd_dbug::value_ptr(THD *t
 }
 
 
+bool sys_var_event_scheduler::check(THD *thd, set_var *var)
+{
+  return check_enum(thd, var, &Events::var_typelib);
+}
+
+
 /*
    The update method of the global variable event_scheduler.
    If event_scheduler is switched from 0 to 1 then the scheduler main
@@ -3948,27 +3955,25 @@ sys_var_event_scheduler::update(THD *thd
   DBUG_ENTER("sys_var_event_scheduler::update");
   if (Events::opt_event_scheduler == 0)
   {
-    my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--event-scheduler=0");
+    my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--event-scheduler=DISABLED");
     DBUG_RETURN(TRUE);
   }
 
   DBUG_PRINT("new_value", ("%lu", (bool)var->save_result.ulong_value));
 
-  if (var->save_result.ulonglong_value < 1 ||
-      var->save_result.ulonglong_value > 2)
-  {
-    char buf[64];
-    my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "event_scheduler",
-             llstr(var->save_result.ulonglong_value, buf));
-    DBUG_RETURN(TRUE);
-  }
-  if (var->save_result.ulonglong_value == 1)
+  Item_result var_type= var->value->result_type();
+
+  if (var->save_result.ulong_value == 1)
     res= Events::get_instance()->start_execution_of_events();
-  else
+  else if (var->save_result.ulong_value == 0)
     res= Events::get_instance()->stop_execution_of_events();
-
+  else
+  {
+    DBUG_ASSERT(0);
+  }
   if (res)
     my_error(ER_EVENT_SET_VAR_ERROR, MYF(0));
+
   DBUG_RETURN((bool) res);
 }
 
@@ -3976,14 +3981,15 @@ sys_var_event_scheduler::update(THD *thd
 byte *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
                                          LEX_STRING *base)
 {
+  int state;
   if (Events::opt_event_scheduler == 0)
-    thd->sys_var_tmp.long_value= 0;
+    state= 0;                                    // This should be DISABLED
   else if (Events::get_instance()->is_execution_of_events_started())
-    thd->sys_var_tmp.long_value= 1;
+    state= 1;                                   // This should be ON
   else
-    thd->sys_var_tmp.long_value= 2;
+    state= 2;                                   // This should be OFF
 
-  return (byte*) &thd->sys_var_tmp;
+  return (byte*) Events::opt_typelib.type_names[state];
 }
 
 

--- 1.92/sql/set_var.h	2006-08-30 14:12:34 +02:00
+++ 1.93/sql/set_var.h	2006-08-30 14:12:34 +02:00
@@ -932,6 +932,12 @@ public:
     sys_var_long_ptr(name_arg, NULL, NULL) {};
   bool update(THD *thd, set_var *var);
   byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+  SHOW_TYPE type() { return SHOW_CHAR; }
+  bool check(THD *thd, set_var *var);
+  bool check_update_type(Item_result type)
+  {
+    return type != STRING_RESULT && type != INT_RESULT;
+  }
 };
 
 #ifdef HAVE_ROW_BASED_REPLICATION
Thread
bk commit into 5.1 tree (andrey:1.2285)ahristov30 Aug