MySQL 9.0.0
Source Code Documentation
index.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_INCLUDED
25#define DD__INDEX_INCLUDED
26
27#include "lex_string.h"
28#include "my_inttypes.h"
29#include "sql/dd/collection.h" // dd::Collection
30#include "sql/dd/sdi_fwd.h" // dd::Sdi_rcontext
31#include "sql/dd/sdi_fwd.h" // dd::Sdi_wcontext
32#include "sql/dd/types/entity_object.h" // dd::Entity_object
33
34namespace dd {
35
36///////////////////////////////////////////////////////////////////////////
37
38class Column;
39class Index_impl;
40class Index_element;
41class Object_table;
42class Properties;
43class Table;
44
45namespace tables {
46class Indexes;
47}
48
49///////////////////////////////////////////////////////////////////////////
50
51class Index : virtual public Entity_object {
52 public:
56
57 public:
58 enum enum_index_type // similar to Keytype in sql_class.h but w/o FOREIGN_KEY
64
65 enum enum_index_algorithm // similar to ha_key_alg
71
72 public:
73 ~Index() override = default;
74
75 /**
76 Dummy method to be able to use Partition_index and Index interchangeably
77 in templates.
78 */
79 const Index &index() const { return *this; }
80
81 Index &index() { return *this; }
82
83 /////////////////////////////////////////////////////////////////////////
84 // Table.
85 /////////////////////////////////////////////////////////////////////////
86
87 virtual const Table &table() const = 0;
88
89 virtual Table &table() = 0;
90
91 /////////////////////////////////////////////////////////////////////////
92 // is_generated
93 /////////////////////////////////////////////////////////////////////////
94
95 virtual bool is_generated() const = 0;
96 virtual void set_generated(bool generated) = 0;
97
98 /////////////////////////////////////////////////////////////////////////
99 // hidden.
100 /////////////////////////////////////////////////////////////////////////
101
102 virtual bool is_hidden() const = 0;
103 virtual void set_hidden(bool hidden) = 0;
104
105 /////////////////////////////////////////////////////////////////////////
106 // comment.
107 /////////////////////////////////////////////////////////////////////////
108
109 virtual const String_type &comment() const = 0;
110 virtual void set_comment(const String_type &comment) = 0;
111
112 /////////////////////////////////////////////////////////////////////////
113 // Options.
114 /////////////////////////////////////////////////////////////////////////
115
116 virtual const Properties &options() const = 0;
117
118 virtual Properties &options() = 0;
119 virtual bool set_options(const Properties &options) = 0;
120 virtual bool set_options(const String_type &options_raw) = 0;
121
122 /////////////////////////////////////////////////////////////////////////
123 // se_private_data.
124 /////////////////////////////////////////////////////////////////////////
125
126 virtual const Properties &se_private_data() const = 0;
127
129 virtual bool set_se_private_data(const String_type &se_private_data_raw) = 0;
131
132 /////////////////////////////////////////////////////////////////////////
133 // Tablespace.
134 /////////////////////////////////////////////////////////////////////////
135
136 virtual Object_id tablespace_id() const = 0;
138
139 /////////////////////////////////////////////////////////////////////////
140 // Engine.
141 /////////////////////////////////////////////////////////////////////////
142
143 virtual const String_type &engine() const = 0;
144 virtual void set_engine(const String_type &engine) = 0;
145
146 /////////////////////////////////////////////////////////////////////////
147 // Index type.
148 /////////////////////////////////////////////////////////////////////////
149
150 virtual enum_index_type type() const = 0;
151 virtual void set_type(enum_index_type type) = 0;
152
153 /////////////////////////////////////////////////////////////////////////
154 // Index algorithm.
155 /////////////////////////////////////////////////////////////////////////
156
157 virtual enum_index_algorithm algorithm() const = 0;
159
160 virtual bool is_algorithm_explicit() const = 0;
161 virtual void set_algorithm_explicit(bool alg_expl) = 0;
162
163 virtual bool is_visible() const = 0;
164 virtual void set_visible(bool is_visible) = 0;
165
166 /////////////////////////////////////////////////////////////////////////
167 // SE-specific json attributes
168 /////////////////////////////////////////////////////////////////////////
169
170 virtual LEX_CSTRING engine_attribute() const = 0;
172
175
176 /////////////////////////////////////////////////////////////////////////
177 // Index-element collection.
178 /////////////////////////////////////////////////////////////////////////
179
181
182 virtual const Index_elements &elements() const = 0;
183
185
186 virtual uint ordinal_position() const = 0;
187
188 /**
189 Converts *this into json.
190
191 Converts all member variables that are to be included in the sdi
192 into json by transforming them appropriately and passing them to
193 the rapidjson writer provided.
194
195 @param wctx opaque context for data needed by serialization
196 @param w rapidjson writer which will perform conversion to json
197
198 */
199
200 virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const = 0;
201
202 /**
203 Re-establishes the state of *this by reading sdi information from
204 the rapidjson DOM subobject provided.
205
206 Cross-references encountered within this object are tracked in
207 sdictx, so that they can be updated when the entire object graph
208 has been established.
209
210 @param rctx stores book-keeping information for the
211 deserialization process
212 @param val subobject of rapidjson DOM containing json
213 representation of this object
214 */
215
216 virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) = 0;
217
218 /**
219 Check if index represents candidate key.
220 */
221 virtual bool is_candidate_key() const = 0;
222};
223
224///////////////////////////////////////////////////////////////////////////
225
226} // namespace dd
227
228#endif // DD__INDEX_INCLUDED
Definition: collection.h:44
Definition: column.h:88
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:48
Definition: index_element.h:46
Definition: index_impl.h:59
Definition: index.h:51
virtual const Properties & se_private_data() const =0
virtual const String_type & engine() const =0
virtual const Table & table() const =0
virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val)=0
Re-establishes the state of *this by reading sdi information from the rapidjson DOM subobject provide...
virtual const String_type & comment() const =0
virtual bool set_se_private_data(const String_type &se_private_data_raw)=0
virtual void set_type(enum_index_type type)=0
virtual bool set_options(const String_type &options_raw)=0
virtual void set_secondary_engine_attribute(LEX_CSTRING)=0
enum_index_algorithm
Definition: index.h:66
@ IA_FULLTEXT
Definition: index.h:70
@ IA_HASH
Definition: index.h:69
@ IA_SE_SPECIFIC
Definition: index.h:66
@ IA_RTREE
Definition: index.h:68
@ IA_BTREE
Definition: index.h:67
virtual bool is_hidden() const =0
virtual bool set_options(const Properties &options)=0
virtual void set_comment(const String_type &comment)=0
virtual Table & table()=0
virtual enum_index_type type() const =0
virtual const Index_elements & elements() const =0
const Index & index() const
Dummy method to be able to use Partition_index and Index interchangeably in templates.
Definition: index.h:79
Index & index()
Definition: index.h:81
virtual void set_engine_attribute(LEX_CSTRING)=0
virtual void set_algorithm(enum_index_algorithm algorithm)=0
virtual Object_id tablespace_id() const =0
virtual LEX_CSTRING engine_attribute() const =0
virtual void set_hidden(bool hidden)=0
virtual Index_element * add_element(Column *c)=0
virtual LEX_CSTRING secondary_engine_attribute() const =0
tables::Indexes DD_table
Definition: index.h:55
~Index() override=default
virtual void set_tablespace_id(Object_id tablespace_id)=0
virtual uint ordinal_position() const =0
virtual enum_index_algorithm algorithm() const =0
virtual bool is_candidate_key() const =0
Check if index represents candidate key.
virtual bool is_algorithm_explicit() const =0
Index_impl Impl
Definition: index.h:54
virtual void set_algorithm_explicit(bool alg_expl)=0
enum_index_type
Definition: index.h:59
@ IT_FULLTEXT
Definition: index.h:62
@ IT_MULTIPLE
Definition: index.h:61
@ IT_UNIQUE
Definition: index.h:60
@ IT_PRIMARY
Definition: index.h:59
@ IT_SPATIAL
Definition: index.h:63
virtual bool is_generated() const =0
virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const =0
Converts *this into json.
virtual void set_ordinal_position(uint ordinal_position)=0
virtual Properties & se_private_data()=0
virtual bool set_se_private_data(const Properties &se_private_data)=0
virtual void set_generated(bool generated)=0
virtual Properties & options()=0
virtual void set_visible(bool is_visible)=0
virtual void set_engine(const String_type &engine)=0
virtual bool is_visible() const =0
virtual const Properties & options() const =0
Collection< Index_element * > Index_elements
Definition: index.h:53
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
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.h:47
Definition: indexes.h:40
Some integer typedefs for easier portability.
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
This header provides Rapidjson Type Aliases.
Definition: mysql_lex_string.h:40