| 1 | #ifndef _EVENT_DB_REPOSITORY_H_ |
| 2 | #define _EVENT_DB_REPOSITORY_H_ |
| 3 | /* Copyright (c) 2006, 2011, Oracle and/or its affiliates. |
| 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 | */ |
| 18 | |
| 19 | /** |
| 20 | @addtogroup Event_Scheduler |
| 21 | @{ |
| 22 | |
| 23 | @file event_db_repository.h |
| 24 | |
| 25 | Data Dictionary related operations of Event Scheduler. |
| 26 | |
| 27 | This is a private header file of Events module. Please do not include it |
| 28 | directly. All public declarations of Events module should be stored in |
| 29 | events.h and event_data_objects.h. |
| 30 | */ |
| 31 | |
| 32 | enum enum_events_table_field |
| 33 | { |
| 34 | ET_FIELD_DB = 0, |
| 35 | ET_FIELD_NAME, |
| 36 | ET_FIELD_BODY, |
| 37 | ET_FIELD_DEFINER, |
| 38 | ET_FIELD_EXECUTE_AT, |
| 39 | ET_FIELD_INTERVAL_EXPR, |
| 40 | ET_FIELD_TRANSIENT_INTERVAL, |
| 41 | ET_FIELD_CREATED, |
| 42 | ET_FIELD_MODIFIED, |
| 43 | ET_FIELD_LAST_EXECUTED, |
| 44 | ET_FIELD_STARTS, |
| 45 | ET_FIELD_ENDS, |
| 46 | ET_FIELD_STATUS, |
| 47 | ET_FIELD_ON_COMPLETION, |
| 48 | ET_FIELD_SQL_MODE, |
| 49 | , |
| 50 | ET_FIELD_ORIGINATOR, |
| 51 | ET_FIELD_TIME_ZONE, |
| 52 | ET_FIELD_CHARACTER_SET_CLIENT, |
| 53 | ET_FIELD_COLLATION_CONNECTION, |
| 54 | ET_FIELD_DB_COLLATION, |
| 55 | ET_FIELD_BODY_UTF8, |
| 56 | ET_FIELD_COUNT /* a cool trick to count the number of fields :) */ |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | int |
| 61 | events_table_index_read_for_db(THD *thd, TABLE *schema_table, |
| 62 | TABLE *event_table); |
| 63 | |
| 64 | int |
| 65 | events_table_scan_all(THD *thd, TABLE *schema_table, TABLE *event_table); |
| 66 | |
| 67 | |
| 68 | class Event_basic; |
| 69 | class Event_parse_data; |
| 70 | |
| 71 | class Event_db_repository |
| 72 | { |
| 73 | public: |
| 74 | Event_db_repository(){} |
| 75 | |
| 76 | bool |
| 77 | create_event(THD *thd, Event_parse_data *parse_data, |
| 78 | bool *event_already_exists); |
| 79 | bool |
| 80 | update_event(THD *thd, Event_parse_data *parse_data, LEX_CSTRING *new_dbname, |
| 81 | LEX_CSTRING *new_name); |
| 82 | |
| 83 | bool |
| 84 | drop_event(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *name, |
| 85 | bool drop_if_exists); |
| 86 | |
| 87 | void |
| 88 | drop_schema_events(THD *thd, const LEX_CSTRING *schema); |
| 89 | |
| 90 | bool |
| 91 | find_named_event(const LEX_CSTRING *db, const LEX_CSTRING *name, |
| 92 | TABLE *table); |
| 93 | |
| 94 | bool |
| 95 | load_named_event(THD *thd, const LEX_CSTRING *dbname, |
| 96 | const LEX_CSTRING *name, |
| 97 | Event_basic *et); |
| 98 | |
| 99 | static bool |
| 100 | open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table); |
| 101 | |
| 102 | bool |
| 103 | fill_schema_events(THD *thd, TABLE_LIST *tables, const char *db); |
| 104 | |
| 105 | bool |
| 106 | update_timing_fields_for_event(THD *thd, |
| 107 | const LEX_CSTRING *event_db_name, |
| 108 | const LEX_CSTRING *event_name, |
| 109 | my_time_t last_executed, |
| 110 | ulonglong status); |
| 111 | public: |
| 112 | static bool |
| 113 | check_system_tables(THD *thd); |
| 114 | private: |
| 115 | bool |
| 116 | index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table, |
| 117 | const char *db); |
| 118 | |
| 119 | bool |
| 120 | table_scan_all_for_i_s(THD *thd, TABLE *schema_table, TABLE *event_table); |
| 121 | |
| 122 | private: |
| 123 | /* Prevent use of these */ |
| 124 | Event_db_repository(const Event_db_repository &); |
| 125 | void operator=(Event_db_repository &); |
| 126 | }; |
| 127 | |
| 128 | /** |
| 129 | @} (End of group Event_Scheduler) |
| 130 | */ |
| 131 | #endif /* _EVENT_DB_REPOSITORY_H_ */ |
| 132 | |