MySQL 9.0.0
Source Code Documentation
column_statistics.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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__COLUMN_STATISTIC_INCLUDED
25#define DD__COLUMN_STATISTIC_INCLUDED
26
27#include "my_alloc.h" // MEM_ROOT
28#include "sql/dd/sdi_fwd.h" // RJ_Document
29#include "sql/dd/types/entity_object.h" // dd::Entity_object
30
31class THD;
32struct MDL_key;
33
34namespace histograms {
35class Histogram;
36}
37
38namespace dd {
39
40///////////////////////////////////////////////////////////////////////////
41
42class Column_statistics_impl;
43class Item_name_key;
44class Primary_id_key;
45class Void_key;
46
47namespace tables {
48class Column_statistics;
49}
50
51///////////////////////////////////////////////////////////////////////////
52
53class Column_statistics : virtual public Entity_object {
54 protected:
55 /// MEM_ROOT on which the histogram data is allocated.
57
58 public:
65
66 // We need a set of functions to update a preallocated key.
67 bool update_id_key(Id_key *key) const { return update_id_key(key, id()); }
68
69 static bool update_id_key(Id_key *key, Object_id id);
70
72 return update_name_key(key, name());
73 }
74
75 static bool update_name_key(Name_key *key, const String_type &name);
76
77 bool update_aux_key(Aux_key *) const { return true; }
78
79 ~Column_statistics() override = default;
80
81 virtual const String_type &schema_name() const = 0;
82 virtual void set_schema_name(const String_type &schema_name) = 0;
83
84 virtual const String_type &table_name() const = 0;
85 virtual void set_table_name(const String_type &table_name) = 0;
86
87 virtual const String_type &column_name() const = 0;
88 virtual void set_column_name(const String_type &column_name) = 0;
89
90 virtual const histograms::Histogram *histogram() const = 0;
92
93 /**
94 Converts *this into json.
95
96 Converts all member variables that are to be included in the sdi
97 into json by transforming them appropriately and passing them to
98 the rapidjson writer provided.
99
100 @param wctx opaque context for data needed by serialization
101 @param w rapidjson writer which will perform conversion to json
102
103 */
104 virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const = 0;
105
106 /**
107 Re-establishes the state of *this by reading sdi information from
108 the rapidjson DOM subobject provided.
109
110 Cross-references encountered within this object are tracked in
111 sdictx, so that they can be updated when the entire object graph
112 has been established.
113
114 @param rctx stores book-keeping information for the
115 deserialization process
116 @param val subobject of rapidjson DOM containing json
117 representation of this object
118 */
119 virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) = 0;
120
121 /*
122 Create a unique name for a column statistic object based on the triplet
123 SCHEMA_NAME TABLE_NAME COLUMN_NAME separated with the 'Unit Separator'
124 character.
125 */
127 const String_type &table_name,
128 const String_type &column_name);
129
132 column_name());
133 }
134
135 static void create_mdl_key(const String_type &schema_name,
136 const String_type &table_name,
138
141 column_name(), key);
142 }
143
144 virtual Column_statistics *clone() const = 0;
145
146 /**
147 Allocate a new object which can serve as a placeholder for the original
148 object in the Dictionary_client's dropped registry. Such object has the
149 same keys as the original but has no other info and as result occupies
150 less memory.
151 */
153};
154
155///////////////////////////////////////////////////////////////////////////
156
157} // namespace dd
158
159#endif // DD__COLUMN_STATISTIC_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: column_statistics_impl.h:58
Definition: column_statistics.h:53
virtual const String_type & table_name() const =0
virtual const histograms::Histogram * histogram() const =0
~Column_statistics() override=default
bool update_aux_key(Aux_key *) const
Definition: column_statistics.h:77
virtual void set_schema_name(const String_type &schema_name)=0
bool update_name_key(Name_key *key) const
Definition: column_statistics.h:71
MEM_ROOT m_mem_root
MEM_ROOT on which the histogram data is allocated.
Definition: column_statistics.h:56
bool update_id_key(Id_key *key) const
Definition: column_statistics.h:67
Column_statistics_impl Impl
Definition: column_statistics.h:59
Item_name_key Name_key
Definition: column_statistics.h:63
virtual void set_column_name(const String_type &column_name)=0
tables::Column_statistics DD_table
Definition: column_statistics.h:61
Void_key Aux_key
Definition: column_statistics.h:64
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...
Column_statistics Cache_partition
Definition: column_statistics.h:60
virtual Column_statistics * clone_dropped_object_placeholder() const =0
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const =0
Converts *this into json.
void create_mdl_key(MDL_key *key) const
Definition: column_statistics.h:139
virtual void set_table_name(const String_type &table_name)=0
virtual const String_type & column_name() const =0
static void create_mdl_key(const String_type &schema_name, const String_type &table_name, const String_type &column_name, MDL_key *key)
Definition: column_statistics_impl.cc:81
virtual const String_type & schema_name() const =0
String_type create_name() const
Definition: column_statistics.h:130
virtual Column_statistics * clone() const =0
Primary_id_key Id_key
Definition: column_statistics.h:62
virtual void set_histogram(const histograms::Histogram *histogram)=0
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:48
virtual const String_type & name() const =0
Definition: object_keys.h:166
Definition: object_keys.h:77
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: object_keys.h:54
Definition: column_statistics.h:43
Histogram base class.
Definition: histogram.h:314
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
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: column_statistics.h:34
required string key
Definition: replication_asynchronous_connection_failover.proto:60
This header provides Rapidjson Type Aliases.
Metadata lock object key.
Definition: mdl.h:365
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83