mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / sql / events.h
blob99895de88d2f950015c9e3df04cd143442c1e939
1 #ifndef _EVENT_H_
2 #define _EVENT_H_
3 /* Copyright (c) 2004-2007 MySQL AB
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
18 /**
19 @defgroup Event_Scheduler Event Scheduler
20 @ingroup Runtime_Environment
23 @file events.h
25 A public interface of Events_Scheduler module.
28 class Event_parse_data;
29 class Event_db_repository;
30 class Event_queue;
31 class Event_scheduler;
33 /* Return codes */
34 enum enum_events_error_code
36 OP_OK= 0,
37 OP_NOT_RUNNING,
38 OP_CANT_KILL,
39 OP_CANT_INIT,
40 OP_DISABLED_EVENT,
41 OP_LOAD_ERROR,
42 OP_ALREADY_EXISTS
46 int
47 sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
49 /**
50 @brief A facade to the functionality of the Event Scheduler.
52 Every public operation against the scheduler has to be executed via the
53 interface provided by a static method of this class. No instance of this
54 class is ever created and it has no non-static data members.
56 The life cycle of the Events module is the following:
58 At server start up:
59 set_opt_event_scheduler() -> init_mutexes() -> init()
60 When the server is running:
61 create_event(), drop_event(), start_or_stop_event_scheduler(), etc
62 At shutdown:
63 deinit(), destroy_mutexes().
65 The peculiar initialization and shutdown cycle is an adaptation to the
66 outside server startup/shutdown framework and mimics the rest of MySQL
67 subsystems (ACL, time zone tables, etc).
70 class Events
72 public:
73 /* The order should match the order in opt_typelib */
74 enum enum_opt_event_scheduler
76 EVENTS_OFF= 0,
77 EVENTS_ON= 1,
78 EVENTS_DISABLED= 4
81 /* Possible values of @@event_scheduler variable */
82 static const TYPELIB var_typelib;
84 static bool
85 set_opt_event_scheduler(char *argument);
87 static const char *
88 get_opt_event_scheduler_str();
90 /* A hack needed for Event_queue_element */
91 static Event_db_repository *
92 get_db_repository() { return db_repository; }
94 static bool
95 init(my_bool opt_noacl);
97 static void
98 deinit();
100 static void
101 init_mutexes();
103 static void
104 destroy_mutexes();
106 static bool
107 switch_event_scheduler_state(enum enum_opt_event_scheduler new_state);
109 static bool
110 create_event(THD *thd, Event_parse_data *parse_data, bool if_exists);
112 static bool
113 update_event(THD *thd, Event_parse_data *parse_data,
114 LEX_STRING *new_dbname, LEX_STRING *new_name);
116 static bool
117 drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists);
119 static void
120 drop_schema_events(THD *thd, char *db);
122 static bool
123 show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
125 /* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
126 static int
127 reconstruct_interval_expression(String *buf, interval_type interval,
128 longlong expression);
130 static int
131 fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */);
133 static void
134 dump_internal_status();
136 private:
137 static bool check_if_system_tables_error();
139 static bool
140 load_events_from_db(THD *thd);
142 private:
143 /* Command line option names */
144 static const TYPELIB opt_typelib;
145 static pthread_mutex_t LOCK_event_metadata;
146 static Event_queue *event_queue;
147 static Event_scheduler *scheduler;
148 static Event_db_repository *db_repository;
149 /* Current state of Event Scheduler */
150 static enum enum_opt_event_scheduler opt_event_scheduler;
151 /* Set to TRUE if an error at start up */
152 static bool check_system_tables_error;
154 private:
155 /* Prevent use of these */
156 Events(const Events &);
157 void operator=(Events &);
161 @} (end of group Event Scheduler)
164 #endif /* _EVENT_H_ */