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