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