MySQL 8.0.39
Source Code Documentation
abstract_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__ABSTRACT_TABLE_INCLUDED
25#define DD__ABSTRACT_TABLE_INCLUDED
26
27#include "my_inttypes.h"
28#include "sql/dd/collection.h" // dd::Collection
29#include "sql/dd/object_id.h" // dd::Object_id
30#include "sql/dd/types/entity_object.h" // dd::Entity_object
31
32namespace dd {
33
34///////////////////////////////////////////////////////////////////////////
35
36class Abstract_table_impl;
37class Column;
38class Item_name_key;
39class Primary_id_key;
40class Properties;
41class Se_private_id_key;
42
43namespace tables {
44class Tables;
45}
46
47///////////////////////////////////////////////////////////////////////////
48
49/////////////////////////////////////////////////////////////////////////
50// enum_table_type.
51/////////////////////////////////////////////////////////////////////////
52
53enum class enum_table_type {
58};
59
60/**
61 Abstract base class for tables and views.
62
63 @note This class may be inherited along different paths
64 for some subclasses due to the diamond shaped
65 inheritance hierarchy; thus, direct subclasses
66 must inherit this class virtually.
67*/
68
69class Abstract_table : virtual public Entity_object {
70 public:
78
79 // We need a set of functions to update a preallocated key.
80 virtual bool update_id_key(Id_key *key) const {
81 return update_id_key(key, id());
82 }
83
84 static bool update_id_key(Id_key *key, Object_id id);
85
86 virtual bool update_name_key(Name_key *key) const {
87 return update_name_key(key, schema_id(), name());
88 }
89
91 const String_type &name);
92
93 virtual bool update_aux_key(Aux_key *) const { return true; }
94
95 public:
96 ~Abstract_table() override = default;
97
98 public:
99 /**
100 Enumeration type which indicates whether the table is hidden,
101 and if yes then which type of hidden table it is.
102 */
104 /* Normal, user-visible table. */
106 /* Hidden. System (e.g. data-dictionary) table. */
108 /*
109 Hidden. Table which is implicitly created and dropped by SE.
110 For example, InnoDB's auxiliary table for FTS.
111 */
113 /*
114 Hidden. Temporary table created by ALTER TABLE implementation.
115 */
117 };
118
119 /////////////////////////////////////////////////////////////////////////
120 // schema.
121 /////////////////////////////////////////////////////////////////////////
122
123 virtual Object_id schema_id() const = 0;
125
126 /////////////////////////////////////////////////////////////////////////
127 // mysql_version_id.
128 /////////////////////////////////////////////////////////////////////////
129
130 virtual uint mysql_version_id() const = 0;
131 // virtual void set_mysql_version_id(uint mysql_version_id) = 0;
132
133 /////////////////////////////////////////////////////////////////////////
134 // options.
135 /////////////////////////////////////////////////////////////////////////
136
137 virtual const Properties &options() const = 0;
138 virtual Properties &options() = 0;
139 virtual bool set_options(const Properties &options) = 0;
140 virtual bool set_options(const String_type &options_raw) = 0;
141
142 /////////////////////////////////////////////////////////////////////////
143 // created.
144 /////////////////////////////////////////////////////////////////////////
145
146 virtual ulonglong created(bool convert_time) const = 0;
147 virtual void set_created(ulonglong created) = 0;
148
149 /////////////////////////////////////////////////////////////////////////
150 // last altered.
151 /////////////////////////////////////////////////////////////////////////
152
153 virtual ulonglong last_altered(bool convert_time) const = 0;
155
156 virtual enum_table_type type() const = 0;
157
158 /////////////////////////////////////////////////////////////////////////
159 // hidden.
160 /////////////////////////////////////////////////////////////////////////
161
162 virtual enum_hidden_type hidden() const = 0;
164
165 /////////////////////////////////////////////////////////////////////////
166 // Column collection.
167 /////////////////////////////////////////////////////////////////////////
168
169 virtual Column *add_column() = 0;
170 virtual bool drop_column(const String_type &name) = 0;
171
172 virtual const Column_collection &columns() const = 0;
173
175
176 virtual const Column *get_column(const String_type &name) const = 0;
177
178 /**
179 Allocate a new object graph and invoke the copy constructor for
180 each object.
181
182 @return pointer to dynamically allocated copy
183 */
184 virtual Abstract_table *clone() const = 0;
185
186 /**
187 Allocate a new object which can serve as a placeholder for the original
188 object in the Dictionary_client's dropped registry. Such object has the
189 same keys as the original but has no other info and as result occupies
190 less memory.
191 */
193};
194
195///////////////////////////////////////////////////////////////////////////
196} // namespace dd
197
198#endif // DD__ABSTRACT_TABLE_INCLUDED
Definition: abstract_table_impl.h:58
Abstract base class for tables and views.
Definition: abstract_table.h:69
virtual const Properties & options() const =0
virtual Column_collection * columns()=0
virtual uint mysql_version_id() const =0
Abstract_table_impl Impl
Definition: abstract_table.h:71
virtual Column * add_column()=0
virtual bool set_options(const Properties &options)=0
Collection< Column * > Column_collection
Definition: abstract_table.h:77
virtual Abstract_table * clone_dropped_object_placeholder() const =0
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
virtual bool update_name_key(Name_key *key) const
Definition: abstract_table.h:86
Se_private_id_key Aux_key
Definition: abstract_table.h:76
virtual bool update_id_key(Id_key *key) const
Definition: abstract_table.h:80
virtual void set_created(ulonglong created)=0
virtual bool set_options(const String_type &options_raw)=0
~Abstract_table() override=default
virtual void set_schema_id(Object_id schema_id)=0
virtual ulonglong created(bool convert_time) const =0
virtual enum_table_type type() const =0
virtual const Column * get_column(const String_type &name) const =0
Primary_id_key Id_key
Definition: abstract_table.h:74
virtual ulonglong last_altered(bool convert_time) const =0
Item_name_key Name_key
Definition: abstract_table.h:75
tables::Tables DD_table
Definition: abstract_table.h:73
virtual Abstract_table * clone() const =0
Allocate a new object graph and invoke the copy constructor for each object.
virtual enum_hidden_type hidden() const =0
virtual bool update_aux_key(Aux_key *) const
Definition: abstract_table.h:93
Abstract_table Cache_partition
Definition: abstract_table.h:72
virtual const Column_collection & columns() const =0
virtual bool drop_column(const String_type &name)=0
virtual Object_id schema_id() const =0
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
@ HT_HIDDEN_SYSTEM
Definition: abstract_table.h:107
@ HT_HIDDEN_SE
Definition: abstract_table.h:112
@ HT_HIDDEN_DDL
Definition: abstract_table.h:116
@ HT_VISIBLE
Definition: abstract_table.h:105
virtual void set_hidden(enum_hidden_type hidden)=0
virtual Properties & options()=0
virtual void set_last_altered(ulonglong last_altered)=0
Definition: collection.h:44
Definition: column.h:87
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:48
virtual const String_type & name() const =0
Definition: object_keys.h:166
Definition: object_keys.h:77
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
Definition: object_keys.h:219
Definition: tables.h:47
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
unsigned long long Object_id
Definition: object_id.h:31
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
enum_table_type
Definition: abstract_table.h:53
Definition: options.cc:49
required string key
Definition: replication_asynchronous_connection_failover.proto:60
unsigned int uint
Definition: uca9-dump.cc:75