1 #ifndef _EVENT_DB_REPOSITORY_H_
2 #define _EVENT_DB_REPOSITORY_H_
3 
4 /*
5    Copyright (c) 2006, 2021, Oracle and/or its affiliates.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License, version 2.0,
9    as published by the Free Software Foundation.
10 
11    This program is also distributed with certain software (including
12    but not limited to OpenSSL) that is licensed under separate terms,
13    as designated in a particular file or component or in included license
14    documentation.  The authors of MySQL hereby grant you an additional
15    permission to link the program and your derivative works with the
16    separately licensed software that they have included with MySQL.
17 
18    This program is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21    GNU General Public License, version 2.0, for more details.
22 
23    You should have received a copy of the GNU General Public License
24    along with this program; if not, write to the Free Software
25    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
26 */
27 
28 #include "my_global.h"
29 #include "my_time.h"                            // my_time_t
30 #include "thr_lock.h"                           // thr_lock_type
31 #include "mysql/mysql_lex_string.h"             // LEX_STRING
32 
33 struct TABLE;
34 struct TABLE_LIST;
35 typedef struct st_mysql_lex_string LEX_STRING;
36 
37 /**
38   @addtogroup Event_Scheduler
39   @{
40 
41   @file event_db_repository.h
42 
43   Data Dictionary related operations of Event Scheduler.
44 
45   This is a private header file of Events module. Please do not include it
46   directly. All public declarations of Events module should be stored in
47   events.h and event_data_objects.h.
48 */
49 
50 enum enum_events_table_field
51 {
52   ET_FIELD_DB = 0,
53   ET_FIELD_NAME,
54   ET_FIELD_BODY,
55   ET_FIELD_DEFINER,
56   ET_FIELD_EXECUTE_AT,
57   ET_FIELD_INTERVAL_EXPR,
58   ET_FIELD_TRANSIENT_INTERVAL,
59   ET_FIELD_CREATED,
60   ET_FIELD_MODIFIED,
61   ET_FIELD_LAST_EXECUTED,
62   ET_FIELD_STARTS,
63   ET_FIELD_ENDS,
64   ET_FIELD_STATUS,
65   ET_FIELD_ON_COMPLETION,
66   ET_FIELD_SQL_MODE,
67   ET_FIELD_COMMENT,
68   ET_FIELD_ORIGINATOR,
69   ET_FIELD_TIME_ZONE,
70   ET_FIELD_CHARACTER_SET_CLIENT,
71   ET_FIELD_COLLATION_CONNECTION,
72   ET_FIELD_DB_COLLATION,
73   ET_FIELD_BODY_UTF8,
74   ET_FIELD_COUNT /* a cool trick to count the number of fields :) */
75 };
76 
77 
78 int
79 events_table_index_read_for_db(THD *thd, TABLE *schema_table,
80                                TABLE *event_table);
81 
82 int
83 events_table_scan_all(THD *thd, TABLE *schema_table, TABLE *event_table);
84 
85 
86 class Event_basic;
87 class Event_parse_data;
88 
89 class Event_db_repository
90 {
91 public:
Event_db_repository()92   Event_db_repository(){}
93 
94   bool
95   create_event(THD *thd, Event_parse_data *parse_data, bool create_if_not,
96                bool *event_already_exists);
97 
98   bool
99   update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname,
100                LEX_STRING *new_name);
101 
102   bool
103   drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists);
104 
105   void
106   drop_schema_events(THD *thd, LEX_STRING schema);
107 
108   bool
109   find_named_event(LEX_STRING db, LEX_STRING name, TABLE *table);
110 
111   bool
112   load_named_event(THD *thd, LEX_STRING dbname, LEX_STRING name, Event_basic *et);
113 
114   static bool
115   open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
116 
117   bool
118   fill_schema_events(THD *thd, TABLE_LIST *tables, const char *db);
119 
120   bool
121   update_timing_fields_for_event(THD *thd,
122                                  LEX_STRING event_db_name,
123                                  LEX_STRING event_name,
124                                  my_time_t last_executed,
125                                  ulonglong status);
126 public:
127   static bool
128   check_system_tables(THD *thd);
129 private:
130   bool
131   index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table,
132                             const char *db);
133 
134   bool
135   table_scan_all_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table);
136 
137 private:
138   /* Prevent use of these */
139   Event_db_repository(const Event_db_repository &);
140   void operator=(Event_db_repository &);
141 };
142 
143 /**
144   @} (End of group Event_Scheduler)
145 */
146 #endif /* _EVENT_DB_REPOSITORY_H_ */
147