MySQL 8.4.2
Source Code Documentation
tablespace_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__TABLESPACE_IMPL_INCLUDED
25#define DD__TABLESPACE_IMPL_INCLUDED
26
27#include <memory> // std::unique_ptr
28#include <new>
29#include <string>
30
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/tablespace.h" // dd::Tablespace
39#include "sql/dd/types/tablespace_file.h" // dd::Tablespace_file
40#include "sql/strfunc.h"
41
42class THD;
43
44namespace dd {
45
46///////////////////////////////////////////////////////////////////////////
47
48class Object_table;
49class Open_dictionary_tables_ctx;
50class Properties;
51class Sdi_rcontext;
52class Sdi_wcontext;
53class Tablespace_file;
54class Weak_object;
55class Object_table;
56
58 public:
60
61 ~Tablespace_impl() override;
62
63 public:
64 const Object_table &object_table() const override;
65
66 bool validate() const override;
67
69
71
72 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
73
74 bool store_attributes(Raw_record *r) override;
75
76 bool restore_attributes(const Raw_record &r) override;
77
78 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override;
79
80 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override;
81
82 void debug_print(String_type &outb) const override;
83
84 bool is_empty(THD *thd, bool *empty) const override;
85
86 public:
88
89 /////////////////////////////////////////////////////////////////////////
90 // comment.
91 /////////////////////////////////////////////////////////////////////////
92
93 const String_type &comment() const override { return m_comment; }
94
95 void set_comment(const String_type &comment) override { m_comment = comment; }
96
97 /////////////////////////////////////////////////////////////////////////
98 // options.
99 /////////////////////////////////////////////////////////////////////////
100
101 const Properties &options() const override { return m_options; }
102
103 Properties &options() override { return m_options; }
104
105 bool set_options(const String_type &options_raw) override {
106 return m_options.insert_values(options_raw);
107 }
108
109 /////////////////////////////////////////////////////////////////////////
110 // se_private_data.
111 /////////////////////////////////////////////////////////////////////////
112
113 const Properties &se_private_data() const override {
114 return m_se_private_data;
115 }
116
118
119 bool set_se_private_data(const String_type &se_private_data_raw) override {
120 return m_se_private_data.insert_values(se_private_data_raw);
121 }
122
123 /////////////////////////////////////////////////////////////////////////
124 // m_engine.
125 /////////////////////////////////////////////////////////////////////////
126
127 const String_type &engine() const override { return m_engine; }
128
129 void set_engine(const String_type &engine) override { m_engine = engine; }
130
131 LEX_CSTRING engine_attribute() const override {
133 }
135 m_engine_attribute.assign(a.str, a.length);
136 }
137
138 /////////////////////////////////////////////////////////////////////////
139 // Tablespace file collection.
140 /////////////////////////////////////////////////////////////////////////
141
142 Tablespace_file *add_file() override;
143
144 bool remove_file(String_type data_file) override;
145
146 const Tablespace_file_collection &files() const override { return m_files; }
147
148 // Fix "inherits ... via dominance" warnings
150 const Entity_object_impl *impl() const override {
152 }
153 Object_id id() const override { return Entity_object_impl::id(); }
154 bool is_persistent() const override {
156 }
157 const String_type &name() const override {
159 }
160 void set_name(const String_type &name) override {
162 }
163
164 private:
165 // Fields
166
172
173 // Collections.
174
176
178
179 Tablespace *clone() const override { return new Tablespace_impl(*this); }
180
182 Tablespace_impl *placeholder = new Tablespace_impl();
183 placeholder->set_id(id());
184 placeholder->set_name(name());
185 return placeholder;
186 }
187};
188
189///////////////////////////////////////////////////////////////////////////
190
191} // namespace dd
192
193#endif // DD__TABLESPACE_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: collection.h:44
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
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
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
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
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:231
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:129
Definition: tablespace_file.h:45
Definition: tablespace_impl.h:57
Properties & se_private_data() override
Definition: tablespace_impl.h:117
Tablespace * 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: tablespace_impl.h:181
bool remove_file(String_type data_file) override
Definition: tablespace_impl.cc:315
Tablespace * clone() const override
Allocate a new object graph and invoke the copy constructor for each object.
Definition: tablespace_impl.h:179
const String_type & engine() const override
Definition: tablespace_impl.h:127
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override
Converts *this into json.
Definition: tablespace_impl.cc:215
const String_type & name() const override
Definition: tablespace_impl.h:157
Tablespace_file_collection m_files
Definition: tablespace_impl.h:175
const String_type & comment() const override
Definition: tablespace_impl.h:93
bool restore_attributes(const Raw_record &r) override
Definition: tablespace_impl.cc:158
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: tablespace_impl.cc:334
const Properties & options() const override
Definition: tablespace_impl.h:101
~Tablespace_impl() override
const Tablespace_file_collection & files() const override
Definition: tablespace_impl.h:146
const Entity_object_impl * impl() const override
Definition: tablespace_impl.h:150
Tablespace_file * add_file() override
Definition: tablespace_impl.cc:307
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: tablespace_impl.cc:134
LEX_CSTRING engine_attribute() const override
Definition: tablespace_impl.h:131
bool set_se_private_data(const String_type &se_private_data_raw) override
Definition: tablespace_impl.h:119
bool validate() const override
Definition: tablespace_impl.cc:108
Properties_impl m_options
Definition: tablespace_impl.h:168
Object_id id() const override
The unique dictionary object id.
Definition: tablespace_impl.h:153
Tablespace_impl()
Definition: tablespace_impl.cc:99
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: tablespace_impl.h:154
Properties & options() override
Definition: tablespace_impl.h:103
bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override
Re-establishes the state of *this by reading sdi information from the rapidjson DOM subobject provide...
Definition: tablespace_impl.cc:229
void set_comment(const String_type &comment) override
Definition: tablespace_impl.h:95
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: tablespace_impl.cc:126
String_type m_engine_attribute
Definition: tablespace_impl.h:171
void debug_print(String_type &outb) const override
Definition: tablespace_impl.cc:282
Entity_object_impl * impl() override
Definition: tablespace_impl.h:149
bool set_options(const String_type &options_raw) override
Definition: tablespace_impl.h:105
String_type m_comment
Definition: tablespace_impl.h:167
const Object_table & object_table() const override
Definition: tablespace_impl.cc:328
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: tablespace_impl.cc:150
bool is_empty(THD *thd, bool *empty) const override
Check if the tablespace is empty, i.e., whether it has any tables.
Definition: tablespace_impl.cc:257
void set_engine_attribute(LEX_CSTRING a) override
Definition: tablespace_impl.h:134
const Properties & se_private_data() const override
Definition: tablespace_impl.h:113
Properties_impl m_se_private_data
Definition: tablespace_impl.h:169
void set_name(const String_type &name) override
Definition: tablespace_impl.h:160
void set_engine(const String_type &engine) override
Definition: tablespace_impl.h:129
String_type m_engine
Definition: tablespace_impl.h:170
bool store_attributes(Raw_record *r) override
Definition: tablespace_impl.cc:181
Definition: tablespace.h:56
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
RJ_Writer Sdi_writer
Alias for the rapidjson Writer type to use in serialization.
Definition: sdi_fwd.h:64
unsigned long long Object_id
Definition: object_id.h:31
rapidjson::GenericValue< RJ_Encoding, RJ_Allocator > RJ_Value
Definition: sdi_fwd.h:49
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
This header provides Rapidjson Type Aliases.
MYSQL_LEX_CSTRING lex_cstring_handle(const STDSTRINGLIKE_TYPE &s)
Return a LEX_CSTRING handle to a std::string like (meaning something which has the c_str() and length...
Definition: strfunc.h:74
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42