My Project
event_data_objects.h
Go to the documentation of this file.
00001 #ifndef _EVENT_DATA_OBJECTS_H_
00002 #define _EVENT_DATA_OBJECTS_H_
00003 /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; version 2 of the License.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software Foundation,
00016    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
00017 
00025 #include "event_parse_data.h"
00026 #include "thr_lock.h"                           /* thr_lock_type */
00027 
00028 class Field;
00029 class THD;
00030 class Time_zone;
00031 struct TABLE;
00032 
00033 class Event_queue_element_for_exec
00034 {
00035 public:
00036   Event_queue_element_for_exec(){};
00037   ~Event_queue_element_for_exec();
00038 
00039   bool
00040   init(LEX_STRING dbname, LEX_STRING name);
00041 
00042   LEX_STRING dbname;
00043   LEX_STRING name;
00044   bool dropped;
00045   THD *thd;
00046 
00047 private:
00048   /* Prevent use of these */
00049   Event_queue_element_for_exec(const Event_queue_element_for_exec &);
00050   void operator=(Event_queue_element_for_exec &);
00051 };
00052 
00053 
00054 class Event_basic
00055 {
00056 protected:
00057   MEM_ROOT mem_root;
00058 
00059 public:
00060 
00061   LEX_STRING dbname;
00062   LEX_STRING name;
00063   LEX_STRING definer;// combination of user and host
00064 
00065   Time_zone *time_zone;
00066 
00067   Event_basic();
00068   virtual ~Event_basic();
00069 
00070   virtual bool
00071   load_from_row(THD *thd, TABLE *table) = 0;
00072 
00073 protected:
00074   bool
00075   load_string_fields(Field **fields, ...);
00076 
00077   bool
00078   load_time_zone(THD *thd, const LEX_STRING tz_name);
00079 };
00080 
00081 
00082 
00083 class Event_queue_element : public Event_basic
00084 {
00085 public:
00086   int on_completion;
00087   int status;
00088   longlong originator;
00089 
00090   my_time_t last_executed;
00091   my_time_t execute_at;
00092   my_time_t starts;
00093   my_time_t ends;
00094   my_bool starts_null;
00095   my_bool ends_null;
00096   my_bool execute_at_null;
00097 
00098   longlong expression;
00099   interval_type interval;
00100 
00101   bool dropped;
00102 
00103   uint execution_count;
00104 
00105   Event_queue_element();
00106   virtual ~Event_queue_element();
00107 
00108   virtual bool
00109   load_from_row(THD *thd, TABLE *table);
00110 
00111   bool
00112   compute_next_execution_time();
00113 
00114   void
00115   mark_last_executed(THD *thd);
00116 };
00117 
00118 
00119 class Event_timed : public Event_queue_element
00120 {
00121   Event_timed(const Event_timed &);     /* Prevent use of these */
00122   void operator=(Event_timed &);
00123 
00124 public:
00125   LEX_STRING body;
00126 
00127   LEX_STRING definer_user;
00128   LEX_STRING definer_host;
00129 
00130   LEX_STRING comment;
00131 
00132   ulonglong created;
00133   ulonglong modified;
00134 
00135   sql_mode_t sql_mode;
00136 
00137   class Stored_program_creation_ctx *creation_ctx;
00138   LEX_STRING body_utf8;
00139 
00140   Event_timed();
00141   virtual ~Event_timed();
00142 
00143   void
00144   init();
00145 
00146   virtual bool
00147   load_from_row(THD *thd, TABLE *table);
00148 
00149   int
00150   get_create_event(THD *thd, String *buf);
00151 };
00152 
00153 
00154 class Event_job_data : public Event_basic
00155 {
00156 public:
00157   LEX_STRING body;
00158   LEX_STRING definer_user;
00159   LEX_STRING definer_host;
00160 
00161   sql_mode_t sql_mode;
00162 
00163   class Stored_program_creation_ctx *creation_ctx;
00164 
00165   Event_job_data();
00166 
00167   virtual bool
00168   load_from_row(THD *thd, TABLE *table);
00169 
00170   bool
00171   execute(THD *thd, bool drop);
00172 private:
00173   bool
00174   construct_sp_sql(THD *thd, String *sp_sql);
00175   bool
00176   construct_drop_event_sql(THD *thd, String *sp_sql);
00177 
00178   Event_job_data(const Event_job_data &);       /* Prevent use of these */
00179   void operator=(Event_job_data &);
00180 };
00181 
00182 
00183 /* Compares only the schema part of the identifier */
00184 bool
00185 event_basic_db_equal(LEX_STRING db, Event_basic *et);
00186 
00187 /* Compares the whole identifier*/
00188 bool
00189 event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b);
00190 
00195 #endif /* _EVENT_DATA_OBJECTS_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines