My Project
|
00001 #ifndef _EVENT_H_ 00002 #define _EVENT_H_ 00003 /* Copyright (c) 2004, 2013, 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 00016 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00017 00028 #ifdef HAVE_PSI_INTERFACE 00029 extern PSI_mutex_key key_event_scheduler_LOCK_scheduler_state; 00030 extern PSI_cond_key key_event_scheduler_COND_state; 00031 extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker; 00032 #endif /* HAVE_PSI_INTERFACE */ 00033 00034 /* Always defined, for SHOW PROCESSLIST. */ 00035 extern PSI_stage_info stage_waiting_on_empty_queue; 00036 extern PSI_stage_info stage_waiting_for_next_activation; 00037 extern PSI_stage_info stage_waiting_for_scheduler_to_stop; 00038 00039 #include "sql_string.h" /* LEX_STRING */ 00040 #include "my_time.h" /* interval_type */ 00041 00042 class Event_db_repository; 00043 class Event_parse_data; 00044 class Event_queue; 00045 class Event_scheduler; 00046 struct TABLE_LIST; 00047 class THD; 00048 typedef struct charset_info_st CHARSET_INFO; 00049 00050 int 00051 sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs); 00052 00074 class Events 00075 { 00076 public: 00077 /* 00078 the following block is to support --event-scheduler command line option 00079 and the @@global.event_scheduler SQL variable. 00080 See sys_var.cc 00081 */ 00082 enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED }; 00083 /* Protected using LOCK_global_system_variables only. */ 00084 static ulong opt_event_scheduler; 00085 static bool check_if_system_tables_error(); 00086 static bool start(int *err_no); 00087 static bool stop(); 00088 00089 public: 00090 /* A hack needed for Event_queue_element */ 00091 static Event_db_repository * 00092 get_db_repository() { return db_repository; } 00093 00094 static bool 00095 init(my_bool opt_noacl); 00096 00097 static void 00098 deinit(); 00099 00100 static void 00101 init_mutexes(); 00102 00103 static void 00104 destroy_mutexes(); 00105 00106 static bool 00107 create_event(THD *thd, Event_parse_data *parse_data, bool if_exists); 00108 00109 static bool 00110 update_event(THD *thd, Event_parse_data *parse_data, 00111 LEX_STRING *new_dbname, LEX_STRING *new_name); 00112 00113 static bool 00114 drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists); 00115 00116 static void 00117 drop_schema_events(THD *thd, char *db); 00118 00119 static bool 00120 show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name); 00121 00122 /* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */ 00123 static int 00124 reconstruct_interval_expression(String *buf, interval_type interval, 00125 longlong expression); 00126 00127 static int 00128 fill_schema_events(THD *thd, TABLE_LIST *tables, Item * /* cond */); 00129 00130 static void 00131 dump_internal_status(); 00132 00133 private: 00134 00135 static bool 00136 load_events_from_db(THD *thd); 00137 00138 private: 00139 static Event_queue *event_queue; 00140 static Event_scheduler *scheduler; 00141 static Event_db_repository *db_repository; 00142 /* Set to TRUE if an error at start up */ 00143 static bool check_system_tables_error; 00144 00145 private: 00146 /* Prevent use of these */ 00147 Events(const Events &); 00148 void operator=(Events &); 00149 }; 00150 00155 #endif /* _EVENT_H_ */