MySQL 8.0.37
Source Code Documentation
routine.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_INCLUDED
25#define DD__ROUTINE_INCLUDED
26
27#include "my_inttypes.h"
28#include "sql/dd/impl/raw/object_keys.h" // IWYU pragma: keep
29#include "sql/dd/types/entity_object.h" // dd::Entity_object
30#include "sql/dd/types/view.h" // dd::Column::enum_security_type
31
32struct MDL_key;
33struct CHARSET_INFO;
34
35namespace dd {
36
37///////////////////////////////////////////////////////////////////////////
38
39class Routine_impl;
40class Primary_id_key;
41class Void_key;
42class Parameter;
43class Properties;
44class Routine_name_key;
45
46namespace tables {
47class Routines;
48}
49
50///////////////////////////////////////////////////////////////////////////
51
52/**
53 Abstract base class for functions and procedures.
54
55 @note This class may be inherited along different paths
56 for some subclasses due to the diamond shaped
57 inheritance hierarchy; thus, direct subclasses
58 must inherit this class virtually.
59*/
60
61class Routine : virtual public Entity_object {
62 public:
70
71 // We need a set of functions to update a preallocated key.
72 virtual bool update_id_key(Id_key *key) const {
73 return update_id_key(key, id());
74 }
75
76 static bool update_id_key(Id_key *key, Object_id id);
77
78 virtual bool update_name_key(Name_key *key) const {
80 }
81
83 const String_type &name) const = 0;
84
85 virtual bool update_aux_key(Aux_key *) const { return true; }
86
87 public:
89
95 };
96
97 public:
98 ~Routine() override = default;
99
100 public:
101 /////////////////////////////////////////////////////////////////////////
102 // schema.
103 /////////////////////////////////////////////////////////////////////////
104
105 virtual Object_id schema_id() const = 0;
107
108 /////////////////////////////////////////////////////////////////////////
109 // routine type.
110 /////////////////////////////////////////////////////////////////////////
111
112 virtual enum_routine_type type() const = 0;
113
114 /////////////////////////////////////////////////////////////////////////
115 // definition/utf8.
116 /////////////////////////////////////////////////////////////////////////
117
118 virtual const String_type &definition() const = 0;
119 virtual void set_definition(const String_type &definition) = 0;
120
121 virtual const String_type &definition_utf8() const = 0;
123
124 /////////////////////////////////////////////////////////////////////////
125 // parameter_str
126 /////////////////////////////////////////////////////////////////////////
127
128 virtual const String_type &parameter_str() const = 0;
130
131 /////////////////////////////////////////////////////////////////////////
132 // is_deterministic.
133 /////////////////////////////////////////////////////////////////////////
134
135 virtual bool is_deterministic() const = 0;
136 virtual void set_deterministic(bool deterministic) = 0;
137
138 /////////////////////////////////////////////////////////////////////////
139 // sql data access.
140 /////////////////////////////////////////////////////////////////////////
141
144
145 /////////////////////////////////////////////////////////////////////////
146 // security type.
147 /////////////////////////////////////////////////////////////////////////
148
151
152 /////////////////////////////////////////////////////////////////////////
153 // sql_mode
154 /////////////////////////////////////////////////////////////////////////
155
156 virtual ulonglong sql_mode() const = 0;
157 virtual void set_sql_mode(ulonglong sm) = 0;
158
159 /////////////////////////////////////////////////////////////////////////
160 // definer.
161 /////////////////////////////////////////////////////////////////////////
162
163 virtual const String_type &definer_user() const = 0;
164 virtual const String_type &definer_host() const = 0;
165 virtual void set_definer(const String_type &username,
166 const String_type &hostname) = 0;
167
168 /////////////////////////////////////////////////////////////////////////
169 // collations.
170 /////////////////////////////////////////////////////////////////////////
171
172 virtual Object_id client_collation_id() const = 0;
174
178
179 virtual Object_id schema_collation_id() const = 0;
181
182 /////////////////////////////////////////////////////////////////////////
183 // created.
184 /////////////////////////////////////////////////////////////////////////
185
186 virtual ulonglong created(bool convert_time) const = 0;
187 virtual void set_created(ulonglong created) = 0;
188
189 /////////////////////////////////////////////////////////////////////////
190 // last altered.
191 /////////////////////////////////////////////////////////////////////////
192
193 virtual ulonglong last_altered(bool convert_time) const = 0;
195
196 /////////////////////////////////////////////////////////////////////////
197 // comment.
198 /////////////////////////////////////////////////////////////////////////
199
200 virtual const String_type &comment() const = 0;
201 virtual void set_comment(const String_type &comment) = 0;
202
203 /////////////////////////////////////////////////////////////////////////
204 // parameter collection.
205 /////////////////////////////////////////////////////////////////////////
206
207 virtual Parameter *add_parameter() = 0;
208
209 virtual const Parameter_collection &parameters() const = 0;
210
211 /**
212 Allocate a new object graph and invoke the copy constructor for
213 each object. Only used in unit testing.
214
215 @return pointer to dynamically allocated copy
216 */
217 virtual Routine *clone() const = 0;
218
219 /**
220 Allocate a new object which can serve as a placeholder for the original
221 object in the Dictionary_client's dropped registry. Such object has the
222 same keys as the original but has no other info and as result occupies
223 less memory.
224 */
226
228 const String_type &schema_name,
229 const String_type &name, MDL_key *key);
230 static const CHARSET_INFO *name_collation();
231};
232
233///////////////////////////////////////////////////////////////////////////
234
235} // namespace dd
236
237#endif // DD__ROUTINE_INCLUDED
Definition: collection.h:44
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:48
virtual const String_type & name() const =0
Definition: parameter.h:45
Definition: object_keys.h:77
Definition: routine_impl.h:52
Definition: object_keys.h:435
Abstract base class for functions and procedures.
Definition: routine.h:61
virtual void set_last_altered(ulonglong last_altered)=0
virtual bool update_aux_key(Aux_key *) const
Definition: routine.h:85
virtual Parameter * add_parameter()=0
virtual void set_parameter_str(const String_type &parameter_str)=0
virtual void set_comment(const String_type &comment)=0
virtual void set_security_type(View::enum_security_type st)=0
virtual void set_sql_mode(ulonglong sm)=0
virtual bool update_routine_name_key(Name_key *key, Object_id schema_id, const String_type &name) const =0
virtual Object_id schema_collation_id() const =0
Primary_id_key Id_key
Definition: routine.h:66
virtual Object_id schema_id() const =0
virtual void set_schema_collation_id(Object_id schema_collation_id)=0
virtual enum_routine_type type() const =0
virtual const String_type & parameter_str() const =0
virtual View::enum_security_type security_type() const =0
virtual enum_sql_data_access sql_data_access() const =0
virtual const String_type & comment() const =0
virtual ulonglong last_altered(bool convert_time) const =0
virtual void set_sql_data_access(enum_sql_data_access sda)=0
Void_key Aux_key
Definition: routine.h:68
static const CHARSET_INFO * name_collation()
Definition: routine_impl.cc:313
virtual Object_id connection_collation_id() const =0
virtual void set_definer(const String_type &username, const String_type &hostname)=0
virtual const String_type & definition_utf8() const =0
Routine_name_key Name_key
Definition: routine.h:67
virtual void set_client_collation_id(Object_id client_collation_id)=0
virtual void set_deterministic(bool deterministic)=0
virtual ulonglong sql_mode() const =0
virtual bool update_id_key(Id_key *key) const
Definition: routine.h:72
enum_sql_data_access
Definition: routine.h:90
@ SDA_READS_SQL_DATA
Definition: routine.h:93
@ SDA_NO_SQL
Definition: routine.h:92
@ SDA_MODIFIES_SQL_DATA
Definition: routine.h:94
@ SDA_CONTAINS_SQL
Definition: routine.h:91
virtual bool is_deterministic() const =0
virtual void set_schema_id(Object_id schema_id)=0
virtual void set_created(ulonglong created)=0
Collection< Parameter * > Parameter_collection
Definition: routine.h:69
enum_routine_type
Definition: routine.h:88
@ RT_PROCEDURE
Definition: routine.h:88
@ RT_FUNCTION
Definition: routine.h:88
virtual Object_id client_collation_id() const =0
~Routine() override=default
tables::Routines DD_table
Definition: routine.h:65
virtual ulonglong created(bool convert_time) const =0
virtual bool update_name_key(Name_key *key) const
Definition: routine.h:78
Routine_impl Impl
Definition: routine.h:63
virtual const Parameter_collection & parameters() const =0
virtual void set_definition(const String_type &definition)=0
virtual Routine * clone() const =0
Allocate a new object graph and invoke the copy constructor for each object.
static void create_mdl_key(enum_routine_type type, const String_type &schema_name, const String_type &name, MDL_key *key)
Definition: routine_impl.cc:284
virtual void set_definition_utf8(const String_type &definition_utf8)=0
virtual Routine * clone_dropped_object_placeholder() const =0
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
Routine Cache_partition
Definition: routine.h:64
virtual void set_connection_collation_id(Object_id connection_collation_id)=0
virtual const String_type & definition() const =0
virtual const String_type & definer_user() const =0
virtual const String_type & definer_host() const =0
enum_security_type
Definition: view.h:58
Definition: object_keys.h:54
Definition: routines.h:43
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
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: m_ctype.h:385
Metadata lock object key.
Definition: mdl.h:365