MySQL 9.1.0
Source Code Documentation
index_element.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_ELEMENT_INCLUDED
25#define DD__INDEX_ELEMENT_INCLUDED
26
27#include "m_string.h"
28#include "my_inttypes.h"
29#include "sql/dd/sdi_fwd.h" // dd::Sdi_wcontext
30#include "sql/dd/types/weak_object.h" // dd::Weak_object
31
32namespace dd {
33
34///////////////////////////////////////////////////////////////////////////
35
36class Column;
37class Index;
38class Index_element_impl;
39
40namespace tables {
41class Index_column_usage;
42}
43
44///////////////////////////////////////////////////////////////////////////
45
46class Index_element : virtual public Weak_object {
47 public:
50
51 public:
53
54 public:
55 ~Index_element() override = default;
56
57 /////////////////////////////////////////////////////////////////////////
58 // index.
59 /////////////////////////////////////////////////////////////////////////
60
61 virtual const Index &index() const = 0;
62
63 virtual Index &index() = 0;
64
65 /////////////////////////////////////////////////////////////////////////
66 // column.
67 /////////////////////////////////////////////////////////////////////////
68
69 virtual const Column &column() const = 0;
70
71 virtual Column &column() = 0;
72
73 /////////////////////////////////////////////////////////////////////////
74 // ordinal_position.
75 /////////////////////////////////////////////////////////////////////////
76
77 virtual uint ordinal_position() const = 0;
78
79 /////////////////////////////////////////////////////////////////////////
80 // length.
81 /////////////////////////////////////////////////////////////////////////
82
83 virtual uint length() const = 0;
84 virtual void set_length(uint length) = 0;
85 virtual void set_length_null(bool is_null) = 0;
86 virtual bool is_length_null() const = 0;
87
88 /////////////////////////////////////////////////////////////////////////
89 // order.
90 /////////////////////////////////////////////////////////////////////////
91
92 virtual enum_index_element_order order() const = 0;
94
95 /////////////////////////////////////////////////////////////////////////
96 // hidden.
97 /////////////////////////////////////////////////////////////////////////
98
99 virtual bool is_hidden() const = 0;
100 virtual void set_hidden(bool hidden) = 0;
101
102 /**
103 Converts *this into json.
104
105 Converts all member variables that are to be included in the sdi
106 into json by transforming them appropriately and passing them to
107 the rapidjson writer provided.
108
109 @param wctx opaque context for data needed by serialization
110 @param w rapidjson writer which will perform conversion to json
111
112 */
113
114 virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const = 0;
115
116 /**
117 Re-establishes the state of *this by reading sdi information from
118 the rapidjson DOM subobject provided.
119
120 Cross-references encountered within this object are tracked in
121 sdictx, so that they can be updated when the entire object graph
122 has been established.
123
124 @param rctx stores book-keeping information for the
125 deserialization process
126 @param val subobject of rapidjson DOM containing json
127 representation of this object
128 */
129
130 virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) = 0;
131
132 /**
133 Check if index element (a.k.a. key part) is a prefix of the column used.
134 */
135 virtual bool is_prefix() const = 0;
136};
137
138///////////////////////////////////////////////////////////////////////////
139
140} // namespace dd
141
142#endif // DD__INDEX_ELEMENT_INCLUDED
Definition: column.h:88
Definition: index_element_impl.h:54
Definition: index_element.h:46
virtual uint ordinal_position() const =0
virtual bool is_length_null() const =0
virtual void set_length(uint length)=0
virtual enum_index_element_order order() const =0
virtual Column & column()=0
virtual const Index & index() const =0
enum_index_element_order
Definition: index_element.h:52
@ ORDER_ASC
Definition: index_element.h:52
@ ORDER_UNDEF
Definition: index_element.h:52
@ ORDER_DESC
Definition: index_element.h:52
virtual bool is_prefix() const =0
Check if index element (a.k.a.
virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const =0
Converts *this into json.
virtual void set_order(enum_index_element_order order)=0
Index_element_impl Impl
Definition: index_element.h:48
virtual void set_length_null(bool is_null)=0
virtual Index & index()=0
virtual bool is_hidden() 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...
tables::Index_column_usage DD_table
Definition: index_element.h:49
virtual const Column & column() const =0
virtual void set_hidden(bool hidden)=0
~Index_element() override=default
virtual uint length() const =0
Definition: index.h:51
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
Base class for all data dictionary objects.
Definition: weak_object.h:42
Definition: index_column_usage.h:38
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
rapidjson::GenericValue< RJ_Encoding, RJ_Allocator > RJ_Value
Definition: sdi_fwd.h:49
This header provides Rapidjson Type Aliases.