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