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