diff options
author | unknown <andrey@lmy004.> | 2006-07-10 13:44:43 +0200 |
---|---|---|
committer | unknown <andrey@lmy004.> | 2006-07-10 13:44:43 +0200 |
commit | 974eecc246db18e29e5ef06db6f48a0f4b3f7951 (patch) | |
tree | 692560cb267120b449f56b1df9db9a918e5c7477 /sql/event_data_objects.h | |
parent | b9a7fe2757d9040296311e96a9e2740416d181f2 (diff) | |
download | mariadb-git-974eecc246db18e29e5ef06db6f48a0f4b3f7951.tar.gz |
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
Diffstat (limited to 'sql/event_data_objects.h')
-rw-r--r-- | sql/event_data_objects.h | 202 |
1 files changed, 117 insertions, 85 deletions
diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h index a5aaf0e66fa..d405cafe42d 100644 --- a/sql/event_data_objects.h +++ b/sql/event_data_objects.h @@ -47,30 +47,46 @@ class sp_head; class Sql_alloc; - -class Event_timed; +class Event_basic; /* Compares only the schema part of the identifier */ bool -event_timed_db_equal(Event_timed *et, LEX_STRING *db); +event_basic_db_equal( LEX_STRING *db, Event_basic *et); /* Compares the whole identifier*/ bool -event_timed_identifier_equal(LEX_STRING db, LEX_STRING name, Event_timed *b); - +event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b); -class Event_timed +class Event_basic { - Event_timed(const Event_timed &); /* Prevent use of these */ - void operator=(Event_timed &); +protected: + MEM_ROOT mem_root; +public: + LEX_STRING dbname; + LEX_STRING name; + LEX_STRING definer;// combination of user and host + + Event_basic(); + virtual ~Event_basic(); + + virtual int + load_from_row(TABLE *table) = 0; + +protected: + bool + load_string_fields(Field **fields, ...); +}; + + + +class Event_queue_element : public Event_basic +{ +protected: bool status_changed; bool last_executed_changed; - - MEM_ROOT mem_root; public: - THD *thd; enum enum_status { ENABLED = 1, @@ -83,17 +99,10 @@ public: ON_COMPLETION_PRESERVE }; + enum enum_on_completion on_completion; + enum enum_status status; TIME last_executed; - LEX_STRING dbname; - LEX_STRING name; - LEX_STRING body; - - LEX_STRING definer_user; - LEX_STRING definer_host; - LEX_STRING definer;// combination of user and host - - LEX_STRING comment; TIME starts; TIME ends; TIME execute_at; @@ -104,20 +113,32 @@ public: longlong expression; interval_type interval; - ulonglong created; - ulonglong modified; - enum enum_on_completion on_completion; - enum enum_status status; - sp_head *sphead; - ulong sql_mode; + uint flags;//all kind of purposes bool dropped; - uint flags;//all kind of purposes + + Event_queue_element(); + virtual ~Event_queue_element(); + + virtual int + load_from_row(TABLE *table); + + bool + compute_next_execution_time(); + + int + drop(THD *thd); + + void + mark_last_executed(THD *thd); + + bool + update_timing_fields(THD *thd); static void *operator new(size_t size) { void *p; - DBUG_ENTER("Event_timed::new(size)"); + DBUG_ENTER("Event_queue_element::new(size)"); p= my_malloc(size, MYF(0)); DBUG_PRINT("info", ("alloc_ptr=0x%lx", p)); DBUG_RETURN(p); @@ -125,54 +146,84 @@ public: static void operator delete(void *ptr, size_t size) { - DBUG_ENTER("Event_timed::delete(ptr,size)"); + DBUG_ENTER("Event_queue_element::delete(ptr,size)"); DBUG_PRINT("enter", ("free_ptr=0x%lx", ptr)); TRASH(ptr, size); my_free((gptr) ptr, MYF(0)); DBUG_VOID_RETURN; } +}; - Event_timed(); - ~Event_timed(); +class Event_timed : public Event_queue_element +{ + Event_timed(const Event_timed &); /* Prevent use of these */ + void operator=(Event_timed &); - void - init(); +public: + LEX_STRING body; - int - load_from_row(TABLE *table); + LEX_STRING definer_user; + LEX_STRING definer_host; - bool - compute_next_execution_time(); + LEX_STRING comment; - int - drop(THD *thd); + ulonglong created; + ulonglong modified; + + ulong sql_mode; + + Event_timed(); + virtual ~Event_timed(); void - mark_last_executed(THD *thd); + init(); - bool - update_fields(THD *thd); + virtual int + load_from_row(TABLE *table); int get_create_event(THD *thd, String *buf); +}; + + +class Event_job_data : public Event_basic +{ +public: + THD *thd; + sp_head *sphead; + + LEX_STRING body; + LEX_STRING definer_user; + LEX_STRING definer_host; + + ulong sql_mode; + + Event_job_data(); + virtual ~Event_job_data(); + + virtual int + load_from_row(TABLE *table); int execute(THD *thd, MEM_ROOT *mem_root); +private: + int + get_fake_create_event(THD *thd, String *buf); int compile(THD *thd, MEM_ROOT *mem_root); - + void free_sp(); + + Event_job_data(const Event_job_data &); /* Prevent use of these */ + void operator=(Event_job_data &); }; class Event_parse_data : public Sql_alloc { - Event_parse_data(const Event_parse_data &); /* Prevent use of these */ - void operator=(Event_parse_data &); - public: enum enum_status { @@ -185,7 +236,6 @@ public: ON_COMPLETION_DROP = 1, ON_COMPLETION_PRESERVE }; - enum enum_on_completion on_completion; enum enum_status status; @@ -193,8 +243,8 @@ public: LEX_STRING dbname; LEX_STRING name; - LEX_STRING body; LEX_STRING definer;// combination of user and host + LEX_STRING body; LEX_STRING comment; Item* item_starts; @@ -216,59 +266,41 @@ public: static Event_parse_data * new_instance(THD *thd); - Event_parse_data(); - ~Event_parse_data(); + bool + check_parse_data(THD *); - int - init_definer(THD *thd); + void + init_body(THD *thd); - int - init_execute_at(THD *thd, Item *expr); +private: int - init_interval(THD *thd, Item *expr, interval_type new_interval); + init_definer(THD *thd); void init_name(THD *thd, sp_name *spn); int - init_starts(THD *thd, Item *starts); + init_execute_at(THD *thd); int - init_ends(THD *thd, Item *ends); - - void - init_body(THD *thd); -}; - - -class Event_job_data -{ -public: - LEX_STRING dbname; - LEX_STRING name; - sp_head *sphead; - LEX_STRING definer; - LEX_STRING body; - ulong sql_mode; - - THD *thd; - - Event_job_data(){} - ~Event_job_data(){} + init_interval(THD *thd); int - execute(); + init_starts(THD *thd); -private: - int - load_from_disk(); - int - compile(); + init_ends(THD *thd); + + Event_parse_data(); + ~Event_parse_data(); + void + report_bad_value(const char *item_name, Item *bad_item); - Event_job_data(const Event_job_data &); /* Prevent use of these */ - void operator=(Event_job_data &); + Event_parse_data(const Event_parse_data &); /* Prevent use of these */ + void operator=(Event_parse_data &); }; + + #endif /* _EVENT_DATA_OBJECTS_H_ */ |