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