MySQL 8.0.31
Source Code Documentation
triggers.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_TABLES__TRIGGERS_INCLUDED
24#define DD_TABLES__TRIGGERS_INCLUDED
25
26#include <string>
27
30#include "sql/dd/impl/types/object_table_impl.h" // dd::Object_table_i...
31#include "sql/dd/impl/types/trigger_impl.h" // dd::Trigger_impl
32#include "sql/dd/object_id.h"
33#include "sql/dd/string_type.h"
34
35class THD;
36
37namespace dd {
38class Object_key;
39} // namespace dd
40
41namespace dd {
42namespace tables {
43
44///////////////////////////////////////////////////////////////////////////
45
46class Triggers : virtual public Object_table_impl {
47 public:
48 static const Triggers &instance() {
49 static Triggers *s_instance = new Triggers();
50 return *s_instance;
51 }
52
53 static const CHARSET_INFO *name_collation();
54
73 NUMBER_OF_FIELDS // Always keep this entry at the end of the enum
74 };
75
84 };
85
92 };
93
94 Triggers();
95
96 /**
97 Create a key to find all triggers for a given schema.
98
99 @param schema_id Object_id of the schema.
100
101 @returns Pointer to Object_key.
102 */
103
105
106 /**
107 Create a key to find all triggers for a given table.
108
109 @param table_id Object_id of the table.
110
111 @returns Pointer to Object_key.
112 */
113
115
116 /**
117 Find table's Object_id for a given trigger name.
118
119 @param thd Thread
120 @param schema_id Object_id of schema in which the trigger exists.
121 @param trigger_name Name of trigger we are search for.
122 @param oid [out] The Object_id of trigger.
123
124 @returns
125 false on success.
126 true upon failure.
127 */
128
129 static bool get_trigger_table_id(THD *thd, Object_id schema_id,
130 const String_type &trigger_name,
131 Object_id *oid);
132
133 /**
134 Create a key to find all triggers for a given definer.
135
136 @param definer Name of the definer.
137
138 @returns Pointer to Object_key.
139 */
140 static Object_key *create_key_by_definer(const String_type &definer);
141
142 private:
143 /**
144 Create a key to find a trigger by schema_id and trigger name.
145
146 @param schema_id Object_id of the table.
147 @param trigger_name Name of trigger.
148
149 @returns Pointer to Object_key.
150 */
152 const char *trigger_name);
153
154 /**
155 Get the table id from the record.
156
157 @param r const Reference to the Raw_record.
158
159 @returns Object_id of the table.
160 */
161
162 static Object_id read_table_id(const Raw_record &r);
163};
164
165///////////////////////////////////////////////////////////////////////////
166
167} // namespace tables
168} // namespace dd
169
170#endif // DD_TABLES__TRIGGERS_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
Definition: object_key.h:37
Definition: object_table_impl.h:35
Definition: raw_record.h:45
Definition: triggers.h:46
enum_foreign_keys
Definition: triggers.h:86
@ FK_SCHEMA_ID
Definition: triggers.h:87
@ FK_CLIENT_COLLATION_ID
Definition: triggers.h:89
@ FK_CONNECTION_COLLATION_ID
Definition: triggers.h:90
@ FK_TABLE_ID
Definition: triggers.h:88
@ FK_SCHEMA_COLLATION_ID
Definition: triggers.h:91
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:130
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:146
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:138
enum_fields
Definition: triggers.h:55
@ FIELD_ACTION_STATEMENT
Definition: triggers.h:63
@ FIELD_TABLE_ID
Definition: triggers.h:60
@ FIELD_CLIENT_COLLATION_ID
Definition: triggers.h:69
@ FIELD_DEFINER
Definition: triggers.h:68
@ FIELD_EVENT_TYPE
Definition: triggers.h:59
@ NUMBER_OF_FIELDS
Definition: triggers.h:73
@ FIELD_CONNECTION_COLLATION_ID
Definition: triggers.h:70
@ FIELD_ACTION_STATEMENT_UTF8
Definition: triggers.h:64
@ FIELD_SCHEMA_COLLATION_ID
Definition: triggers.h:71
@ FIELD_LAST_ALTERED
Definition: triggers.h:66
@ FIELD_OPTIONS
Definition: triggers.h:72
@ FIELD_NAME
Definition: triggers.h:58
@ FIELD_SCHEMA_ID
Definition: triggers.h:57
@ FIELD_CREATED
Definition: triggers.h:65
@ FIELD_SQL_MODE
Definition: triggers.h:67
@ FIELD_ID
Definition: triggers.h:56
@ FIELD_ACTION_TIMING
Definition: triggers.h:61
@ FIELD_ACTION_ORDER
Definition: triggers.h:62
enum_indexes
Definition: triggers.h:76
@ INDEX_UK_SCHEMA_ID_NAME
Definition: triggers.h:78
@ INDEX_K_DEFINER
Definition: triggers.h:83
@ INDEX_K_CLIENT_COLLATION_ID
Definition: triggers.h:80
@ INDEX_UK_TABLE_ID_EVENT_TYPE_ACTION_TIMING_ACTION_ORDER
Definition: triggers.h:79
@ INDEX_K_CONNECTION_COLLATION_ID
Definition: triggers.h:81
@ INDEX_K_SCHEMA_COLLATION_ID
Definition: triggers.h:82
@ INDEX_PK_ID
Definition: triggers.h:77
Triggers()
Definition: triggers.cc:50
static const Triggers & instance()
Definition: triggers.h:48
static Object_id read_table_id(const Raw_record &r)
Get the table id from the record.
Definition: triggers.cc:154
static const CHARSET_INFO * name_collation()
Definition: triggers.cc:44
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:160
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:189
const dd::system_views::Columns_extensions * s_instance
Definition: columns_extensions.cc:40
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
unsigned long long Object_id
Definition: object_id.h:30
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
Definition: m_ctype.h:382
unsigned int uint
Definition: uca-dump.cc:29