MySQL 8.0.30
Source Code Documentation
routine_impl.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__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 // security_type.
147 /////////////////////////////////////////////////////////////////////////
148
150 return m_security_type;
151 }
152
155 }
156
157 /////////////////////////////////////////////////////////////////////////
158 // sql_mode
159 /////////////////////////////////////////////////////////////////////////
160
161 ulonglong sql_mode() const override { return m_sql_mode; }
162
163 void set_sql_mode(ulonglong sm) override { m_sql_mode = sm; }
164
165 /////////////////////////////////////////////////////////////////////////
166 // definer.
167 /////////////////////////////////////////////////////////////////////////
168
169 const String_type &definer_user() const override { return m_definer_user; }
170
171 const String_type &definer_host() const override { return m_definer_host; }
172
173 void set_definer(const String_type &username,
174 const String_type &hostname) override {
175 m_definer_user = username;
176 m_definer_host = hostname;
177 }
178
179 /////////////////////////////////////////////////////////////////////////
180 // collation.
181 /////////////////////////////////////////////////////////////////////////
182
185 }
186
189 }
190
193 }
194
197 }
198
201 }
202
205 }
206
207 /////////////////////////////////////////////////////////////////////////
208 // created.
209 /////////////////////////////////////////////////////////////////////////
210
211 ulonglong created(bool convert_time) const override {
212 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
213 }
214
216
217 /////////////////////////////////////////////////////////////////////////
218 // last altered.
219 /////////////////////////////////////////////////////////////////////////
220
221 ulonglong last_altered(bool convert_time) const override {
222 return convert_time ? gmt_time_to_local_time(m_last_altered)
224 }
225
228 }
229
230 /////////////////////////////////////////////////////////////////////////
231 // comment.
232 /////////////////////////////////////////////////////////////////////////
233
234 const String_type &comment() const override { return m_comment; }
235
236 void set_comment(const String_type &comment) override { m_comment = comment; }
237
238 /////////////////////////////////////////////////////////////////////////
239 // Parameter collection.
240 /////////////////////////////////////////////////////////////////////////
241
242 Parameter *add_parameter() override;
243
244 const Parameter_collection &parameters() const override {
245 return m_parameters;
246 }
247
248 // Fix "inherits ... via dominance" warnings
250 const Entity_object_impl *impl() const override {
252 }
253 Object_id id() const override { return Entity_object_impl::id(); }
254 bool is_persistent() const override {
256 }
257 const String_type &name() const override {
259 }
260 void set_name(const String_type &name) override {
262 }
263
264 private:
268
270
274
281
282 // Collections.
283
285
286 // References.
287
292
293 protected:
294 Routine_impl(const Routine_impl &src);
295};
296
297///////////////////////////////////////////////////////////////////////////
298
299} // namespace dd
300
301#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:173
bool is_deterministic() const override
Definition: routine_impl.h:127
Object_id schema_collation_id() const override
Definition: routine_impl.h:199
const Object_table & object_table() const override
Definition: routine_impl.cc:243
ulonglong created(bool convert_time) const override
Definition: routine_impl.h:211
String_type m_definition
Definition: routine_impl.h:275
ulonglong m_sql_mode
Definition: routine_impl.h:271
void set_comment(const String_type &comment) override
Definition: routine_impl.h:236
void set_parameter_str(const String_type &parameter_str) override
Definition: routine_impl.h:119
String_type m_definer_user
Definition: routine_impl.h:278
void set_sql_mode(ulonglong sm) override
Definition: routine_impl.h:163
ulonglong sql_mode() const override
Definition: routine_impl.h:161
const String_type & definer_host() const override
Definition: routine_impl.h:171
enum_sql_data_access sql_data_access() const override
Definition: routine_impl.h:137
ulonglong m_last_altered
Definition: routine_impl.h:273
Parameter_collection m_parameters
Definition: routine_impl.h:284
void debug_print(String_type &outb) const override
Definition: routine_impl.cc:199
Object_id client_collation_id() const override
Definition: routine_impl.h:183
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: routine_impl.cc:85
void set_security_type(View::enum_security_type security_type) override
Definition: routine_impl.h:153
Object_id m_schema_id
Definition: routine_impl.h:288
View::enum_security_type security_type() const override
Definition: routine_impl.h:149
Object_id m_connection_collation_id
Definition: routine_impl.h:290
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: routine_impl.cc:93
const String_type & definer_user() const override
Definition: routine_impl.h:169
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:99
Object_id id() const override
The unique dictionary object id.
Definition: routine_impl.h:253
enum_sql_data_access m_sql_data_access
Definition: routine_impl.h:266
Object_id m_schema_collation_id
Definition: routine_impl.h:291
bool store_attributes(Raw_record *r) override
Definition: routine_impl.cc:164
String_type m_definer_host
Definition: routine_impl.h:279
String_type m_parameter_str
Definition: routine_impl.h:277
const Entity_object_impl * impl() const override
Definition: routine_impl.h:250
const String_type & parameter_str() const override
Definition: routine_impl.h:117
ulonglong last_altered(bool convert_time) const override
Definition: routine_impl.h:221
void set_schema_collation_id(Object_id schema_collation_id) override
Definition: routine_impl.h:203
View::enum_security_type m_security_type
Definition: routine_impl.h:267
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:73
~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:269
Routine_impl()
Definition: routine_impl.cc:55
Object_id connection_collation_id() const override
Definition: routine_impl.h:191
void set_client_collation_id(Object_id client_collation_id) override
Definition: routine_impl.h:187
const String_type & definition_utf8() const override
Definition: routine_impl.h:105
Object_id m_client_collation_id
Definition: routine_impl.h:289
Entity_object_impl * impl() override
Definition: routine_impl.h:249
enum_routine_type m_routine_type
Definition: routine_impl.h:265
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:215
const Parameter_collection & parameters() const override
Definition: routine_impl.h:244
enum_routine_type type() const override
Definition: routine_impl.h:89
Parameter * add_parameter() override
Definition: routine_impl.cc:235
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:107
ulonglong m_created
Definition: routine_impl.h:272
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: routine_impl.h:254
String_type m_comment
Definition: routine_impl.h:280
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:195
void set_last_altered(ulonglong last_altered) override
Definition: routine_impl.h:226
const String_type & comment() const override
Definition: routine_impl.h:234
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: routine_impl.cc:249
const String_type & name() const override
Definition: routine_impl.h:257
String_type m_definition_utf8
Definition: routine_impl.h:276
void set_name(const String_type &name) override
Definition: routine_impl.h:260
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:840
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.