MySQL 8.0.30
Source Code Documentation
abstract_table_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2022, 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 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__ABSTRACT_TABLE_IMPL_INCLUDED
24#define DD__ABSTRACT_TABLE_IMPL_INCLUDED
25
26#include <stddef.h>
27#include <sys/types.h>
28#include <memory> // std::unique_ptr
29
30#include "my_dbug.h"
31#include "my_inttypes.h"
32#include "sql/dd/impl/properties_impl.h" // Properties_impl
34#include "sql/dd/impl/types/entity_object_impl.h" // dd::Entity_object_impl
36#include "sql/dd/object_id.h"
37#include "sql/dd/properties.h"
38#include "sql/dd/sdi_fwd.h"
39#include "sql/dd/string_type.h"
40#include "sql/dd/types/abstract_table.h" // dd::Abstract_table
41#include "sql/dd/types/column.h" // IWYU pragma: keep
42#include "sql/sql_time.h" // gmt_time_to_local_time
43
44class Time_zone;
45
46namespace dd {
47
48///////////////////////////////////////////////////////////////////////////
49
50class Object_table;
51class Open_dictionary_tables_ctx;
52class Sdi_rcontext;
53class Sdi_wcontext;
54class Weak_object;
55
57 virtual public Abstract_table {
58 public:
59 const Object_table &object_table() const override;
60
62
63 bool validate() const override;
64
66
68
69 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
70
71 bool restore_attributes(const Raw_record &r) override;
72
73 bool store_attributes(Raw_record *r) override;
74
75 protected:
76 void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const;
77
78 bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val);
79
80 public:
81 void debug_print(String_type &outb) const override;
82
83 public:
84 /////////////////////////////////////////////////////////////////////////
85 // schema.
86 /////////////////////////////////////////////////////////////////////////
87
88 Object_id schema_id() const override { return m_schema_id; }
89
91
92 /////////////////////////////////////////////////////////////////////////
93 // mysql_version_id.
94 // Primarily intended for debugging, but can be used as a last-resort
95 // version check for SE data and other items, but in general other
96 // mechanisms should be preferred.
97 /////////////////////////////////////////////////////////////////////////
98
99 uint mysql_version_id() const override { return m_mysql_version_id; }
100
101 // TODO: Commented out as it is not needed as we either use the value
102 // assigned by the constructor, or restore a value from the TABLES
103 // table. It may be necessary when implementing upgrade.
104 // virtual void set_mysql_version_id(uint mysql_version_id)
105 //{ m_mysql_version_id= mysql_version_id; }
106
107 /////////////////////////////////////////////////////////////////////////
108 // options.
109 /////////////////////////////////////////////////////////////////////////
110
111 const Properties &options() const override { return m_options; }
112
113 Properties &options() override { return m_options; }
114
115 bool set_options(const Properties &options) override {
117 }
118
119 bool set_options(const String_type &options_raw) override {
120 return m_options.insert_values(options_raw);
121 }
122
123 /////////////////////////////////////////////////////////////////////////
124 // created.
125 /////////////////////////////////////////////////////////////////////////
126
127 ulonglong created(bool convert_time) const override {
128 return convert_time ? gmt_time_to_local_time(m_created) : m_created;
129 }
130
132
133 /////////////////////////////////////////////////////////////////////////
134 // last altered.
135 /////////////////////////////////////////////////////////////////////////
136
137 ulonglong last_altered(bool convert_time) const override {
138 return convert_time ? gmt_time_to_local_time(m_last_altered)
140 }
141
144 }
145
146 /////////////////////////////////////////////////////////////////////////
147 // hidden.
148 /////////////////////////////////////////////////////////////////////////
149
150 enum_hidden_type hidden() const override { return m_hidden; }
151
153
154 /////////////////////////////////////////////////////////////////////////
155 // Column collection.
156 /////////////////////////////////////////////////////////////////////////
157
158 Column *add_column() override;
159 bool drop_column(const String_type &name) override;
160
161 const Column_collection &columns() const override { return m_columns; }
162
163 Column_collection *columns() override { return &m_columns; }
164
165 const Column *get_column(Object_id column_id) const;
166
167 Column *get_column(Object_id column_id);
168
169 const Column *get_column(const String_type &name) const override;
170
172
173 // Fix "inherits ... via dominance" warnings
175 const Entity_object_impl *impl() const override {
177 }
178 Object_id id() const override { return Entity_object_impl::id(); }
179 bool is_persistent() const override {
181 }
182 const String_type &name() const override {
184 }
185 void set_name(const String_type &name) override {
187 }
188
189 protected:
191
192 ~Abstract_table_impl() override = default;
193
194 private:
195 // Fields.
196
198
199 // TODO-POST-MERGE-TO-TRUNK:
200 // Add new field m_last_checked_for_upgrade
201
204
206
208
209 // References to tightly-coupled objects.
210
212
213 // References to other objects.
214
216
217 protected:
219};
220
221///////////////////////////////////////////////////////////////////////////
222
223} // namespace dd
224
225#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:48
Definition: abstract_table_impl.h:57
bool store_attributes(Raw_record *r) override
Definition: abstract_table_impl.cc:159
void set_created(ulonglong created) override
Definition: abstract_table_impl.h:131
Object_id m_schema_id
Definition: abstract_table_impl.h:215
Properties_impl m_options
Definition: abstract_table_impl.h:207
Properties & options() override
Definition: abstract_table_impl.h:113
const String_type & name() const override
Definition: abstract_table_impl.h:182
Object_id schema_id() const override
Definition: abstract_table_impl.h:88
void debug_print(String_type &outb) const override
Definition: abstract_table_impl.cc:237
bool validate() const override
Definition: abstract_table_impl.cc:108
Column_collection * columns() override
Definition: abstract_table_impl.h:163
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: abstract_table_impl.cc:340
uint m_mysql_version_id
Definition: abstract_table_impl.h:197
void set_hidden(enum_hidden_type hidden) override
Definition: abstract_table_impl.h:152
ulonglong last_altered(bool convert_time) const override
Definition: abstract_table_impl.h:137
void set_schema_id(Object_id schema_id) override
Definition: abstract_table_impl.h:90
Object_id id() const override
The unique dictionary object id.
Definition: abstract_table_impl.h:178
void set_last_altered(ulonglong last_altered) override
Definition: abstract_table_impl.h:142
bool restore_attributes(const Raw_record &r) override
Definition: abstract_table_impl.cc:140
Column * add_column() override
Definition: abstract_table_impl.cc:268
const Object_table & object_table() const override
Definition: abstract_table_impl.cc:334
void set_name(const String_type &name) override
Definition: abstract_table_impl.h:185
const Column_collection & columns() const override
Definition: abstract_table_impl.h:161
const Properties & options() const override
Definition: abstract_table_impl.h:111
Column_collection m_columns
Definition: abstract_table_impl.h:211
enum_hidden_type m_hidden
Definition: abstract_table_impl.h:205
uint mysql_version_id() const override
Definition: abstract_table_impl.h:99
Entity_object_impl * impl() override
Definition: abstract_table_impl.h:174
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: abstract_table_impl.cc:120
void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const
Definition: abstract_table_impl.cc:201
bool drop_column(const String_type &name) override
Definition: abstract_table_impl.cc:274
bool set_options(const Properties &options) override
Definition: abstract_table_impl.h:115
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: abstract_table_impl.cc:127
~Abstract_table_impl() override=default
const Column * get_column(Object_id column_id) const
Definition: abstract_table_impl.cc:298
enum_hidden_type hidden() const override
Definition: abstract_table_impl.h:150
bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val)
Definition: abstract_table_impl.cc:215
Abstract_table_impl()
Definition: abstract_table_impl.cc:97
ulonglong m_last_altered
Definition: abstract_table_impl.h:203
ulonglong created(bool convert_time) const override
Definition: abstract_table_impl.h:127
ulonglong m_created
Definition: abstract_table_impl.h:202
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: abstract_table_impl.h:179
const Entity_object_impl * impl() const override
Definition: abstract_table_impl.h:175
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: abstract_table_impl.cc:133
bool set_options(const String_type &options_raw) override
Definition: abstract_table_impl.h:119
Abstract base class for tables and views.
Definition: abstract_table.h:68
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:102
Definition: collection.h:43
Definition: column.h:86
Definition: entity_object_impl.h:43
void set_name(const String_type &name) override
Definition: entity_object_impl.h:61
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:48
const String_type & name() const override
Definition: entity_object_impl.h:59
Entity_object_impl * impl() override
Definition: entity_object_impl.h:67
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:56
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:71
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:75
The Properties_impl class implements the Properties interface.
Definition: properties_impl.h:76
bool insert_values(const Properties &properties) override
Insert key/value pairs from a different property object.
Definition: properties_impl.cc:103
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:73
Definition: raw_record.h:45
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:230
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:128
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:840
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
RJ_Writer Sdi_writer
Alias for the rapidjson Writer type to use in serialization.
Definition: sdi_fwd.h:63
unsigned long long Object_id
Definition: object_id.h:30
rapidjson::GenericValue< RJ_Encoding, RJ_Allocator > RJ_Value
Definition: sdi_fwd.h:48
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Definition: options.cc:48
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
This header provides Rapidjson Type Aliases.
Interface for server time utilities.
unsigned int uint
Definition: uca-dump.cc:29