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