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