summaryrefslogtreecommitdiff
path: root/sql/event_scheduler.cc
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2006-06-29 00:42:25 +0200
committerunknown <andrey@lmy004.>2006-06-29 00:42:25 +0200
commit9fa9378b2e5713250e1262879c7bc4d999e1bb40 (patch)
tree068608d07a92fd7d98e1c7f13c7b9dc9a3167f37 /sql/event_scheduler.cc
parent739ea377bd702a6438d1491222e8ec671ad0fbf3 (diff)
downloadmariadb-git-9fa9378b2e5713250e1262879c7bc4d999e1bb40.tar.gz
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
Diffstat (limited to 'sql/event_scheduler.cc')
-rw-r--r--sql/event_scheduler.cc78
1 files changed, 19 insertions, 59 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index cb500de53b9..35c30e5fc5a 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -785,7 +785,7 @@ Event_scheduler::destroy()
*/
int
-Event_scheduler::create_event(THD *thd, Event_timed *et, bool check_existence)
+Event_scheduler::create_event(THD *thd, Event_parse_data *et, bool check_existence)
{
int res;
Event_timed *et_new;
@@ -799,14 +799,15 @@ Event_scheduler::create_event(THD *thd, Event_timed *et, bool check_existence)
UNLOCK_SCHEDULER_DATA();
DBUG_RETURN(OP_OK);
}
- if (check_existence && find_event(et, FALSE))
+ if (check_existence && find_event(et->dbname, et->name, FALSE))
{
res= OP_ALREADY_EXISTS;
goto end;
}
/* We need to load the event on scheduler_root */
- if (!(res= db_repository->load_named_event(thd, et, &et_new)))
+ if (!(res= db_repository->
+ load_named_event(thd, et->dbname, et->name, &et_new)))
{
queue_insert_safe(&queue, (byte *) et_new);
DBUG_PRINT("info", ("Sending COND_new_work"));
@@ -850,7 +851,7 @@ Event_scheduler::drop_event(THD *thd, sp_name *name)
DBUG_RETURN(OP_OK);
}
- if (!(et_old= find_event(name, TRUE)))
+ if (!(et_old= find_event(name->m_db, name->m_name, TRUE)))
DBUG_PRINT("info", ("No such event found, probably DISABLED"));
UNLOCK_SCHEDULER_DATA();
@@ -906,7 +907,7 @@ Event_scheduler::drop_event(THD *thd, sp_name *name)
*/
int
-Event_scheduler::update_event(THD *thd, Event_timed *et,
+Event_scheduler::update_event(THD *thd, Event_parse_data *et,
LEX_STRING *new_schema,
LEX_STRING *new_name)
{
@@ -931,7 +932,7 @@ Event_scheduler::update_event(THD *thd, Event_timed *et,
DBUG_RETURN(OP_OK);
}
- if (!(et_old= find_event(et, TRUE)))
+ if (!(et_old= find_event(et->dbname, et->name, TRUE)))
DBUG_PRINT("info", ("%s.%s not found cached, probably was DISABLED",
et->dbname.str, et->name.str));
@@ -948,7 +949,8 @@ Event_scheduler::update_event(THD *thd, Event_timed *et,
1. Error occured
2. If the replace is DISABLED, we don't load it into the queue.
*/
- if (!(res= db_repository->load_named_event(thd, et, &et_new)))
+ if (!(res= db_repository->
+ load_named_event(thd, et->dbname, et->name, &et_new)))
{
queue_insert_safe(&queue, (byte *) et_new);
DBUG_PRINT("info", ("Sending COND_new_work"));
@@ -1014,50 +1016,8 @@ Event_scheduler::update_event(THD *thd, Event_timed *et,
SYNOPSIS
Event_scheduler::find_event()
- etn The event to find
- comparator The function to use for comparing
- remove_from_q If found whether to remove from the Q
-
- RETURN VALUE
- NULL Not found
- otherwise Address
-
- NOTE
- The caller should do the locking also the caller is responsible for
- actual signalling in case an event is removed from the queue
- (signalling COND_new_work for instance).
-*/
-
-Event_timed *
-Event_scheduler::find_event(Event_timed *etn, bool remove_from_q)
-{
- uint i;
- DBUG_ENTER("Event_scheduler::find_event");
-
- for (i= 0; i < queue.elements; ++i)
- {
- Event_timed *et= (Event_timed *) queue_element(&queue, i);
- DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", etn->dbname.str, etn->name.str,
- et->dbname.str, et->name.str));
- if (event_timed_identifier_equal(etn, et))
- {
- if (remove_from_q)
- queue_remove(&queue, i);
- DBUG_RETURN(et);
- }
- }
-
- DBUG_RETURN(NULL);
-}
-
-
-/*
- Searches for an event in the scheduler queue
-
- SYNOPSIS
- Event_scheduler::find_event()
+ db The schema of the event to find
name The event to find
- comparator The function to use for comparing
remove_from_q If found whether to remove from the Q
RETURN VALUE
@@ -1071,7 +1031,7 @@ Event_scheduler::find_event(Event_timed *etn, bool remove_from_q)
*/
Event_timed *
-Event_scheduler::find_event(sp_name *name, bool remove_from_q)
+Event_scheduler::find_event(LEX_STRING db, LEX_STRING name, bool remove_from_q)
{
uint i;
DBUG_ENTER("Event_scheduler::find_event");
@@ -1079,9 +1039,9 @@ Event_scheduler::find_event(sp_name *name, bool remove_from_q)
for (i= 0; i < queue.elements; ++i)
{
Event_timed *et= (Event_timed *) queue_element(&queue, i);
- DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", name->m_db.str, name->m_name.str,
+ DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", db.str, name.str,
et->dbname.str, et->name.str));
- if (event_timed_identifier_equal(name, et))
+ if (event_timed_identifier_equal(db, name, et))
{
if (remove_from_q)
queue_remove(&queue, i);
@@ -1624,7 +1584,7 @@ Event_scheduler::clean_queue(THD *thd)
SYNOPSIS
Event_scheduler::stop_all_running_events()
thd Thread
-
+
NOTE
LOCK_scheduler data must be acquired prior to call to this method
*/
@@ -1726,7 +1686,7 @@ Event_scheduler::stop()
/*
One situation to be here is if there was a start that forked a new
thread but the new thread did not acquire yet LOCK_scheduler_data.
- Hence, in this case return an error.
+ Hence, in this case return an error.
*/
DBUG_PRINT("info", ("manager not running but %d. doing nothing", state));
UNLOCK_SCHEDULER_DATA();
@@ -1841,7 +1801,7 @@ Event_scheduler::workers_count()
}
VOID(pthread_mutex_unlock(&LOCK_thread_count));
DBUG_PRINT("exit", ("%d", count));
- DBUG_RETURN(count);
+ DBUG_RETURN(count);
}
@@ -1851,7 +1811,7 @@ Event_scheduler::workers_count()
SYNOPSIS
Event_scheduler::check_n_suspend_if_needed()
thd Thread
-
+
RETURN VALUE
FALSE Not suspended, we haven't slept
TRUE We were suspended. LOCK_scheduler_data is unlocked.
@@ -1936,7 +1896,7 @@ Event_scheduler::check_n_wait_for_non_empty_queue(THD *thd)
if (!queue.elements)
thd->enter_cond(&cond_vars[COND_new_work], &LOCK_scheduler_data,
- "Empty queue, sleeping");
+ "Empty queue, sleeping");
/* Wait in a loop protecting against catching spurious signals */
while (!queue.elements && state == RUNNING)
@@ -2079,7 +2039,7 @@ Event_scheduler::get_state()
SYNOPSIS
Event_scheduler::initialized()
-
+
RETURN VALUE
FALSE Was not initialized so far
TRUE Was initialized