MySQL 8.0.39
Source Code Documentation
partition_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__PARTITION_IMPL_INCLUDED
25#define DD__PARTITION_IMPL_INCLUDED
26
27#include <sys/types.h>
28#include <memory>
29#include <new>
30
31#include "sql/dd/collection.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/sdi_fwd.h"
37#include "sql/dd/string_type.h"
38#include "sql/dd/types/partition.h" // dd::Partition
39#include "sql/dd/types/partition_index.h" // IWYU pragma: keep
40#include "sql/dd/types/partition_value.h" // IWYU pragma: keep
41#include "sql/dd/types/table.h"
42
43namespace dd {
44
45///////////////////////////////////////////////////////////////////////////
46
47class Index;
48class Object_table;
49class Open_dictionary_tables_ctx;
50class Properties;
51class Raw_record;
52class Sdi_rcontext;
53class Sdi_wcontext;
54class Table;
55class Table_impl;
56class Weak_object;
57
58///////////////////////////////////////////////////////////////////////////
59
61 public:
63
65
67
69
70 Partition_impl(const Partition_impl &src, Partition_impl *partition);
71
72 ~Partition_impl() override;
73
74 public:
75 const Object_table &object_table() const override;
76
77 bool validate() const override;
78
80
82
83 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
84
85 bool restore_attributes(const Raw_record &r) override;
86
87 bool store_attributes(Raw_record *r) override;
88
89 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override;
90
91 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override;
92
93 void debug_print(String_type &outb) const override;
94
96
97 virtual uint ordinal_position() const { return -1; }
98
99 public:
101
102 /////////////////////////////////////////////////////////////////////////
103 // Table.
104 /////////////////////////////////////////////////////////////////////////
105
106 const Table &table() const override;
107
108 Table &table() override;
109
110 /* non-virtual */ const Table_impl &table_impl() const { return *m_table; }
111
112 /* non-virtual */ Table_impl &table_impl() { return *m_table; }
113
114 /////////////////////////////////////////////////////////////////////////
115 // Parent partition.
116 /////////////////////////////////////////////////////////////////////////
117
118 virtual const Partition *parent_partition() const { return m_parent; }
119
121 return const_cast<dd::Partition *>(m_parent);
122 }
123
124 /////////////////////////////////////////////////////////////////////////
125 // parent_partition_id
126 /////////////////////////////////////////////////////////////////////////
127
130 }
131
134 }
135
136 /////////////////////////////////////////////////////////////////////////
137 // number.
138 /////////////////////////////////////////////////////////////////////////
139
140 uint number() const override { return m_number; }
141
142 void set_number(uint number) override { m_number = number; }
143
144 /////////////////////////////////////////////////////////////////////////
145 // description_utf8.
146 /////////////////////////////////////////////////////////////////////////
147
148 const String_type &description_utf8() const override {
149 return m_description_utf8;
150 }
151
154 }
155
156 /////////////////////////////////////////////////////////////////////////
157 // engine.
158 /////////////////////////////////////////////////////////////////////////
159
160 const String_type &engine() const override { return m_engine; }
161
162 void set_engine(const String_type &engine) override { m_engine = engine; }
163
164 /////////////////////////////////////////////////////////////////////////
165 // comment.
166 /////////////////////////////////////////////////////////////////////////
167
168 const String_type &comment() const override { return m_comment; }
169
170 void set_comment(const String_type &comment) override { m_comment = comment; }
171
172 /////////////////////////////////////////////////////////////////////////
173 // Options.
174 /////////////////////////////////////////////////////////////////////////
175
176 const Properties &options() const override { return m_options; }
177
178 Properties &options() override { return m_options; }
179
180 bool set_options(const Properties &options) override {
182 }
183
184 bool set_options(const String_type &options_raw) override {
185 return m_options.insert_values(options_raw);
186 }
187
188 /////////////////////////////////////////////////////////////////////////
189 // se_private_data.
190 /////////////////////////////////////////////////////////////////////////
191
192 const Properties &se_private_data() const override {
193 return m_se_private_data;
194 }
195
197
198 bool set_se_private_data(const String_type &se_private_data_raw) override {
199 return m_se_private_data.insert_values(se_private_data_raw);
200 }
201
204 }
205
206 /////////////////////////////////////////////////////////////////////////
207 // se_private_id.
208 /////////////////////////////////////////////////////////////////////////
209
210 Object_id se_private_id() const override { return m_se_private_id; }
211
214 }
215
216 /////////////////////////////////////////////////////////////////////////
217 // Tablespace.
218 /////////////////////////////////////////////////////////////////////////
219
220 Object_id tablespace_id() const override { return m_tablespace_id; }
221
224 }
225
226 /////////////////////////////////////////////////////////////////////////
227 // Partition-value collection
228 /////////////////////////////////////////////////////////////////////////
229
230 Partition_value *add_value() override;
231
232 const Partition_values &values() const override { return m_values; }
233
234 /////////////////////////////////////////////////////////////////////////
235 // Partition-index collection
236 /////////////////////////////////////////////////////////////////////////
237
238 Partition_index *add_index(Index *idx) override;
239
240 const Partition_indexes &indexes() const override { return m_indexes; }
241
242 /* purecov: begin deadcode */
243 Partition_indexes *indexes() override { return &m_indexes; }
244 /* purecov: end */
245
246 /////////////////////////////////////////////////////////////////////////
247 // Sub Partition collection.
248 /////////////////////////////////////////////////////////////////////////
249
250 Partition *add_subpartition() override;
251
253 return m_subpartitions;
254 }
255
257 return &m_subpartitions;
258 }
259
260 const Partition *parent() const override { return m_parent; }
261 void set_parent(const Partition *parent) override { m_parent = parent; }
262
263 // Fix "inherits ... via dominance" warnings
265 const Entity_object_impl *impl() const override {
267 }
268 Object_id id() const override { return Entity_object_impl::id(); }
269 bool is_persistent() const override {
271 }
272 const String_type &name() const override {
274 }
275 void set_name(const String_type &name) override {
277 }
278
279 public:
281 return new (std::nothrow) Partition_impl(table);
282 }
283
286 new (std::nothrow) Partition_impl(&part->table_impl(), part);
287 p->set_parent(part);
288
289 return p;
290 }
291
293 return new (std::nothrow) Partition_impl(other, table);
294 }
295
296 static Partition_impl *clone(const Partition_impl &other,
297 Partition_impl *part) {
298 return new (std::nothrow) Partition_impl(other, part);
299 }
300
301 private:
302 // Fields.
303
307
313
314 // References to tightly-coupled objects.
315
317
319
323
324 // References to loosely-coupled objects.
325
327};
328
329///////////////////////////////////////////////////////////////////////////
330
331/** Used to compare two partition elements. */
333 // TODO : do we really need this ordering now ?
334 bool operator()(const dd::Partition *p1, const dd::Partition *p2) const {
335 if (p1->parent_partition_id() == p2->parent_partition_id())
336 return p1->number() < p2->number();
337 return p1->parent_partition_id() < p2->parent_partition_id();
338 }
339};
340
341} // namespace dd
342
343#endif // DD__PARTITION_IMPL_INCLUDED
Definition: collection.h:44
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
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: index.h:51
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: partition_impl.h:60
String_type m_comment
Definition: partition_impl.h:310
Properties_impl m_se_private_data
Definition: partition_impl.h:312
bool set_options(const String_type &options_raw) override
Definition: partition_impl.h:184
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override
Converts *this into json.
Definition: partition_impl.cc:260
Table::Partition_collection m_subpartitions
Definition: partition_impl.h:322
void set_se_private_id(Object_id se_private_id) override
Definition: partition_impl.h:212
Object_id se_private_id() const override
Definition: partition_impl.h:210
String_type m_description_utf8
Definition: partition_impl.h:308
Partition * add_subpartition() override
Add a subpartition to a parent partition.
Definition: partition_impl.cc:375
const String_type & name() const override
Definition: partition_impl.h:272
const Partition * m_parent
Definition: partition_impl.h:318
Properties & se_private_data() override
Definition: partition_impl.h:196
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: partition_impl.cc:192
const String_type & comment() const override
Definition: partition_impl.h:168
void set_parent_partition_id(Object_id parent_partition_id) override
Definition: partition_impl.h:132
Partition_indexes * indexes() override
Definition: partition_impl.h:243
static Partition_impl * restore_item(Table_impl *table)
Definition: partition_impl.h:280
Partition_value * add_value() override
Definition: partition_impl.cc:359
const Table_impl & table_impl() const
Definition: partition_impl.h:110
const Partition_indexes & indexes() const override
Definition: partition_impl.h:240
void set_number(uint number) override
Definition: partition_impl.h:142
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: partition_impl.cc:183
Object_id tablespace_id() const override
Definition: partition_impl.h:220
Table_impl & table_impl()
Definition: partition_impl.h:112
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: partition_impl.cc:163
static Partition_impl * restore_item(Partition_impl *part)
Definition: partition_impl.h:284
uint number() const override
Definition: partition_impl.h:140
virtual Partition * parent_partition()
Definition: partition_impl.h:120
Entity_object_impl * impl() override
Definition: partition_impl.h:264
const Table & table() const override
Definition: partition_impl.cc:123
Partition_index * add_index(Index *idx) override
Definition: partition_impl.cc:367
String_type m_engine
Definition: partition_impl.h:309
bool validate() const override
Definition: partition_impl.cc:129
const Partition * parent() const override
Definition: partition_impl.h:260
void set_engine(const String_type &engine) override
Definition: partition_impl.h:162
const Partition_values & values() const override
Definition: partition_impl.h:232
Object_id parent_partition_id() const override
Definition: partition_impl.h:128
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: partition_impl.cc:281
void set_comment(const String_type &comment) override
Definition: partition_impl.h:170
bool set_se_private_data(const String_type &se_private_data_raw) override
Definition: partition_impl.h:198
bool set_se_private_data(const Properties &se_private_data) override
Definition: partition_impl.h:202
static Partition_impl * clone(const Partition_impl &other, Partition_impl *part)
Definition: partition_impl.h:296
void debug_print(String_type &outb) const override
Definition: partition_impl.cc:304
static Partition_impl * clone(const Partition_impl &other, Table_impl *table)
Definition: partition_impl.h:292
const String_type & description_utf8() const override
Definition: partition_impl.h:148
Object_id m_se_private_id
Definition: partition_impl.h:306
bool restore_attributes(const Raw_record &r) override
Definition: partition_impl.cc:207
const Table::Partition_collection & subpartitions() const override
Return reference to const collection of sub partitions.
Definition: partition_impl.h:252
const Entity_object_impl * impl() const override
Definition: partition_impl.h:265
void set_ordinal_position(uint)
Definition: partition_impl.h:95
bool set_options(const Properties &options) override
Definition: partition_impl.h:180
const Properties & options() const override
Definition: partition_impl.h:176
Partition_values m_values
Definition: partition_impl.h:320
Object_id m_parent_partition_id
Definition: partition_impl.h:304
void set_name(const String_type &name) override
Definition: partition_impl.h:275
void set_description_utf8(const String_type &description_utf8) override
Definition: partition_impl.h:152
uint m_number
Definition: partition_impl.h:305
const Object_table & object_table() const override
Definition: partition_impl.cc:441
Properties_impl m_options
Definition: partition_impl.h:311
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: partition_impl.h:269
Properties & options() override
Definition: partition_impl.h:178
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: partition_impl.cc:447
virtual const Partition * parent_partition() const
Definition: partition_impl.h:118
Partition_impl()
Definition: partition_impl.cc:75
void set_parent(const Partition *parent) override
Definition: partition_impl.h:261
Table_impl * m_table
Definition: partition_impl.h:316
~Partition_impl() override
const String_type & engine() const override
Definition: partition_impl.h:160
Object_id id() const override
The unique dictionary object id.
Definition: partition_impl.h:268
bool store_attributes(Raw_record *r) override
Definition: partition_impl.cc:236
virtual uint ordinal_position() const
Definition: partition_impl.h:97
void set_tablespace_id(Object_id tablespace_id) override
Definition: partition_impl.h:222
const Properties & se_private_data() const override
Definition: partition_impl.h:192
Table::Partition_collection * subpartitions() override
Return non-const point to collection of sub partitions.
Definition: partition_impl.h:256
Object_id m_tablespace_id
Definition: partition_impl.h:326
Partition_indexes m_indexes
Definition: partition_impl.h:321
Definition: partition_index.h:47
Definition: partition_value.h:45
Definition: partition.h:51
virtual Object_id parent_partition_id() const =0
virtual uint number() const =0
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: table_impl.h:68
Definition: table.h:47
const char * p
Definition: ctype-mb.cc:1237
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
Definition: options.cc:49
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
This header provides Rapidjson Type Aliases.
Used to compare two partition elements.
Definition: partition_impl.h:332
bool operator()(const dd::Partition *p1, const dd::Partition *p2) const
Definition: partition_impl.h:334
unsigned int uint
Definition: uca9-dump.cc:75