1 | #ifndef _EVENT_DATA_OBJECTS_H_ |
2 | #define _EVENT_DATA_OBJECTS_H_ |
3 | /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. |
4 | |
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. |
8 | |
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. |
13 | |
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 St, Fifth Floor, Boston, MA 02110-1301 USA */ |
17 | |
18 | /** |
19 | @addtogroup Event_Scheduler |
20 | @{ |
21 | |
22 | @file event_data_objects.h |
23 | */ |
24 | |
25 | #include "event_parse_data.h" |
26 | #include "thr_lock.h" /* thr_lock_type */ |
27 | |
28 | class Field; |
29 | class THD; |
30 | class Time_zone; |
31 | struct TABLE; |
32 | |
33 | class Event_queue_element_for_exec |
34 | { |
35 | public: |
36 | Event_queue_element_for_exec(){}; |
37 | ~Event_queue_element_for_exec(); |
38 | |
39 | bool |
40 | init(const LEX_CSTRING *dbname, const LEX_CSTRING *name); |
41 | |
42 | LEX_CSTRING dbname; |
43 | LEX_CSTRING name; |
44 | bool dropped; |
45 | THD *thd; |
46 | |
47 | private: |
48 | /* Prevent use of these */ |
49 | Event_queue_element_for_exec(const Event_queue_element_for_exec &); |
50 | void operator=(Event_queue_element_for_exec &); |
51 | }; |
52 | |
53 | |
54 | class Event_basic |
55 | { |
56 | protected: |
57 | MEM_ROOT mem_root; |
58 | |
59 | public: |
60 | |
61 | LEX_CSTRING dbname; |
62 | LEX_CSTRING name; |
63 | LEX_CSTRING definer;// combination of user and host |
64 | |
65 | Time_zone *time_zone; |
66 | |
67 | Event_basic(); |
68 | virtual ~Event_basic(); |
69 | |
70 | virtual bool |
71 | load_from_row(THD *thd, TABLE *table) = 0; |
72 | |
73 | protected: |
74 | bool |
75 | load_string_fields(Field **fields, ...); |
76 | |
77 | bool |
78 | load_time_zone(THD *thd, const LEX_CSTRING *tz_name); |
79 | }; |
80 | |
81 | |
82 | |
83 | class Event_queue_element : public Event_basic |
84 | { |
85 | public: |
86 | int on_completion; |
87 | int status; |
88 | uint32 originator; |
89 | |
90 | my_time_t last_executed; |
91 | my_time_t execute_at; |
92 | my_time_t starts; |
93 | my_time_t ends; |
94 | bool starts_null; |
95 | bool ends_null; |
96 | bool execute_at_null; |
97 | |
98 | longlong expression; |
99 | interval_type interval; |
100 | |
101 | bool dropped; |
102 | |
103 | uint execution_count; |
104 | |
105 | Event_queue_element(); |
106 | virtual ~Event_queue_element(); |
107 | |
108 | virtual bool |
109 | load_from_row(THD *thd, TABLE *table); |
110 | |
111 | bool |
112 | compute_next_execution_time(); |
113 | |
114 | void |
115 | mark_last_executed(THD *thd); |
116 | }; |
117 | |
118 | |
119 | class Event_timed : public Event_queue_element |
120 | { |
121 | Event_timed(const Event_timed &); /* Prevent use of these */ |
122 | void operator=(Event_timed &); |
123 | |
124 | public: |
125 | LEX_CSTRING body; |
126 | |
127 | LEX_CSTRING definer_user; |
128 | LEX_CSTRING definer_host; |
129 | |
130 | LEX_CSTRING ; |
131 | |
132 | ulonglong created; |
133 | ulonglong modified; |
134 | |
135 | sql_mode_t sql_mode; |
136 | |
137 | class Stored_program_creation_ctx *creation_ctx; |
138 | LEX_CSTRING body_utf8; |
139 | |
140 | Event_timed(); |
141 | virtual ~Event_timed(); |
142 | |
143 | void |
144 | init(); |
145 | |
146 | virtual bool |
147 | load_from_row(THD *thd, TABLE *table); |
148 | |
149 | int |
150 | get_create_event(THD *thd, String *buf); |
151 | }; |
152 | |
153 | |
154 | class Event_job_data : public Event_basic |
155 | { |
156 | public: |
157 | LEX_CSTRING body; |
158 | LEX_CSTRING definer_user; |
159 | LEX_CSTRING definer_host; |
160 | |
161 | sql_mode_t sql_mode; |
162 | |
163 | class Stored_program_creation_ctx *creation_ctx; |
164 | |
165 | Event_job_data(); |
166 | |
167 | virtual bool |
168 | load_from_row(THD *thd, TABLE *table); |
169 | |
170 | bool |
171 | execute(THD *thd, bool drop); |
172 | private: |
173 | bool |
174 | construct_sp_sql(THD *thd, String *sp_sql); |
175 | bool |
176 | construct_drop_event_sql(THD *thd, String *sp_sql); |
177 | |
178 | Event_job_data(const Event_job_data &); /* Prevent use of these */ |
179 | void operator=(Event_job_data &); |
180 | }; |
181 | |
182 | |
183 | /* Compares only the schema part of the identifier */ |
184 | bool |
185 | event_basic_db_equal(const LEX_CSTRING *db, Event_basic *et); |
186 | |
187 | /* Compares the whole identifier*/ |
188 | bool |
189 | event_basic_identifier_equal(const LEX_CSTRING *db, const LEX_CSTRING *name, |
190 | Event_basic *b); |
191 | |
192 | /** |
193 | @} (End of group Event_Scheduler) |
194 | */ |
195 | |
196 | #endif /* _EVENT_DATA_OBJECTS_H_ */ |
197 | |