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