MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 Library;
54class Raw_record;
55class Sdi_rcontext;
56class Sdi_wcontext;
57class Table;
58class View;
59class Weak_object;
60class Object_table;
61
62///////////////////////////////////////////////////////////////////////////
63
64class Schema_impl : public Entity_object_impl, public Schema {
65 public:
67
68 public:
69 const Object_table &object_table() const override;
70
71 bool validate() const override;
72
73 bool store_attributes(Raw_record *r) override;
74
75 bool restore_attributes(const Raw_record &r) override;
76
77 public:
79
80 /////////////////////////////////////////////////////////////////////////
81 // Default collation.
82 /////////////////////////////////////////////////////////////////////////
83
86 }
87
90 }
91
92 /////////////////////////////////////////////////////////////////////////
93 // Default encryption.
94 /////////////////////////////////////////////////////////////////////////
95
96 bool default_encryption() const override {
98 }
99
103 }
104
105 /////////////////////////////////////////////////////////////////////////
106 // Read only.
107 /////////////////////////////////////////////////////////////////////////
108 bool read_only() const override;
109 void set_read_only(bool state) override;
110
111 /////////////////////////////////////////////////////////////////////////
112 // created
113 /////////////////////////////////////////////////////////////////////////
114
115 ulonglong created(bool convert_time) const override {
116 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
117 }
118
120
121 /////////////////////////////////////////////////////////////////////////
122 // last_altered
123 /////////////////////////////////////////////////////////////////////////
124
125 ulonglong last_altered(bool convert_time) const override {
126 return convert_time ? gmt_time_to_local_time(m_last_altered)
128 }
129
132 }
133
134 /////////////////////////////////////////////////////////////////////////
135 // se_private_data.
136 /////////////////////////////////////////////////////////////////////////
137
138 const Properties &se_private_data() const override {
139 return m_se_private_data;
140 }
141
143
144 bool set_se_private_data(const String_type &se_private_data_raw) override {
145 return m_se_private_data.insert_values(se_private_data_raw);
146 }
147
150 }
151
152 /////////////////////////////////////////////////////////////////////////
153 // options.
154 /////////////////////////////////////////////////////////////////////////
155
156 const Properties &options() const override { return m_options; }
157
158 Properties &options() override { return m_options; }
159
160 bool set_options(const Properties &options) override {
162 }
163
164 bool set_options(const String_type &options_raw) override {
165 return m_options.insert_values(options_raw);
166 }
167
168 // Fix "inherits ... via dominance" warnings
170
171 const Entity_object_impl *impl() const override {
173 }
174
175 Object_id id() const override { return Entity_object_impl::id(); }
176
177 bool is_persistent() const override {
179 }
180
181 const String_type &name() const override {
183 }
184
185 void set_name(const String_type &name) override {
187 }
188
189 public:
190 Event *create_event(THD *thd) const override;
191
192 Function *create_function(THD *thd) const override;
193
194 Procedure *create_procedure(THD *thd) const override;
195
196 Library *create_library(THD *thd) const override;
197
198 Table *create_table(THD *thd) const override;
199
200 View *create_view(THD *thd) const override;
201
202 View *create_system_view(THD *thd) const override;
203
204 public:
205 void debug_print(String_type &outb) const override {
206 char outbuf[1024];
207 sprintf(outbuf,
208 "SCHEMA OBJECT: id= {OID: %lld}, name= %s, "
209 "collation_id={OID: %lld},"
210 "m_created= %llu, m_last_altered= %llu,"
211 "m_default_encryption= %d, "
212 "se_private_data= %s, options= %s",
213 id(), name().c_str(), m_default_collation_id, m_created,
214 m_last_altered, static_cast<int>(m_default_encryption),
216 m_options.raw_string().c_str());
217 outb = String_type(outbuf);
218 }
219
220 private:
221 // Fields
225
226 // The se_private_data column of a schema might be used by several storage
227 // engines at the same time as the schema is not associated with any specific
228 // engine. So to avoid any naming conflicts, we have the convention that the
229 // keys should be prefixed with the engine name.
231
233
234 // References to other objects
236
237 Schema *clone() const override { return new Schema_impl(*this); }
238
240 /*
241 Even though we don't drop databases en masse we still create slimmed
242 down version for consistency sake.
243 */
244 Schema_impl *placeholder = new Schema_impl();
245 placeholder->set_id(id());
246 placeholder->set_name(name());
247 return placeholder;
248 }
249};
250
251///////////////////////////////////////////////////////////////////////////
252
253} // namespace dd
254
255#endif // DD__SCHEMA_IMPL_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
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
Definition: library.h:37
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:77
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:64
void set_default_collation_id(Object_id default_collation_id) override
Definition: schema_impl.h:88
const String_type & name() const override
Definition: schema_impl.h:181
Event * create_event(THD *thd) const override
Definition: schema_impl.cc:192
ulonglong created(bool convert_time) const override
Definition: schema_impl.h:115
bool set_options(const Properties &options) override
Definition: schema_impl.h:160
Object_id default_collation_id() const override
Definition: schema_impl.h:84
enum_encryption_type m_default_encryption
Definition: schema_impl.h:224
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: schema_impl.h:177
Library * create_library(THD *thd) const override
Definition: schema_impl.cc:240
Schema_impl()
Definition: schema_impl.cc:82
Entity_object_impl * impl() override
Definition: schema_impl.h:169
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:239
Object_id id() const override
The unique dictionary object id.
Definition: schema_impl.h:175
bool default_encryption() const override
Definition: schema_impl.h:96
void set_last_altered(ulonglong last_altered) override
Definition: schema_impl.h:130
ulonglong m_last_altered
Definition: schema_impl.h:223
Table * create_table(THD *thd) const override
Definition: schema_impl.cc:256
Properties_impl m_se_private_data
Definition: schema_impl.h:230
bool set_se_private_data(const String_type &se_private_data_raw) override
Definition: schema_impl.h:144
View * create_system_view(THD *thd) const override
Definition: schema_impl.cc:308
bool read_only() const override
Definition: schema_impl.cc:99
View * create_view(THD *thd) const override
Definition: schema_impl.cc:283
bool restore_attributes(const Raw_record &r) override
Definition: schema_impl.cc:115
bool validate() const override
Definition: schema_impl.cc:87
Properties & options() override
Definition: schema_impl.h:158
Properties & se_private_data() override
Definition: schema_impl.h:142
Procedure * create_procedure(THD *thd) const override
Definition: schema_impl.cc:224
ulonglong m_created
Definition: schema_impl.h:222
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: schema_impl.cc:340
ulonglong last_altered(bool convert_time) const override
Definition: schema_impl.h:125
Schema * clone() const override
Allocate a new object and invoke the copy constructor.
Definition: schema_impl.h:237
const Entity_object_impl * impl() const override
Definition: schema_impl.h:171
void set_created(ulonglong created) override
Definition: schema_impl.h:119
bool store_attributes(Raw_record *r) override
Definition: schema_impl.cc:147
bool set_options(const String_type &options_raw) override
Definition: schema_impl.h:164
void set_read_only(bool state) override
Definition: schema_impl.cc:109
const Properties & options() const override
Definition: schema_impl.h:156
void set_name(const String_type &name) override
Definition: schema_impl.h:185
Properties_impl m_options
Definition: schema_impl.h:232
const Object_table & object_table() const override
Definition: schema_impl.cc:334
const Properties & se_private_data() const override
Definition: schema_impl.h:138
bool set_se_private_data(const Properties &se_private_data) override
Definition: schema_impl.h:148
Function * create_function(THD *thd) const override
Definition: schema_impl.cc:208
void debug_print(String_type &outb) const override
Definition: schema_impl.h:205
void set_default_encryption(bool default_encryption) override
Definition: schema_impl.h:100
Object_id m_default_collation_id
Definition: schema_impl.h:235
Definition: schema.h:64
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:868
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:60
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: options.cc:57
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
This header provides Rapidjson Type Aliases.
Interface for server time utilities.