MySQL 8.4.3
Source Code Documentation
object_table.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__OBJECT_TABLE_INCLUDED
25#define DD__OBJECT_TABLE_INCLUDED
26
27#include "my_inttypes.h"
28#include "sql/dd/string_type.h" // dd::String_type
29
30class THD;
31
32namespace dd {
33
34///////////////////////////////////////////////////////////////////////////
35
36class Object_table_definition;
37class Properties;
38
39///////////////////////////////////////////////////////////////////////////
40
41/**
42 This class represents all data dictionary table like mysql.tables,
43 mysql.columns and more. This is the base class of all the classes
44 defined in sql/dd/impl/tables/ headers. This class is also the base
45 class of tables requested by the DDSE and by plugins.
46
47 The server code should contain a Object_table subclass for each DD table
48 which is a target table for at least one of the supported DD versions (i.e.,
49 the DD versions from which this server can upgrade). So even if a previous
50 DD version stops using a DD table, the later servers which can upgrade need
51 to keep the Object_table subclass for that table. The motivation for that
52 is to be able to recognize the table, and to be able to remove it.
53
54 Instances of this class will contain one or two table definitions, depending
55 on the context:
56
57 - The actual table definition reflects the persistently stored DD table,
58 i.e., what is reflected in the persistently stored mete data.
59 - The target table definition reflects the DD table which the server
60 is using during normal operation.
61
62 If the actual DD version is different from the target DD version, upgrade
63 is required. The actual table definition is used only in situations where
64 we have an upgrade or downgrade.
65
66 @note This class may be inherited along different paths
67 for some subclasses due to the diamond shaped
68 inheritance hierarchy; thus, direct subclasses
69 must inherit this class virtually.
70*/
71
73 public:
74 /**
75 Allocate a new Object_table instance on the heap.
76
77 The new instance has the predefined options that all DD tables share:
78
79 ENGINE=INNODB
80 DEFAULT CHARSET=utf8mb3
81 COLLATE=utf8mb3_bin
82 ROW_FORMAT=DYNAMIC
83 STATS_PERSISTENT=0
84 TABLESPACE=mysql
85
86 @note The object is owned by the caller.
87
88 @returns pointer to new Object_table instance.
89 */
91
92 /**
93 Get the table name used by the target definition for the dictionary table.
94
95 @return table name.
96 */
97 virtual const String_type &name() const = 0;
98
99 /**
100 Get the target definition for the dictionary table.
101
102 @note There are const and non-const variants.
103
104 @return Pointer to the definition of the table.
105 */
107
109
110 /**
111 Mark the target definition for the dictionary table as abandoned.
112
113 @param last_dd_version Last version where this object table was used.
114 */
115 virtual void set_abandoned(uint last_dd_version) const = 0;
116
117 /**
118 Check if the dictionary table is abandoned.
119
120 @return true if the table is abandoned.
121 */
122 virtual bool is_abandoned() const = 0;
123
124 /**
125 Get the actual definition for the dictionary table.
126
127 The actual definition is the definition which is used by a DD table
128 which is stored persistently. Normally, for an ordinary running server,
129 the actual table definitions are equal to the target table definitions.
130 In an upgrade context, they may differ.
131
132 @return Pointer to the definition of the table.
133 */
135
136 /**
137 Set the actual definition for the dictionary table.
138
139 @param table_def_properties Actual table definition represented as
140 a set of properties.
141
142 @return false if no error.
143 */
145 const Properties &table_def_properties) const = 0;
146
147 /**
148 Get the field ordinal position in the object table.
149
150 @return Integer ordinal position.
151 */
152 virtual int field_number(const String_type &field_label) const = 0;
153
154 /**
155 Execute low level code for populating the table.
156
157 @return Boolean operation outcome, false if success.
158 */
159 virtual bool populate(THD *thd) const = 0;
160
161 /**
162 Check if the table should be hidden.
163
164 Most of Object tables (alias DD tables) are hidden from users,
165 but some of them are expected to be visible (not hidden) to user and be
166 able to update them, e.g., innodb_index_stats/innodb_table_stats.
167
168 @returns true if the table should be hidden.
169 */
170 virtual bool is_hidden() const = 0;
171
172 /**
173 Mark the dictionary table as hidden or visible.
174
175 @param hidden Set to 'true' if the table should be hidden.
176 */
177 virtual void set_hidden(bool hidden) = 0;
178
179 public:
180 virtual ~Object_table() = default;
181};
182
183///////////////////////////////////////////////////////////////////////////
184
185} // namespace dd
186
187#endif // DD__OBJECT_TABLE_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
The purpose of this interface is to enable retrieving the SQL statements necessary to create and popu...
Definition: object_table_definition.h:48
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:72
virtual bool is_abandoned() const =0
Check if the dictionary table is abandoned.
virtual const Object_table_definition * actual_table_definition() const =0
Get the actual definition for the dictionary table.
virtual const String_type & name() const =0
Get the table name used by the target definition for the dictionary table.
virtual void set_abandoned(uint last_dd_version) const =0
Mark the target definition for the dictionary table as abandoned.
virtual int field_number(const String_type &field_label) const =0
Get the field ordinal position in the object table.
virtual ~Object_table()=default
static Object_table * create_object_table()
Allocate a new Object_table instance on the heap.
Definition: object_table_impl.cc:87
virtual bool is_hidden() const =0
Check if the table should be hidden.
virtual const Object_table_definition * target_table_definition() const =0
virtual bool populate(THD *thd) const =0
Execute low level code for populating the table.
virtual void set_hidden(bool hidden)=0
Mark the dictionary table as hidden or visible.
virtual Object_table_definition * target_table_definition()=0
Get the target definition for the dictionary table.
virtual bool set_actual_table_definition(const Properties &table_def_properties) const =0
Set the actual definition for the dictionary table.
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
Some integer typedefs for easier portability.
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51