MySQL 8.4.2
Source Code Documentation
index_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__INDEX_IMPL_INCLUDED
25#define DD__INDEX_IMPL_INCLUDED
26
27#include <sys/types.h>
28#include <memory>
29#include <new>
30
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/properties.h"
36#include "sql/dd/sdi_fwd.h"
37#include "sql/dd/string_type.h"
38#include "sql/dd/types/index.h" // dd::Index
39#include "sql/dd/types/index_element.h" // IWYU pragma: keep
40#include "sql/strfunc.h"
41
42namespace dd {
43
44///////////////////////////////////////////////////////////////////////////
45
46class Column;
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
59class Index_impl : public Entity_object_impl, public Index {
60 public:
61 Index_impl();
62
64
65 Index_impl(const Index_impl &src, Table_impl *parent);
66
67 ~Index_impl() override;
68
69 public:
70 const Object_table &object_table() const override;
71
72 bool validate() const override;
73
75
77
78 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
79
80 bool restore_attributes(const Raw_record &r) override;
81
82 bool store_attributes(Raw_record *r) override;
83
84 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override;
85
86 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override;
87
88 void debug_print(String_type &outb) const override;
89
92 }
93
94 uint ordinal_position() const override { return m_ordinal_position; }
95
96 public:
98
99 /////////////////////////////////////////////////////////////////////////
100 // Table.
101 /////////////////////////////////////////////////////////////////////////
102
103 const Table &table() const override;
104
105 Table &table() override;
106
107 /* non-virtual */ const Table_impl &table_impl() const { return *m_table; }
108
109 /* non-virtual */ Table_impl &table_impl() { return *m_table; }
110
111 /////////////////////////////////////////////////////////////////////////
112 // is_generated
113 /////////////////////////////////////////////////////////////////////////
114
115 bool is_generated() const override { return m_is_generated; }
116
117 void set_generated(bool generated) override { m_is_generated = generated; }
118
119 /////////////////////////////////////////////////////////////////////////
120 // is_hidden.
121 /////////////////////////////////////////////////////////////////////////
122
123 bool is_hidden() const override { return m_hidden; }
124
125 void set_hidden(bool hidden) override { m_hidden = hidden; }
126
127 /////////////////////////////////////////////////////////////////////////
128 // comment.
129 /////////////////////////////////////////////////////////////////////////
130
131 const String_type &comment() const override { return m_comment; }
132
133 void set_comment(const String_type &comment) override { m_comment = comment; }
134
135 /////////////////////////////////////////////////////////////////////////
136 // Options.
137 /////////////////////////////////////////////////////////////////////////
138
139 const Properties &options() const override { return m_options; }
140
141 Properties &options() override { return m_options; }
142
143 bool set_options(const Properties &options) override {
145 }
146
147 bool set_options(const String_type &options_raw) override {
148 return m_options.insert_values(options_raw);
149 }
150
151 /////////////////////////////////////////////////////////////////////////
152 // se_private_data.
153 /////////////////////////////////////////////////////////////////////////
154
155 const Properties &se_private_data() const override {
156 return m_se_private_data;
157 }
158
160
161 bool set_se_private_data(const String_type &se_private_data_raw) override {
162 return m_se_private_data.insert_values(se_private_data_raw);
163 }
164
167 }
168
169 /////////////////////////////////////////////////////////////////////////
170 // Tablespace.
171 /////////////////////////////////////////////////////////////////////////
172
173 Object_id tablespace_id() const override { return m_tablespace_id; }
174
177 }
178
179 /////////////////////////////////////////////////////////////////////////
180 // Engine.
181 /////////////////////////////////////////////////////////////////////////
182
183 const String_type &engine() const override { return m_engine; }
184
185 void set_engine(const String_type &engine) override { m_engine = engine; }
186
187 /////////////////////////////////////////////////////////////////////////
188 // Index type.
189 /////////////////////////////////////////////////////////////////////////
190
191 Index::enum_index_type type() const override { return m_type; }
192
194
195 /////////////////////////////////////////////////////////////////////////
196 // Index algorithm.
197 /////////////////////////////////////////////////////////////////////////
198
200
203 }
204
205 bool is_algorithm_explicit() const override {
207 }
208
209 void set_algorithm_explicit(bool alg_expl) override {
210 m_is_algorithm_explicit = alg_expl;
211 }
212
213 bool is_visible() const override { return m_is_visible; }
214
216
217 LEX_CSTRING engine_attribute() const override {
219 }
221 m_engine_attribute.assign(a.str, a.length);
222 }
225 }
228 }
229
230 /////////////////////////////////////////////////////////////////////////
231 // Index-element collection
232 /////////////////////////////////////////////////////////////////////////
233
234 Index_element *add_element(Column *c) override;
235
236 const Index_elements &elements() const override { return m_elements; }
237
238 bool is_candidate_key() const override;
239
240 // Fix "inherits ... via dominance" warnings
242 const Entity_object_impl *impl() const override {
244 }
245 Object_id id() const override { return Entity_object_impl::id(); }
246 bool is_persistent() const override {
248 }
249 const String_type &name() const override {
251 }
252 void set_name(const String_type &name) override {
254 }
255
256 public:
258 return new (std::nothrow) Index_impl(table);
259 }
260
261 static Index_impl *clone(const Index_impl &other, Table_impl *table) {
262 return new (std::nothrow) Index_impl(other, table);
263 }
264
265 private:
266 // Fields.
267
270
272
276
281
283
286
287 // References to tightly-coupled objects.
288
290
292
293 // References to loosely-coupled objects.
294
296};
297
298///////////////////////////////////////////////////////////////////////////
299
300} // namespace dd
301
302#endif // DD__INDEX_IMPL_INCLUDED
Definition: collection.h:44
Definition: column.h:87
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_element.h:46
Definition: index_impl.h:59
Object_id id() const override
The unique dictionary object id.
Definition: index_impl.h:245
void set_name(const String_type &name) override
Definition: index_impl.h:252
Table_impl & table_impl()
Definition: index_impl.h:109
const Entity_object_impl * impl() const override
Definition: index_impl.h:242
Object_id tablespace_id() const override
Definition: index_impl.h:173
void set_generated(bool generated) override
Definition: index_impl.h:117
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: index_impl.h:246
void set_algorithm(Index::enum_index_algorithm algorithm) override
Definition: index_impl.h:201
const Table_impl & table_impl() const
Definition: index_impl.h:107
bool is_visible() const override
Definition: index_impl.h:213
Index::enum_index_type type() const override
Definition: index_impl.h:191
bool set_se_private_data(const Properties &se_private_data) override
Definition: index_impl.h:165
void set_visible(bool is_visible) override
Definition: index_impl.h:215
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: index_impl.cc:152
Properties & se_private_data() override
Definition: index_impl.h:159
const String_type & engine() const override
Definition: index_impl.h:183
bool validate() const override
Definition: index_impl.cc:113
const Table & table() const override
Definition: index_impl.cc:107
Index::enum_index_algorithm algorithm() const override
Definition: index_impl.h:199
void debug_print(String_type &outb) const override
Definition: index_impl.cc:300
bool set_se_private_data(const String_type &se_private_data_raw) override
Definition: index_impl.h:161
Object_id m_tablespace_id
Definition: index_impl.h:295
bool is_candidate_key() const override
Check if index represents candidate key.
Definition: index_impl.cc:352
const String_type & comment() const override
Definition: index_impl.h:131
void set_engine(const String_type &engine) override
Definition: index_impl.h:185
uint m_ordinal_position
Definition: index_impl.h:271
const Properties & options() const override
Definition: index_impl.h:139
bool is_algorithm_explicit() const override
Definition: index_impl.h:205
void set_secondary_engine_attribute(LEX_CSTRING a) override
Definition: index_impl.h:226
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: index_impl.cc:268
void set_hidden(bool hidden) override
Definition: index_impl.h:125
Index_element * add_element(Column *c) override
Definition: index_impl.cc:338
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override
Converts *this into json.
Definition: index_impl.cc:239
LEX_CSTRING secondary_engine_attribute() const override
Definition: index_impl.h:223
Properties & options() override
Definition: index_impl.h:141
Index_elements m_elements
Definition: index_impl.h:291
bool store_attributes(Raw_record *r) override
Definition: index_impl.cc:197
const Object_table & object_table() const override
Definition: index_impl.cc:413
const Properties & se_private_data() const override
Definition: index_impl.h:155
bool is_generated() const override
Definition: index_impl.h:115
const Index_elements & elements() const override
Definition: index_impl.h:236
uint ordinal_position() const override
Definition: index_impl.h:94
bool m_hidden
Definition: index_impl.h:268
void set_tablespace_id(Object_id tablespace_id) override
Definition: index_impl.h:175
LEX_CSTRING engine_attribute() const override
Definition: index_impl.h:217
bool m_is_algorithm_explicit
Definition: index_impl.h:279
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: index_impl.cc:419
Table_impl * m_table
Definition: index_impl.h:289
Properties_impl m_se_private_data
Definition: index_impl.h:275
void set_ordinal_position(uint ordinal_position) override
Definition: index_impl.h:90
static Index_impl * restore_item(Table_impl *table)
Definition: index_impl.h:257
bool m_is_visible
Definition: index_impl.h:280
~Index_impl() override
String_type m_engine
Definition: index_impl.h:282
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: index_impl.cc:136
bool set_options(const String_type &options_raw) override
Definition: index_impl.h:147
String_type m_engine_attribute
Definition: index_impl.h:284
bool set_options(const Properties &options) override
Definition: index_impl.h:143
bool m_is_generated
Definition: index_impl.h:269
void set_algorithm_explicit(bool alg_expl) override
Definition: index_impl.h:209
Properties_impl m_options
Definition: index_impl.h:274
Index::enum_index_type m_type
Definition: index_impl.h:277
String_type m_comment
Definition: index_impl.h:273
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: index_impl.cc:146
void set_engine_attribute(LEX_CSTRING a) override
Definition: index_impl.h:220
void set_comment(const String_type &comment) override
Definition: index_impl.h:133
Index_impl()
Definition: index_impl.cc:75
String_type m_secondary_engine_attribute
Definition: index_impl.h:285
Entity_object_impl * impl() override
Definition: index_impl.h:241
static Index_impl * clone(const Index_impl &other, Table_impl *table)
Definition: index_impl.h:261
void set_type(Index::enum_index_type type) override
Definition: index_impl.h:193
Index::enum_index_algorithm m_algorithm
Definition: index_impl.h:278
const String_type & name() const override
Definition: index_impl.h:249
bool is_hidden() const override
Definition: index_impl.h:123
bool restore_attributes(const Raw_record &r) override
Definition: index_impl.cc:160
Definition: index.h:51
enum_index_algorithm
Definition: index.h:66
enum_index_type
Definition: index.h:59
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: table_impl.h:68
Definition: table.h:47
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:57
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