| 1 | /* |
| 2 | Copyright (c) 2008, 2011, Oracle and/or its affiliates. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 16 | |
| 17 | #ifndef _EVENT_PARSE_DATA_H_ |
| 18 | #define _EVENT_PARSE_DATA_H_ |
| 19 | |
| 20 | #include "sql_alloc.h" |
| 21 | |
| 22 | class Item; |
| 23 | class THD; |
| 24 | class sp_name; |
| 25 | |
| 26 | #define EVEX_GET_FIELD_FAILED -2 |
| 27 | #define EVEX_BAD_PARAMS -5 |
| 28 | #define EVEX_MICROSECOND_UNSUP -6 |
| 29 | #define EVEX_MAX_INTERVAL_VALUE 1000000000L |
| 30 | |
| 31 | class Event_parse_data : public Sql_alloc |
| 32 | { |
| 33 | public: |
| 34 | /* |
| 35 | ENABLED = feature can function normally (is turned on) |
| 36 | SLAVESIDE_DISABLED = feature is turned off on slave |
| 37 | DISABLED = feature is turned off |
| 38 | */ |
| 39 | enum enum_status |
| 40 | { |
| 41 | ENABLED = 1, |
| 42 | DISABLED, |
| 43 | SLAVESIDE_DISABLED |
| 44 | }; |
| 45 | |
| 46 | enum enum_on_completion |
| 47 | { |
| 48 | /* |
| 49 | On CREATE EVENT, DROP is the DEFAULT as per the docs. |
| 50 | On ALTER EVENT, "no change" is the DEFAULT. |
| 51 | */ |
| 52 | ON_COMPLETION_DEFAULT = 0, |
| 53 | ON_COMPLETION_DROP, |
| 54 | ON_COMPLETION_PRESERVE |
| 55 | }; |
| 56 | |
| 57 | int on_completion; |
| 58 | int status; |
| 59 | bool status_changed; |
| 60 | uint32 originator; |
| 61 | /* |
| 62 | do_not_create will be set if STARTS time is in the past and |
| 63 | on_completion == ON_COMPLETION_DROP. |
| 64 | */ |
| 65 | bool do_not_create; |
| 66 | |
| 67 | bool body_changed; |
| 68 | |
| 69 | LEX_CSTRING dbname; |
| 70 | LEX_CSTRING name; |
| 71 | LEX_CSTRING definer;// combination of user and host |
| 72 | LEX_CSTRING ; |
| 73 | |
| 74 | Item* item_starts; |
| 75 | Item* item_ends; |
| 76 | Item* item_execute_at; |
| 77 | |
| 78 | my_time_t starts; |
| 79 | my_time_t ends; |
| 80 | my_time_t execute_at; |
| 81 | bool starts_null; |
| 82 | bool ends_null; |
| 83 | bool execute_at_null; |
| 84 | |
| 85 | sp_name *identifier; |
| 86 | Item* item_expression; |
| 87 | longlong expression; |
| 88 | interval_type interval; |
| 89 | |
| 90 | static Event_parse_data * |
| 91 | new_instance(THD *thd); |
| 92 | |
| 93 | bool |
| 94 | check_parse_data(THD *thd); |
| 95 | |
| 96 | bool |
| 97 | check_dates(THD *thd, int previous_on_completion); |
| 98 | |
| 99 | private: |
| 100 | |
| 101 | void |
| 102 | init_definer(THD *thd); |
| 103 | |
| 104 | void |
| 105 | init_name(THD *thd, sp_name *spn); |
| 106 | |
| 107 | int |
| 108 | init_execute_at(THD *thd); |
| 109 | |
| 110 | int |
| 111 | init_interval(THD *thd); |
| 112 | |
| 113 | int |
| 114 | init_starts(THD *thd); |
| 115 | |
| 116 | int |
| 117 | init_ends(THD *thd); |
| 118 | |
| 119 | Event_parse_data(); |
| 120 | ~Event_parse_data(); |
| 121 | |
| 122 | void |
| 123 | report_bad_value(const char *item_name, Item *bad_item); |
| 124 | |
| 125 | void |
| 126 | check_if_in_the_past(THD *thd, my_time_t ltime_utc); |
| 127 | |
| 128 | Event_parse_data(const Event_parse_data &); /* Prevent use of these */ |
| 129 | void check_originator_id(THD *thd); |
| 130 | void operator=(Event_parse_data &); |
| 131 | }; |
| 132 | #endif |
| 133 | |