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