MySQL 9.1.0
Source Code Documentation
column_statistics_impl.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_IMPL_INCLUDED
25#define DD__COLUMN_STATISTIC_IMPL_INCLUDED
26
27#include <stdio.h>
28#include <algorithm>
29#include <new>
30
31#include "my_alloc.h"
32#include "my_inttypes.h"
33#include "my_sys.h"
34#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_impl
35#include "sql/dd/object_id.h" // dd::Object_id
36#include "sql/dd/sdi_fwd.h"
37#include "sql/dd/string_type.h"
38#include "sql/dd/types/column_statistics.h" // dd::Column_statistics
40#include "sql/psi_memory_key.h" // key_memory_DD_column_statistics
41
42class THD;
43
44namespace dd {
45
46///////////////////////////////////////////////////////////////////////////
47
48class Open_dictionary_tables_ctx;
49class Raw_record;
50class Sdi_rcontext;
51class Sdi_wcontext;
52class Weak_object;
53class Object_table;
54
55///////////////////////////////////////////////////////////////////////////
56
58 public Column_statistics {
59 public:
63 }
64
65 private:
74
75 if (column_statistics.m_histogram != nullptr)
76 m_histogram = column_statistics.m_histogram->clone(&m_mem_root);
77 }
78
79 public:
80 const Object_table &object_table() const override;
81
83
84 bool validate() const override { return m_histogram == nullptr; }
85
86 bool store_attributes(Raw_record *r) override;
87
88 bool restore_attributes(const Raw_record &r) override;
89
90 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override;
91
92 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override;
93
94 const String_type &schema_name() const override { return m_schema_name; }
95
96 void set_schema_name(const String_type &schema_name) override {
98 }
99
100 const String_type &table_name() const override { return m_table_name; }
101
102 void set_table_name(const String_type &table_name) override {
104 }
105
106 const String_type &column_name() const override { return m_column_name; }
107
110 }
111
112 const histograms::Histogram *histogram() const override {
113 return m_histogram;
114 }
115
117 // Free any existing histogram data
119
120 // Take responsibility for the MEM_ROOT of the histogram provided
121 m_mem_root = std::move(*histogram->get_mem_root());
122 m_histogram = std::move(histogram);
123 }
124
126
127 const Entity_object_impl *impl() const override {
129 }
130
131 Object_id id() const override { return Entity_object_impl::id(); }
132
133 bool is_persistent() const override {
135 }
136
137 const String_type &name() const override {
139 }
140
141 void set_name(const String_type &name) override {
143 }
144
145 void debug_print(String_type &outb) const override {
146 char outbuf[1024];
147 sprintf(outbuf,
148 "COLUMN STATISTIC OBJECT: id= {OID: %lld}, name= %s, "
149 "schema_name= %s, table_name= %s, column_name= %s",
150 id(), name().c_str(), schema_name().c_str(), table_name().c_str(),
151 column_name().c_str());
152 outb = String_type(outbuf);
153 }
154
155 private:
160
161 Column_statistics *clone() const override {
162 return new Column_statistics_impl(*this);
163 }
164
167 placeholder->set_id(id());
168 placeholder->set_name(name());
169 /*
170 Even though schema, table and column name members are not used in keys
171 directly, they are still used to check that correct metadata locks are
172 held, so for safety we copy them as well.
173 */
174 placeholder->set_schema_name(schema_name());
175 placeholder->set_table_name(table_name());
176 placeholder->set_column_name(column_name());
177 return placeholder;
178 }
179};
180
181///////////////////////////////////////////////////////////////////////////
182
183} // namespace dd
184
185#endif // DD__COLUMN_STATISTIC_IMPL_INCLUDED
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
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
const String_type & table_name() const override
Definition: column_statistics_impl.h:100
void set_schema_name(const String_type &schema_name) override
Definition: column_statistics_impl.h:96
const Entity_object_impl * impl() const override
Definition: column_statistics_impl.h:127
Object_id id() const override
The unique dictionary object id.
Definition: column_statistics_impl.h:131
Column_statistics_impl(const Column_statistics_impl &column_statistics)
Definition: column_statistics_impl.h:66
void set_histogram(const histograms::Histogram *histogram) override
Definition: column_statistics_impl.h:116
const String_type & name() const override
Definition: column_statistics_impl.h:137
const String_type & schema_name() const override
Definition: column_statistics_impl.h:94
Entity_object_impl * impl() override
Definition: column_statistics_impl.h:125
const histograms::Histogram * histogram() const override
Definition: column_statistics_impl.h:112
bool store_attributes(Raw_record *r) override
Definition: column_statistics_impl.cc:131
bool validate() const override
Definition: column_statistics_impl.h:84
String_type m_table_name
Definition: column_statistics_impl.h:157
const String_type & column_name() const override
Definition: column_statistics_impl.h:106
bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) override
Re-establishes the state of *this by reading sdi information from the rapidjson DOM subobject provide...
Definition: column_statistics_impl.cc:174
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const override
Converts *this into json.
Definition: column_statistics_impl.cc:153
Column_statistics_impl()
Definition: column_statistics_impl.h:60
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: column_statistics_impl.cc:210
bool restore_attributes(const Raw_record &r) override
Definition: column_statistics_impl.cc:103
const histograms::Histogram * m_histogram
Definition: column_statistics_impl.h:159
void set_column_name(const String_type &column_name) override
Definition: column_statistics_impl.h:108
Column_statistics * clone() const override
Definition: column_statistics_impl.h:161
void set_table_name(const String_type &table_name) override
Definition: column_statistics_impl.h:102
String_type m_schema_name
Definition: column_statistics_impl.h:156
void set_name(const String_type &name) override
Definition: column_statistics_impl.h:141
Column_statistics * clone_dropped_object_placeholder() const override
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
Definition: column_statistics_impl.h:165
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: column_statistics_impl.h:133
void debug_print(String_type &outb) const override
Definition: column_statistics_impl.h:145
String_type m_column_name
Definition: column_statistics_impl.h:158
const Object_table & object_table() const override
Definition: column_statistics_impl.cc:204
Definition: column_statistics.h:53
MEM_ROOT m_mem_root
MEM_ROOT on which the histogram data is allocated.
Definition: column_statistics.h:56
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
void set_id(Object_id id)
Definition: entity_object_impl.h:51
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:49
const String_type & name() const override
Definition: entity_object_impl.h:60
Entity_object_impl * impl() override
Definition: entity_object_impl.h:68
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:57
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:72
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:76
Definition: raw_record.h:46
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
Histogram base class.
Definition: histogram.h:314
MEM_ROOT * get_mem_root() const
Definition: histogram.h:530
Histogram base class.
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Some integer typedefs for easier portability.
Common header for many mysys elements.
static bool column_statistics
Definition: mysqldump.cc:141
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
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
PSI_memory_key key_memory_DD_column_statistics
Definition: psi_memory_key.cc:38
This header provides Rapidjson Type Aliases.
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void Clear()
Deallocate all the RAM used.
Definition: my_alloc.cc:172