MySQL 8.0.40
Source Code Documentation
abstract_table_impl.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__ABSTRACT_TABLE_IMPL_INCLUDED
25#define DD__ABSTRACT_TABLE_IMPL_INCLUDED
26
27#include <stddef.h>
28#include <sys/types.h>
29#include <memory> // std::unique_ptr
30
31#include "my_dbug.h"
32#include "my_inttypes.h"
33#include "sql/dd/impl/properties_impl.h" // Properties_impl
35#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_impl
37#include "sql/dd/object_id.h"
38#include "sql/dd/properties.h"
39#include "sql/dd/sdi_fwd.h"
40#include "sql/dd/string_type.h"
41#include "sql/dd/types/abstract_table.h" // dd::Abstract_table
42#include "sql/dd/types/column.h" // IWYU pragma: keep
43#include "sql/sql_time.h" // gmt_time_to_local_time
44
45class Time_zone;
46
47namespace dd {
48
49///////////////////////////////////////////////////////////////////////////
50
51class Object_table;
52class Open_dictionary_tables_ctx;
53class Sdi_rcontext;
54class Sdi_wcontext;
55class Weak_object;
56
58 virtual public Abstract_table {
59 public:
60 const Object_table &object_table() const override;
61
63
64 bool validate() const override;
65
67
69
70 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
71
72 bool restore_attributes(const Raw_record &r) override;
73
74 bool store_attributes(Raw_record *r) override;
75
76 protected:
77 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const;
78
79 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val);
80
81 public:
82 void debug_print(String_type &outb) const override;
83
84 public:
85 /////////////////////////////////////////////////////////////////////////
86 // schema.
87 /////////////////////////////////////////////////////////////////////////
88
89 Object_id schema_id() const override { return m_schema_id; }
90
92
93 /////////////////////////////////////////////////////////////////////////
94 // mysql_version_id.
95 // Primarily intended for debugging, but can be used as a last-resort
96 // version check for SE data and other items, but in general other
97 // mechanisms should be preferred.
98 /////////////////////////////////////////////////////////////////////////
99
100 uint mysql_version_id() const override { return m_mysql_version_id; }
101
102 // TODO: Commented out as it is not needed as we either use the value
103 // assigned by the constructor, or restore a value from the TABLES
104 // table. It may be necessary when implementing upgrade.
105 // virtual void set_mysql_version_id(uint mysql_version_id)
106 //{ m_mysql_version_id= mysql_version_id; }
107
108 /////////////////////////////////////////////////////////////////////////
109 // options.
110 /////////////////////////////////////////////////////////////////////////
111
112 const Properties &options() const override { return m_options; }
113
114 Properties &options() override { return m_options; }
115
116 bool set_options(const Properties &options) override {
118 }
119
120 bool set_options(const String_type &options_raw) override {
121 return m_options.insert_values(options_raw);
122 }
123
124 /////////////////////////////////////////////////////////////////////////
125 // created.
126 /////////////////////////////////////////////////////////////////////////
127
128 ulonglong created(bool convert_time) const override {
129 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
130 }
131
133
134 /////////////////////////////////////////////////////////////////////////
135 // last altered.
136 /////////////////////////////////////////////////////////////////////////
137
138 ulonglong last_altered(bool convert_time) const override {
139 return convert_time ? gmt_time_to_local_time(m_last_altered)
141 }
142
145 }
146
147 /////////////////////////////////////////////////////////////////////////
148 // hidden.
149 /////////////////////////////////////////////////////////////////////////
150
151 enum_hidden_type hidden() const override { return m_hidden; }
152
154
155 /////////////////////////////////////////////////////////////////////////
156 // Column collection.
157 /////////////////////////////////////////////////////////////////////////
158
159 Column *add_column() override;
160 bool drop_column(const String_type &name) override;
161
162 const Column_collection &columns() const override { return m_columns; }
163
164 Column_collection *columns() override { return &m_columns; }
165
166 const Column *get_column(Object_id column_id) const;
167
168 Column *get_column(Object_id column_id);
169
170 const Column *get_column(const String_type &name) const override;
171
173
174 // Fix "inherits ... via dominance" warnings
176 const Entity_object_impl *impl() const override {
178 }
179 Object_id id() const override { return Entity_object_impl::id(); }
180 bool is_persistent() const override {
182 }
183 const String_type &name() const override {
185 }
186 void set_name(const String_type &name) override {
188 }
189
190 protected:
192
193 ~Abstract_table_impl() override = default;
194
195 private:
196 // Fields.
197
199
200 // TODO-POST-MERGE-TO-TRUNK:
201 // Add new field m_last_checked_for_upgrade
202
205
207
209
210 // References to tightly-coupled objects.
211
213
214 // References to other objects.
215
217
218 protected:
220};
221
222///////////////////////////////////////////////////////////////////////////
223
224} // namespace dd
225
226#endif // DD__ABSTRACT_TABLE_IMPL_INCLUDED
This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t co...
Definition: tztime.h:49
Definition: abstract_table_impl.h:58
bool store_attributes(Raw_record *r) override
Definition: abstract_table_impl.cc:160
void set_created(ulonglong created) override
Definition: abstract_table_impl.h:132
Object_id m_schema_id
Definition: abstract_table_impl.h:216
Properties_impl m_options
Definition: abstract_table_impl.h:208
Properties & options() override
Definition: abstract_table_impl.h:114
const String_type & name() const override
Definition: abstract_table_impl.h:183
Object_id schema_id() const override
Definition: abstract_table_impl.h:89
void debug_print(String_type &outb) const override
Definition: abstract_table_impl.cc:238
bool validate() const override
Definition: abstract_table_impl.cc:109
Column_collection * columns() override
Definition: abstract_table_impl.h:164
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: abstract_table_impl.cc:341
uint m_mysql_version_id
Definition: abstract_table_impl.h:198
void set_hidden(enum_hidden_type hidden) override
Definition: abstract_table_impl.h:153
ulonglong last_altered(bool convert_time) const override
Definition: abstract_table_impl.h:138
void set_schema_id(Object_id schema_id) override
Definition: abstract_table_impl.h:91
Object_id id() const override
The unique dictionary object id.
Definition: abstract_table_impl.h:179
void set_last_altered(ulonglong last_altered) override
Definition: abstract_table_impl.h:143
bool restore_attributes(const Raw_record &r) override
Definition: abstract_table_impl.cc:141
Column * add_column() override
Definition: abstract_table_impl.cc:269
const Object_table & object_table() const override
Definition: abstract_table_impl.cc:335
void set_name(const String_type &name) override
Definition: abstract_table_impl.h:186
const Column_collection & columns() const override
Definition: abstract_table_impl.h:162
const Properties & options() const override
Definition: abstract_table_impl.h:112
Column_collection m_columns
Definition: abstract_table_impl.h:212
enum_hidden_type m_hidden
Definition: abstract_table_impl.h:206
uint mysql_version_id() const override
Definition: abstract_table_impl.h:100
Entity_object_impl * impl() override
Definition: abstract_table_impl.h:175
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: abstract_table_impl.cc:121
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const
Definition: abstract_table_impl.cc:202
bool drop_column(const String_type &name) override
Definition: abstract_table_impl.cc:275
bool set_options(const Properties &options) override
Definition: abstract_table_impl.h:116
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: abstract_table_impl.cc:128
~Abstract_table_impl() override=default
const Column * get_column(Object_id column_id) const
Definition: abstract_table_impl.cc:299
enum_hidden_type hidden() const override
Definition: abstract_table_impl.h:151
bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val)
Definition: abstract_table_impl.cc:216
Abstract_table_impl()
Definition: abstract_table_impl.cc:98
ulonglong m_last_altered
Definition: abstract_table_impl.h:204
ulonglong created(bool convert_time) const override
Definition: abstract_table_impl.h:128
ulonglong m_created
Definition: abstract_table_impl.h:203
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: abstract_table_impl.h:180
const Entity_object_impl * impl() const override
Definition: abstract_table_impl.h:176
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: abstract_table_impl.cc:134
bool set_options(const String_type &options_raw) override
Definition: abstract_table_impl.h:120
Abstract base class for tables and views.
Definition: abstract_table.h:69
enum_hidden_type
Enumeration type which indicates whether the table is hidden, and if yes then which type of hidden ta...
Definition: abstract_table.h:103
Definition: collection.h:44
Definition: column.h:87
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
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
The Properties_impl class implements the Properties interface.
Definition: properties_impl.h:77
bool insert_values(const Properties &properties) override
Insert key/value pairs from a different property object.
Definition: properties_impl.cc:104
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
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
ulonglong gmt_time_to_local_time(ulonglong gmt_time)
This function gets GMT time and adds value of time_zone to get the local time.
Definition: sql_time.cc:841
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
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: options.cc:49
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
This header provides Rapidjson Type Aliases.
Interface for server time utilities.
unsigned int uint
Definition: uca9-dump.cc:75