diff options
author | unknown <andrey@lmy004.> | 2006-06-27 11:51:11 +0200 |
---|---|---|
committer | unknown <andrey@lmy004.> | 2006-06-27 11:51:11 +0200 |
commit | ef9a97e6856ec8128b66a47b124ce3c09f0fd1bc (patch) | |
tree | 7b795dc8246cf6e4fffc0272f2f6500ae979babe /sql/event_scheduler.cc | |
parent | d2db48c69bf473101cceffe8305a5922dd1a2af2 (diff) | |
download | mariadb-git-ef9a97e6856ec8128b66a47b124ce3c09f0fd1bc.tar.gz |
WL#3337 (Event scheduler new architecture)
Third cut to simplify parsing phase. Now DROP EVENT works.
Overloaded few functions to be able to use either sp_name or pass two LEX_STRINGs
instead of a Event_timed pointer. This is transitional and eventually the old
functions will be removed. For now DROP EVENT also works, does not need anymore
a parsing object (Event_timed) and definer initialization because everyone who
has EVENT_ACL can drop events, and this is checked on execution time in sql_parse.cc
from the security context, as it should be.
sql/event_data_objects.cc:
overload few functions
sql/event_scheduler.cc:
Event_scheduler::drop_event() actually does not need Event_timed object
but just an identifier, hence pass only sp_name.
Overloaded Event_scheduler::find_event() to work with sp_name object. Eventually
the old version will be removed. This is being done as transitional step to
be able to test frequently code.
sql/event_scheduler.h:
Event_scheduler::drop_event() actually does not need Event_timed object
but just an identifier, hence pass only sp_name.
Overloaded Event_scheduler::find_event() to work with sp_name object. Eventually
the old version will be removed. This is being done as transitional step to
be able to test frequently code.
sql/events.cc:
Change db_drop_event() not to use Event_timed, either coming from parsing
or from Event_timed::drop, but use LEX_STRINGs. sp_name is not convinient
because in Event_timed::drop a temporary object has to be created. Hence,
dereference the sp_name in Events::drop_event() and pass the LEX_STRINGs.
sql/events.h:
Change db_drop_event() not to use Event_timed, either coming from parsing
or from Event_timed::drop, but use LEX_STRINGs. sp_name is not convinient
because in Event_timed::drop a temporary object has to be created. Hence,
dereference the sp_name in Events::drop_event() and pass the LEX_STRINGs.
sql/events_priv.h:
Change db_drop_event() not to use Event_timed, either coming from parsing
or from Event_timed::drop, but use LEX_STRINGs. sp_name is not convinient
because in Event_timed::drop a temporary object has to be created. Hence,
dereference the sp_name in Events::drop_event() and pass the LEX_STRINGs.
sql/sql_parse.cc:
SQLCOM_DROP_EVENT does not need lex->event_parse_data object and
is more like SQLCOM_SHOW_CREATE_EVENT. Therefore, move it to the block that
handles the latter.
sql/sql_yacc.yy:
DROP EVENT does not need a parsing object, just a name.
Store it as lex->spname. Pretty similar handling to the one of
SHOW CREATE EVENT.
Diffstat (limited to 'sql/event_scheduler.cc')
-rw-r--r-- | sql/event_scheduler.cc | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index fc2ad75b272..f83bc5f25a3 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -833,12 +833,13 @@ end: */ bool -Event_scheduler::drop_event(THD *thd, Event_timed *et) +Event_scheduler::drop_event(THD *thd, sp_name *name) { int res; Event_timed *et_old; DBUG_ENTER("Event_scheduler::drop_event"); - DBUG_PRINT("enter", ("thd=%p et=%p lock=%p",thd,et,&LOCK_scheduler_data)); + DBUG_PRINT("enter", ("thd=%p name=%p lock=%p", thd, name, + &LOCK_scheduler_data)); LOCK_SCHEDULER_DATA(); if (!is_running_or_suspended()) @@ -848,7 +849,7 @@ Event_scheduler::drop_event(THD *thd, Event_timed *et) DBUG_RETURN(OP_OK); } - if (!(et_old= find_event(et, TRUE))) + if (!(et_old= find_event(name, TRUE))) DBUG_PRINT("info", ("No such event found, probably DISABLED")); UNLOCK_SCHEDULER_DATA(); @@ -1050,6 +1051,48 @@ Event_scheduler::find_event(Event_timed *etn, bool remove_from_q) /* + Searches for an event in the scheduler queue + + SYNOPSIS + Event_scheduler::find_event() + 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 + 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(sp_name *name, 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]?", name->m_db.str, name->m_name.str, + et->dbname.str, et->name.str)); + if (event_timed_identifier_equal(name, et)) + { + if (remove_from_q) + queue_remove(&queue, i); + DBUG_RETURN(et); + } + } + + DBUG_RETURN(NULL); +} + + +/* Drops all events from the in-memory queue and disk that match certain pattern evaluated by a comparator function |