MySQL 8.0.31
Source Code Documentation
trigger_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef DD__TRIGGER_IMPL_INCLUDED
24#define DD__TRIGGER_IMPL_INCLUDED
25
26#include "my_config.h"
27
28#include "my_inttypes.h"
29#include "sql/dd/string_type.h"
30
31#ifdef HAVE_SYS_TIME_H
32#include <sys/time.h>
33#endif
34#include <sys/types.h>
35#include <new>
36
38#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_impl
39#include "sql/dd/impl/types/table_impl.h" // dd::Table_impl
41#include "sql/dd/object_id.h"
42#include "sql/dd/types/trigger.h" // dd::Trigger
43
44namespace dd {
45
46///////////////////////////////////////////////////////////////////////////
47
48class Object_table;
49class Open_dictionary_tables_ctx;
50class Table;
51class Weak_object;
52
53class Trigger_impl : virtual public Entity_object_impl, virtual public Trigger {
54 public:
56
58
59 Trigger_impl(const Trigger_impl &src, Table_impl *parent);
60
61 public:
62 const Object_table &object_table() const override;
63
64 bool validate() const override;
65
66 bool restore_attributes(const Raw_record &r) override;
67
68 bool store_attributes(Raw_record *r) override;
69
70 void debug_print(String_type &outb) const override;
71
74 }
75
77
78 public:
80
81 /////////////////////////////////////////////////////////////////////////
82 // Table.
83 /////////////////////////////////////////////////////////////////////////
84
85 virtual const Table &table() const;
86
87 virtual Table &table();
88
89 /* non-virtual */ void set_table(Table_impl *parent) { m_table = parent; }
90
91 /* non-virtual */ const Table_impl &table_impl() const { return *m_table; }
92
93 /* non-virtual */ Table_impl &table_impl() { return *m_table; }
94
95 /////////////////////////////////////////////////////////////////////////
96 // schema.
97 /////////////////////////////////////////////////////////////////////////
98
99 Object_id schema_id() const override {
100 return (m_table != nullptr ? m_table->schema_id() : INVALID_OBJECT_ID);
101 }
102
103 /////////////////////////////////////////////////////////////////////////
104 // event type
105 /////////////////////////////////////////////////////////////////////////
106
107 enum_event_type event_type() const override { return m_event_type; }
108
111 }
112
113 /////////////////////////////////////////////////////////////////////////
114 // table.
115 /////////////////////////////////////////////////////////////////////////
116
117 Object_id table_id() const override { return m_table->id(); }
118
119 /////////////////////////////////////////////////////////////////////////
120 // action timing
121 /////////////////////////////////////////////////////////////////////////
122
124
127 }
128
129 /////////////////////////////////////////////////////////////////////////
130 // action_order.
131 /////////////////////////////////////////////////////////////////////////
132
133 uint action_order() const override { return m_action_order; }
134
137 }
138
139 /////////////////////////////////////////////////////////////////////////
140 // action_statement/utf8.
141 /////////////////////////////////////////////////////////////////////////
142
143 const String_type &action_statement() const override {
144 return m_action_statement;
145 }
146
149 }
150
151 const String_type &action_statement_utf8() const override {
153 }
154
156 const String_type &action_statement_utf8) override {
158 }
159
160 /////////////////////////////////////////////////////////////////////////
161 // created.
162 /////////////////////////////////////////////////////////////////////////
163
164 my_timeval created() const override { return m_created; }
165
167
168 /////////////////////////////////////////////////////////////////////////
169 // last altered.
170 /////////////////////////////////////////////////////////////////////////
171
172 my_timeval last_altered() const override { return m_last_altered; }
173
176 }
177
178 /////////////////////////////////////////////////////////////////////////
179 // sql_mode
180 /////////////////////////////////////////////////////////////////////////
181
182 ulonglong sql_mode() const override { return m_sql_mode; }
183
185
186 /////////////////////////////////////////////////////////////////////////
187 // definer.
188 /////////////////////////////////////////////////////////////////////////
189
190 const String_type &definer_user() const override { return m_definer_user; }
191
192 const String_type &definer_host() const override { return m_definer_host; }
193
194 void set_definer(const String_type &username,
195 const String_type &hostname) override {
196 m_definer_user = username;
197 m_definer_host = hostname;
198 }
199
200 /////////////////////////////////////////////////////////////////////////
201 // collation.
202 /////////////////////////////////////////////////////////////////////////
203
206 }
207
210 }
211
214 }
215
218 }
219
222 }
223
226 }
227
228 // Fix "inherits ... via dominance" warnings
230
231 const Entity_object_impl *impl() const override {
233 }
234
235 Object_id id() const override { return Entity_object_impl::id(); }
236
237 bool is_persistent() const override {
239 }
240
241 const String_type &name() const override {
243 }
244
245 void set_name(const String_type &name) override {
247 }
248
249 public:
251 return new (std::nothrow) Trigger_impl(table);
252 }
253
255 return new (std::nothrow) Trigger_impl(other, table);
256 }
257
258 private:
261
262 /*
263 We use m_ordinal_position to help implement
264 add_trigger_following and add_trigger_preceding.
265 This is required mainly because we maintain a single
266 collection to maintain all triggers.
267 */
270
274
279
280 // References to tightly-coupled objects.
281
283
284 // References to loosely-coupled objects.
285
289};
290
291///////////////////////////////////////////////////////////////////////////
292
293/**
294 Used to sort Triggers of the same table by action timing, event type and
295 action order.
296*/
297
299 bool operator()(const dd::Trigger *t1, const dd::Trigger *t2) const {
300 return ((t1->action_timing() < t2->action_timing()) ||
301 (t1->action_timing() == t2->action_timing() &&
302 t1->event_type() < t2->event_type()) ||
303 (t1->action_timing() == t2->action_timing() &&
304 t1->event_type() == t2->event_type() &&
305 t1->action_order() < t2->action_order()));
306 }
307};
308
309///////////////////////////////////////////////////////////////////////////
310} // namespace dd
311
312#endif // DD__TRIGGER_IMPL_INCLUDED
Definition: entity_object_impl.h:43
void set_name(const String_type &name) override
Definition: entity_object_impl.h:61
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:48
const String_type & name() const override
Definition: entity_object_impl.h:59
Entity_object_impl * impl() override
Definition: entity_object_impl.h:67
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:56
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:71
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:75
Definition: raw_record.h:45
Definition: table_impl.h:67
Object_id schema_id() const override
Definition: table_impl.h:430
Object_id id() const override
The unique dictionary object id.
Definition: table_impl.h:420
Definition: table.h:46
Definition: trigger_impl.h:53
Object_id schema_collation_id() const override
Definition: trigger_impl.h:220
static Trigger_impl * clone(const Trigger_impl &other, Table_impl *table)
Definition: trigger_impl.h:254
uint ordinal_position() const
Definition: trigger_impl.h:76
String_type m_action_statement
Definition: trigger_impl.h:276
bool store_attributes(Raw_record *r) override
Definition: trigger_impl.cc:150
enum_event_type event_type() const override
Definition: trigger_impl.h:107
ulonglong m_sql_mode
Definition: trigger_impl.h:271
void set_table(Table_impl *parent)
Definition: trigger_impl.h:89
my_timeval last_altered() const override
Definition: trigger_impl.h:172
void set_definer(const String_type &username, const String_type &hostname) override
Definition: trigger_impl.h:194
void set_last_altered(my_timeval last_altered) override
Definition: trigger_impl.h:174
String_type m_definer_host
Definition: trigger_impl.h:278
void set_sql_mode(ulonglong sql_mode) override
Definition: trigger_impl.h:184
String_type m_definer_user
Definition: trigger_impl.h:277
const String_type & action_statement_utf8() const override
Definition: trigger_impl.h:151
Object_id client_collation_id() const override
Definition: trigger_impl.h:204
Object_id schema_id() const override
Definition: trigger_impl.h:99
String_type m_action_statement_utf8
Definition: trigger_impl.h:275
void set_connection_collation_id(Object_id connection_collation_id) override
Definition: trigger_impl.h:216
void set_client_collation_id(Object_id client_collation_id) override
Definition: trigger_impl.h:208
const Entity_object_impl * impl() const override
Definition: trigger_impl.h:231
const String_type & definer_host() const override
Definition: trigger_impl.h:192
bool restore_attributes(const Raw_record &r) override
Definition: trigger_impl.cc:94
static Trigger_impl * restore_item(Table_impl *table)
Definition: trigger_impl.h:250
void set_action_statement(const String_type &action_statement) override
Definition: trigger_impl.h:147
const String_type & action_statement() const override
Definition: trigger_impl.h:143
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: trigger_impl.cc:229
const Object_table & object_table() const override
Definition: trigger_impl.cc:223
void set_event_type(enum_event_type event_type) override
Definition: trigger_impl.h:109
uint m_ordinal_position
Definition: trigger_impl.h:268
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: trigger_impl.h:237
Object_id id() const override
The unique dictionary object id.
Definition: trigger_impl.h:235
void set_ordinal_position(uint ordinal_position)
Definition: trigger_impl.h:72
my_timeval m_last_altered
Definition: trigger_impl.h:273
Object_id m_client_collation_id
Definition: trigger_impl.h:286
const Table_impl & table_impl() const
Definition: trigger_impl.h:91
void set_name(const String_type &name) override
Definition: trigger_impl.h:245
Trigger_impl()
Definition: trigger_impl.cc:53
void set_action_statement_utf8(const String_type &action_statement_utf8) override
Definition: trigger_impl.h:155
Entity_object_impl * impl() override
Definition: trigger_impl.h:229
void set_created(my_timeval created) override
Definition: trigger_impl.h:166
my_timeval created() const override
Definition: trigger_impl.h:164
ulonglong sql_mode() const override
Definition: trigger_impl.h:182
enum_event_type m_event_type
Definition: trigger_impl.h:259
enum_action_timing m_action_timing
Definition: trigger_impl.h:260
void debug_print(String_type &outb) const override
Definition: trigger_impl.cc:176
virtual const Table & table() const
Definition: trigger_impl.cc:76
Table_impl & table_impl()
Definition: trigger_impl.h:93
Object_id m_connection_collation_id
Definition: trigger_impl.h:287
void set_action_timing(enum_action_timing action_timing) override
Definition: trigger_impl.h:125
bool validate() const override
Definition: trigger_impl.cc:82
const String_type & definer_user() const override
Definition: trigger_impl.h:190
void set_action_order(uint action_order) override
Definition: trigger_impl.h:135
uint action_order() const override
Definition: trigger_impl.h:133
uint m_action_order
Definition: trigger_impl.h:269
Object_id m_schema_collation_id
Definition: trigger_impl.h:288
Table_impl * m_table
Definition: trigger_impl.h:282
const String_type & name() const override
Definition: trigger_impl.h:241
Object_id connection_collation_id() const override
Definition: trigger_impl.h:212
void set_schema_collation_id(Object_id schema_collation_id) override
Definition: trigger_impl.h:224
Object_id table_id() const override
Definition: trigger_impl.h:117
enum_action_timing action_timing() const override
Definition: trigger_impl.h:123
my_timeval m_created
Definition: trigger_impl.h:272
Class representing a Trigger in DD framework.
Definition: trigger.h:53
virtual uint action_order() const =0
virtual enum_action_timing action_timing() const =0
enum_action_timing
Definition: trigger.h:61
virtual enum_event_type event_type() const =0
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
unsigned long long Object_id
Definition: object_id.h:30
const Object_id INVALID_OBJECT_ID
The default object ID which represents that the DD object is new and not persistent in dictionary tab...
Definition: object_id.h:36
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
enum_event_type
Enum values for the NESTING_EVENT_TYPE columns.
Definition: pfs_column_types.h:270
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
Used to sort Triggers of the same table by action timing, event type and action order.
Definition: trigger_impl.h:298
bool operator()(const dd::Trigger *t1, const dd::Trigger *t2) const
Definition: trigger_impl.h:299
Replacement of system's struct timeval to ensure we can carry 64 bit values even on a platform which ...
Definition: my_time_t.h:44
Include file for Sun RPC to compile out of the box.
unsigned int uint
Definition: uca-dump.cc:29