fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
/* Copyright (C) 2004-2006 MySQL AB
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
2006-03-09 17:37:59 -08:00
|
|
|
#define MYSQL_LEX 1
|
2006-06-08 23:07:11 +02:00
|
|
|
#include "mysql_priv.h"
|
|
|
|
#include "events.h"
|
2006-06-27 08:48:50 +02:00
|
|
|
#include "event_data_objects.h"
|
2006-06-28 01:28:03 +02:00
|
|
|
#include "event_db_repository.h"
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
#include "sp_head.h"
|
|
|
|
|
2007-01-29 20:46:29 +03:00
|
|
|
/* That's a provisional solution */
|
|
|
|
extern Event_db_repository events_event_db_repository;
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
#define EVEX_MAX_INTERVAL_VALUE 1000000000L
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
2006-07-13 12:19:01 +02:00
|
|
|
static bool
|
|
|
|
event_change_security_context(THD *thd, LEX_STRING user, LEX_STRING host,
|
2006-07-13 16:24:55 +02:00
|
|
|
LEX_STRING db, Security_context *backup);
|
2006-07-13 12:19:01 +02:00
|
|
|
|
|
|
|
static void
|
2006-07-13 16:24:55 +02:00
|
|
|
event_restore_security_context(THD *thd, Security_context *backup);
|
2006-07-13 12:19:01 +02:00
|
|
|
|
2007-01-29 20:46:29 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
Initiliazes dbname and name of an Event_queue_element_for_exec
|
|
|
|
object
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_queue_element_for_exec::init()
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error (OOM)
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
|
|
|
|
{
|
|
|
|
if (!(dbname.str= my_strndup(db.str, dbname.length= db.length, MYF(MY_WME))))
|
|
|
|
return TRUE;
|
|
|
|
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
|
|
|
|
{
|
|
|
|
my_free((gptr) dbname.str, MYF(0));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Destructor
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_queue_element_for_exec::~Event_queue_element_for_exec()
|
|
|
|
*/
|
|
|
|
|
|
|
|
Event_queue_element_for_exec::~Event_queue_element_for_exec()
|
|
|
|
{
|
|
|
|
my_free((gptr) dbname.str, MYF(0));
|
|
|
|
my_free((gptr) name.str, MYF(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
/*
|
2006-07-03 11:20:08 +02:00
|
|
|
Returns a new instance
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-03 11:20:08 +02:00
|
|
|
Event_parse_data::new_instance()
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
2006-07-03 11:20:08 +02:00
|
|
|
RETURN VALUE
|
|
|
|
Address or NULL in case of error
|
|
|
|
|
|
|
|
NOTE
|
|
|
|
Created on THD's mem_root
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
*/
|
|
|
|
|
WL#3337 (Events new infrasctructure)
Second cut of separating parsing phase from execution phase
Separate Event_timed from parsing phase and introducing Event_parse_data.
sql/event_data_objects.cc:
second cut,
copy Event_timed::init_body() to Event_parse_data::init_body()
Init the body during parsing, everything else keep as a pointer to
Item or some other pointer to use for later initialization.
sql/event_data_objects.h:
get the identifier as sp_name*, later will initialize our structures
sql/events.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/events.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
BitKeeper/etc/ignore:
Added libmysql/viosocket.o.6WmSJk libmysqld/event_data_objects.cc libmysqld/event_db_repository.cc libmysqld/event_queue.cc server-tools/instance-manager/net_serv.cc to the ignore list
sql/share/errmsg.txt:
remove this message, not used and needed for now
sql/sql_lex.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_parse.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_yacc.yy:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
2006-06-27 10:53:26 +02:00
|
|
|
Event_parse_data *
|
|
|
|
Event_parse_data::new_instance(THD *thd)
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
{
|
WL#3337 (Events new infrasctructure)
Second cut of separating parsing phase from execution phase
Separate Event_timed from parsing phase and introducing Event_parse_data.
sql/event_data_objects.cc:
second cut,
copy Event_timed::init_body() to Event_parse_data::init_body()
Init the body during parsing, everything else keep as a pointer to
Item or some other pointer to use for later initialization.
sql/event_data_objects.h:
get the identifier as sp_name*, later will initialize our structures
sql/events.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/events.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
BitKeeper/etc/ignore:
Added libmysql/viosocket.o.6WmSJk libmysqld/event_data_objects.cc libmysqld/event_db_repository.cc libmysqld/event_queue.cc server-tools/instance-manager/net_serv.cc to the ignore list
sql/share/errmsg.txt:
remove this message, not used and needed for now
sql/sql_lex.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_parse.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_yacc.yy:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
2006-06-27 10:53:26 +02:00
|
|
|
return new (thd->mem_root) Event_parse_data;
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
}
|
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
/*
|
2006-07-03 11:20:08 +02:00
|
|
|
Constructor
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
2006-07-03 11:20:08 +02:00
|
|
|
Event_parse_data::Event_parse_data()
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
WL#3337 (Events new infrasctructure)
Second cut of separating parsing phase from execution phase
Separate Event_timed from parsing phase and introducing Event_parse_data.
sql/event_data_objects.cc:
second cut,
copy Event_timed::init_body() to Event_parse_data::init_body()
Init the body during parsing, everything else keep as a pointer to
Item or some other pointer to use for later initialization.
sql/event_data_objects.h:
get the identifier as sp_name*, later will initialize our structures
sql/events.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/events.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
BitKeeper/etc/ignore:
Added libmysql/viosocket.o.6WmSJk libmysqld/event_data_objects.cc libmysqld/event_db_repository.cc libmysqld/event_queue.cc server-tools/instance-manager/net_serv.cc to the ignore list
sql/share/errmsg.txt:
remove this message, not used and needed for now
sql/sql_lex.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_parse.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_yacc.yy:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
2006-06-27 10:53:26 +02:00
|
|
|
Event_parse_data::Event_parse_data()
|
2006-08-17 14:22:59 +02:00
|
|
|
:on_completion(ON_COMPLETION_DROP), status(ENABLED),
|
|
|
|
item_starts(NULL), item_ends(NULL), item_execute_at(NULL),
|
|
|
|
starts_null(TRUE), ends_null(TRUE), execute_at_null(TRUE),
|
|
|
|
item_expression(NULL), expression(0)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::Event_parse_data");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
/* Actually in the parser STARTS is always set */
|
2005-12-08 00:17:05 +01:00
|
|
|
set_zero_time(&starts, MYSQL_TIMESTAMP_DATETIME);
|
|
|
|
set_zero_time(&ends, MYSQL_TIMESTAMP_DATETIME);
|
|
|
|
set_zero_time(&execute_at, MYSQL_TIMESTAMP_DATETIME);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
body.str= comment.str= NULL;
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
body.length= comment.length= 0;
|
2006-02-20 23:52:22 +01:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-02-15 21:08:44 +03:00
|
|
|
Set a name of the event
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_name()
|
2006-02-15 21:08:44 +03:00
|
|
|
thd THD
|
|
|
|
spn the name extracted in the parser
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_name(THD *thd, sp_name *spn)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::init_name");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
/* We have to copy strings to get them into the right memroot */
|
2006-07-07 03:07:45 +04:00
|
|
|
dbname.length= spn->m_db.length;
|
2006-07-10 23:54:46 +02:00
|
|
|
dbname.str= thd->strmake(spn->m_db.str, spn->m_db.length);
|
2006-07-07 03:07:45 +04:00
|
|
|
name.length= spn->m_name.length;
|
2006-07-10 23:54:46 +02:00
|
|
|
name.str= thd->strmake(spn->m_name.str, spn->m_name.length);
|
2006-07-07 03:07:45 +04:00
|
|
|
|
|
|
|
if (spn->m_qname.length == 0)
|
|
|
|
spn->init_qname(thd);
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-02-15 21:08:44 +03:00
|
|
|
Set body of the event - what should be executed.
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_body()
|
2006-02-15 21:08:44 +03:00
|
|
|
thd THD
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
NOTE
|
|
|
|
The body is extracted by copying all data between the
|
|
|
|
start of the body set by another method and the current pointer in Lex.
|
2006-07-10 23:54:46 +02:00
|
|
|
|
2006-05-03 09:55:34 -04:00
|
|
|
Some questionable removal of characters is done in here, and that part
|
|
|
|
should be refactored when the parser is smarter.
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_body(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::init_body");
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("body: '%s' body_begin: 0x%lx end: 0x%lx", body_begin,
|
|
|
|
(long) body_begin, (long) thd->lex->ptr));
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
body.length= thd->lex->ptr - body_begin;
|
2006-05-03 09:55:34 -04:00
|
|
|
const uchar *body_end= body_begin + body.length - 1;
|
|
|
|
|
|
|
|
/* Trim nuls or close-comments ('*'+'/') or spaces at the end */
|
|
|
|
while (body_begin < body_end)
|
|
|
|
{
|
|
|
|
|
|
|
|
if ((*body_end == '\0') ||
|
|
|
|
(my_isspace(thd->variables.character_set_client, *body_end)))
|
|
|
|
{ /* consume NULs and meaningless whitespace */
|
|
|
|
--body.length;
|
|
|
|
--body_end;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
/*
|
2006-05-03 09:55:34 -04:00
|
|
|
consume closing comments
|
|
|
|
|
|
|
|
This is arguably wrong, but it's the best we have until the parser is
|
|
|
|
changed to be smarter. FIXME PARSER
|
|
|
|
|
|
|
|
See also the sp_head code, where something like this is done also.
|
|
|
|
|
|
|
|
One idea is to keep in the lexer structure the count of the number of
|
|
|
|
open-comments we've entered, and scan left-to-right looking for a
|
|
|
|
closing comment IFF the count is greater than zero.
|
|
|
|
|
|
|
|
Another idea is to remove the closing comment-characters wholly in the
|
|
|
|
parser, since that's where it "removes" the opening characters.
|
|
|
|
*/
|
|
|
|
if ((*(body_end - 1) == '*') && (*body_end == '/'))
|
|
|
|
{
|
2006-08-17 14:22:59 +02:00
|
|
|
DBUG_PRINT("info", ("consumend one '*" "/' comment in the query '%s'",
|
2006-05-03 09:55:34 -04:00
|
|
|
body_begin));
|
|
|
|
body.length-= 2;
|
|
|
|
body_end-= 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break; /* none were found, so we have excised all we can. */
|
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-21 02:40:23 +01:00
|
|
|
/* the first is always whitespace which I cannot skip in the parser */
|
|
|
|
while (my_isspace(thd->variables.character_set_client, *body_begin))
|
|
|
|
{
|
|
|
|
++body_begin;
|
|
|
|
--body.length;
|
|
|
|
}
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
body.str= thd->strmake((char *)body_begin, body.length);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-11 18:28:15 +02:00
|
|
|
Sets time for execution for one-time event.
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_execute_at()
|
2006-07-11 18:28:15 +02:00
|
|
|
thd Thread
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
RETURN VALUE
|
2006-07-11 18:28:15 +02:00
|
|
|
0 OK
|
|
|
|
ER_WRONG_VALUE Wrong value for execute at (reported)
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_parse_data::init_execute_at(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
my_bool not_used;
|
|
|
|
TIME ltime;
|
2006-03-03 01:39:11 +01:00
|
|
|
my_time_t t;
|
2005-12-05 11:45:04 +01:00
|
|
|
TIME time_tmp;
|
|
|
|
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::init_execute_at");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (!item_execute_at)
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
|
|
|
|
if (item_execute_at->fix_fields(thd, &item_execute_at))
|
|
|
|
goto wrong_value;
|
2006-02-28 11:43:10 +01:00
|
|
|
|
|
|
|
/* no starts and/or ends in case of execute_at */
|
|
|
|
DBUG_PRINT("info", ("starts_null && ends_null should be 1 is %d",
|
2006-02-28 14:43:49 +01:00
|
|
|
(starts_null && ends_null)));
|
2006-02-28 11:43:10 +01:00
|
|
|
DBUG_ASSERT(starts_null && ends_null);
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
|
2006-02-28 14:43:49 +01:00
|
|
|
/* let's check whether time is in the past */
|
2006-08-17 14:22:59 +02:00
|
|
|
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,
|
2006-02-28 14:43:49 +01:00
|
|
|
(my_time_t) thd->query_start());
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if ((not_used= item_execute_at->get_date(<ime, TIME_NO_ZERO_DATE)))
|
|
|
|
goto wrong_value;
|
2006-01-26 21:21:21 +01:00
|
|
|
|
|
|
|
if (TIME_to_ulonglong_datetime(<ime) <
|
|
|
|
TIME_to_ulonglong_datetime(&time_tmp))
|
2006-07-10 13:44:43 +02:00
|
|
|
{
|
|
|
|
my_error(ER_EVENT_EXEC_TIME_IN_THE_PAST, MYF(0));
|
|
|
|
DBUG_RETURN(ER_WRONG_VALUE);
|
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
/*
|
2006-02-15 21:08:44 +03:00
|
|
|
This may result in a 1970-01-01 date if ltime is > 2037-xx-xx.
|
|
|
|
CONVERT_TZ has similar problem.
|
2006-03-03 01:39:11 +01:00
|
|
|
mysql_priv.h currently lists
|
|
|
|
#define TIMESTAMP_MAX_YEAR 2038 (see TIME_to_timestamp())
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-03-03 01:39:11 +01:00
|
|
|
my_tz_UTC->gmt_sec_to_TIME(<ime,t=TIME_to_timestamp(thd,<ime,¬_used));
|
|
|
|
if (!t)
|
|
|
|
{
|
|
|
|
DBUG_PRINT("error", ("Execute AT after year 2037"));
|
2006-07-10 13:44:43 +02:00
|
|
|
goto wrong_value;
|
2006-03-03 01:39:11 +01:00
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= FALSE;
|
2005-12-08 00:17:05 +01:00
|
|
|
execute_at= ltime;
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_RETURN(0);
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
wrong_value:
|
|
|
|
report_bad_value("AT", item_execute_at);
|
|
|
|
DBUG_RETURN(ER_WRONG_VALUE);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-11 18:28:15 +02:00
|
|
|
Sets time for execution of multi-time event.s
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_interval()
|
2006-07-11 18:28:15 +02:00
|
|
|
thd Thread
|
2005-12-05 11:45:04 +01:00
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
RETURN VALUE
|
2006-07-11 18:28:15 +02:00
|
|
|
0 OK
|
|
|
|
EVEX_BAD_PARAMS Interval is not positive or MICROSECOND (reported)
|
|
|
|
ER_WRONG_VALUE Wrong value for interval (reported)
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_parse_data::init_interval(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-01-18 20:41:22 +01:00
|
|
|
String value;
|
2006-05-29 13:12:34 +02:00
|
|
|
INTERVAL interval_tmp;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::init_interval");
|
2006-07-10 13:44:43 +02:00
|
|
|
if (!item_expression)
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
|
|
|
|
switch (interval) {
|
|
|
|
case INTERVAL_MINUTE_MICROSECOND:
|
|
|
|
case INTERVAL_HOUR_MICROSECOND:
|
|
|
|
case INTERVAL_DAY_MICROSECOND:
|
|
|
|
case INTERVAL_SECOND_MICROSECOND:
|
|
|
|
case INTERVAL_MICROSECOND:
|
|
|
|
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "MICROSECOND");
|
|
|
|
DBUG_RETURN(EVEX_BAD_PARAMS);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (item_expression->fix_fields(thd, &item_expression))
|
|
|
|
goto wrong_value;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-01-18 20:41:22 +01:00
|
|
|
value.alloc(MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN);
|
2006-07-10 13:44:43 +02:00
|
|
|
if (get_interval_value(item_expression, interval, &value, &interval_tmp))
|
|
|
|
goto wrong_value;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-01-18 20:41:22 +01:00
|
|
|
expression= 0;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
switch (interval) {
|
2006-01-18 20:41:22 +01:00
|
|
|
case INTERVAL_YEAR:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.year;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_QUARTER:
|
|
|
|
case INTERVAL_MONTH:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.month;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_WEEK:
|
|
|
|
case INTERVAL_DAY:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.day;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_HOUR:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.hour;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_MINUTE:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.minute;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_SECOND:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.second;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
2006-02-15 21:08:44 +03:00
|
|
|
case INTERVAL_YEAR_MONTH: // Allow YEAR-MONTH YYYYYMM
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.year* 12 + interval_tmp.month;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_DAY_HOUR:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.day* 24 + interval_tmp.hour;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_DAY_MINUTE:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= (interval_tmp.day* 24 + interval_tmp.hour) * 60 +
|
|
|
|
interval_tmp.minute;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
2006-02-28 14:43:49 +01:00
|
|
|
case INTERVAL_HOUR_SECOND: /* day is anyway 0 */
|
2006-01-18 20:41:22 +01:00
|
|
|
case INTERVAL_DAY_SECOND:
|
|
|
|
/* DAY_SECOND having problems because of leap seconds? */
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= ((interval_tmp.day* 24 + interval_tmp.hour) * 60 +
|
|
|
|
interval_tmp.minute)*60
|
|
|
|
+ interval_tmp.second;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_HOUR_MINUTE:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.hour * 60 + interval_tmp.minute;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_MINUTE_SECOND:
|
2006-05-29 13:12:34 +02:00
|
|
|
expression= interval_tmp.minute * 60 + interval_tmp.second;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
2006-06-08 23:07:11 +02:00
|
|
|
case INTERVAL_LAST:
|
|
|
|
DBUG_ASSERT(0);
|
2006-07-10 13:44:43 +02:00
|
|
|
default:
|
|
|
|
;/* these are the microsec stuff */
|
2006-01-18 20:41:22 +01:00
|
|
|
}
|
2006-05-29 13:12:34 +02:00
|
|
|
if (interval_tmp.neg || expression > EVEX_MAX_INTERVAL_VALUE)
|
2006-07-10 13:44:43 +02:00
|
|
|
{
|
|
|
|
my_error(ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG, MYF(0));
|
2006-01-18 20:41:22 +01:00
|
|
|
DBUG_RETURN(EVEX_BAD_PARAMS);
|
2006-07-10 13:44:43 +02:00
|
|
|
}
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_RETURN(0);
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
wrong_value:
|
2006-09-25 16:49:25 +02:00
|
|
|
report_bad_value("INTERVAL", item_expression);
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_RETURN(ER_WRONG_VALUE);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-11 18:28:15 +02:00
|
|
|
Sets STARTS.
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_starts()
|
|
|
|
expr how much?
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
NOTES
|
|
|
|
Note that activation time is not execution time.
|
|
|
|
EVERY 5 MINUTE STARTS "2004-12-12 10:00:00" means that
|
|
|
|
the event will be executed every 5 minutes but this will
|
|
|
|
start at the date shown above. Expressions are possible :
|
|
|
|
DATE_ADD(NOW(), INTERVAL 1 DAY) -- start tommorow at
|
|
|
|
same time.
|
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
RETURN VALUE
|
2006-07-11 18:28:15 +02:00
|
|
|
0 OK
|
|
|
|
ER_WRONG_VALUE Starts before now
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_parse_data::init_starts(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
my_bool not_used;
|
2006-01-26 21:21:21 +01:00
|
|
|
TIME ltime, time_tmp;
|
2006-03-03 01:39:11 +01:00
|
|
|
my_time_t t;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::init_starts");
|
2006-07-10 13:44:43 +02:00
|
|
|
if (!item_starts)
|
|
|
|
DBUG_RETURN(0);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (item_starts->fix_fields(thd, &item_starts))
|
|
|
|
goto wrong_value;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if ((not_used= item_starts->get_date(<ime, TIME_NO_ZERO_DATE)))
|
|
|
|
goto wrong_value;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-12-05 19:04:46 +03:00
|
|
|
/*
|
|
|
|
Let's check whether time is in the past.
|
|
|
|
Note: This call is not post year 2038 safe. That's because
|
|
|
|
thd->query_start() is of time_t, while gmt_sec_to_TIME()
|
|
|
|
wants my_time_t. In the case time_t is larger than my_time_t
|
|
|
|
an overflow might happen and events subsystem will not work as
|
|
|
|
expected.
|
|
|
|
*/
|
2006-02-15 21:08:44 +03:00
|
|
|
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,
|
|
|
|
(my_time_t) thd->query_start());
|
2006-01-26 21:21:21 +01:00
|
|
|
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info",("now: %ld starts: %ld",
|
|
|
|
(long) TIME_to_ulonglong_datetime(&time_tmp),
|
|
|
|
(long) TIME_to_ulonglong_datetime(<ime)));
|
2006-01-26 21:21:21 +01:00
|
|
|
if (TIME_to_ulonglong_datetime(<ime) <
|
|
|
|
TIME_to_ulonglong_datetime(&time_tmp))
|
2006-07-10 13:44:43 +02:00
|
|
|
goto wrong_value;
|
2006-01-26 21:21:21 +01:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
/*
|
2006-12-05 19:04:46 +03:00
|
|
|
Again, after 2038 this code won't work. As
|
|
|
|
mysql_priv.h currently lists
|
2006-03-03 01:39:11 +01:00
|
|
|
#define TIMESTAMP_MAX_YEAR 2038 (see TIME_to_timestamp())
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-12-05 19:04:46 +03:00
|
|
|
my_tz_UTC->gmt_sec_to_TIME(<ime,t=TIME_to_timestamp(thd, <ime,
|
|
|
|
¬_used));
|
2006-03-03 01:39:11 +01:00
|
|
|
if (!t)
|
2006-07-10 13:44:43 +02:00
|
|
|
goto wrong_value;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
starts= ltime;
|
2006-02-28 11:43:10 +01:00
|
|
|
starts_null= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_RETURN(0);
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
wrong_value:
|
|
|
|
report_bad_value("STARTS", item_starts);
|
|
|
|
DBUG_RETURN(ER_WRONG_VALUE);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-11 18:28:15 +02:00
|
|
|
Sets ENDS (deactivation time).
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_parse_data::init_ends()
|
2006-02-15 21:08:44 +03:00
|
|
|
thd THD
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
Note that activation time is not execution time.
|
|
|
|
EVERY 5 MINUTE ENDS "2004-12-12 10:00:00" means that
|
|
|
|
the event will be executed every 5 minutes but this will
|
|
|
|
end at the date shown above. Expressions are possible :
|
|
|
|
DATE_ADD(NOW(), INTERVAL 1 DAY) -- end tommorow at
|
|
|
|
same time.
|
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
RETURN VALUE
|
2006-02-15 21:08:44 +03:00
|
|
|
0 OK
|
2006-07-10 13:44:43 +02:00
|
|
|
EVEX_BAD_PARAMS Error (reported)
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_parse_data::init_ends(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-02-28 11:43:10 +01:00
|
|
|
TIME ltime, ltime_now;
|
2005-12-05 11:45:04 +01:00
|
|
|
my_bool not_used;
|
2006-03-03 01:39:11 +01:00
|
|
|
my_time_t t;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
DBUG_ENTER("Event_parse_data::init_ends");
|
2006-07-10 13:44:43 +02:00
|
|
|
if (!item_ends)
|
|
|
|
DBUG_RETURN(0);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (item_ends->fix_fields(thd, &item_ends))
|
|
|
|
goto error_bad_params;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-28 11:43:10 +01:00
|
|
|
DBUG_PRINT("info", ("convert to TIME"));
|
2006-07-10 13:44:43 +02:00
|
|
|
if ((not_used= item_ends->get_date(<ime, TIME_NO_ZERO_DATE)))
|
|
|
|
goto error_bad_params;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
/*
|
2006-12-05 19:04:46 +03:00
|
|
|
Again, after 2038 this code won't work. As
|
|
|
|
mysql_priv.h currently lists
|
2006-03-03 01:39:11 +01:00
|
|
|
#define TIMESTAMP_MAX_YEAR 2038 (see TIME_to_timestamp())
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-02-28 11:43:10 +01:00
|
|
|
DBUG_PRINT("info", ("get the UTC time"));
|
2006-12-05 19:04:46 +03:00
|
|
|
my_tz_UTC->gmt_sec_to_TIME(<ime,t=TIME_to_timestamp(thd, <ime,
|
|
|
|
¬_used));
|
2006-03-03 01:39:11 +01:00
|
|
|
if (!t)
|
2006-07-10 13:44:43 +02:00
|
|
|
goto error_bad_params;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-02-28 11:43:10 +01:00
|
|
|
/* Check whether ends is after starts */
|
|
|
|
DBUG_PRINT("info", ("ENDS after STARTS?"));
|
|
|
|
if (!starts_null && my_time_compare(&starts, <ime) != -1)
|
2006-07-10 13:44:43 +02:00
|
|
|
goto error_bad_params;
|
2006-02-28 11:43:10 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
The parser forces starts to be provided but one day STARTS could be
|
|
|
|
set before NOW() and in this case the following check should be done.
|
|
|
|
Check whether ENDS is not in the past.
|
|
|
|
*/
|
|
|
|
DBUG_PRINT("info", ("ENDS after NOW?"));
|
2006-02-28 14:43:49 +01:00
|
|
|
my_tz_UTC->gmt_sec_to_TIME(<ime_now, thd->query_start());
|
2006-02-28 11:43:10 +01:00
|
|
|
if (my_time_compare(<ime_now, <ime) == 1)
|
2006-07-10 13:44:43 +02:00
|
|
|
goto error_bad_params;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
ends= ltime;
|
2006-02-28 11:43:10 +01:00
|
|
|
ends_null= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_RETURN(0);
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
error_bad_params:
|
|
|
|
my_error(ER_EVENT_ENDS_BEFORE_STARTS, MYF(0));
|
|
|
|
DBUG_RETURN(EVEX_BAD_PARAMS);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-10 13:44:43 +02:00
|
|
|
Prints an error message about invalid value. Internally used
|
|
|
|
during input data verification
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_parse_data::report_bad_value()
|
|
|
|
item_name The name of the parameter
|
|
|
|
bad_item The parameter
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_parse_data::report_bad_value(const char *item_name, Item *bad_item)
|
|
|
|
{
|
|
|
|
char buff[120];
|
|
|
|
String str(buff,(uint32) sizeof(buff), system_charset_info);
|
|
|
|
String *str2= bad_item->fixed? bad_item->val_str(&str):NULL;
|
|
|
|
my_error(ER_WRONG_VALUE, MYF(0), item_name, str2? str2->c_ptr_safe():"NULL");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-11 18:28:15 +02:00
|
|
|
Checks for validity the data gathered during the parsing phase.
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_parse_data::check_parse_data()
|
|
|
|
thd Thread
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error (reported)
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
Event_parse_data::check_parse_data(THD *thd)
|
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
DBUG_ENTER("Event_parse_data::check_parse_data");
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("execute_at: 0x%lx expr=0x%lx starts=0x%lx ends=0x%lx",
|
|
|
|
(long) item_execute_at, (long) item_expression,
|
|
|
|
(long) item_starts, (long) item_ends));
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
init_name(thd, identifier);
|
|
|
|
|
|
|
|
init_definer(thd);
|
|
|
|
|
|
|
|
ret= init_execute_at(thd) || init_interval(thd) || init_starts(thd) ||
|
|
|
|
init_ends(thd);
|
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
/*
|
|
|
|
Inits definer (definer_user and definer_host) during parsing.
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_parse_data::init_definer()
|
|
|
|
thd Thread
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Event_parse_data::init_definer(THD *thd)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_parse_data::init_definer");
|
|
|
|
|
2007-02-02 20:43:33 +03:00
|
|
|
DBUG_ASSERT(thd->lex->definer);
|
|
|
|
|
|
|
|
const char *definer_user= thd->lex->definer->user.str;
|
|
|
|
const char *definer_host= thd->lex->definer->host.str;
|
|
|
|
int definer_user_len= thd->lex->definer->user.length;
|
|
|
|
int definer_host_len= thd->lex->definer->host.length;
|
2006-07-13 16:24:55 +02:00
|
|
|
|
2007-02-02 20:43:33 +03:00
|
|
|
DBUG_PRINT("info",("init definer_user thd->mem_root: 0x%lx "
|
|
|
|
"definer_user: 0x%lx", (long) thd->mem_root,
|
|
|
|
(long) definer_user));
|
2006-07-13 16:24:55 +02:00
|
|
|
|
|
|
|
/* + 1 for @ */
|
|
|
|
DBUG_PRINT("info",("init definer as whole"));
|
|
|
|
definer.length= definer_user_len + definer_host_len + 1;
|
|
|
|
definer.str= thd->alloc(definer.length + 1);
|
|
|
|
|
|
|
|
DBUG_PRINT("info",("copy the user"));
|
2007-02-02 20:43:33 +03:00
|
|
|
memcpy(definer.str, definer_user, definer_user_len);
|
2006-07-13 16:24:55 +02:00
|
|
|
definer.str[definer_user_len]= '@';
|
|
|
|
|
|
|
|
DBUG_PRINT("info",("copy the host"));
|
2007-02-02 20:43:33 +03:00
|
|
|
memcpy(definer.str + definer_user_len + 1, definer_host, definer_host_len);
|
2006-07-13 16:24:55 +02:00
|
|
|
definer.str[definer.length]= '\0';
|
|
|
|
DBUG_PRINT("info",("definer [%s] initted", definer.str));
|
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
/*
|
|
|
|
Constructor
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_basic::Event_basic()
|
|
|
|
*/
|
|
|
|
|
|
|
|
Event_basic::Event_basic()
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_basic::Event_basic");
|
|
|
|
/* init memory root */
|
|
|
|
init_alloc_root(&mem_root, 256, 512);
|
|
|
|
dbname.str= name.str= NULL;
|
|
|
|
dbname.length= name.length= 0;
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2006-07-10 23:54:46 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Destructor
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
SYNOPSIS
|
|
|
|
Event_basic::Event_basic()
|
|
|
|
*/
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_basic::~Event_basic()
|
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_basic::~Event_basic");
|
|
|
|
free_root(&mem_root, MYF(0));
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-10 13:44:43 +02:00
|
|
|
Short function to load a char column into a LEX_STRING
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_basic::load_string_field()
|
|
|
|
field_name The field( enum_events_table_field is not actually used
|
|
|
|
because it's unknown in event_data_objects.h)
|
|
|
|
fields The Field array
|
|
|
|
field_value The value
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
Event_basic::load_string_fields(Field **fields, ...)
|
|
|
|
{
|
|
|
|
bool ret= FALSE;
|
|
|
|
va_list args;
|
|
|
|
enum enum_events_table_field field_name;
|
|
|
|
LEX_STRING *field_value;
|
|
|
|
|
|
|
|
DBUG_ENTER("Event_basic::load_string_fields");
|
2006-07-10 23:54:46 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
va_start(args, fields);
|
|
|
|
field_name= (enum enum_events_table_field) va_arg(args, int);
|
|
|
|
while (field_name != ET_FIELD_COUNT)
|
|
|
|
{
|
|
|
|
field_value= va_arg(args, LEX_STRING *);
|
|
|
|
if ((field_value->str= get_field(&mem_root, fields[field_name])) == NullS)
|
|
|
|
{
|
|
|
|
ret= TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
field_value->length= strlen(field_value->str);
|
|
|
|
|
|
|
|
field_name= (enum enum_events_table_field) va_arg(args, int);
|
|
|
|
}
|
|
|
|
va_end(args);
|
2006-07-10 23:54:46 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Constructor
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_queue_element::Event_queue_element()
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::Event_queue_element():
|
|
|
|
status_changed(FALSE), last_executed_changed(FALSE),
|
|
|
|
on_completion(ON_COMPLETION_DROP), status(ENABLED),
|
2006-07-17 16:52:45 +02:00
|
|
|
expression(0), dropped(FALSE), execution_count(0)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_queue_element::Event_queue_element");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
set_zero_time(&starts, MYSQL_TIMESTAMP_DATETIME);
|
|
|
|
set_zero_time(&ends, MYSQL_TIMESTAMP_DATETIME);
|
|
|
|
set_zero_time(&execute_at, MYSQL_TIMESTAMP_DATETIME);
|
|
|
|
set_zero_time(&last_executed, MYSQL_TIMESTAMP_DATETIME);
|
|
|
|
starts_null= ends_null= execute_at_null= TRUE;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
2006-02-15 21:08:44 +03:00
|
|
|
|
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL)
EVENT_SCHEMA - MYSQL_TYPE_STRING (the database)
EVENT_NAME - MYSQL_TYPE_STRING (the name)
DEFINER - MYSQL_TYPE_STRING (user@host)
EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event)
EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING")
EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL)
INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL)
SQL_MODE - MYSQL_TYPE_STRING (for now NULL)
STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED)
ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE)
CREATED - MYSQL_TYPE_TIMESTAMP
LAST_ALTERED - MYSQL_TYPE_TIMESTAMP
LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP
EVENT_COMMENT - MYSQL_TYPE_STRING
SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.
This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
because the PK of mysql.event is (definer, db, name) several
users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
of all users. The user has to have PROCESS privilege, if not then
SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
SHOW EVENTS returns table with the following columns, which are subset of
the data which is returned by SELECT * FROM I_S.EVENTS
Db
Name
Definer
Type
Execute at
Interval value
Interval field
Starts
Ends
Status
mysql-test/lib/init_db.sql:
change the PK - (definer, db, name)
quicker searches when SHOW EVENTS;
allow also different users to have events with the same name ->
no information disclosure
mysql-test/r/events.result:
result of new tests
mysql-test/r/information_schema.result:
result of new tests
mysql-test/r/information_schema_db.result:
result of new tests
mysql-test/r/system_mysql_db.result:
result of new tests
mysql-test/t/events.test:
new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
change the PK of mysql.event to (definer, db, name)
sql/event.cc:
pass around the definer of the event because of the new PK
which is (definer, db, name). It's needed for index searching.
sql/event.h:
- make enum evex_table_field again public so it can be used
in sql_show.cc
- make created and modified ulonglong, because they should be such
- make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
- cosmetics
sql/event_priv.h:
- moved enum evex_table_field and evex_open_event_table()
to event.h (made them therefore public)
sql/event_timed.cc:
- in event_timed::init_definer() always fill this.definer with
the concatenated value of definer_user@definer_host. Makes
later the work easier.
- pass around the definer wherever is needed for searching
(new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
- add counter for SHOW EVENTS
sql/sql_lex.h:
- register SHOW EVENTS as command
sql/sql_parse.cc:
- handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
- make additional check in case of SHOW EVENTS (check for EVENT on
the current database. if it is null check_access() gives appropriate
message back.
sql/sql_show.cc:
- add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
- I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
asked to be added so bug #16642 can be completely closed. There
is another bug report which will fix the lack of storage of
SQL_MODE during event creation.
sql/sql_yacc.yy:
- always call event_timed::init_definer() when CREATE/ALTER/DROP
EVENT but not when just compiling the body of the event because
in this case this operation is not needed, it takes memory and
CPU time and at the end the result is not used. event_timed::definer
is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
statement compilation.
- add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
in case of FULL and the user has PROCESS privilege then he will see
also others' events in the current database, otherwise the output
is the same as of SHOW EVENTS. Because the events are per DB only
the events from the current database are shown. pattern is applied
against event name. FROM db is self explanatory.
sql/table.h:
add SCH_EVENTS as part of INFORMATION_SCHEMA
2006-01-30 13:15:23 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
/*
|
|
|
|
Destructor
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
SYNOPSIS
|
|
|
|
Event_queue_element::Event_queue_element()
|
|
|
|
*/
|
|
|
|
Event_queue_element::~Event_queue_element()
|
|
|
|
{
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Constructor
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_timed::Event_timed()
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_timed::Event_timed():
|
|
|
|
created(0), modified(0), sql_mode(0)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_timed::Event_timed");
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
init();
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Destructor
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
Event_timed::~Event_timed()
|
|
|
|
*/
|
|
|
|
|
|
|
|
Event_timed::~Event_timed()
|
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Constructor
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_job_data::Event_job_data()
|
|
|
|
*/
|
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
Event_job_data::Event_job_data()
|
2007-01-29 20:46:29 +03:00
|
|
|
:sphead(NULL), sql_mode(0)
|
2006-07-10 13:44:43 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Destructor
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_timed::~Event_timed()
|
|
|
|
*/
|
|
|
|
|
|
|
|
Event_job_data::~Event_job_data()
|
2006-07-10 23:54:46 +02:00
|
|
|
{
|
2006-07-13 10:59:58 +02:00
|
|
|
DBUG_ENTER("Event_job_data::~Event_job_data");
|
|
|
|
delete sphead;
|
|
|
|
sphead= NULL;
|
|
|
|
DBUG_VOID_RETURN;
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Init all member variables
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_timed::init()
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
Event_timed::init()
|
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_timed::init");
|
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
definer_user.str= definer_host.str= body.str= comment.str= NULL;
|
|
|
|
definer_user.length= definer_host.length= body.length= comment.length= 0;
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
|
|
|
|
sql_mode= 0;
|
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-07-10 13:44:43 +02:00
|
|
|
Loads an event's body from a row from mysql.event
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_job_data::load_from_row(MEM_ROOT *mem_root, TABLE *table)
|
2006-02-15 21:08:44 +03:00
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
RETURN VALUE
|
|
|
|
0 OK
|
|
|
|
EVEX_GET_FIELD_FAILED Error
|
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
NOTES
|
|
|
|
This method is silent on errors and should behave like that. Callers
|
|
|
|
should handle throwing of error messages. The reason is that the class
|
|
|
|
should not know about how to deal with communication.
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_job_data::load_from_row(TABLE *table)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
uint len;
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_job_data::load_from_row");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
if (!table)
|
|
|
|
goto error;
|
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
if (table->s->fields != ET_FIELD_COUNT)
|
2005-12-05 11:45:04 +01:00
|
|
|
goto error;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
load_string_fields(table->field, ET_FIELD_DB, &dbname, ET_FIELD_NAME, &name,
|
|
|
|
ET_FIELD_BODY, &body, ET_FIELD_DEFINER, &definer,
|
|
|
|
ET_FIELD_COUNT);
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
ptr= strchr(definer.str, '@');
|
|
|
|
|
|
|
|
if (! ptr)
|
|
|
|
ptr= definer.str;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
len= ptr - definer.str;
|
|
|
|
definer_user.str= strmake_root(&mem_root, definer.str, len);
|
|
|
|
definer_user.length= len;
|
|
|
|
len= definer.length - len - 1;
|
|
|
|
/* 1:because of @ */
|
2006-07-10 23:54:46 +02:00
|
|
|
definer_host.str= strmake_root(&mem_root, ptr + 1, len);
|
2006-07-10 13:44:43 +02:00
|
|
|
definer_host.length= len;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int();
|
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
error:
|
|
|
|
DBUG_RETURN(EVEX_GET_FIELD_FAILED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Loads an event from a row from mysql.event
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_queue_element::load_from_row(MEM_ROOT *mem_root, TABLE *table)
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
0 OK
|
|
|
|
EVEX_GET_FIELD_FAILED Error
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
This method is silent on errors and should behave like that. Callers
|
|
|
|
should handle throwing of error messages. The reason is that the class
|
|
|
|
should not know about how to deal with communication.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
Event_queue_element::load_from_row(TABLE *table)
|
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
bool res1, res2;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_queue_element::load_from_row");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (!table)
|
2005-12-05 11:45:04 +01:00
|
|
|
goto error;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (table->s->fields != ET_FIELD_COUNT)
|
|
|
|
goto error;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
load_string_fields(table->field, ET_FIELD_DB, &dbname, ET_FIELD_NAME, &name,
|
|
|
|
ET_FIELD_DEFINER, &definer, ET_FIELD_COUNT);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
starts_null= table->field[ET_FIELD_STARTS]->is_null();
|
|
|
|
res1= table->field[ET_FIELD_STARTS]->get_date(&starts, TIME_NO_ZERO_DATE);
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
ends_null= table->field[ET_FIELD_ENDS]->is_null();
|
|
|
|
res2= table->field[ET_FIELD_ENDS]->get_date(&ends, TIME_NO_ZERO_DATE);
|
2006-07-10 23:54:46 +02:00
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
if (!table->field[ET_FIELD_INTERVAL_EXPR]->is_null())
|
2006-07-10 13:44:43 +02:00
|
|
|
expression= table->field[ET_FIELD_INTERVAL_EXPR]->val_int();
|
2006-02-28 11:43:10 +01:00
|
|
|
else
|
2006-07-10 13:44:43 +02:00
|
|
|
expression= 0;
|
2005-12-05 11:45:04 +01:00
|
|
|
/*
|
2006-07-10 13:44:43 +02:00
|
|
|
If res1 and res2 are TRUE then both fields are empty.
|
2006-07-11 18:28:15 +02:00
|
|
|
Hence, if ET_FIELD_EXECUTE_AT is empty there is an error.
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-07-10 13:44:43 +02:00
|
|
|
execute_at_null= table->field[ET_FIELD_EXECUTE_AT]->is_null();
|
|
|
|
DBUG_ASSERT(!(starts_null && ends_null && !expression && execute_at_null));
|
|
|
|
if (!expression &&
|
|
|
|
table->field[ET_FIELD_EXECUTE_AT]->get_date(&execute_at,
|
|
|
|
TIME_NO_ZERO_DATE))
|
2005-12-05 11:45:04 +01:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
/*
|
2006-10-10 17:59:46 +02:00
|
|
|
We load the interval type from disk as string and then map it to
|
|
|
|
an integer. This decouples the values of enum interval_type
|
|
|
|
and values actually stored on disk. Therefore the type can be
|
|
|
|
reordered without risking incompatibilities of data between versions.
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-06-28 01:28:03 +02:00
|
|
|
if (!table->field[ET_FIELD_TRANSIENT_INTERVAL]->is_null())
|
2006-10-10 17:59:46 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char buff[MAX_FIELD_WIDTH];
|
|
|
|
String str(buff, sizeof(buff), &my_charset_bin);
|
|
|
|
LEX_STRING tmp;
|
|
|
|
|
|
|
|
table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_str(&str);
|
|
|
|
if (!(tmp.length= str.length()))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
tmp.str= str.c_ptr_safe();
|
|
|
|
|
|
|
|
i= find_string_in_array(interval_type_to_name, &tmp, system_charset_info);
|
|
|
|
if (i < 0)
|
|
|
|
goto error;
|
|
|
|
interval= (interval_type) i;
|
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
table->field[ET_FIELD_LAST_EXECUTED]->get_date(&last_executed,
|
|
|
|
TIME_NO_ZERO_DATE);
|
|
|
|
last_executed_changed= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
|
2006-07-04 18:44:35 +02:00
|
|
|
if ((ptr= get_field(&mem_root, table->field[ET_FIELD_STATUS])) == NullS)
|
2005-12-05 11:45:04 +01:00
|
|
|
goto error;
|
2006-04-07 09:08:58 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_PRINT("load_from_row", ("Event [%s] is [%s]", name.str, ptr));
|
|
|
|
status= (ptr[0]=='E'? Event_queue_element::ENABLED:
|
|
|
|
Event_queue_element::DISABLED);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-28 14:43:49 +01:00
|
|
|
/* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
|
2006-07-04 18:44:35 +02:00
|
|
|
if ((ptr= get_field(&mem_root,
|
2006-07-10 13:44:43 +02:00
|
|
|
table->field[ET_FIELD_ON_COMPLETION])) == NullS)
|
2005-12-05 11:45:04 +01:00
|
|
|
goto error;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
on_completion= (ptr[0]=='D'? Event_queue_element::ON_COMPLETION_DROP:
|
|
|
|
Event_queue_element::ON_COMPLETION_PRESERVE);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
error:
|
|
|
|
DBUG_RETURN(EVEX_GET_FIELD_FAILED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Loads an event from a row from mysql.event
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
0 OK
|
|
|
|
EVEX_GET_FIELD_FAILED Error
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
This method is silent on errors and should behave like that. Callers
|
|
|
|
should handle throwing of error messages. The reason is that the class
|
|
|
|
should not know about how to deal with communication.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
Event_timed::load_from_row(TABLE *table)
|
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
uint len;
|
|
|
|
|
|
|
|
DBUG_ENTER("Event_timed::load_from_row");
|
|
|
|
|
|
|
|
if (Event_queue_element::load_from_row(table))
|
2005-12-05 11:45:04 +01:00
|
|
|
goto error;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
load_string_fields(table->field, ET_FIELD_BODY, &body, ET_FIELD_COUNT);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
ptr= strchr(definer.str, '@');
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (! ptr)
|
|
|
|
ptr= definer.str;
|
|
|
|
|
|
|
|
len= ptr - definer.str;
|
|
|
|
definer_user.str= strmake_root(&mem_root, definer.str, len);
|
|
|
|
definer_user.length= len;
|
|
|
|
len= definer.length - len - 1;
|
|
|
|
/* 1:because of @ */
|
|
|
|
definer_host.str= strmake_root(&mem_root, ptr + 1, len);
|
|
|
|
definer_host.length= len;
|
|
|
|
|
|
|
|
created= table->field[ET_FIELD_CREATED]->val_int();
|
|
|
|
modified= table->field[ET_FIELD_MODIFIED]->val_int();
|
|
|
|
|
|
|
|
comment.str= get_field(&mem_root, table->field[ET_FIELD_COMMENT]);
|
|
|
|
if (comment.str != NullS)
|
|
|
|
comment.length= strlen(comment.str);
|
2005-12-05 11:45:04 +01:00
|
|
|
else
|
2006-07-10 13:44:43 +02:00
|
|
|
comment.length= 0;
|
2006-02-20 23:52:22 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
sql_mode= (ulong) table->field[ET_FIELD_SQL_MODE]->val_int();
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
error:
|
|
|
|
DBUG_RETURN(EVEX_GET_FIELD_FAILED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
/*
|
2006-04-07 09:08:58 +02:00
|
|
|
Computes the sum of a timestamp plus interval. Presumed is that at least one
|
|
|
|
previous execution has occured.
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
get_next_time(TIME *start, int interval_value, interval_type interval)
|
|
|
|
next the sum
|
|
|
|
start add interval_value to this time
|
2006-04-07 09:08:58 +02:00
|
|
|
time_now current time
|
2006-02-15 21:08:44 +03:00
|
|
|
i_value quantity of time type interval to add
|
|
|
|
i_type type of interval to add (SECOND, MINUTE, HOUR, WEEK ...)
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
RETURN VALUE
|
2006-04-07 09:08:58 +02:00
|
|
|
0 OK
|
|
|
|
1 Error
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
1) If the interval is conversible to SECOND, like MINUTE, HOUR, DAY, WEEK.
|
|
|
|
Then we use TIMEDIFF()'s implementation as underlying and number of
|
|
|
|
seconds as resolution for computation.
|
|
|
|
2) In all other cases - MONTH, QUARTER, YEAR we use MONTH as resolution
|
|
|
|
and PERIOD_DIFF()'s implementation
|
|
|
|
3) We get the difference between time_now and `start`, then divide it
|
|
|
|
by the months, respectively seconds and round up. Then we multiply
|
|
|
|
monts/seconds by the rounded value and add it to `start` -> we get
|
|
|
|
the next execution time.
|
2006-01-18 20:41:22 +01:00
|
|
|
*/
|
2005-12-08 00:17:05 +01:00
|
|
|
|
2006-01-18 20:41:22 +01:00
|
|
|
static
|
2006-04-07 09:08:58 +02:00
|
|
|
bool get_next_time(TIME *next, TIME *start, TIME *time_now, TIME *last_exec,
|
|
|
|
int i_value, interval_type i_type)
|
2006-01-18 20:41:22 +01:00
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
INTERVAL interval;
|
|
|
|
TIME tmp;
|
2006-04-07 09:08:58 +02:00
|
|
|
longlong months=0, seconds=0;
|
|
|
|
DBUG_ENTER("get_next_time");
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("enter", ("start: %lu now: %lu",
|
|
|
|
(long) TIME_to_ulonglong_datetime(start),
|
|
|
|
(long) TIME_to_ulonglong_datetime(time_now)));
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-01-18 20:41:22 +01:00
|
|
|
bzero(&interval, sizeof(interval));
|
|
|
|
|
|
|
|
switch (i_type) {
|
|
|
|
case INTERVAL_YEAR:
|
2006-04-07 09:08:58 +02:00
|
|
|
months= i_value*12;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_QUARTER:
|
2006-04-07 09:08:58 +02:00
|
|
|
/* Has already been converted to months */
|
2006-01-18 20:41:22 +01:00
|
|
|
case INTERVAL_YEAR_MONTH:
|
|
|
|
case INTERVAL_MONTH:
|
2006-04-07 09:08:58 +02:00
|
|
|
months= i_value;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_WEEK:
|
2006-04-07 09:08:58 +02:00
|
|
|
/* WEEK has already been converted to days */
|
2006-01-18 20:41:22 +01:00
|
|
|
case INTERVAL_DAY:
|
2006-04-07 09:08:58 +02:00
|
|
|
seconds= i_value*24*3600;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_DAY_HOUR:
|
|
|
|
case INTERVAL_HOUR:
|
2006-04-07 09:08:58 +02:00
|
|
|
seconds= i_value*3600;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_DAY_MINUTE:
|
|
|
|
case INTERVAL_HOUR_MINUTE:
|
|
|
|
case INTERVAL_MINUTE:
|
2006-04-07 09:08:58 +02:00
|
|
|
seconds= i_value*60;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_DAY_SECOND:
|
|
|
|
case INTERVAL_HOUR_SECOND:
|
|
|
|
case INTERVAL_MINUTE_SECOND:
|
|
|
|
case INTERVAL_SECOND:
|
2006-04-07 09:08:58 +02:00
|
|
|
seconds= i_value;
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
|
|
|
case INTERVAL_DAY_MICROSECOND:
|
|
|
|
case INTERVAL_HOUR_MICROSECOND:
|
|
|
|
case INTERVAL_MINUTE_MICROSECOND:
|
|
|
|
case INTERVAL_SECOND_MICROSECOND:
|
|
|
|
case INTERVAL_MICROSECOND:
|
2006-04-07 09:08:58 +02:00
|
|
|
/*
|
|
|
|
We should return an error here so SHOW EVENTS/ SELECT FROM I_S.EVENTS
|
|
|
|
would give an error then.
|
|
|
|
*/
|
|
|
|
DBUG_RETURN(1);
|
2006-01-18 20:41:22 +01:00
|
|
|
break;
|
2006-06-08 23:07:11 +02:00
|
|
|
case INTERVAL_LAST:
|
|
|
|
DBUG_ASSERT(0);
|
2006-01-18 20:41:22 +01:00
|
|
|
}
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("seconds: %ld months: %ld", (long) seconds, (long) months));
|
2006-04-07 09:08:58 +02:00
|
|
|
if (seconds)
|
|
|
|
{
|
|
|
|
longlong seconds_diff;
|
|
|
|
long microsec_diff;
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-04-07 09:08:58 +02:00
|
|
|
if (calc_time_diff(time_now, start, 1, &seconds_diff, µsec_diff))
|
|
|
|
{
|
|
|
|
DBUG_PRINT("error", ("negative difference"));
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
2006-11-30 03:40:42 +02:00
|
|
|
uint multiplier= (uint) (seconds_diff / seconds);
|
2006-04-07 09:08:58 +02:00
|
|
|
/*
|
|
|
|
Increase the multiplier is the modulus is not zero to make round up.
|
|
|
|
Or if time_now==start then we should not execute the same
|
|
|
|
event two times for the same time
|
|
|
|
get the next exec if the modulus is not
|
|
|
|
*/
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("multiplier: %d", multiplier));
|
2006-04-18 22:21:43 +03:00
|
|
|
if (seconds_diff % seconds || (!seconds_diff && last_exec->year) ||
|
|
|
|
TIME_to_ulonglong_datetime(time_now) ==
|
|
|
|
TIME_to_ulonglong_datetime(last_exec))
|
2006-04-07 09:08:58 +02:00
|
|
|
++multiplier;
|
|
|
|
interval.second= seconds * multiplier;
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("multiplier: %lu interval.second: %lu", (ulong) multiplier,
|
|
|
|
(ulong) interval.second));
|
2006-04-07 09:08:58 +02:00
|
|
|
tmp= *start;
|
|
|
|
if (!(ret= date_add_interval(&tmp, INTERVAL_SECOND, interval)))
|
|
|
|
*next= tmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* PRESUMED is that at least one execution took already place */
|
|
|
|
int diff_months= (time_now->year - start->year)*12 +
|
|
|
|
(time_now->month - start->month);
|
|
|
|
/*
|
|
|
|
Note: If diff_months is 0 that means we are in the same month as the
|
|
|
|
last execution which is also the first execution.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
First we try with the smaller if not then + 1, because if we try with
|
|
|
|
directly with +1 we will be after the current date but it could be that
|
|
|
|
we will be 1 month ahead, so 2 steps are necessary.
|
|
|
|
*/
|
2006-11-30 03:40:42 +02:00
|
|
|
interval.month= (ulong) ((diff_months / months)*months);
|
2006-04-07 09:08:58 +02:00
|
|
|
/*
|
|
|
|
Check if the same month as last_exec (always set - prerequisite)
|
2006-08-17 14:22:59 +02:00
|
|
|
An event happens at most once per month so there is no way to
|
|
|
|
schedule it two times for the current month. This saves us from two
|
|
|
|
calls to date_add_interval() if the event was just executed. But if
|
|
|
|
the scheduler is started and there was at least 1 scheduled date
|
|
|
|
skipped this one does not help and two calls to date_add_interval()
|
|
|
|
will be done, which is a bit more expensive but compared to the
|
|
|
|
rareness of the case is neglectable.
|
2006-04-07 09:08:58 +02:00
|
|
|
*/
|
2006-08-17 14:22:59 +02:00
|
|
|
if (time_now->year == last_exec->year &&
|
|
|
|
time_now->month == last_exec->month)
|
2006-11-30 03:40:42 +02:00
|
|
|
interval.month+= (ulong) months;
|
2006-04-07 09:08:58 +02:00
|
|
|
|
|
|
|
tmp= *start;
|
|
|
|
if ((ret= date_add_interval(&tmp, INTERVAL_MONTH, interval)))
|
|
|
|
goto done;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
2006-04-07 09:08:58 +02:00
|
|
|
/* If `tmp` is still before time_now just add one more time the interval */
|
|
|
|
if (my_time_compare(&tmp, time_now) == -1)
|
|
|
|
{
|
2006-11-30 03:40:42 +02:00
|
|
|
interval.month+= (ulong) months;
|
2006-04-07 09:08:58 +02:00
|
|
|
tmp= *start;
|
|
|
|
if ((ret= date_add_interval(&tmp, INTERVAL_MONTH, interval)))
|
|
|
|
goto done;
|
|
|
|
}
|
2006-01-18 20:41:22 +01:00
|
|
|
*next= tmp;
|
2006-04-07 09:08:58 +02:00
|
|
|
/* assert on that the next is after now */
|
|
|
|
DBUG_ASSERT(1==my_time_compare(next, time_now));
|
|
|
|
}
|
2006-01-18 20:41:22 +01:00
|
|
|
|
2006-04-07 09:08:58 +02:00
|
|
|
done:
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("next: %lu", (long) TIME_to_ulonglong_datetime(next)));
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_RETURN(ret);
|
2006-01-18 20:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-02-15 21:08:44 +03:00
|
|
|
Computes next execution time.
|
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::compute_next_execution_time()
|
2006-02-15 21:08:44 +03:00
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
RETURN VALUE
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error
|
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
NOTES
|
|
|
|
The time is set in execute_at, if no more executions the latter is set to
|
|
|
|
0000-00-00.
|
2005-12-08 00:17:05 +01:00
|
|
|
*/
|
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
bool
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::compute_next_execution_time()
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
TIME time_now;
|
|
|
|
int tmp;
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_queue_element::compute_next_execution_time");
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("enter", ("starts: %lu ends: %lu last_executed: %lu this: 0x%lx",
|
|
|
|
(long) TIME_to_ulonglong_datetime(&starts),
|
|
|
|
(long) TIME_to_ulonglong_datetime(&ends),
|
|
|
|
(long) TIME_to_ulonglong_datetime(&last_executed),
|
|
|
|
(long) this));
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
if (status == Event_queue_element::DISABLED)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
DBUG_PRINT("compute_next_execution_time",
|
2006-11-27 01:47:38 +02:00
|
|
|
("Event %s is DISABLED", name.str));
|
2005-12-05 11:45:04 +01:00
|
|
|
goto ret;
|
|
|
|
}
|
2006-02-15 21:08:44 +03:00
|
|
|
/* If one-time, no need to do computation */
|
2005-12-08 00:17:05 +01:00
|
|
|
if (!expression)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-02-15 21:08:44 +03:00
|
|
|
/* Let's check whether it was executed */
|
2005-12-08 00:17:05 +01:00
|
|
|
if (last_executed.year)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-02-28 11:43:10 +01:00
|
|
|
DBUG_PRINT("info",("One-time event %s.%s of was already executed",
|
2006-11-27 01:47:38 +02:00
|
|
|
dbname.str, name.str));
|
2006-07-10 13:44:43 +02:00
|
|
|
dropped= (on_completion == Event_queue_element::ON_COMPLETION_DROP);
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info",("One-time event will be dropped: %d.", dropped));
|
2006-02-28 11:43:10 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
status= Event_queue_element::DISABLED;
|
|
|
|
status_changed= TRUE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
goto ret;
|
|
|
|
}
|
2006-05-29 10:39:45 +02:00
|
|
|
|
2006-04-07 09:08:58 +02:00
|
|
|
my_tz_UTC->gmt_sec_to_TIME(&time_now, current_thd->query_start());
|
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL)
EVENT_SCHEMA - MYSQL_TYPE_STRING (the database)
EVENT_NAME - MYSQL_TYPE_STRING (the name)
DEFINER - MYSQL_TYPE_STRING (user@host)
EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event)
EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING")
EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL)
INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL)
SQL_MODE - MYSQL_TYPE_STRING (for now NULL)
STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED)
ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE)
CREATED - MYSQL_TYPE_TIMESTAMP
LAST_ALTERED - MYSQL_TYPE_TIMESTAMP
LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP
EVENT_COMMENT - MYSQL_TYPE_STRING
SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.
This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
because the PK of mysql.event is (definer, db, name) several
users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
of all users. The user has to have PROCESS privilege, if not then
SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
SHOW EVENTS returns table with the following columns, which are subset of
the data which is returned by SELECT * FROM I_S.EVENTS
Db
Name
Definer
Type
Execute at
Interval value
Interval field
Starts
Ends
Status
mysql-test/lib/init_db.sql:
change the PK - (definer, db, name)
quicker searches when SHOW EVENTS;
allow also different users to have events with the same name ->
no information disclosure
mysql-test/r/events.result:
result of new tests
mysql-test/r/information_schema.result:
result of new tests
mysql-test/r/information_schema_db.result:
result of new tests
mysql-test/r/system_mysql_db.result:
result of new tests
mysql-test/t/events.test:
new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
change the PK of mysql.event to (definer, db, name)
sql/event.cc:
pass around the definer of the event because of the new PK
which is (definer, db, name). It's needed for index searching.
sql/event.h:
- make enum evex_table_field again public so it can be used
in sql_show.cc
- make created and modified ulonglong, because they should be such
- make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
- cosmetics
sql/event_priv.h:
- moved enum evex_table_field and evex_open_event_table()
to event.h (made them therefore public)
sql/event_timed.cc:
- in event_timed::init_definer() always fill this.definer with
the concatenated value of definer_user@definer_host. Makes
later the work easier.
- pass around the definer wherever is needed for searching
(new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
- add counter for SHOW EVENTS
sql/sql_lex.h:
- register SHOW EVENTS as command
sql/sql_parse.cc:
- handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
- make additional check in case of SHOW EVENTS (check for EVENT on
the current database. if it is null check_access() gives appropriate
message back.
sql/sql_show.cc:
- add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
- I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
asked to be added so bug #16642 can be completely closed. There
is another bug report which will fix the lack of storage of
SQL_MODE during event creation.
sql/sql_yacc.yy:
- always call event_timed::init_definer() when CREATE/ALTER/DROP
EVENT but not when just compiling the body of the event because
in this case this operation is not needed, it takes memory and
CPU time and at the end the result is not used. event_timed::definer
is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
statement compilation.
- add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
in case of FULL and the user has PROCESS privilege then he will see
also others' events in the current database, otherwise the output
is the same as of SHOW EVENTS. Because the events are per DB only
the events from the current database are shown. pattern is applied
against event name. FROM db is self explanatory.
sql/table.h:
add SCH_EVENTS as part of INFORMATION_SCHEMA
2006-01-30 13:15:23 +01:00
|
|
|
|
2006-11-27 18:16:08 +02:00
|
|
|
DBUG_PRINT("info",("NOW: [%lu]",
|
|
|
|
(ulong) TIME_to_ulonglong_datetime(&time_now)));
|
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL)
EVENT_SCHEMA - MYSQL_TYPE_STRING (the database)
EVENT_NAME - MYSQL_TYPE_STRING (the name)
DEFINER - MYSQL_TYPE_STRING (user@host)
EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event)
EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING")
EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL)
INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL)
SQL_MODE - MYSQL_TYPE_STRING (for now NULL)
STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED)
ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE)
CREATED - MYSQL_TYPE_TIMESTAMP
LAST_ALTERED - MYSQL_TYPE_TIMESTAMP
LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP
EVENT_COMMENT - MYSQL_TYPE_STRING
SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.
This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
because the PK of mysql.event is (definer, db, name) several
users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
of all users. The user has to have PROCESS privilege, if not then
SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
SHOW EVENTS returns table with the following columns, which are subset of
the data which is returned by SELECT * FROM I_S.EVENTS
Db
Name
Definer
Type
Execute at
Interval value
Interval field
Starts
Ends
Status
mysql-test/lib/init_db.sql:
change the PK - (definer, db, name)
quicker searches when SHOW EVENTS;
allow also different users to have events with the same name ->
no information disclosure
mysql-test/r/events.result:
result of new tests
mysql-test/r/information_schema.result:
result of new tests
mysql-test/r/information_schema_db.result:
result of new tests
mysql-test/r/system_mysql_db.result:
result of new tests
mysql-test/t/events.test:
new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
change the PK of mysql.event to (definer, db, name)
sql/event.cc:
pass around the definer of the event because of the new PK
which is (definer, db, name). It's needed for index searching.
sql/event.h:
- make enum evex_table_field again public so it can be used
in sql_show.cc
- make created and modified ulonglong, because they should be such
- make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
- cosmetics
sql/event_priv.h:
- moved enum evex_table_field and evex_open_event_table()
to event.h (made them therefore public)
sql/event_timed.cc:
- in event_timed::init_definer() always fill this.definer with
the concatenated value of definer_user@definer_host. Makes
later the work easier.
- pass around the definer wherever is needed for searching
(new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
- add counter for SHOW EVENTS
sql/sql_lex.h:
- register SHOW EVENTS as command
sql/sql_parse.cc:
- handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
- make additional check in case of SHOW EVENTS (check for EVENT on
the current database. if it is null check_access() gives appropriate
message back.
sql/sql_show.cc:
- add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
- I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
asked to be added so bug #16642 can be completely closed. There
is another bug report which will fix the lack of storage of
SQL_MODE during event creation.
sql/sql_yacc.yy:
- always call event_timed::init_definer() when CREATE/ALTER/DROP
EVENT but not when just compiling the body of the event because
in this case this operation is not needed, it takes memory and
CPU time and at the end the result is not used. event_timed::definer
is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
statement compilation.
- add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
in case of FULL and the user has PROCESS privilege then he will see
also others' events in the current database, otherwise the output
is the same as of SHOW EVENTS. Because the events are per DB only
the events from the current database are shown. pattern is applied
against event name. FROM db is self explanatory.
sql/table.h:
add SCH_EVENTS as part of INFORMATION_SCHEMA
2006-01-30 13:15:23 +01:00
|
|
|
|
2006-02-28 12:08:13 +01:00
|
|
|
/* if time_now is after ends don't execute anymore */
|
2006-02-28 11:43:10 +01:00
|
|
|
if (!ends_null && (tmp= my_time_compare(&ends, &time_now)) == -1)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("NOW after ENDS, don't execute anymore"));
|
2006-02-15 21:08:44 +03:00
|
|
|
/* time_now is after ends. don't execute anymore */
|
2005-12-08 00:17:05 +01:00
|
|
|
set_zero_time(&execute_at, MYSQL_TIMESTAMP_DATETIME);
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= TRUE;
|
2006-07-10 13:44:43 +02:00
|
|
|
if (on_completion == Event_queue_element::ON_COMPLETION_DROP)
|
|
|
|
dropped= TRUE;
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("Dropped: %d", dropped));
|
2006-07-10 13:44:43 +02:00
|
|
|
status= Event_queue_element::DISABLED;
|
|
|
|
status_changed= TRUE;
|
2007-01-29 20:46:29 +03:00
|
|
|
dropped= TRUE;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
goto ret;
|
|
|
|
}
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
Here time_now is before or equals ends if the latter is set.
|
|
|
|
Let's check whether time_now is before starts.
|
|
|
|
If so schedule for starts.
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-02-28 11:43:10 +01:00
|
|
|
if (!starts_null && (tmp= my_time_compare(&time_now, &starts)) < 1)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2005-12-08 00:17:05 +01:00
|
|
|
if (tmp == 0 && my_time_compare(&starts, &last_executed) == 0)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-02-15 21:08:44 +03:00
|
|
|
/*
|
2005-12-08 00:17:05 +01:00
|
|
|
time_now = starts = last_executed
|
|
|
|
do nothing or we will schedule for second time execution at starts.
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("STARTS is future, NOW <= STARTS,sched for STARTS"));
|
2005-12-08 00:17:05 +01:00
|
|
|
/*
|
|
|
|
starts is in the future
|
|
|
|
time_now before starts. Scheduling for starts
|
|
|
|
*/
|
|
|
|
execute_at= starts;
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
}
|
2006-02-28 14:43:49 +01:00
|
|
|
|
2006-02-28 11:43:10 +01:00
|
|
|
if (!starts_null && !ends_null)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-02-15 21:08:44 +03:00
|
|
|
/*
|
2005-12-08 00:17:05 +01:00
|
|
|
Both starts and m_ends are set and time_now is between them (incl.)
|
|
|
|
If last_executed is set then increase with m_expression. The new TIME is
|
|
|
|
after m_ends set execute_at to 0. And check for on_completion
|
2005-12-05 11:45:04 +01:00
|
|
|
If not set then schedule for now.
|
|
|
|
*/
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("Both STARTS & ENDS are set"));
|
2005-12-08 00:17:05 +01:00
|
|
|
if (!last_executed.year)
|
2006-02-28 11:43:10 +01:00
|
|
|
{
|
2006-04-18 22:21:43 +03:00
|
|
|
DBUG_PRINT("info", ("Not executed so far."));
|
2006-02-28 11:43:10 +01:00
|
|
|
}
|
2006-04-18 22:21:43 +03:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-01-18 20:41:22 +01:00
|
|
|
TIME next_exec;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-04-18 22:21:43 +03:00
|
|
|
if (get_next_time(&next_exec, &starts, &time_now,
|
|
|
|
last_executed.year? &last_executed:&starts,
|
2006-11-30 03:40:42 +02:00
|
|
|
(int) expression, interval))
|
2006-01-18 20:41:22 +01:00
|
|
|
goto err;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
/* There was previous execution */
|
2006-01-18 20:41:22 +01:00
|
|
|
if (my_time_compare(&ends, &next_exec) == -1)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
DBUG_PRINT("info", ("Next execution of %s after ENDS. Stop executing.",
|
|
|
|
name.str));
|
2006-02-15 21:08:44 +03:00
|
|
|
/* Next execution after ends. No more executions */
|
2005-12-08 00:17:05 +01:00
|
|
|
set_zero_time(&execute_at, MYSQL_TIMESTAMP_DATETIME);
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= TRUE;
|
2006-07-10 13:44:43 +02:00
|
|
|
if (on_completion == Event_queue_element::ON_COMPLETION_DROP)
|
|
|
|
dropped= TRUE;
|
|
|
|
status= Event_queue_element::DISABLED;
|
|
|
|
status_changed= TRUE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
else
|
2006-02-28 11:43:10 +01:00
|
|
|
{
|
2006-11-27 18:16:08 +02:00
|
|
|
DBUG_PRINT("info",("Next[%lu]",
|
|
|
|
(ulong) TIME_to_ulonglong_datetime(&next_exec)));
|
2006-01-18 20:41:22 +01:00
|
|
|
execute_at= next_exec;
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= FALSE;
|
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
goto ret;
|
|
|
|
}
|
2006-08-17 14:22:59 +02:00
|
|
|
else if (starts_null && ends_null)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-04-18 22:21:43 +03:00
|
|
|
/* starts is always set, so this is a dead branch !! */
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("Neither STARTS nor ENDS are set"));
|
2006-02-15 21:08:44 +03:00
|
|
|
/*
|
|
|
|
Both starts and m_ends are not set, so we schedule for the next
|
|
|
|
based on last_executed.
|
|
|
|
*/
|
2006-01-18 20:41:22 +01:00
|
|
|
if (last_executed.year)
|
|
|
|
{
|
2006-04-07 09:08:58 +02:00
|
|
|
TIME next_exec;
|
|
|
|
if (get_next_time(&next_exec, &starts, &time_now, &last_executed,
|
2006-11-30 03:40:42 +02:00
|
|
|
(int) expression, interval))
|
2006-01-18 20:41:22 +01:00
|
|
|
goto err;
|
2006-04-07 09:08:58 +02:00
|
|
|
execute_at= next_exec;
|
2006-11-27 18:16:08 +02:00
|
|
|
DBUG_PRINT("info",("Next[%lu]",
|
|
|
|
(ulong) TIME_to_ulonglong_datetime(&next_exec)));
|
2006-01-18 20:41:22 +01:00
|
|
|
}
|
|
|
|
else
|
2006-02-15 21:08:44 +03:00
|
|
|
{
|
|
|
|
/* last_executed not set. Schedule the event for now */
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("Execute NOW"));
|
2005-12-08 00:17:05 +01:00
|
|
|
execute_at= time_now;
|
2006-02-15 21:08:44 +03:00
|
|
|
}
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-28 12:08:13 +01:00
|
|
|
/* either starts or m_ends is set */
|
2006-02-28 11:43:10 +01:00
|
|
|
if (!starts_null)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("STARTS is set"));
|
2005-12-05 11:45:04 +01:00
|
|
|
/*
|
2005-12-08 00:17:05 +01:00
|
|
|
- starts is set.
|
|
|
|
- starts is not in the future according to check made before
|
|
|
|
Hence schedule for starts + m_expression in case last_executed
|
|
|
|
is not set, otherwise to last_executed + m_expression
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
2006-04-18 22:21:43 +03:00
|
|
|
if (!last_executed.year)
|
|
|
|
{
|
|
|
|
DBUG_PRINT("info", ("Not executed so far."));
|
|
|
|
}
|
|
|
|
|
2006-01-18 20:41:22 +01:00
|
|
|
{
|
2006-04-07 09:08:58 +02:00
|
|
|
TIME next_exec;
|
2006-08-17 14:22:59 +02:00
|
|
|
if (get_next_time(&next_exec, &starts, &time_now,
|
2006-04-18 22:21:43 +03:00
|
|
|
last_executed.year? &last_executed:&starts,
|
2006-11-30 03:40:42 +02:00
|
|
|
(int) expression, interval))
|
2006-01-18 20:41:22 +01:00
|
|
|
goto err;
|
2006-04-07 09:08:58 +02:00
|
|
|
execute_at= next_exec;
|
2006-11-27 18:16:08 +02:00
|
|
|
DBUG_PRINT("info",("Next[%lu]",
|
|
|
|
(ulong) TIME_to_ulonglong_datetime(&next_exec)));
|
2006-01-18 20:41:22 +01:00
|
|
|
}
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-18 22:21:43 +03:00
|
|
|
/* this is a dead branch, because starts is always set !!! */
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("STARTS is not set. ENDS is set"));
|
2005-12-05 11:45:04 +01:00
|
|
|
/*
|
|
|
|
- m_ends is set
|
|
|
|
- m_ends is after time_now or is equal
|
2005-12-08 00:17:05 +01:00
|
|
|
Hence check for m_last_execute and increment with m_expression.
|
|
|
|
If last_executed is not set then schedule for now
|
2005-12-05 11:45:04 +01:00
|
|
|
*/
|
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
if (!last_executed.year)
|
|
|
|
execute_at= time_now;
|
2005-12-05 11:45:04 +01:00
|
|
|
else
|
|
|
|
{
|
2006-01-18 20:41:22 +01:00
|
|
|
TIME next_exec;
|
|
|
|
|
2006-04-07 09:08:58 +02:00
|
|
|
if (get_next_time(&next_exec, &starts, &time_now, &last_executed,
|
2006-11-30 03:40:42 +02:00
|
|
|
(int) expression, interval))
|
2006-01-18 20:41:22 +01:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (my_time_compare(&ends, &next_exec) == -1)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("Next execution after ENDS. Stop executing."));
|
2005-12-08 00:17:05 +01:00
|
|
|
set_zero_time(&execute_at, MYSQL_TIMESTAMP_DATETIME);
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= TRUE;
|
2006-07-10 13:44:43 +02:00
|
|
|
status= Event_queue_element::DISABLED;
|
|
|
|
status_changed= TRUE;
|
|
|
|
if (on_completion == Event_queue_element::ON_COMPLETION_DROP)
|
|
|
|
dropped= TRUE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
else
|
2006-02-28 11:43:10 +01:00
|
|
|
{
|
2006-11-27 18:16:08 +02:00
|
|
|
DBUG_PRINT("info", ("Next[%lu]",
|
|
|
|
(ulong) TIME_to_ulonglong_datetime(&next_exec)));
|
2006-01-18 20:41:22 +01:00
|
|
|
execute_at= next_exec;
|
2006-02-28 11:43:10 +01:00
|
|
|
execute_at_null= FALSE;
|
|
|
|
}
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
goto ret;
|
|
|
|
}
|
|
|
|
ret:
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("ret: 0 execute_at: %lu",
|
|
|
|
(long) TIME_to_ulonglong_datetime(&execute_at)));
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_RETURN(FALSE);
|
2006-01-18 20:41:22 +01:00
|
|
|
err:
|
2006-04-07 09:08:58 +02:00
|
|
|
DBUG_PRINT("info", ("ret=1"));
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_RETURN(TRUE);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-14 16:20:48 +01:00
|
|
|
/*
|
|
|
|
Set the internal last_executed TIME struct to now. NOW is the
|
|
|
|
time according to thd->query_start(), so the THD's clock.
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::mark_last_executed()
|
2006-02-15 21:08:44 +03:00
|
|
|
thd thread context
|
2006-02-14 16:20:48 +01:00
|
|
|
*/
|
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
void
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::mark_last_executed(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
TIME time_now;
|
|
|
|
|
2006-01-18 20:41:22 +01:00
|
|
|
thd->end_time();
|
|
|
|
my_tz_UTC->gmt_sec_to_TIME(&time_now, (my_time_t) thd->query_start());
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-02-28 14:43:49 +01:00
|
|
|
last_executed= time_now; /* was execute_at */
|
2006-07-10 13:44:43 +02:00
|
|
|
last_executed_changed= TRUE;
|
2006-07-17 16:52:45 +02:00
|
|
|
|
|
|
|
execution_count++;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-14 16:20:48 +01:00
|
|
|
/*
|
|
|
|
Saves status and last_executed_at to the disk if changed.
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::update_timing_fields()
|
2006-02-14 16:20:48 +01:00
|
|
|
thd - thread context
|
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
RETURN VALUE
|
2006-07-11 18:28:15 +02:00
|
|
|
FALSE OK
|
2006-08-17 14:22:59 +02:00
|
|
|
TRUE Error while opening mysql.event for writing or during
|
|
|
|
write on disk
|
2006-02-14 16:20:48 +01:00
|
|
|
*/
|
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
bool
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue_element::update_timing_fields(THD *thd)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
|
|
|
TABLE *table;
|
2006-07-11 18:28:15 +02:00
|
|
|
Field **fields;
|
2005-12-13 23:10:29 +01:00
|
|
|
Open_tables_state backup;
|
2006-07-11 18:28:15 +02:00
|
|
|
int ret= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_queue_element::update_timing_fields");
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
DBUG_PRINT("enter", ("name: %*s", name.length, name.str));
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
/* No need to update if nothing has changed */
|
2005-12-08 00:17:05 +01:00
|
|
|
if (!(status_changed || last_executed_changed))
|
2006-05-29 10:39:45 +02:00
|
|
|
DBUG_RETURN(0);
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2005-12-13 23:10:29 +01:00
|
|
|
thd->reset_n_backup_open_tables_state(&backup);
|
|
|
|
|
2007-01-29 20:46:29 +03:00
|
|
|
if (events_event_db_repository.open_event_table(thd, TL_WRITE, &table))
|
2005-12-13 23:10:29 +01:00
|
|
|
{
|
2006-07-11 18:28:15 +02:00
|
|
|
ret= TRUE;
|
2005-12-13 23:10:29 +01:00
|
|
|
goto done;
|
|
|
|
}
|
2006-07-11 18:28:15 +02:00
|
|
|
fields= table->field;
|
2007-01-29 20:46:29 +03:00
|
|
|
if ((ret= events_event_db_repository.
|
2006-07-11 18:28:15 +02:00
|
|
|
find_named_event(thd, dbname, name, table)))
|
2005-12-05 11:45:04 +01:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
store_record(table,record[1]);
|
2006-02-15 21:08:44 +03:00
|
|
|
/* Don't update create on row update. */
|
|
|
|
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
if (last_executed_changed)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-11 18:28:15 +02:00
|
|
|
fields[ET_FIELD_LAST_EXECUTED]->set_notnull();
|
|
|
|
fields[ET_FIELD_LAST_EXECUTED]->store_time(&last_executed,
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
MYSQL_TIMESTAMP_DATETIME);
|
2006-07-10 13:44:43 +02:00
|
|
|
last_executed_changed= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
2005-12-08 00:17:05 +01:00
|
|
|
if (status_changed)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-11 18:28:15 +02:00
|
|
|
fields[ET_FIELD_STATUS]->set_notnull();
|
|
|
|
fields[ET_FIELD_STATUS]->store((longlong)status, TRUE);
|
2006-07-10 13:44:43 +02:00
|
|
|
status_changed= FALSE;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-07-11 18:28:15 +02:00
|
|
|
if ((table->file->ha_update_row(table->record[1], table->record[0])))
|
|
|
|
ret= TRUE;
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
close_thread_tables(thd);
|
2005-12-13 23:10:29 +01:00
|
|
|
thd->restore_backup_open_tables_state(&backup);
|
2005-12-05 11:45:04 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-14 16:20:48 +01:00
|
|
|
/*
|
|
|
|
Get SHOW CREATE EVENT as string
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-02-28 18:33:38 +01:00
|
|
|
Event_timed::get_create_event(THD *thd, String *buf)
|
2006-02-15 21:08:44 +03:00
|
|
|
thd Thread
|
|
|
|
buf String*, should be already allocated. CREATE EVENT goes inside.
|
|
|
|
|
|
|
|
RETURN VALUE
|
2006-02-20 16:06:05 +01:00
|
|
|
0 OK
|
|
|
|
EVEX_MICROSECOND_UNSUP Error (for now if mysql.event has been
|
|
|
|
tampered and MICROSECONDS interval or
|
|
|
|
derivative has been put there.
|
2006-02-14 16:20:48 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2006-02-28 18:33:38 +01:00
|
|
|
Event_timed::get_create_event(THD *thd, String *buf)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-07-10 13:44:43 +02:00
|
|
|
char tmp_buf[2 * STRING_BUFFER_USUAL_SIZE];
|
|
|
|
String expr_buf(tmp_buf, sizeof(tmp_buf), system_charset_info);
|
2006-02-14 16:20:48 +01:00
|
|
|
expr_buf.length(0);
|
|
|
|
|
|
|
|
DBUG_ENTER("get_create_event");
|
2006-01-20 22:24:58 +01:00
|
|
|
DBUG_PRINT("ret_info",("body_len=[%d]body=[%s]", body.length, body.str));
|
2005-12-05 11:45:04 +01:00
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
if (expression && Events::reconstruct_interval_expression(&expr_buf, interval,
|
|
|
|
expression))
|
2006-02-20 16:06:05 +01:00
|
|
|
DBUG_RETURN(EVEX_MICROSECOND_UNSUP);
|
2006-02-14 16:20:48 +01:00
|
|
|
|
|
|
|
buf->append(STRING_WITH_LEN("CREATE EVENT "));
|
|
|
|
append_identifier(thd, buf, name.str, name.length);
|
|
|
|
|
|
|
|
if (expression)
|
|
|
|
{
|
2006-07-11 18:28:15 +02:00
|
|
|
buf->append(STRING_WITH_LEN(" ON SCHEDULE EVERY "));
|
2006-02-14 16:20:48 +01:00
|
|
|
buf->append(expr_buf);
|
2006-02-16 13:11:16 +01:00
|
|
|
buf->append(' ');
|
|
|
|
LEX_STRING *ival= &interval_type_to_name[interval];
|
|
|
|
buf->append(ival->str, ival->length);
|
2006-02-14 16:20:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-28 14:43:49 +01:00
|
|
|
char dtime_buff[20*2+32];/* +32 to make my_snprintf_{8bit|ucs2} happy */
|
2006-07-11 18:28:15 +02:00
|
|
|
buf->append(STRING_WITH_LEN(" ON SCHEDULE AT '"));
|
2006-02-15 21:08:44 +03:00
|
|
|
/*
|
|
|
|
Pass the buffer and the second param tells fills the buffer and
|
|
|
|
returns the number of chars to copy.
|
2006-02-14 16:20:48 +01:00
|
|
|
*/
|
|
|
|
buf->append(dtime_buff, my_datetime_to_str(&execute_at, dtime_buff));
|
|
|
|
buf->append(STRING_WITH_LEN("'"));
|
|
|
|
}
|
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
if (on_completion == Event_timed::ON_COMPLETION_DROP)
|
2006-02-14 16:20:48 +01:00
|
|
|
buf->append(STRING_WITH_LEN(" ON COMPLETION NOT PRESERVE "));
|
|
|
|
else
|
|
|
|
buf->append(STRING_WITH_LEN(" ON COMPLETION PRESERVE "));
|
|
|
|
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
if (status == Event_timed::ENABLED)
|
2006-02-14 16:20:48 +01:00
|
|
|
buf->append(STRING_WITH_LEN("ENABLE"));
|
|
|
|
else
|
|
|
|
buf->append(STRING_WITH_LEN("DISABLE"));
|
|
|
|
|
|
|
|
if (comment.length)
|
|
|
|
{
|
|
|
|
buf->append(STRING_WITH_LEN(" COMMENT "));
|
|
|
|
append_unescaped(buf, comment.str, comment.length);
|
|
|
|
}
|
|
|
|
buf->append(STRING_WITH_LEN(" DO "));
|
2006-02-15 21:08:44 +03:00
|
|
|
buf->append(body.str, body.length);
|
2006-02-14 16:20:48 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
/*
|
|
|
|
Get SHOW CREATE EVENT as string
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_job_data::get_create_event(THD *thd, String *buf)
|
|
|
|
thd Thread
|
|
|
|
buf String*, should be already allocated. CREATE EVENT goes inside.
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
0 OK
|
|
|
|
EVEX_MICROSECOND_UNSUP Error (for now if mysql.event has been
|
|
|
|
tampered and MICROSECONDS interval or
|
|
|
|
derivative has been put there.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
Event_job_data::get_fake_create_event(THD *thd, String *buf)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("Event_job_data::get_create_event");
|
2006-07-11 18:28:15 +02:00
|
|
|
buf->append(STRING_WITH_LEN("CREATE EVENT anonymous ON SCHEDULE "
|
2006-07-10 13:44:43 +02:00
|
|
|
"EVERY 3337 HOUR DO "));
|
|
|
|
buf->append(body.str, body.length);
|
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
/*
|
|
|
|
Executes the event (the underlying sp_head object);
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
Event_job_data::execute()
|
|
|
|
thd THD
|
|
|
|
|
|
|
|
RETURN VALUE
|
|
|
|
0 success
|
|
|
|
-99 No rights on this.dbname.str
|
|
|
|
others retcodes of sp_head::execute_procedure()
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
Event_job_data::execute(THD *thd)
|
|
|
|
{
|
|
|
|
Security_context save_ctx;
|
|
|
|
/* this one is local and not needed after exec */
|
|
|
|
int ret= 0;
|
|
|
|
|
|
|
|
DBUG_ENTER("Event_job_data::execute");
|
|
|
|
DBUG_PRINT("info", ("EXECUTING %s.%s", dbname.str, name.str));
|
|
|
|
|
|
|
|
if ((ret= compile(thd, NULL)))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
event_change_security_context(thd, definer_user, definer_host, dbname,
|
|
|
|
&save_ctx);
|
|
|
|
/*
|
2006-08-17 14:22:59 +02:00
|
|
|
THD::~THD will clean this or if there is DROP DATABASE in the
|
|
|
|
SP then it will be free there. It should not point to our buffer
|
|
|
|
which is allocated on a mem_root.
|
2006-07-13 16:24:55 +02:00
|
|
|
*/
|
|
|
|
thd->db= my_strdup(dbname.str, MYF(0));
|
|
|
|
thd->db_length= dbname.length;
|
|
|
|
if (!check_access(thd, EVENT_ACL,dbname.str, 0, 0, 0,is_schema_db(dbname.str)))
|
|
|
|
{
|
|
|
|
List<Item> empty_item_list;
|
|
|
|
empty_item_list.empty();
|
|
|
|
if (thd->enable_slow_log)
|
|
|
|
sphead->m_flags|= sp_head::LOG_SLOW_STATEMENTS;
|
|
|
|
sphead->m_flags|= sp_head::LOG_GENERAL_LOG;
|
|
|
|
|
|
|
|
ret= sphead->execute_procedure(thd, &empty_item_list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBUG_PRINT("error", ("%s@%s has no rights on %s", definer_user.str,
|
|
|
|
definer_host.str, dbname.str));
|
|
|
|
ret= -99;
|
|
|
|
}
|
|
|
|
|
|
|
|
event_restore_security_context(thd, &save_ctx);
|
|
|
|
done:
|
|
|
|
thd->end_statement();
|
|
|
|
thd->cleanup_after_query();
|
|
|
|
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("EXECUTED %s.%s ret: %d", dbname.str, name.str, ret));
|
2006-07-13 16:24:55 +02:00
|
|
|
|
|
|
|
DBUG_RETURN(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-08 15:34:11 +01:00
|
|
|
/*
|
2006-02-14 16:20:48 +01:00
|
|
|
Compiles an event before it's execution. Compiles the anonymous
|
|
|
|
sp_head object held by the event
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_job_data::compile()
|
2006-02-15 21:08:44 +03:00
|
|
|
thd thread context, used for memory allocation mostly
|
|
|
|
mem_root if != NULL then this memory root is used for allocs
|
|
|
|
instead of thd->mem_root
|
2005-12-08 15:34:11 +01:00
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
RETURN VALUE
|
2006-02-20 16:06:05 +01:00
|
|
|
0 success
|
|
|
|
EVEX_COMPILE_ERROR error during compilation
|
|
|
|
EVEX_MICROSECOND_UNSUP mysql.event was tampered
|
2005-12-08 15:34:11 +01:00
|
|
|
*/
|
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2005-12-08 20:37:54 +01:00
|
|
|
int ret= 0;
|
2005-12-05 11:45:04 +01:00
|
|
|
MEM_ROOT *tmp_mem_root= 0;
|
|
|
|
LEX *old_lex= thd->lex, lex;
|
|
|
|
char *old_db;
|
2006-02-16 00:43:11 +01:00
|
|
|
int old_db_length;
|
2005-12-05 11:45:04 +01:00
|
|
|
char *old_query;
|
|
|
|
uint old_query_len;
|
2006-02-20 23:52:22 +01:00
|
|
|
ulong old_sql_mode= thd->variables.sql_mode;
|
2006-07-10 13:44:43 +02:00
|
|
|
char create_buf[15 * STRING_BUFFER_USUAL_SIZE];
|
2006-02-14 16:20:48 +01:00
|
|
|
String show_create(create_buf, sizeof(create_buf), system_charset_info);
|
|
|
|
CHARSET_INFO *old_character_set_client,
|
|
|
|
*old_collation_connection,
|
2005-12-08 20:37:54 +01:00
|
|
|
*old_character_set_results;
|
2006-07-13 10:59:58 +02:00
|
|
|
Security_context save_ctx;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
DBUG_ENTER("Event_job_data::compile");
|
2006-02-20 16:06:05 +01:00
|
|
|
|
2006-02-14 16:20:48 +01:00
|
|
|
show_create.length(0);
|
2006-02-20 16:06:05 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
switch (get_fake_create_event(thd, &show_create)) {
|
2006-02-20 16:06:05 +01:00
|
|
|
case EVEX_MICROSECOND_UNSUP:
|
|
|
|
DBUG_RETURN(EVEX_MICROSECOND_UNSUP);
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
|
2005-12-08 20:37:54 +01:00
|
|
|
old_character_set_client= thd->variables.character_set_client;
|
|
|
|
old_character_set_results= thd->variables.character_set_results;
|
|
|
|
old_collation_connection= thd->variables.collation_connection;
|
2006-02-15 21:08:44 +03:00
|
|
|
|
|
|
|
thd->variables.character_set_client=
|
2005-12-08 20:37:54 +01:00
|
|
|
thd->variables.character_set_results=
|
|
|
|
thd->variables.collation_connection=
|
|
|
|
get_charset_by_csname("utf8", MY_CS_PRIMARY, MYF(MY_WME));
|
|
|
|
|
|
|
|
thd->update_charset();
|
2006-02-15 21:08:44 +03:00
|
|
|
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info",("old_sql_mode: %lu new_sql_mode: %lu",old_sql_mode, sql_mode));
|
2006-02-20 23:52:22 +01:00
|
|
|
thd->variables.sql_mode= this->sql_mode;
|
2006-02-15 21:08:44 +03:00
|
|
|
/* Change the memory root for the execution time */
|
2005-12-05 11:45:04 +01:00
|
|
|
if (mem_root)
|
|
|
|
{
|
|
|
|
tmp_mem_root= thd->mem_root;
|
|
|
|
thd->mem_root= mem_root;
|
|
|
|
}
|
|
|
|
old_query_len= thd->query_length;
|
|
|
|
old_query= thd->query;
|
|
|
|
old_db= thd->db;
|
2006-02-16 00:43:11 +01:00
|
|
|
old_db_length= thd->db_length;
|
2005-12-08 00:17:05 +01:00
|
|
|
thd->db= dbname.str;
|
2006-02-16 00:43:11 +01:00
|
|
|
thd->db_length= dbname.length;
|
2006-02-14 16:20:48 +01:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
thd->query= show_create.c_ptr_safe();
|
2006-02-14 16:20:48 +01:00
|
|
|
thd->query_length= show_create.length();
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("info", ("query: %s",thd->query));
|
2005-12-05 11:45:04 +01:00
|
|
|
|
2006-07-13 12:19:01 +02:00
|
|
|
event_change_security_context(thd, definer_user, definer_host, dbname,
|
|
|
|
&save_ctx);
|
2005-12-05 11:45:04 +01:00
|
|
|
thd->lex= &lex;
|
2006-07-13 10:59:58 +02:00
|
|
|
mysql_init_query(thd, (uchar*) thd->query, thd->query_length);
|
2006-03-09 17:37:59 -08:00
|
|
|
if (MYSQLparse((void *)thd) || thd->is_fatal_error)
|
2005-12-05 11:45:04 +01:00
|
|
|
{
|
2006-11-27 01:47:38 +02:00
|
|
|
DBUG_PRINT("error", ("error during compile or thd->is_fatal_error: %d",
|
2006-01-20 22:24:58 +01:00
|
|
|
thd->is_fatal_error));
|
2007-01-31 21:16:48 +03:00
|
|
|
lex.unit.cleanup();
|
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
sql_print_error("SCHEDULER: Error during compilation of %s.%s or "
|
2006-11-27 01:47:38 +02:00
|
|
|
"thd->is_fatal_error: %d",
|
2006-01-20 22:24:58 +01:00
|
|
|
dbname.str, name.str, thd->is_fatal_error);
|
2006-07-13 10:59:58 +02:00
|
|
|
|
2005-12-08 20:37:54 +01:00
|
|
|
ret= EVEX_COMPILE_ERROR;
|
|
|
|
goto done;
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
2006-01-20 22:24:58 +01:00
|
|
|
DBUG_PRINT("note", ("success compiling %s.%s", dbname.str, name.str));
|
2006-02-15 21:08:44 +03:00
|
|
|
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
sphead= lex.sphead;
|
2006-02-28 12:08:13 +01:00
|
|
|
|
2005-12-08 00:17:05 +01:00
|
|
|
sphead->set_definer(definer.str, definer.length);
|
2006-02-20 23:52:22 +01:00
|
|
|
sphead->set_info(0, 0, &lex.sp_chistics, sql_mode);
|
2005-12-08 00:17:05 +01:00
|
|
|
sphead->optimize();
|
2005-12-08 20:37:54 +01:00
|
|
|
ret= 0;
|
|
|
|
done:
|
2006-03-16 13:14:40 +01:00
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
lex_end(&lex);
|
2006-07-13 12:19:01 +02:00
|
|
|
event_restore_security_context(thd, &save_ctx);
|
2006-01-20 22:24:58 +01:00
|
|
|
DBUG_PRINT("note", ("return old data on its place. set back NAMES"));
|
|
|
|
|
2005-12-05 11:45:04 +01:00
|
|
|
thd->lex= old_lex;
|
|
|
|
thd->query= old_query;
|
|
|
|
thd->query_length= old_query_len;
|
|
|
|
thd->db= old_db;
|
2005-12-08 20:37:54 +01:00
|
|
|
|
2006-02-20 23:52:22 +01:00
|
|
|
thd->variables.sql_mode= old_sql_mode;
|
2005-12-08 20:37:54 +01:00
|
|
|
thd->variables.character_set_client= old_character_set_client;
|
|
|
|
thd->variables.character_set_results= old_character_set_results;
|
|
|
|
thd->variables.collation_connection= old_collation_connection;
|
|
|
|
thd->update_charset();
|
|
|
|
|
2006-02-15 21:08:44 +03:00
|
|
|
/* Change the memory root for the execution time. */
|
2005-12-05 11:45:04 +01:00
|
|
|
if (mem_root)
|
|
|
|
thd->mem_root= tmp_mem_root;
|
|
|
|
|
2005-12-08 20:37:54 +01:00
|
|
|
DBUG_RETURN(ret);
|
2005-12-05 11:45:04 +01:00
|
|
|
}
|
|
|
|
|
2006-02-16 00:43:11 +01:00
|
|
|
|
|
|
|
/*
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
Checks whether two events are in the same schema
|
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
event_basic_db_equal()
|
2006-07-11 18:28:15 +02:00
|
|
|
db Schema
|
|
|
|
et Compare et->dbname to `db`
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
RETURN VALUE
|
2006-07-10 13:44:43 +02:00
|
|
|
TRUE Equal
|
|
|
|
FALSE Not equal
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
2006-07-11 18:28:15 +02:00
|
|
|
event_basic_db_equal(LEX_STRING db, Event_basic *et)
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
{
|
2006-07-11 18:28:15 +02:00
|
|
|
return !sortcmp_lex_string(et->dbname, db, system_charset_info);
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-08-17 14:22:59 +02:00
|
|
|
Checks whether an event has equal `db` and `name`
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
2006-07-10 13:44:43 +02:00
|
|
|
event_basic_identifier_equal()
|
2006-08-17 14:22:59 +02:00
|
|
|
db Schema
|
|
|
|
name Name
|
|
|
|
et The event object
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
|
|
|
|
RETURN VALUE
|
2006-07-10 13:44:43 +02:00
|
|
|
TRUE Equal
|
|
|
|
FALSE Not equal
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
2006-07-10 13:44:43 +02:00
|
|
|
event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b)
|
fix for bug #17619 Scheduler race conditions
- Scheduler is either initialized at server start or never.
Starting & stopping is now suspending & resuming.
- The scheduler has clear OO interface
- Now all calls to the scheduler are synchronous
- GLOBAL event_scheduler uses thd::sys_var_tmp (see set_var.cc)
- External API is encapsulated into class Events
- Includes fixes for all comments of Kostja's review of 19.05.2005
Starting to merge into 5.1-release (5.1.10) and push
BitKeeper/etc/ignore:
Added libmysqld/event_scheduler.cc to the ignore list
libmysqld/Makefile.am:
executor -> scheduler
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_microsec.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/disabled.def:
enable these tests
mysql-test/t/events.test:
optimize the test a bit for speed, save some seconds runtime
remove FULL from SHOW EVENTS
mostly use I_S.EVENTS
mysql-test/t/events_bugs.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_logs_tests.test:
optimize the test a bit for speed
mysql-test/t/events_microsec.test:
Skip irrelevant for the current design tests - all events are loaded
on server startup. Change in mysql.event will be visible on next server start.
Don't use numeric error codes.
mysql-test/t/events_scheduling.test:
broader test
mysql-test/t/events_stress.test:
Rework the test to the new architecture of suspending/resuming.
Use less events, no need for thousands, hundreds is still ok.
sql/Makefile.am:
executor -> scheduler
sql/cmakelists.txt:
executor -> scheduler
sql/event.cc:
- remove todo comments
- remove unneded evex_queue abstraction functions
- move events_init() and events_shutdown() from event_executor.cc to here
- export db_create_event
- remove evex_load_and_compile_event, part of class Event_scheduler
- integrate the public interface found in event.h and used by sql_parse.cc
to use the new class Event_scheduler.
sql/event.h:
- add COND_finished so if one thread kills a running event it waits on this
- export callback event_timed_definer_equal, event_timed_identifier_equal(),
event_timed_name_equal and event_timed_db_equal()
to be used by Event_scheduler::drop_matching_events()
- cleanup event.h
- encapsulated all external interface into class Events
sql/event_executor.cc:
make it empty, will delete after that
sql/event_priv.h:
- more things in the private header
- remove event queue abstraction functions. tightly bind to QUEUE
- export privately db_drop_event, db_find_event, db_create_event()
- made change_security_context() and restore_security_context() free functions
sql/event_timed.cc:
- fix calculation of time when ENDS is set (STARTS is always set)
- during Event_timed::compile() set the right Security_ctx. Prevents a crash
during Event_scheduler::load_events_from_db()
- add Event_timed::kill_thread()
- implement event_timed_*_equal()
- made change_security_context() and restore_security_context() free functions.
- Comments cleanups
sql/lex.h:
new word scheduler for SHOW SCHEDULER STATUS (available only debug builds)
sql/log.cc:
move these from event_scheduler.cc
sql/mysql_priv.h:
refactor kill_one_thread
export sql_print_message_func and sql_print_message_handlers
sql/mysqld.cc:
In close_connections, called by kill_server() skip the main scheduler
thread and use events_shutdown() for shutting down the scheduler, in the same
manner it's done for RPL.
Add a new value to --event-scheduler :
0 <- No scheduler available
1 <- Start with scheduler enabled
2 <- Start with scheduler suspended
sql/repl_failsafe.cc:
refactor thd::system_thread to be an enum
sql/set_var.cc:
move sys_var_event_executor::update() to set_var.cc
executor -> scheduler
use thd::sys_var_tmp
sql/set_var.h:
executor -> scheduler
sql/share/errmsg.txt:
3 new error messages
sql/sql_class.cc:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_class.h:
refactor thd::system_thread to be an enum . more type-safety
sql/sql_db.cc:
get the error from evex_drop_schema_events
sql/sql_error.h:
export warning_level_names
sql/sql_lex.h:
new command SHOW SCHEDULER STATUS, available only in debug build and
for debug purposes.
sql/sql_parse.cc:
refactor kill_one_thread() -> does the *dirty* work, and sql_kill
just the reporting.
add handler for SQLCOM_SHOW_SCHEDULER_STATUS
sql/sql_show.cc:
fix verbosity handling (this will be obsoleted anyway by the fix for 17394).
sql/sql_yacc.yy:
remove FULL from SHOW EVENTS
add SHOW SCHEDULER STATUS in debug builds
sql/table.cc:
Fix valgrind warning.
2006-05-22 20:46:13 +02:00
|
|
|
{
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
return !sortcmp_lex_string(name, b->name, system_charset_info) &&
|
|
|
|
!sortcmp_lex_string(db, b->dbname, system_charset_info);
|
2006-02-16 00:43:11 +01:00
|
|
|
}
|
2006-07-13 16:24:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-08-17 14:22:59 +02:00
|
|
|
Switches the security context.
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
SYNOPSIS
|
|
|
|
event_change_security_context()
|
|
|
|
thd Thread
|
|
|
|
user The user
|
|
|
|
host The host of the user
|
|
|
|
db The schema for which the security_ctx will be loaded
|
|
|
|
backup Where to store the old context
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
RETURN VALUE
|
|
|
|
FALSE OK
|
|
|
|
TRUE Error (generates error too)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool
|
|
|
|
event_change_security_context(THD *thd, LEX_STRING user, LEX_STRING host,
|
|
|
|
LEX_STRING db, Security_context *backup)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("event_change_security_context");
|
|
|
|
DBUG_PRINT("info",("%s@%s@%s", user.str, host.str, db.str));
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
|
|
|
|
|
|
|
*backup= thd->main_security_ctx;
|
|
|
|
if (acl_getroot_no_password(&thd->main_security_ctx, user.str, host.str,
|
|
|
|
host.str, db.str))
|
|
|
|
{
|
|
|
|
my_error(ER_NO_SUCH_USER, MYF(0), user.str, host.str);
|
|
|
|
DBUG_RETURN(TRUE);
|
|
|
|
}
|
|
|
|
thd->security_ctx= &thd->main_security_ctx;
|
|
|
|
#endif
|
|
|
|
DBUG_RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-08-17 14:22:59 +02:00
|
|
|
Restores the security context.
|
|
|
|
|
2006-07-13 16:24:55 +02:00
|
|
|
SYNOPSIS
|
|
|
|
event_restore_security_context()
|
|
|
|
thd Thread
|
|
|
|
backup Context to switch to
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
event_restore_security_context(THD *thd, Security_context *backup)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("event_restore_security_context");
|
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
|
|
|
if (backup)
|
|
|
|
{
|
|
|
|
thd->main_security_ctx= *backup;
|
|
|
|
thd->security_ctx= &thd->main_security_ctx;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|