diff options
author | unknown <andrey@lmy004.> | 2006-07-05 17:12:50 +0200 |
---|---|---|
committer | unknown <andrey@lmy004.> | 2006-07-05 17:12:50 +0200 |
commit | b9a7fe2757d9040296311e96a9e2740416d181f2 (patch) | |
tree | b703fe1427d5c31cc528ae515b4514eeb6c9dce8 /sql/events.cc | |
parent | a5dfeb02e991e6e5e9e332443522de1bb4592df8 (diff) | |
download | mariadb-git-b9a7fe2757d9040296311e96a9e2740416d181f2.tar.gz |
WL#3337 (Event scheduler new architecture)
Cleaned up the code a bit. Fixed few leaks.
This code still does not load events on server startup
from disk. The problem is that there is a need for a THD instance, which
does not exist during server boot. This will be solved soon.
Still Event_timed is used both for the memory queue and for exectution.
This will be changed according to WL#3337 probably in the next commit.
sql/event_data_objects.cc:
Strip unneeded stuff from class Event_timed
Event_timed is still used for the queue and execution.
That will be changed in the next commit.
sql/event_data_objects.h:
Strip unneeded stuff from class Event_timed
Event_timed is still used for the queue and execution.
That will be changed in the next commit.
sql/event_db_repository.cc:
Cosmetics.
Add a new method load_named_event_job, to be made complete in the
next commit. It will load from disk an instance of Event_job_data to
be used during execution.
sql/event_db_repository.h:
find_event does not need MEM_ROOT anymore
because the memory is allocated on Event's own root.
sql/event_queue.cc:
Remove dead code.
Move dumping of the queue to separate method.
Make critical sections in create_event & update_event
as small as possible - load the new event outside of the section
and free the object also outside of it.
sql/event_queue.h:
init -> init_queue -> easier for ctags
deinit -> deinit_queue -> easier for ctags
sql/event_scheduler.cc:
empty this file
sql/event_scheduler.h:
empty this file
sql/event_scheduler_ng.cc:
add back DBUG_RETURN(0) in thread handlers.
We don't stop running events when stopping the scheduler. Therefore
remove this method now. If it is needed later it can be added back.
sql/event_scheduler_ng.h:
Remove stop_all_running_threads()
init -> init_scheduler
deinit -> deinit_scheduler
easier for ctags
sql/events.cc:
Cosmetics
sql/events.h:
Cosmetics
sql/set_var.cc:
Remove references to dead code
sql/sql_parse.cc:
Reorganize a bit.
Diffstat (limited to 'sql/events.cc')
-rw-r--r-- | sql/events.cc | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/sql/events.cc b/sql/events.cc index e4b6de965f7..d1bbb6be884 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -17,10 +17,10 @@ #include "mysql_priv.h" #include "events.h" #include "event_data_objects.h" -#include "event_scheduler.h" #include "event_db_repository.h" -#include "sp_head.h" +#include "event_queue.h" #include "event_scheduler_ng.h" +#include "sp_head.h" /* TODO list : @@ -48,6 +48,21 @@ Warning: */ +/* + If the user (un)intentionally removes an event directly from mysql.event + the following sequence has to be used to be able to remove the in-memory + counterpart. + 1. CREATE EVENT the_name ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1; + 2. DROP EVENT the_name + + In other words, the first one will create a row in mysql.event . In the + second step because there will be a line, disk based drop will pass and + the scheduler will remove the memory counterpart. The reason is that + in-memory queue does not check whether the event we try to drop from memory + is disabled. Disabled events are not kept in-memory because they are not + eligible for execution. +*/ + const char *event_scheduler_state_names[]= { "OFF", "0", "ON", "1", "SUSPEND", "2", NullS }; @@ -284,17 +299,15 @@ Events::open_event_table(THD *thd, enum thr_lock_type lock_type, */ int -Events::create_event(THD *thd, Event_parse_data *parse_data, uint create_options, +Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists, uint *rows_affected) { int ret; DBUG_ENTER("Events::create_event"); - if (!(ret= db_repository-> - create_event(thd, parse_data, - create_options & HA_LEX_CREATE_IF_NOT_EXISTS, - rows_affected))) + if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists, + rows_affected))) { - if ((ret= event_queue->create_event(thd, parse_data, true))) + if ((ret= event_queue->create_event(thd, parse_data))) my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0), ret); } /* No need to close the table, it will be closed in sql_parse::do_command */ @@ -350,9 +363,10 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *new_name, SYNOPSIS Events::drop_event() thd THD - name event's name - drop_if_exists if set and the event not existing => warning onto the stack - rows_affected affected number of rows is returned heres + name Event's name + if_exists When set and the event does not exist => warning onto + the stack + rows_affected Affected number of rows is returned heres RETURN VALUE 0 OK @@ -360,15 +374,13 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *new_name, */ int -Events::drop_event(THD *thd, sp_name *name, bool drop_if_exists, - uint *rows_affected) +Events::drop_event(THD *thd, sp_name *name, bool if_exists, uint *rows_affected) { int ret; - DBUG_ENTER("Events::drop_event"); - if (!(ret= db_repository->drop_event(thd, name->m_db, name->m_name, - drop_if_exists, rows_affected))) + if (!(ret= db_repository->drop_event(thd, name->m_db, name->m_name, if_exists, + rows_affected))) { if ((ret= event_queue->drop_event(thd, name))) my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0), ret); @@ -401,7 +413,7 @@ Events::show_create_event(THD *thd, sp_name *spn) DBUG_PRINT("enter", ("name: %*s", spn->m_name.length, spn->m_name.str)); thd->reset_n_backup_open_tables_state(&backup); - ret= db_repository->find_event(thd, spn->m_db, spn->m_name, &et, NULL, thd->mem_root); + ret= db_repository->find_event(thd, spn->m_db, spn->m_name, &et, NULL); thd->restore_backup_open_tables_state(&backup); if (!ret) @@ -472,7 +484,7 @@ Events::drop_schema_events(THD *thd, char *db) DBUG_ENTER("evex_drop_db_events"); DBUG_PRINT("enter", ("dropping events from %s", db)); - ret= event_queue->drop_schema_events(thd, db_lex); + event_queue->drop_schema_events(thd, db_lex); ret= db_repository->drop_schema_events(thd, db_lex); DBUG_RETURN(ret); @@ -500,9 +512,8 @@ Events::init() Event_db_repository *db_repo; DBUG_ENTER("Events::init"); db_repository->init_repository(); - event_queue->init(db_repository); - event_queue->scheduler= scheduler_ng; - scheduler_ng->init(event_queue); + event_queue->init_queue(db_repository, scheduler_ng); + scheduler_ng->init_scheduler(event_queue); /* it should be an assignment! */ if (opt_event_scheduler) @@ -532,8 +543,9 @@ Events::deinit() DBUG_ENTER("Events::deinit"); scheduler_ng->stop(); - scheduler_ng->deinit(); - event_queue->deinit(); + scheduler_ng->deinit_scheduler(); + + event_queue->deinit_queue(); db_repository->deinit_repository(); DBUG_VOID_RETURN; |