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