1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/* Copyright (c) 2014, 2025, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is designed to work with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have either included with
the program or referenced in the documentation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifndef DD__OBJECT_TABLE_INCLUDED
#define DD__OBJECT_TABLE_INCLUDED
#include "my_inttypes.h"
#include "sql/dd/string_type.h" // dd::String_type
class THD;
namespace dd {
///////////////////////////////////////////////////////////////////////////
class Object_table_definition;
class Properties;
///////////////////////////////////////////////////////////////////////////
/**
This class represents all data dictionary table like mysql.tables,
mysql.columns and more. This is the base class of all the classes
defined in sql/dd/impl/tables/ headers. This class is also the base
class of tables requested by the DDSE and by plugins.
The server code should contain a Object_table subclass for each DD table
which is a target table for at least one of the supported DD versions (i.e.,
the DD versions from which this server can upgrade). So even if a previous
DD version stops using a DD table, the later servers which can upgrade need
to keep the Object_table subclass for that table. The motivation for that
is to be able to recognize the table, and to be able to remove it.
Instances of this class will contain one or two table definitions, depending
on the context:
- The actual table definition reflects the persistently stored DD table,
i.e., what is reflected in the persistently stored mete data.
- The target table definition reflects the DD table which the server
is using during normal operation.
If the actual DD version is different from the target DD version, upgrade
is required. The actual table definition is used only in situations where
we have an upgrade or downgrade.
@note This class may be inherited along different paths
for some subclasses due to the diamond shaped
inheritance hierarchy; thus, direct subclasses
must inherit this class virtually.
*/
class Object_table {
public:
/**
Allocate a new Object_table instance on the heap.
The new instance has the predefined options that all DD tables share:
ENGINE=INNODB
DEFAULT CHARSET=utf8mb3
COLLATE=utf8mb3_bin
ROW_FORMAT=DYNAMIC
STATS_PERSISTENT=0
TABLESPACE=mysql
@note The object is owned by the caller.
@returns pointer to new Object_table instance.
*/
static Object_table *create_object_table();
/**
Get the table name used by the target definition for the dictionary table.
@return table name.
*/
virtual const String_type &name() const = 0;
/**
Get the target definition for the dictionary table.
@note There are const and non-const variants.
@return Pointer to the definition of the table.
*/
virtual Object_table_definition *target_table_definition() = 0;
virtual const Object_table_definition *target_table_definition() const = 0;
/**
Mark the target definition for the dictionary table as abandoned.
@param last_dd_version Last version where this object table was used.
*/
virtual void set_abandoned(uint last_dd_version) const = 0;
/**
Check if the dictionary table is abandoned.
@return true if the table is abandoned.
*/
virtual bool is_abandoned() const = 0;
/**
Get the actual definition for the dictionary table.
The actual definition is the definition which is used by a DD table
which is stored persistently. Normally, for an ordinary running server,
the actual table definitions are equal to the target table definitions.
In an upgrade context, they may differ.
@return Pointer to the definition of the table.
*/
virtual const Object_table_definition *actual_table_definition() const = 0;
/**
Set the actual definition for the dictionary table.
@param table_def_properties Actual table definition represented as
a set of properties.
@return false if no error.
*/
virtual bool set_actual_table_definition(
const Properties &table_def_properties) const = 0;
/**
Get the field ordinal position in the object table.
@return Integer ordinal position.
*/
virtual int field_number(const String_type &field_label) const = 0;
/**
Execute low level code for populating the table.
@return Boolean operation outcome, false if success.
*/
virtual bool populate(THD *thd) const = 0;
/**
Check if the table should be hidden.
Most of Object tables (alias DD tables) are hidden from users,
but some of them are expected to be visible (not hidden) to user and be
able to update them, e.g., innodb_index_stats/innodb_table_stats.
@returns true if the table should be hidden.
*/
virtual bool is_hidden() const = 0;
/**
Mark the dictionary table as hidden or visible.
@param hidden Set to 'true' if the table should be hidden.
*/
virtual void set_hidden(bool hidden) = 0;
public:
virtual ~Object_table() = default;
};
///////////////////////////////////////////////////////////////////////////
} // namespace dd
#endif // DD__OBJECT_TABLE_INCLUDED
|