MySQL  8.0.19
Source Code Documentation
routine_impl.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
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 
42 namespace dd {
43 class Open_dictionary_tables_ctx;
44 class Parameter;
45 class Parameter_collection;
46 class Weak_object;
47 class Object_table;
48 
49 ///////////////////////////////////////////////////////////////////////////
50 
51 class Routine_impl : public Entity_object_impl, virtual public Routine {
52  public:
53  Routine_impl();
54 
55  virtual ~Routine_impl();
56 
57  public:
58  virtual const Object_table &object_table() const;
59 
60  virtual bool validate() const;
61 
63 
64  virtual bool store_children(Open_dictionary_tables_ctx *otx);
65 
66  virtual bool drop_children(Open_dictionary_tables_ctx *otx) const;
67 
68  virtual bool restore_attributes(const Raw_record &r);
69 
70  virtual bool store_attributes(Raw_record *r);
71 
72  virtual void debug_print(String_type &outb) const;
73 
74  public:
76 
77  /////////////////////////////////////////////////////////////////////////
78  // schema.
79  /////////////////////////////////////////////////////////////////////////
80 
81  virtual Object_id schema_id() const { return m_schema_id; }
82 
84 
85  /////////////////////////////////////////////////////////////////////////
86  // routine Partition type
87  /////////////////////////////////////////////////////////////////////////
88 
89  virtual enum_routine_type type() const { 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  virtual const String_type &definition() const { return m_definition; }
100 
101  virtual void set_definition(const String_type &definition) {
103  }
104 
105  virtual const String_type &definition_utf8() const {
106  return m_definition_utf8;
107  }
108 
111  }
112 
113  /////////////////////////////////////////////////////////////////////////
114  // parameter_str
115  /////////////////////////////////////////////////////////////////////////
116 
117  virtual const String_type &parameter_str() const { return m_parameter_str; }
118 
121  }
122 
123  /////////////////////////////////////////////////////////////////////////
124  // is_deterministic.
125  /////////////////////////////////////////////////////////////////////////
126 
127  virtual bool is_deterministic() const { return m_is_deterministic; }
128 
129  virtual void set_deterministic(bool deterministic) {
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  virtual ulonglong sql_mode() const { return m_sql_mode; }
162 
163  virtual void set_sql_mode(ulonglong sm) { m_sql_mode = sm; }
164 
165  /////////////////////////////////////////////////////////////////////////
166  // definer.
167  /////////////////////////////////////////////////////////////////////////
168 
169  virtual const String_type &definer_user() const { return m_definer_user; }
170 
171  virtual const String_type &definer_host() const { return m_definer_host; }
172 
173  virtual void set_definer(const String_type &username,
174  const String_type &hostname) {
175  m_definer_user = username;
176  m_definer_host = hostname;
177  }
178 
179  /////////////////////////////////////////////////////////////////////////
180  // collation.
181  /////////////////////////////////////////////////////////////////////////
182 
183  virtual Object_id client_collation_id() const {
184  return m_client_collation_id;
185  }
186 
189  }
190 
193  }
194 
197  }
198 
199  virtual Object_id schema_collation_id() const {
200  return m_schema_collation_id;
201  }
202 
205  }
206 
207  /////////////////////////////////////////////////////////////////////////
208  // created.
209  /////////////////////////////////////////////////////////////////////////
210 
211  virtual ulonglong created(bool convert_time) const {
212  return convert_time ? gmt_time_to_local_time(m_created) : m_created;
213  }
214 
216 
217  /////////////////////////////////////////////////////////////////////////
218  // last altered.
219  /////////////////////////////////////////////////////////////////////////
220 
221  virtual ulonglong last_altered(bool convert_time) const {
222  return convert_time ? gmt_time_to_local_time(m_last_altered)
223  : m_last_altered;
224  }
225 
228  }
229 
230  /////////////////////////////////////////////////////////////////////////
231  // comment.
232  /////////////////////////////////////////////////////////////////////////
233 
234  virtual const String_type &comment() const { return m_comment; }
235 
236  virtual void set_comment(const String_type &comment) { m_comment = comment; }
237 
238  /////////////////////////////////////////////////////////////////////////
239  // Parameter collection.
240  /////////////////////////////////////////////////////////////////////////
241 
242  virtual Parameter *add_parameter();
243 
244  virtual const Parameter_collection &parameters() const {
245  return m_parameters;
246  }
247 
248  // Fix "inherits ... via dominance" warnings
250  virtual const Entity_object_impl *impl() const {
251  return Entity_object_impl::impl();
252  }
253  virtual Object_id id() const { return Entity_object_impl::id(); }
254  virtual bool is_persistent() const {
256  }
257  virtual const String_type &name() const { return Entity_object_impl::name(); }
258  virtual void set_name(const String_type &name) {
260  }
261 
262  private:
266 
268 
272 
279 
280  // Collections.
281 
283 
284  // References.
285 
290 
291  protected:
292  Routine_impl(const Routine_impl &src);
293 };
294 
295 ///////////////////////////////////////////////////////////////////////////
296 
297 } // namespace dd
298 
299 #endif // DD__ROUTINE_IMPL_INCLUDED
dd::Routine_impl::schema_collation_id
virtual Object_id schema_collation_id() const
Definition: routine_impl.h:199
dd::Routine_impl::connection_collation_id
virtual Object_id connection_collation_id() const
Definition: routine_impl.h:191
dd::Routine_impl::m_client_collation_id
Object_id m_client_collation_id
Definition: routine_impl.h:287
dd::Routine_impl::set_name
virtual void set_name(const String_type &name)
Definition: routine_impl.h:258
dd::Routine_impl::definition_utf8
virtual const String_type & definition_utf8() const
Definition: routine_impl.h:105
dd::Routine_impl::definer_user
virtual const String_type & definer_user() const
Definition: routine_impl.h:169
dd::Routine_impl::m_is_deterministic
bool m_is_deterministic
Definition: routine_impl.h:267
dd::String_type
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
dd::Entity_object_impl::name
virtual const String_type & name() const override
Definition: entity_object_impl.h:61
dd::Routine_impl::set_deterministic
virtual void set_deterministic(bool deterministic)
Definition: routine_impl.h:129
dd::Routine_impl::debug_print
virtual void debug_print(String_type &outb) const
Definition: routine_impl.cc:199
dd::Routine_impl::m_parameter_str
String_type m_parameter_str
Definition: routine_impl.h:275
dd::Routine_impl::set_parameter_str
virtual void set_parameter_str(const String_type &parameter_str)
Definition: routine_impl.h:119
dd::Routine_impl::Routine_impl
Routine_impl()
Definition: routine_impl.cc:55
dd::Routine_impl::m_schema_id
Object_id m_schema_id
Definition: routine_impl.h:286
dd::Routine_impl::m_definer_user
String_type m_definer_user
Definition: routine_impl.h:276
dd::Routine_impl::set_created
virtual void set_created(ulonglong created)
Definition: routine_impl.h:215
dd::Routine_impl::set_connection_collation_id
virtual void set_connection_collation_id(Object_id connection_collation_id)
Definition: routine_impl.h:195
dd::Routine_impl::definition
virtual const String_type & definition() const
Definition: routine_impl.h:99
dd::Routine_impl::set_schema_id
virtual void set_schema_id(Object_id schema_id)
Definition: routine_impl.h:83
dd::Routine_impl::store_children
virtual bool store_children(Open_dictionary_tables_ctx *otx)
Definition: routine_impl.cc:93
my_dbug.h
dd::Parameter
Definition: parameter.h:44
dd::Routine_impl::register_tables
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: routine_impl.cc:249
parameter.h
dd::Routine_impl::set_sql_mode
virtual void set_sql_mode(ulonglong sm)
Definition: routine_impl.h:163
raw_record.h
dd::Routine_impl::set_definition_utf8
virtual void set_definition_utf8(const String_type &definition_utf8)
Definition: routine_impl.h:109
dd::Routine_impl::set_client_collation_id
virtual void set_client_collation_id(Object_id client_collation_id)
Definition: routine_impl.h:187
dd::Entity_object_impl::set_name
virtual void set_name(const String_type &name) override
Definition: entity_object_impl.h:63
dd::Routine_impl::impl
virtual const Entity_object_impl * impl() const
Definition: routine_impl.h:250
dd::Routine_impl::schema_id
virtual Object_id schema_id() const
Definition: routine_impl.h:81
dd::Routine_impl::name
virtual const String_type & name() const
Definition: routine_impl.h:257
dd::Routine_impl::m_created
ulonglong m_created
Definition: routine_impl.h:270
dd::Routine_impl::type
virtual enum_routine_type type() const
Definition: routine_impl.h:89
dd::View::enum_security_type
enum_security_type
Definition: view.h:57
dd::Routine_impl::m_sql_data_access
enum_sql_data_access m_sql_data_access
Definition: routine_impl.h:264
dd
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
dd::Routine_impl::m_parameters
Parameter_collection m_parameters
Definition: routine_impl.h:282
object_id.h
dd::Routine_impl::drop_children
virtual bool drop_children(Open_dictionary_tables_ctx *otx) const
Definition: routine_impl.cc:99
dd::Open_dictionary_tables_ctx
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:75
dd::Routine_impl::parameters
virtual const Parameter_collection & parameters() const
Definition: routine_impl.h:244
dd::Routine_impl::set_definition
virtual void set_definition(const String_type &definition)
Definition: routine_impl.h:101
dd::Routine_impl::object_table
virtual const Object_table & object_table() const
Definition: routine_impl.cc:243
dd::Routine_impl::m_definition
String_type m_definition
Definition: routine_impl.h:273
dd::Routine_impl
Definition: routine_impl.h:51
dd::Routine_impl::m_connection_collation_id
Object_id m_connection_collation_id
Definition: routine_impl.h:288
dd::Raw_record
Definition: raw_record.h:53
my_inttypes.h
dd::Routine_impl::validate
virtual bool validate() const
Definition: routine_impl.cc:73
dd::Entity_object_impl::id
virtual Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:48
dd::Routine_impl::restore_children
virtual bool restore_children(Open_dictionary_tables_ctx *otx)
Definition: routine_impl.cc:85
dd::Routine_impl::is_deterministic
virtual bool is_deterministic() const
Definition: routine_impl.h:127
dd::Routine_impl::m_security_type
View::enum_security_type m_security_type
Definition: routine_impl.h:265
r
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
dd::Routine_impl::~Routine_impl
virtual ~Routine_impl()
Definition: routine_impl.cc:69
dd::Routine_impl::set_type
virtual void set_type(enum_routine_type routine_type)
Definition: routine_impl.h:91
routine.h
dd::Routine_impl::m_routine_type
enum_routine_type m_routine_type
Definition: routine_impl.h:263
dd::Routine_impl::m_definer_host
String_type m_definer_host
Definition: routine_impl.h:277
dd::Routine::enum_routine_type
enum_routine_type
Definition: routine.h:87
string_type.h
dd::Routine_impl::is_persistent
virtual bool is_persistent() const
Is dictionary object persistent in dictionary tables ?
Definition: routine_impl.h:254
dd::Routine_impl::m_comment
String_type m_comment
Definition: routine_impl.h:278
dd::Routine_impl::security_type
virtual View::enum_security_type security_type() const
Definition: routine_impl.h:149
dd::Routine::Parameter_collection
Collection< Parameter * > Parameter_collection
Definition: routine.h:68
gmt_time_to_local_time
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:794
weak_object_impl.h
sql_time.h
dd::Routine_impl::comment
virtual const String_type & comment() const
Definition: routine_impl.h:234
dd::Routine_impl::restore_attributes
virtual bool restore_attributes(const Raw_record &r)
Definition: routine_impl.cc:107
entity_object_impl.h
dd::Entity_object_impl::is_persistent
virtual bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:56
dd::Routine_impl::set_security_type
virtual void set_security_type(View::enum_security_type security_type)
Definition: routine_impl.h:153
dd::Object_id
unsigned long long Object_id
Definition: object_id.h:30
dd::Routine_impl::set_definer
virtual void set_definer(const String_type &username, const String_type &hostname)
Definition: routine_impl.h:173
dd::Routine_impl::m_definition_utf8
String_type m_definition_utf8
Definition: routine_impl.h:274
dd::Routine_impl::parameter_str
virtual const String_type & parameter_str() const
Definition: routine_impl.h:117
dd::Routine_impl::m_last_altered
ulonglong m_last_altered
Definition: routine_impl.h:271
view.h
dd::Routine_impl::m_sql_mode
ulonglong m_sql_mode
Definition: routine_impl.h:269
dd::Routine_impl::created
virtual ulonglong created(bool convert_time) const
Definition: routine_impl.h:211
dd::Routine_impl::definer_host
virtual const String_type & definer_host() const
Definition: routine_impl.h:171
dd::Routine::enum_sql_data_access
enum_sql_data_access
Definition: routine.h:89
dd::Routine_impl::impl
virtual Entity_object_impl * impl()
Definition: routine_impl.h:249
dd::Entity_object_impl::impl
virtual Entity_object_impl * impl() override
Definition: entity_object_impl.h:71
dd::Routine
Abstract base class for functions and procedures.
Definition: routine.h:60
dd::Object_table
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:71
dd::Routine_impl::sql_mode
virtual ulonglong sql_mode() const
Definition: routine_impl.h:161
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
dd::Routine_impl::id
virtual Object_id id() const
The unique dictionary object id.
Definition: routine_impl.h:253
dd::Entity_object_impl
Definition: entity_object_impl.h:42
dd::Routine_impl::add_parameter
virtual Parameter * add_parameter()
Definition: routine_impl.cc:235
dd::Routine_impl::set_sql_data_access
virtual void set_sql_data_access(enum_sql_data_access sda)
Definition: routine_impl.h:141
dd::Routine_impl::set_last_altered
virtual void set_last_altered(ulonglong last_altered)
Definition: routine_impl.h:226
dd::Routine_impl::last_altered
virtual ulonglong last_altered(bool convert_time) const
Definition: routine_impl.h:221
dd::Routine_impl::store_attributes
virtual bool store_attributes(Raw_record *r)
Definition: routine_impl.cc:164
dd::Routine_impl::sql_data_access
virtual enum_sql_data_access sql_data_access() const
Definition: routine_impl.h:137
dd::Routine_impl::set_comment
virtual void set_comment(const String_type &comment)
Definition: routine_impl.h:236
dd::Routine_impl::m_schema_collation_id
Object_id m_schema_collation_id
Definition: routine_impl.h:289
dd::Routine_impl::client_collation_id
virtual Object_id client_collation_id() const
Definition: routine_impl.h:183
dd::Routine_impl::set_schema_collation_id
virtual void set_schema_collation_id(Object_id schema_collation_id)
Definition: routine_impl.h:203