MySQL 8.3.0
Source Code Documentation
object_table.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2023, 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 ENGINE=INNODB
79 DEFAULT CHARSET=utf8mb3
80 COLLATE=utf8mb3_bin
81 ROW_FORMAT=DYNAMIC
82 STATS_PERSISTENT=0
83 TABLESPACE=mysql
84
85 @note The object is owned by the caller.
86
87 @returns pointer to new Object_table instance.
88 */
90
91 /**
92 Get the table name used by the target definition for the dictionary table.
93
94 @return table name.
95 */
96 virtual const String_type &name() const = 0;
97
98 /**
99 Get the target definition for the dictionary table.
100
101 @note There are const and non-const variants.
102
103 @return Pointer to the definition of the table.
104 */
106
108
109 /**
110 Mark the target definition for the dictionary table as abandoned.
111
112 @param last_dd_version Last version where this object table was used.
113 */
114 virtual void set_abandoned(uint last_dd_version) const = 0;
115
116 /**
117 Check if the dictionary table is abandoned.
118
119 @return true if the table is abandoned.
120 */
121 virtual bool is_abandoned() const = 0;
122
123 /**
124 Get the actual definition for the dictionary table.
125
126 The actual definition is the definition which is used by a DD table
127 which is stored persistently. Normally, for an ordinary running server,
128 the actual table definitions are equal to the target table definitions.
129 In an upgrade context, they may differ.
130
131 @return Pointer to the definition of the table.
132 */
134
135 /**
136 Set the actual definition for the dictionary table.
137
138 @param table_def_properties Actual table definition represented as
139 a set of properties.
140
141 @return false if no error.
142 */
144 const Properties &table_def_properties) const = 0;
145
146 /**
147 Get the field ordinal position in the object table.
148
149 @return Integer ordinal position.
150 */
151 virtual int field_number(const String_type &field_label) const = 0;
152
153 /**
154 Execute low level code for populating the table.
155
156 @return Boolean operation outcome, false if success.
157 */
158 virtual bool populate(THD *thd) const = 0;
159
160 /**
161 Check if the table should be hidden.
162
163 Most of Object tables (alias DD tables) are hidden from users,
164 but some of them are expected to be visible (not hidden) to user and be
165 able to update them, e.g., innodb_index_stats/innodb_table_stats.
166
167 @returns true if the table should be hidden.
168 */
169 virtual bool is_hidden() const = 0;
170
171 /**
172 Mark the dictionary table as hidden or visible.
173
174 @param hidden Set to 'true' if the table should be hidden.
175 */
176 virtual void set_hidden(bool hidden) = 0;
177
178 public:
179 virtual ~Object_table() = default;
180};
181
182///////////////////////////////////////////////////////////////////////////
183
184} // namespace dd
185
186#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:35
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:86
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