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