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