MySQL 9.1.0
Source Code Documentation
triggers.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef DD_TABLES__TRIGGERS_INCLUDED
25#define DD_TABLES__TRIGGERS_INCLUDED
26
27#include <string>
28
31#include "sql/dd/impl/types/object_table_impl.h" // dd::Object_table_i...
32#include "sql/dd/impl/types/trigger_impl.h" // dd::Trigger_impl
33#include "sql/dd/object_id.h"
34#include "sql/dd/string_type.h"
35
36class THD;
37
38struct CHARSET_INFO;
39
40namespace dd {
41class Object_key;
42} // namespace dd
43
44namespace dd {
45namespace tables {
46
47///////////////////////////////////////////////////////////////////////////
48
49class Triggers : virtual public Object_table_impl {
50 public:
51 static const Triggers &instance() {
52 static Triggers *s_instance = new Triggers();
53 return *s_instance;
54 }
55
56 static const CHARSET_INFO *name_collation();
57
76 NUMBER_OF_FIELDS // Always keep this entry at the end of the enum
77 };
78
80 INDEX_PK_ID = static_cast<uint>(Common_index::PK_ID),
87 };
88
95 };
96
97 Triggers();
98
99 /**
100 Create a key to find all triggers for a given schema.
101
102 @param schema_id Object_id of the schema.
103
104 @returns Pointer to Object_key.
105 */
106
108
109 /**
110 Create a key to find all triggers for a given table.
111
112 @param table_id Object_id of the table.
113
114 @returns Pointer to Object_key.
115 */
116
118
119 /**
120 Find table's Object_id for a given trigger name.
121
122 @param thd Thread
123 @param schema_id Object_id of schema in which the trigger exists.
124 @param trigger_name Name of trigger we are search for.
125 @param oid [out] The Object_id of trigger.
126
127 @returns
128 false on success.
129 true upon failure.
130 */
131
132 static bool get_trigger_table_id(THD *thd, Object_id schema_id,
133 const String_type &trigger_name,
134 Object_id *oid);
135
136 /**
137 Create a key to find all triggers for a given definer.
138
139 @param definer Name of the definer.
140
141 @returns Pointer to Object_key.
142 */
143 static Object_key *create_key_by_definer(const String_type &definer);
144
145 private:
146 /**
147 Create a key to find a trigger by schema_id and trigger name.
148
149 @param schema_id Object_id of the table.
150 @param trigger_name Name of trigger.
151
152 @returns Pointer to Object_key.
153 */
155 const char *trigger_name);
156
157 /**
158 Get the table id from the record.
159
160 @param r const Reference to the Raw_record.
161
162 @returns Object_id of the table.
163 */
164
165 static Object_id read_table_id(const Raw_record &r);
166};
167
168///////////////////////////////////////////////////////////////////////////
169
170} // namespace tables
171} // namespace dd
172
173#endif // DD_TABLES__TRIGGERS_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: object_key.h:38
Definition: object_table_impl.h:36
Definition: raw_record.h:46
Definition: triggers.h:49
enum_foreign_keys
Definition: triggers.h:89
@ FK_SCHEMA_ID
Definition: triggers.h:90
@ FK_CLIENT_COLLATION_ID
Definition: triggers.h:92
@ FK_CONNECTION_COLLATION_ID
Definition: triggers.h:93
@ FK_TABLE_ID
Definition: triggers.h:91
@ FK_SCHEMA_COLLATION_ID
Definition: triggers.h:94
static Object_key * create_key_by_schema_id(Object_id schema_id)
Create a key to find all triggers for a given schema.
Definition: triggers.cc:133
static Object_key * create_key_by_trigger_name(Object_id schema_id, const char *trigger_name)
Create a key to find a trigger by schema_id and trigger name.
Definition: triggers.cc:149
static Object_key * create_key_by_table_id(Object_id table_id)
Create a key to find all triggers for a given table.
Definition: triggers.cc:141
enum_fields
Definition: triggers.h:58
@ FIELD_ACTION_STATEMENT
Definition: triggers.h:66
@ FIELD_TABLE_ID
Definition: triggers.h:63
@ FIELD_CLIENT_COLLATION_ID
Definition: triggers.h:72
@ FIELD_DEFINER
Definition: triggers.h:71
@ FIELD_EVENT_TYPE
Definition: triggers.h:62
@ NUMBER_OF_FIELDS
Definition: triggers.h:76
@ FIELD_CONNECTION_COLLATION_ID
Definition: triggers.h:73
@ FIELD_ACTION_STATEMENT_UTF8
Definition: triggers.h:67
@ FIELD_SCHEMA_COLLATION_ID
Definition: triggers.h:74
@ FIELD_LAST_ALTERED
Definition: triggers.h:69
@ FIELD_OPTIONS
Definition: triggers.h:75
@ FIELD_NAME
Definition: triggers.h:61
@ FIELD_SCHEMA_ID
Definition: triggers.h:60
@ FIELD_CREATED
Definition: triggers.h:68
@ FIELD_SQL_MODE
Definition: triggers.h:70
@ FIELD_ID
Definition: triggers.h:59
@ FIELD_ACTION_TIMING
Definition: triggers.h:64
@ FIELD_ACTION_ORDER
Definition: triggers.h:65
enum_indexes
Definition: triggers.h:79
@ INDEX_UK_SCHEMA_ID_NAME
Definition: triggers.h:81
@ INDEX_K_DEFINER
Definition: triggers.h:86
@ INDEX_K_CLIENT_COLLATION_ID
Definition: triggers.h:83
@ INDEX_UK_TABLE_ID_EVENT_TYPE_ACTION_TIMING_ACTION_ORDER
Definition: triggers.h:82
@ INDEX_K_CONNECTION_COLLATION_ID
Definition: triggers.h:84
@ INDEX_K_SCHEMA_COLLATION_ID
Definition: triggers.h:85
@ INDEX_PK_ID
Definition: triggers.h:80
Triggers()
Definition: triggers.cc:53
static const Triggers & instance()
Definition: triggers.h:51
static Object_id read_table_id(const Raw_record &r)
Get the table id from the record.
Definition: triggers.cc:157
static const CHARSET_INFO * name_collation()
Definition: triggers.cc:47
static bool get_trigger_table_id(THD *thd, Object_id schema_id, const String_type &trigger_name, Object_id *oid)
Find table's Object_id for a given trigger name.
Definition: triggers.cc:163
static Object_key * create_key_by_definer(const String_type &definer)
Create a key to find all triggers for a given definer.
Definition: triggers.cc:192
const dd::system_views::Columns_extensions * s_instance
Definition: columns_extensions.cc:42
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
Definition: m_ctype.h:421