MySQL 9.1.0
Source Code Documentation
object_table_impl.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_IMPL_INCLUDED
25#define DD__OBJECT_TABLE_IMPL_INCLUDED
26
27#include "sql/dd/impl/types/object_table_definition_impl.h" // Object_table_def
28#include "sql/dd/types/object_table.h" // Object_table
29
30class THD;
31
32namespace dd {
33
34///////////////////////////////////////////////////////////////////////////
35
36class Object_table_impl : virtual public Object_table {
37 protected:
38 mutable uint m_last_dd_version;
40 mutable bool m_actual_present;
43
44 public:
45 // Enumeration of options that are used by all DD table subclasses.
46 enum class Common_option {
47 ENGINE,
48 CHARSET,
53 };
54
55 /*
56 Enumeration of indexes that are used by several DD table subclasses.
57 Some object keys will implicitly expect these indexes to have a
58 certain predefined ordinal position. Note that the enumeration is
59 the positional index of each index (starting at 0), not the ordinal
60 position of the index (starting at 1).
61 */
62 enum class Common_index { PK_ID, UK_NAME };
63
64 /*
65 Enumeration of fields that are expected by some object keys to have
66 the same ordinal position for most DD tables. The enumeration is the
67 positional index of the field (starting at 0).
68 */
69 enum class Common_field { ID };
70
71 /*
72 Constructor used for tables required by plugins. Common options are
73 not used for those.
74 */
75 Object_table_impl(const String_type &schema_name,
77 const String_type &ddl_statement)
79 m_target_def(schema_name, table_name, ddl_statement),
80 m_actual_present(false),
82 m_hidden(false) {}
83
84 /*
85 Constructor used by DD table subclasses. These will all use the
86 common options.
87 */
89
90 const String_type &name() const override {
92 }
93
95 return (m_last_dd_version != 0 ? nullptr : &m_target_def);
96 }
97
99 return (m_last_dd_version != 0 ? nullptr : &m_target_def);
100 }
101
102 void set_abandoned(uint last_dd_version) const override {
103 m_last_dd_version = last_dd_version;
104 }
105
106 bool is_abandoned() const override { return (m_last_dd_version != 0); }
107
109 return (m_actual_present ? &m_actual_def : nullptr);
110 }
111
113 const Properties &table_def_properties) const override;
114
115 virtual int field_number(int target_field_number,
116 const String_type &field_label) const;
117
118 int field_number(const String_type &field_label) const override;
119
120 bool populate(THD *) const override { return false; }
121
122 bool is_hidden() const override { return m_hidden; }
123
124 void set_hidden(bool hidden) override { m_hidden = hidden; }
125
126 ~Object_table_impl() override = default;
127};
128
129///////////////////////////////////////////////////////////////////////////
130
131} // namespace dd
132
133#endif // DD__OBJECT_TABLE_IMPL_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: object_table_definition_impl.h:44
const String_type & get_table_name() const
Definition: object_table_definition_impl.h:212
Definition: object_table_impl.h:36
Object_table_impl()
Definition: object_table_impl.cc:34
Object_table_definition_impl * target_table_definition() override
Get the target definition for the dictionary table.
Definition: object_table_impl.h:94
~Object_table_impl() override=default
Object_table_impl(const String_type &schema_name, const String_type &table_name, const String_type &ddl_statement)
Definition: object_table_impl.h:75
void set_hidden(bool hidden) override
Mark the dictionary table as hidden or visible.
Definition: object_table_impl.h:124
void set_abandoned(uint last_dd_version) const override
Mark the target definition for the dictionary table as abandoned.
Definition: object_table_impl.h:102
Common_option
Definition: object_table_impl.h:46
bool populate(THD *) const override
Execute low level code for populating the table.
Definition: object_table_impl.h:120
const Object_table_definition_impl * target_table_definition() const override
Definition: object_table_impl.h:98
bool m_hidden
Definition: object_table_impl.h:42
uint m_last_dd_version
Definition: object_table_impl.h:38
bool m_actual_present
Definition: object_table_impl.h:40
bool is_abandoned() const override
Check if the dictionary table is abandoned.
Definition: object_table_impl.h:106
Object_table_definition_impl m_actual_def
Definition: object_table_impl.h:41
Common_index
Definition: object_table_impl.h:62
const Object_table_definition_impl * actual_table_definition() const override
Get the actual definition for the dictionary table.
Definition: object_table_impl.h:108
bool set_actual_table_definition(const Properties &table_def_properties) const override
Set the actual definition for the dictionary table.
Definition: object_table_impl.cc:55
Object_table_definition_impl m_target_def
Definition: object_table_impl.h:39
Common_field
Definition: object_table_impl.h:69
virtual int field_number(int target_field_number, const String_type &field_label) const
Definition: object_table_impl.cc:61
const String_type & name() const override
Get the table name used by the target definition for the dictionary table.
Definition: object_table_impl.h:90
bool is_hidden() const override
Check if the table should be hidden.
Definition: object_table_impl.h:122
This class represents all data dictionary table like mysql.tables, mysql.columns and more.
Definition: object_table.h:72
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
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
const char * table_name
Definition: rules_table_service.cc:56