MySQL 8.0.39
Source Code Documentation
schema_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 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__SCHEMA_IMPL_INCLUDED
25#define DD__SCHEMA_IMPL_INCLUDED
26
27#include <stdio.h>
28#include <new>
29#include <string>
30
31#include "my_inttypes.h"
32#include "sql/dd/impl/properties_impl.h" // Properties_impl
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/sdi_fwd.h"
37#include "sql/dd/string_type.h"
38#include "sql/dd/types/entity_object_table.h" // dd::Entity_object_table
39#include "sql/dd/types/schema.h" // dd::Schema
40#include "sql/sql_time.h" // gmt_time_to_local_time
41
42class THD;
43
44namespace dd {
45
46///////////////////////////////////////////////////////////////////////////
47
48class Event;
49class Function;
50class Object_table;
51class Open_dictionary_tables_ctx;
52class Procedure;
53class Raw_record;
54class Sdi_rcontext;
55class Sdi_wcontext;
56class Table;
57class View;
58class Weak_object;
59class Object_table;
60
61///////////////////////////////////////////////////////////////////////////
62
63class Schema_impl : public Entity_object_impl, public Schema {
64 public:
66
67 public:
68 const Object_table &object_table() const override;
69
70 bool validate() const override;
71
72 bool store_attributes(Raw_record *r) override;
73
74 bool restore_attributes(const Raw_record &r) override;
75
76 public:
78
79 /////////////////////////////////////////////////////////////////////////
80 // Default collation.
81 /////////////////////////////////////////////////////////////////////////
82
85 }
86
89 }
90
91 /////////////////////////////////////////////////////////////////////////
92 // Default encryption.
93 /////////////////////////////////////////////////////////////////////////
94
95 bool default_encryption() const override {
97 }
98
102 }
103
104 /////////////////////////////////////////////////////////////////////////
105 // Read only.
106 /////////////////////////////////////////////////////////////////////////
107 bool read_only() const override;
108 void set_read_only(bool state) override;
109
110 /////////////////////////////////////////////////////////////////////////
111 // created
112 /////////////////////////////////////////////////////////////////////////
113
114 ulonglong created(bool convert_time) const override {
115 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
116 }
117
119
120 /////////////////////////////////////////////////////////////////////////
121 // last_altered
122 /////////////////////////////////////////////////////////////////////////
123
124 ulonglong last_altered(bool convert_time) const override {
125 return convert_time ? gmt_time_to_local_time(m_last_altered)
127 }
128
131 }
132
133 /////////////////////////////////////////////////////////////////////////
134 // se_private_data.
135 /////////////////////////////////////////////////////////////////////////
136
137 const Properties &se_private_data() const override {
138 return m_se_private_data;
139 }
140
142
143 bool set_se_private_data(const String_type &se_private_data_raw) override {
144 return m_se_private_data.insert_values(se_private_data_raw);
145 }
146
149 }
150
151 /////////////////////////////////////////////////////////////////////////
152 // options.
153 /////////////////////////////////////////////////////////////////////////
154
155 const Properties &options() const override { return m_options; }
156
157 Properties &options() override { return m_options; }
158
159 bool set_options(const Properties &options) override {
161 }
162
163 bool set_options(const String_type &options_raw) override {
164 return m_options.insert_values(options_raw);
165 }
166
167 // Fix "inherits ... via dominance" warnings
169
170 const Entity_object_impl *impl() const override {
172 }
173
174 Object_id id() const override { return Entity_object_impl::id(); }
175
176 bool is_persistent() const override {
178 }
179
180 const String_type &name() const override {
182 }
183
184 void set_name(const String_type &name) override {
186 }
187
188 public:
189 Event *create_event(THD *thd) const override;
190
191 Function *create_function(THD *thd) const override;
192
193 Procedure *create_procedure(THD *thd) const override;
194
195 Table *create_table(THD *thd) const override;
196
197 View *create_view(THD *thd) const override;
198
199 View *create_system_view(THD *thd) const override;
200
201 public:
202 void debug_print(String_type &outb) const override {
203 char outbuf[1024];
204 sprintf(outbuf,
205 "SCHEMA OBJECT: id= {OID: %lld}, name= %s, "
206 "collation_id={OID: %lld},"
207 "m_created= %llu, m_last_altered= %llu,"
208 "m_default_encryption= %d, "
209 "se_private_data= %s, options= %s",
210 id(), name().c_str(), m_default_collation_id, m_created,
211 m_last_altered, static_cast<int>(m_default_encryption),
213 m_options.raw_string().c_str());
214 outb = String_type(outbuf);
215 }
216
217 private:
218 // Fields
222
223 // The se_private_data column of a schema might be used by several storage
224 // engines at the same time as the schema is not associated with any specific
225 // engine. So to avoid any naming conflicts, we have the convention that the
226 // keys should be prefixed with the engine name.
228
230
231 // References to other objects
233
234 Schema *clone() const override { return new Schema_impl(*this); }
235
237 /*
238 Even though we don't drop databases en masse we still create slimmed
239 down version for consistency sake.
240 */
241 Schema_impl *placeholder = new Schema_impl();
242 placeholder->set_id(id());
243 placeholder->set_name(name());
244 return placeholder;
245 }
246};
247
248///////////////////////////////////////////////////////////////////////////
249
250} // namespace dd
251
252#endif // DD__SCHEMA_IMPL_INCLUDED
libevent global state management
Definition: http_common.h:60
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
void set_id(Object_id id)
Definition: entity_object_impl.h:51
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:49
const String_type & name() const override
Definition: entity_object_impl.h:60
Entity_object_impl * impl() override
Definition: entity_object_impl.h:68
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:57
Definition: event.h:48
Definition: function.h:39
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:72
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:76
Definition: procedure.h:37
The Properties_impl class implements the Properties interface.
Definition: properties_impl.h:77
bool insert_values(const Properties &properties) override
Insert key/value pairs from a different property object.
Definition: properties_impl.cc:104
const String_type raw_string() const override
Iterate over all entries in the private hash table.
Definition: properties_impl.cc:60
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
Definition: raw_record.h:46
Definition: schema_impl.h:63
void set_default_collation_id(Object_id default_collation_id) override
Definition: schema_impl.h:87
const String_type & name() const override
Definition: schema_impl.h:180
Event * create_event(THD *thd) const override
Definition: schema_impl.cc:191
ulonglong created(bool convert_time) const override
Definition: schema_impl.h:114
bool set_options(const Properties &options) override
Definition: schema_impl.h:159
Object_id default_collation_id() const override
Definition: schema_impl.h:83
enum_encryption_type m_default_encryption
Definition: schema_impl.h:221
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: schema_impl.h:176
Schema_impl()
Definition: schema_impl.cc:81
Entity_object_impl * impl() override
Definition: schema_impl.h:168
Schema * clone_dropped_object_placeholder() const override
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
Definition: schema_impl.h:236
Object_id id() const override
The unique dictionary object id.
Definition: schema_impl.h:174
bool default_encryption() const override
Definition: schema_impl.h:95
void set_last_altered(ulonglong last_altered) override
Definition: schema_impl.h:129
ulonglong m_last_altered
Definition: schema_impl.h:220
Table * create_table(THD *thd) const override
Definition: schema_impl.cc:239
Properties_impl m_se_private_data
Definition: schema_impl.h:227
bool set_se_private_data(const String_type &se_private_data_raw) override
Definition: schema_impl.h:143
View * create_system_view(THD *thd) const override
Definition: schema_impl.cc:291
bool read_only() const override
Definition: schema_impl.cc:98
View * create_view(THD *thd) const override
Definition: schema_impl.cc:266
bool restore_attributes(const Raw_record &r) override
Definition: schema_impl.cc:114
bool validate() const override
Definition: schema_impl.cc:86
Properties & options() override
Definition: schema_impl.h:157
Properties & se_private_data() override
Definition: schema_impl.h:141
Procedure * create_procedure(THD *thd) const override
Definition: schema_impl.cc:223
ulonglong m_created
Definition: schema_impl.h:219
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: schema_impl.cc:323
ulonglong last_altered(bool convert_time) const override
Definition: schema_impl.h:124
Schema * clone() const override
Allocate a new object and invoke the copy constructor.
Definition: schema_impl.h:234
const Entity_object_impl * impl() const override
Definition: schema_impl.h:170
void set_created(ulonglong created) override
Definition: schema_impl.h:118
bool store_attributes(Raw_record *r) override
Definition: schema_impl.cc:146
bool set_options(const String_type &options_raw) override
Definition: schema_impl.h:163
void set_read_only(bool state) override
Definition: schema_impl.cc:108
const Properties & options() const override
Definition: schema_impl.h:155
void set_name(const String_type &name) override
Definition: schema_impl.h:184
Properties_impl m_options
Definition: schema_impl.h:229
const Object_table & object_table() const override
Definition: schema_impl.cc:317
const Properties & se_private_data() const override
Definition: schema_impl.h:137
bool set_se_private_data(const Properties &se_private_data) override
Definition: schema_impl.h:147
Function * create_function(THD *thd) const override
Definition: schema_impl.cc:207
void debug_print(String_type &outb) const override
Definition: schema_impl.h:202
void set_default_encryption(bool default_encryption) override
Definition: schema_impl.h:99
Object_id m_default_collation_id
Definition: schema_impl.h:232
Definition: schema.h:63
Definition: table.h:47
Definition: view.h:39
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:841
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
std::function< void(const Type)> Function
Definition: ut0counter.h:241
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
enum_encryption_type
Definition: schema.h:59
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: options.cc:49
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
This header provides Rapidjson Type Aliases.
Interface for server time utilities.