MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
events.h
Go to the documentation of this file.
1 #ifndef _EVENT_H_
2 #define _EVENT_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 
28 #ifdef HAVE_PSI_INTERFACE
29 extern PSI_mutex_key key_event_scheduler_LOCK_scheduler_state;
30 extern PSI_cond_key key_event_scheduler_COND_state;
31 extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
32 #endif /* HAVE_PSI_INTERFACE */
33 
34 /* Always defined, for SHOW PROCESSLIST. */
35 extern PSI_stage_info stage_waiting_on_empty_queue;
36 extern PSI_stage_info stage_waiting_for_next_activation;
37 extern PSI_stage_info stage_waiting_for_scheduler_to_stop;
38 
39 #include "sql_string.h" /* LEX_STRING */
40 #include "my_time.h" /* interval_type */
41 
43 class Event_parse_data;
44 class Event_queue;
45 class Event_scheduler;
46 struct TABLE_LIST;
47 class THD;
48 typedef struct charset_info_st CHARSET_INFO;
49 
50 int
51 sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
52 
74 class Events
75 {
76 public:
77  /*
78  the following block is to support --event-scheduler command line option
79  and the @@global.event_scheduler SQL variable.
80  See sys_var.cc
81  */
82  enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED };
83  /* Protected using LOCK_global_system_variables only. */
84  static ulong opt_event_scheduler;
85  static bool check_if_system_tables_error();
86  static bool start(int *err_no);
87  static bool stop();
88 
89 public:
90  /* A hack needed for Event_queue_element */
91  static Event_db_repository *
92  get_db_repository() { return db_repository; }
93 
94  static bool
95  init(my_bool opt_noacl);
96 
97  static void
98  deinit();
99 
100  static void
101  init_mutexes();
102 
103  static void
104  destroy_mutexes();
105 
106  static bool
107  create_event(THD *thd, Event_parse_data *parse_data, bool if_exists);
108 
109  static bool
110  update_event(THD *thd, Event_parse_data *parse_data,
111  LEX_STRING *new_dbname, LEX_STRING *new_name);
112 
113  static bool
114  drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists);
115 
116  static void
117  drop_schema_events(THD *thd, char *db);
118 
119  static bool
120  show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
121 
122  /* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
123  static int
124  reconstruct_interval_expression(String *buf, interval_type interval,
125  longlong expression);
126 
127  static int
128  fill_schema_events(THD *thd, TABLE_LIST *tables, Item * /* cond */);
129 
130  static void
131  dump_internal_status();
132 
133 private:
134 
135  static bool
136  load_events_from_db(THD *thd);
137 
138 private:
139  static Event_queue *event_queue;
140  static Event_scheduler *scheduler;
141  static Event_db_repository *db_repository;
142  /* Set to TRUE if an error at start up */
143  static bool check_system_tables_error;
144 
145 private:
146  /* Prevent use of these */
147  Events(const Events &);
148  void operator=(Events &);
149 };
150 
155 #endif /* _EVENT_H_ */