MySQL 9.0.0
Source Code Documentation
event_parse_data.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2008, 2024, 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, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#ifndef _EVENT_PARSE_DATA_H_
26#define _EVENT_PARSE_DATA_H_
27
28#include "lex_string.h"
29#include "my_dbug.h"
30#include "my_inttypes.h"
31#include "my_time.h" // interval_type
32
33class Item;
34struct LEX;
35class THD;
36class sp_head;
37class sp_name;
38class Sql_cmd;
39
40#define EVEX_MICROSECOND_UNSUP -6
41#define EVEX_MAX_INTERVAL_VALUE 1000000000L
42
44 public:
45 /*
46 ENABLED = feature can function normally (is turned on)
47 REPLICA_SIDE_DISABLED = feature is turned off on replica
48 DISABLED = feature is turned off
49 */
51
53 /*
54 On CREATE EVENT, DROP is the DEFAULT as per the docs.
55 On ALTER EVENT, "no change" is the DEFAULT.
56 */
60 };
61
64 bool status_changed{false};
65
66 std::uint64_t originator{0};
67 /*
68 do_not_create will be set if STARTS time is in the past and
69 on_completion == ON_COMPLETION_DROP.
70 */
71 bool do_not_create{false};
72
73 bool body_changed{false};
74
77 LEX_CSTRING definer{}; // combination of user and host
79
80 Item *item_starts{nullptr};
81 Item *item_ends{nullptr};
83
87 bool starts_null{true};
88 bool ends_null{true};
89 bool execute_at_null{true};
90
95
97
98 Event_parse_data() = default;
100 void operator=(Event_parse_data &) = delete;
101
102 bool resolve(THD *);
103 bool check_for_execute(THD *);
104 bool check_dates(THD *thd, enum_on_completion previous_on_completion);
105
106 private:
107 void init_definer(THD *thd);
108
109 void init_name(THD *thd, sp_name *spn);
110
111 bool init_execute_at(THD *thd);
112
113 bool init_interval(THD *thd);
114
115 bool init_starts(THD *thd);
116
117 bool init_ends(THD *thd);
118
119 void report_bad_value(THD *thd, const char *item_name, Item *bad_item);
120
121 [[nodiscard("Need to check for errors!")]] bool check_if_in_the_past(
122 THD *thd, my_time_t ltime_utc);
123
124 void check_originator_id(THD *thd);
125};
126
132#endif
Definition: event_parse_data.h:43
Event_parse_data()=default
enum_status status
Definition: event_parse_data.h:63
Item * item_execute_at
Definition: event_parse_data.h:82
void report_bad_value(THD *thd, const char *item_name, Item *bad_item)
Prints an error message about invalid value.
Definition: event_parse_data.cc:420
bool starts_null
Definition: event_parse_data.h:87
sp_head * event_body
Definition: event_parse_data.h:96
longlong expression
Definition: event_parse_data.h:93
interval_type interval
Definition: event_parse_data.h:94
LEX_CSTRING comment
Definition: event_parse_data.h:78
Item * item_starts
Definition: event_parse_data.h:80
LEX_CSTRING dbname
Definition: event_parse_data.h:75
void init_name(THD *thd, sp_name *spn)
Set a name of the event.
Definition: event_parse_data.cc:61
bool init_interval(THD *thd)
Sets time for execution of multi-time event.
Definition: event_parse_data.cc:221
my_time_t starts
Definition: event_parse_data.h:84
sp_name * identifier
Definition: event_parse_data.h:91
bool check_for_execute(THD *)
Checks performed on every execute.
Definition: event_parse_data.cc:474
void init_definer(THD *thd)
Inits definer (definer_user and definer_host) during parsing.
Definition: event_parse_data.cc:486
enum_on_completion on_completion
Definition: event_parse_data.h:62
Item * item_ends
Definition: event_parse_data.h:81
bool init_execute_at(THD *thd)
Sets time for execution for one-time event.
Definition: event_parse_data.cc:174
my_time_t execute_at
Definition: event_parse_data.h:86
LEX_CSTRING definer
Definition: event_parse_data.h:77
bool init_ends(THD *thd)
Sets ENDS (deactivation time).
Definition: event_parse_data.cc:371
Event_parse_data(const Event_parse_data &)=delete
my_time_t ends
Definition: event_parse_data.h:85
bool resolve(THD *)
Resolves the event parse data by checking the validity of the data gathered during the parsing phase.
Definition: event_parse_data.cc:439
bool do_not_create
Definition: event_parse_data.h:71
std::uint64_t originator
Definition: event_parse_data.h:66
void check_originator_id(THD *thd)
Set the originator id of the event to the server_id if executing on the source or set to the server_i...
Definition: event_parse_data.cc:525
bool execute_at_null
Definition: event_parse_data.h:89
enum_status
Definition: event_parse_data.h:50
@ REPLICA_SIDE_DISABLED
Definition: event_parse_data.h:50
@ ENABLED
Definition: event_parse_data.h:50
@ DISABLED
Definition: event_parse_data.h:50
bool init_starts(THD *thd)
Sets STARTS.
Definition: event_parse_data.cc:324
bool check_dates(THD *thd, enum_on_completion previous_on_completion)
Check time/dates in ALTER EVENT.
Definition: event_parse_data.cc:138
bool ends_null
Definition: event_parse_data.h:88
bool body_changed
Definition: event_parse_data.h:73
void operator=(Event_parse_data &)=delete
enum_on_completion
Definition: event_parse_data.h:52
@ ON_COMPLETION_DEFAULT
Definition: event_parse_data.h:57
@ ON_COMPLETION_PRESERVE
Definition: event_parse_data.h:59
@ ON_COMPLETION_DROP
Definition: event_parse_data.h:58
Item * item_expression
Definition: event_parse_data.h:92
LEX_CSTRING name
Definition: event_parse_data.h:76
bool check_if_in_the_past(THD *thd, my_time_t ltime_utc)
This function is called on CREATE EVENT or ALTER EVENT.
Definition: event_parse_data.cc:93
bool status_changed
Definition: event_parse_data.h:64
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Representation of an SQL command.
Definition: sql_cmd.h:83
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
sp_head represents one instance of a stored program.
Definition: sp_head.h:383
Definition: sp_head.h:123
Sql_cmd * make_create_event_sql_cmd(THD *, sp_name *)
Factory function used by the parser to create the actual Sql_cmd for create event,...
Definition: event_parse_data.cc:678
Event_parse_data * get_event_parse_data(LEX *)
Helper function to retrieve Event_parse_data from the type erased Sql_cmd.
Definition: event_parse_data.cc:710
Sql_cmd * make_alter_event_sql_cmd(THD *, sp_name *)
Factory function used by the parser to create the actual Sql_cmd for alter event, since no Parse_tree...
Definition: event_parse_data.cc:689
void cleanup_event_parse_data(LEX *)
Cleans up event parse data by destroying the event_body sp_head.
Definition: event_parse_data.cc:717
Sql_cmd * make_drop_event_sql_cmd(THD *, sp_name *)
Factory function used by the parser to create the actual Sql_cmd for drop event, since no Parse_tree ...
Definition: event_parse_data.cc:699
Some integer typedefs for easier portability.
long long int longlong
Definition: my_inttypes.h:55
Interface for low level time utilities.
interval_type
Available interval types used in any statement.
Definition: my_time.h:455
@ INTERVAL_LAST
Definition: my_time.h:476
int64_t my_time_t
Portable time_t replacement.
Definition: my_time_t.h:32
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3839
Definition: mysql_lex_string.h:40