MySQL 9.1.0
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 // external language.
148 /////////////////////////////////////////////////////////////////////////
149
150 const String_type &external_language() const override {
151 return m_external_language;
152 }
153
154 void set_external_language(const String_type &el) override {
156 }
157
158 /////////////////////////////////////////////////////////////////////////
159 // security_type.
160 /////////////////////////////////////////////////////////////////////////
161
163 return m_security_type;
164 }
165
168 }
169
170 /////////////////////////////////////////////////////////////////////////
171 // sql_mode
172 /////////////////////////////////////////////////////////////////////////
173
174 ulonglong sql_mode() const override { return m_sql_mode; }
175
176 void set_sql_mode(ulonglong sm) override { m_sql_mode = sm; }
177
178 /////////////////////////////////////////////////////////////////////////
179 // definer.
180 /////////////////////////////////////////////////////////////////////////
181
182 const String_type &definer_user() const override { return m_definer_user; }
183
184 const String_type &definer_host() const override { return m_definer_host; }
185
186 void set_definer(const String_type &username,
187 const String_type &hostname) override {
188 m_definer_user = username;
189 m_definer_host = hostname;
190 }
191
192 /////////////////////////////////////////////////////////////////////////
193 // collation.
194 /////////////////////////////////////////////////////////////////////////
195
198 }
199
202 }
203
206 }
207
210 }
211
214 }
215
218 }
219
220 /////////////////////////////////////////////////////////////////////////
221 // created.
222 /////////////////////////////////////////////////////////////////////////
223
224 ulonglong created(bool convert_time) const override {
225 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
226 }
227
229
230 /////////////////////////////////////////////////////////////////////////
231 // last altered.
232 /////////////////////////////////////////////////////////////////////////
233
234 ulonglong last_altered(bool convert_time) const override {
235 return convert_time ? gmt_time_to_local_time(m_last_altered)
237 }
238
241 }
242
243 /////////////////////////////////////////////////////////////////////////
244 // comment.
245 /////////////////////////////////////////////////////////////////////////
246
247 const String_type &comment() const override { return m_comment; }
248
249 void set_comment(const String_type &comment) override { m_comment = comment; }
250
251 /////////////////////////////////////////////////////////////////////////
252 // Parameter collection.
253 /////////////////////////////////////////////////////////////////////////
254
255 Parameter *add_parameter() override;
256
257 const Parameter_collection &parameters() const override {
258 return m_parameters;
259 }
260
261 // Fix "inherits ... via dominance" warnings
263 const Entity_object_impl *impl() const override {
265 }
266 Object_id id() const override { return Entity_object_impl::id(); }
267 bool is_persistent() const override {
269 }
270 const String_type &name() const override {
272 }
273 void set_name(const String_type &name) override {
275 }
276
277 private:
281
283
287
295
296 // Collections.
297
299
300 // References.
301
306
307 protected:
308 Routine_impl(const Routine_impl &src);
309};
310
311///////////////////////////////////////////////////////////////////////////
312
313} // namespace dd
314
315#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:186
bool is_deterministic() const override
Definition: routine_impl.h:128
Object_id schema_collation_id() const override
Definition: routine_impl.h:212
const Object_table & object_table() const override
Definition: routine_impl.cc:249
ulonglong created(bool convert_time) const override
Definition: routine_impl.h:224
String_type m_definition
Definition: routine_impl.h:288
ulonglong m_sql_mode
Definition: routine_impl.h:284
void set_external_language(const String_type &el) override
Definition: routine_impl.h:154
void set_comment(const String_type &comment) override
Definition: routine_impl.h:249
void set_parameter_str(const String_type &parameter_str) override
Definition: routine_impl.h:120
String_type m_definer_user
Definition: routine_impl.h:291
void set_sql_mode(ulonglong sm) override
Definition: routine_impl.h:176
ulonglong sql_mode() const override
Definition: routine_impl.h:174
const String_type & definer_host() const override
Definition: routine_impl.h:184
enum_sql_data_access sql_data_access() const override
Definition: routine_impl.h:138
ulonglong m_last_altered
Definition: routine_impl.h:286
Parameter_collection m_parameters
Definition: routine_impl.h:298
void debug_print(String_type &outb) const override
Definition: routine_impl.cc:204
Object_id client_collation_id() const override
Definition: routine_impl.h:196
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: routine_impl.cc:88
void set_security_type(View::enum_security_type security_type) override
Definition: routine_impl.h:166
Object_id m_schema_id
Definition: routine_impl.h:302
View::enum_security_type security_type() const override
Definition: routine_impl.h:162
Object_id m_connection_collation_id
Definition: routine_impl.h:304
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: routine_impl.cc:96
const String_type & definer_user() const override
Definition: routine_impl.h:182
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:102
Object_id id() const override
The unique dictionary object id.
Definition: routine_impl.h:266
enum_sql_data_access m_sql_data_access
Definition: routine_impl.h:279
Object_id m_schema_collation_id
Definition: routine_impl.h:305
bool store_attributes(Raw_record *r) override
Definition: routine_impl.cc:168
String_type m_definer_host
Definition: routine_impl.h:292
String_type m_parameter_str
Definition: routine_impl.h:290
const Entity_object_impl * impl() const override
Definition: routine_impl.h:263
const String_type & parameter_str() const override
Definition: routine_impl.h:118
ulonglong last_altered(bool convert_time) const override
Definition: routine_impl.h:234
void set_schema_collation_id(Object_id schema_collation_id) override
Definition: routine_impl.h:216
View::enum_security_type m_security_type
Definition: routine_impl.h:280
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:76
~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:282
Routine_impl()
Definition: routine_impl.cc:58
Object_id connection_collation_id() const override
Definition: routine_impl.h:204
void set_client_collation_id(Object_id client_collation_id) override
Definition: routine_impl.h:200
const String_type & definition_utf8() const override
Definition: routine_impl.h:106
Object_id m_client_collation_id
Definition: routine_impl.h:303
Entity_object_impl * impl() override
Definition: routine_impl.h:262
enum_routine_type m_routine_type
Definition: routine_impl.h:278
const String_type & external_language() const override
Definition: routine_impl.h:150
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:228
const Parameter_collection & parameters() const override
Definition: routine_impl.h:257
enum_routine_type type() const override
Definition: routine_impl.h:90
Parameter * add_parameter() override
Definition: routine_impl.cc:241
String_type m_external_language
Definition: routine_impl.h:294
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:110
ulonglong m_created
Definition: routine_impl.h:285
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: routine_impl.h:267
String_type m_comment
Definition: routine_impl.h:293
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:208
void set_last_altered(ulonglong last_altered) override
Definition: routine_impl.h:239
const String_type & comment() const override
Definition: routine_impl.h:247
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: routine_impl.cc:255
const String_type & name() const override
Definition: routine_impl.h:270
String_type m_definition_utf8
Definition: routine_impl.h:289
void set_name(const String_type &name) override
Definition: routine_impl.h:273
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:62
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:868
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.