From 974eecc246db18e29e5ef06db6f48a0f4b3f7951 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Jul 2006 13:44:43 +0200 Subject: WL#3337 (Event scheduler new architecture) This patch introduces specialized Event data objects Event_basic as parent. Event_queue_element used for queue storage Event_timed used for SHOW EVENTS/ I_S.EVENTS / SHOW CREATE EVENT Event_job_data using during execution. Methods were moved out of Event_timed to other classes. This patch also introduces Events::LOCK_event_metadata. This patch gives new implementation of Events::dump_internal_status(). Now both the Event_scheduler and Event_queue return information during their ::dump_internal_status(). Shortened a bit the runtime for executing events test cases. mysql-test/r/events.result: update results mysql-test/r/events_bugs.result: update results mysql-test/r/events_logs_tests.result: update results mysql-test/r/events_scheduling.result: update results mysql-test/t/events.test: update test make --sleep more appropriate . saving some time could mean failure on loaded boxes though :( add tests for previously uncovered branches. mysql-test/t/events_bugs.test: update test make --sleep more appropriate . saving some time could mean failure on loaded boxes though :( add tests for previously uncovered branches. mysql-test/t/events_logs_tests.test: make the test shorter by time mysql-test/t/events_scheduling.test: when selecting always use ORDER BY mysql-test/t/events_stress.test: sleep 2.5secs for shorter stress test sql/event_data_objects.cc: Event_timed is no more used during execution. Event_timed is no more used during in the memory queue. Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS Event_basic is the parent of almost all Event data objects. Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed Event_basic -> Event_job_data (the object used for execution) Sql_alloc -> Event_parse_data (used during parsing) sql/event_data_objects.h: Event_timed is no more used during execution. Event_timed is no more used during in the memory queue. Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS Event_basic is the parent of almost all Event data objects. Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed Event_basic -> Event_job_data (the object used for execution) Sql_alloc -> Event_parse_data (used during parsing) sql/event_db_repository.cc: Cosmetics. load_named_event now uses Event_basic, for polymorphism find_event uses Event_basic, to be polymorphic. use Field **fields= table->field and then index fields[...] Add documentation. Fix documentation. sql/event_db_repository.h: Event_db_repository depends only on Event_basic's interface sql/event_queue.cc: Cosmetics. Don't use Event_timed for the queue and giving back object for execution. Event_queue_element is for the queue, Event_job_data is for execution. Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command sql/event_queue.h: Cosmetics. Don't use Event_timed for the queue and giving back object for execution. Event_queue_element is for the queue, Event_job_data is for execution. Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command sql/event_scheduler_ng.cc: Add back Event_scheduler::cond_wait() Add back Event_scheduler::dump_internal_status() Using Event_job_data for execution. Make the scheduler thread unkillable (thd->command= COM_DAEMON). Add a lot of documentation. sql/event_scheduler_ng.h: Add back Event_scheduler::cond_wait() Add back Event_scheduler::dump_internal_status() Using Event_job_data for execution. sql/events.cc: Documentation Add LOCK_event_metadata sql/events.h: Change the signature of Events::drop_event() not to use sp_name but LEX_STRING sql/share/errmsg.txt: Fix error message sql/sql_parse.cc: Events::drop_event() has new signature --- sql/event_queue.h | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'sql/event_queue.h') diff --git a/sql/event_queue.h b/sql/event_queue.h index d253e3c7597..142a866e5ba 100644 --- a/sql/event_queue.h +++ b/sql/event_queue.h @@ -17,13 +17,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ class sp_name; -class Event_timed; +class Event_basic; class Event_db_repository; class Event_job_data; +class Event_queue_element; class THD; -typedef bool * (*event_timed_identifier_comparator)(Event_timed*, Event_timed*); - class Event_scheduler_ng; class Event_queue @@ -46,14 +45,14 @@ public: /* Methods for queue management follow */ int - create_event(THD *thd, Event_parse_data *et); + create_event(THD *thd, LEX_STRING dbname, LEX_STRING name); int - update_event(THD *thd, Event_parse_data *et, LEX_STRING *new_schema, - LEX_STRING *new_name); + update_event(THD *thd, LEX_STRING dbname, LEX_STRING name, + LEX_STRING *new_schema, LEX_STRING *new_name); - bool - drop_event(THD *thd, sp_name *name); + void + drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name); void drop_schema_events(THD *thd, LEX_STRING schema); @@ -61,32 +60,20 @@ public: uint events_count(); - uint - events_count_no_lock(); - static bool check_system_tables(THD *thd); void - recalculate_queue(THD *thd); - - void - empty_queue(); + recalculate_activation_times(THD *thd); - Event_timed * + Event_job_data * get_top_for_execution_if_time(THD *thd, time_t now, struct timespec *abstime); - - Event_timed* - get_top(); - - void - remove_top(); - - void - top_changed(); + + bool + dump_internal_status(THD *thd); protected: - Event_timed * + Event_queue_element * find_event(LEX_STRING db, LEX_STRING name, bool remove_from_q); int @@ -94,14 +81,16 @@ protected: void drop_matching_events(THD *thd, LEX_STRING pattern, - bool (*)(Event_timed *,LEX_STRING *)); + bool (*)(LEX_STRING *, Event_basic *)); + + void + empty_queue(); /* LOCK_event_queue is the mutex which protects the access to the queue. */ pthread_mutex_t LOCK_event_queue; Event_db_repository *db_repository; - uint mutex_last_locked_at_line; uint mutex_last_unlocked_at_line; const char* mutex_last_locked_in_func; @@ -123,10 +112,8 @@ protected: Event_scheduler_ng *scheduler; -//public: - /* The sorted queue with the Event_timed objects */ + /* The sorted queue with the Event_job_data objects */ QUEUE queue; - }; #endif /* _EVENT_QUEUE_H_ */ -- cgit v1.2.1