MySQL 8.0.39
Source Code Documentation
routine_impl.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__ROUTINE_IMPL_INCLUDED
25#define DD__ROUTINE_IMPL_INCLUDED
26
27#include <stddef.h>
28#include <memory> // std::unique_ptr
29#include <string>
30
31#include "my_dbug.h"
32#include "my_inttypes.h"
34#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_impl
36#include "sql/dd/object_id.h"
37#include "sql/dd/string_type.h"
38#include "sql/dd/types/parameter.h" // dd::Parameter
39#include "sql/dd/types/routine.h" // dd::Routine
40#include "sql/dd/types/view.h"
41#include "sql/sql_time.h" // gmt_time_to_local_time
42
43namespace dd {
44class Open_dictionary_tables_ctx;
45class Parameter;
46class Parameter_collection;
47class Weak_object;
48class Object_table;
49
50///////////////////////////////////////////////////////////////////////////
51
52class Routine_impl : public Entity_object_impl, virtual public Routine {
53 public:
55
56 ~Routine_impl() override;
57
58 public:
59 const Object_table &object_table() const override;
60
61 bool validate() const override;
62
64
66
67 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
68
69 bool restore_attributes(const Raw_record &r) override;
70
71 bool store_attributes(Raw_record *r) override;
72
73 void debug_print(String_type &outb) const override;
74
75 public:
77
78 /////////////////////////////////////////////////////////////////////////
79 // schema.
80 /////////////////////////////////////////////////////////////////////////
81
82 Object_id schema_id() const override { return m_schema_id; }
83
85
86 /////////////////////////////////////////////////////////////////////////
87 // routine Partition type
88 /////////////////////////////////////////////////////////////////////////
89
90 enum_routine_type type() const override { return m_routine_type; }
91
92 virtual void set_type(enum_routine_type routine_type) {
93 m_routine_type = routine_type;
94 }
95
96 /////////////////////////////////////////////////////////////////////////
97 // definition/utf8.
98 /////////////////////////////////////////////////////////////////////////
99
100 const String_type &definition() const override { return m_definition; }
101
102 void set_definition(const String_type &definition) override {
104 }
105
106 const String_type &definition_utf8() const override {
107 return m_definition_utf8;
108 }
109
112 }
113
114 /////////////////////////////////////////////////////////////////////////
115 // parameter_str
116 /////////////////////////////////////////////////////////////////////////
117
118 const String_type &parameter_str() const override { return m_parameter_str; }
119
122 }
123
124 /////////////////////////////////////////////////////////////////////////
125 // is_deterministic.
126 /////////////////////////////////////////////////////////////////////////
127
128 bool is_deterministic() const override { return m_is_deterministic; }
129
130 void set_deterministic(bool deterministic) override {
131 m_is_deterministic = deterministic;
132 }
133
134 /////////////////////////////////////////////////////////////////////////
135 // sql data access.
136 /////////////////////////////////////////////////////////////////////////
137
139 return m_sql_data_access;
140 }
141
143 m_sql_data_access = sda;
144 }
145
146 /////////////////////////////////////////////////////////////////////////
147 // security_type.
148 /////////////////////////////////////////////////////////////////////////
149
151 return m_security_type;
152 }
153
156 }
157
158 /////////////////////////////////////////////////////////////////////////
159 // sql_mode
160 /////////////////////////////////////////////////////////////////////////
161
162 ulonglong sql_mode() const override { return m_sql_mode; }
163
164 void set_sql_mode(ulonglong sm) override { m_sql_mode = sm; }
165
166 /////////////////////////////////////////////////////////////////////////
167 // definer.
168 /////////////////////////////////////////////////////////////////////////
169
170 const String_type &definer_user() const override { return m_definer_user; }
171
172 const String_type &definer_host() const override { return m_definer_host; }
173
174 void set_definer(const String_type &username,
175 const String_type &hostname) override {
176 m_definer_user = username;
177 m_definer_host = hostname;
178 }
179
180 /////////////////////////////////////////////////////////////////////////
181 // collation.
182 /////////////////////////////////////////////////////////////////////////
183
186 }
187
190 }
191
194 }
195
198 }
199
202 }
203
206 }
207
208 /////////////////////////////////////////////////////////////////////////
209 // created.
210 /////////////////////////////////////////////////////////////////////////
211
212 ulonglong created(bool convert_time) const override {
213 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
214 }
215
217
218 /////////////////////////////////////////////////////////////////////////
219 // last altered.
220 /////////////////////////////////////////////////////////////////////////
221
222 ulonglong last_altered(bool convert_time) const override {
223 return convert_time ? gmt_time_to_local_time(m_last_altered)
225 }
226
229 }
230
231 /////////////////////////////////////////////////////////////////////////
232 // comment.
233 /////////////////////////////////////////////////////////////////////////
234
235 const String_type &comment() const override { return m_comment; }
236
237 void set_comment(const String_type &comment) override { m_comment = comment; }
238
239 /////////////////////////////////////////////////////////////////////////
240 // Parameter collection.
241 /////////////////////////////////////////////////////////////////////////
242
243 Parameter *add_parameter() override;
244
245 const Parameter_collection &parameters() const override {
246 return m_parameters;
247 }
248
249 // Fix "inherits ... via dominance" warnings
251 const Entity_object_impl *impl() const override {
253 }
254 Object_id id() const override { return Entity_object_impl::id(); }
255 bool is_persistent() const override {
257 }
258 const String_type &name() const override {
260 }
261 void set_name(const String_type &name) override {
263 }
264
265 private:
269
271
275
282
283 // Collections.
284
286
287 // References.
288
293
294 protected:
295 Routine_impl(const Routine_impl &src);
296};
297
298///////////////////////////////////////////////////////////////////////////
299
300} // namespace dd
301
302#endif // DD__ROUTINE_IMPL_INCLUDED
Definition: collection.h:44
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:49
const String_type & name() const override
Definition: entity_object_impl.h:60
Entity_object_impl * impl() override
Definition: entity_object_impl.h:68
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:57
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:72
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:76
Definition: parameter.h:45
Definition: raw_record.h:46
Definition: routine_impl.h:52
void set_definer(const String_type &username, const String_type &hostname) override
Definition: routine_impl.h:174
bool is_deterministic() const override
Definition: routine_impl.h:128
Object_id schema_collation_id() const override
Definition: routine_impl.h:200
const Object_table & object_table() const override
Definition: routine_impl.cc:244
ulonglong created(bool convert_time) const override
Definition: routine_impl.h:212
String_type m_definition
Definition: routine_impl.h:276
ulonglong m_sql_mode
Definition: routine_impl.h:272
void set_comment(const String_type &comment) override
Definition: routine_impl.h:237
void set_parameter_str(const String_type &parameter_str) override
Definition: routine_impl.h:120
String_type m_definer_user
Definition: routine_impl.h:279
void set_sql_mode(ulonglong sm) override
Definition: routine_impl.h:164
ulonglong sql_mode() const override
Definition: routine_impl.h:162
const String_type & definer_host() const override
Definition: routine_impl.h:172
enum_sql_data_access sql_data_access() const override
Definition: routine_impl.h:138
ulonglong m_last_altered
Definition: routine_impl.h:274
Parameter_collection m_parameters
Definition: routine_impl.h:285
void debug_print(String_type &outb) const override
Definition: routine_impl.cc:200
Object_id client_collation_id() const override
Definition: routine_impl.h:184
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: routine_impl.cc:86
void set_security_type(View::enum_security_type security_type) override
Definition: routine_impl.h:154
Object_id m_schema_id
Definition: routine_impl.h:289
View::enum_security_type security_type() const override
Definition: routine_impl.h:150
Object_id m_connection_collation_id
Definition: routine_impl.h:291
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: routine_impl.cc:94
const String_type & definer_user() const override
Definition: routine_impl.h:170
virtual void set_type(enum_routine_type routine_type)
Definition: routine_impl.h:92
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: routine_impl.cc:100
Object_id id() const override
The unique dictionary object id.
Definition: routine_impl.h:254
enum_sql_data_access m_sql_data_access
Definition: routine_impl.h:267
Object_id m_schema_collation_id
Definition: routine_impl.h:292
bool store_attributes(Raw_record *r) override
Definition: routine_impl.cc:165
String_type m_definer_host
Definition: routine_impl.h:280
String_type m_parameter_str
Definition: routine_impl.h:278
const Entity_object_impl * impl() const override
Definition: routine_impl.h:251
const String_type & parameter_str() const override
Definition: routine_impl.h:118
ulonglong last_altered(bool convert_time) const override
Definition: routine_impl.h:222
void set_schema_collation_id(Object_id schema_collation_id) override
Definition: routine_impl.h:204
View::enum_security_type m_security_type
Definition: routine_impl.h:268
void set_deterministic(bool deterministic) override
Definition: routine_impl.h:130
void set_definition(const String_type &definition) override
Definition: routine_impl.h:102
Object_id schema_id() const override
Definition: routine_impl.h:82
bool validate() const override
Definition: routine_impl.cc:74
~Routine_impl() override
void set_definition_utf8(const String_type &definition_utf8) override
Definition: routine_impl.h:110
bool m_is_deterministic
Definition: routine_impl.h:270
Routine_impl()
Definition: routine_impl.cc:56
Object_id connection_collation_id() const override
Definition: routine_impl.h:192
void set_client_collation_id(Object_id client_collation_id) override
Definition: routine_impl.h:188
const String_type & definition_utf8() const override
Definition: routine_impl.h:106
Object_id m_client_collation_id
Definition: routine_impl.h:290
Entity_object_impl * impl() override
Definition: routine_impl.h:250
enum_routine_type m_routine_type
Definition: routine_impl.h:266
void set_sql_data_access(enum_sql_data_access sda) override
Definition: routine_impl.h:142
void set_created(ulonglong created) override
Definition: routine_impl.h:216
const Parameter_collection & parameters() const override
Definition: routine_impl.h:245
enum_routine_type type() const override
Definition: routine_impl.h:90
Parameter * add_parameter() override
Definition: routine_impl.cc:236
void set_schema_id(Object_id schema_id) override
Definition: routine_impl.h:84
bool restore_attributes(const Raw_record &r) override
Definition: routine_impl.cc:108
ulonglong m_created
Definition: routine_impl.h:273
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: routine_impl.h:255
String_type m_comment
Definition: routine_impl.h:281
const String_type & definition() const override
Definition: routine_impl.h:100
void set_connection_collation_id(Object_id connection_collation_id) override
Definition: routine_impl.h:196
void set_last_altered(ulonglong last_altered) override
Definition: routine_impl.h:227
const String_type & comment() const override
Definition: routine_impl.h:235
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: routine_impl.cc:250
const String_type & name() const override
Definition: routine_impl.h:258
String_type m_definition_utf8
Definition: routine_impl.h:277
void set_name(const String_type &name) override
Definition: routine_impl.h:261
Abstract base class for functions and procedures.
Definition: routine.h:61
enum_sql_data_access
Definition: routine.h:90
enum_routine_type
Definition: routine.h:88
enum_security_type
Definition: view.h:58
ulonglong gmt_time_to_local_time(ulonglong gmt_time)
This function gets GMT time and adds value of time_zone to get the local time.
Definition: sql_time.cc:841
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
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
Interface for server time utilities.