diff options
author | andrey@lmy004. <> | 2006-07-10 13:44:43 +0200 |
---|---|---|
committer | andrey@lmy004. <> | 2006-07-10 13:44:43 +0200 |
commit | e3d0524bbd79f85d166e7ec369d6a1f612a8c3d1 (patch) | |
tree | 692560cb267120b449f56b1df9db9a918e5c7477 /sql/event_data_objects.h | |
parent | 3b840adee7817d141fa9f5935b1d05243e6a8df4 (diff) | |
download | mariadb-git-e3d0524bbd79f85d166e7ec369d6a1f612a8c3d1.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.
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_ */ |