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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
|
/* 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 */
#include "sql/dd/impl/system_registry.h"
#include "sql/dd/impl/system_views/administrable_role_authorizations.h"
#include "sql/dd/impl/system_views/applicable_roles.h" // Applicable_roles
#include "sql/dd/impl/system_views/character_sets.h" // Character_sets
#include "sql/dd/impl/system_views/check_constraints.h" // Check_constraints
#include "sql/dd/impl/system_views/collation_charset_applicability.h" // Collati...
#include "sql/dd/impl/system_views/collations.h" // Collations
#include "sql/dd/impl/system_views/column_statistics.h" // Column_statistics
#include "sql/dd/impl/system_views/columns.h" // Columns
#include "sql/dd/impl/system_views/columns_extensions.h" // Columns_extensions
#include "sql/dd/impl/system_views/enabled_roles.h" // Enabled_roles
#include "sql/dd/impl/system_views/events.h" // Events
#include "sql/dd/impl/system_views/files.h" // Files
#include "sql/dd/impl/system_views/innodb_datafiles.h" // Innodb_datafiles
#include "sql/dd/impl/system_views/innodb_fields.h" // Innodb_fields
#include "sql/dd/impl/system_views/innodb_foreign.h" // Innodb_foreign
#include "sql/dd/impl/system_views/innodb_foreign_cols.h" // Innodb_foreign_cols
#include "sql/dd/impl/system_views/innodb_tablespaces_brief.h" // Innodb_tablespace_brief
#include "sql/dd/impl/system_views/key_column_usage.h" // key_column_usage
#include "sql/dd/impl/system_views/keywords.h" // keywords
#include "sql/dd/impl/system_views/parameters.h" // Parameters
#include "sql/dd/impl/system_views/partitions.h" // Partitions
#include "sql/dd/impl/system_views/referential_constraints.h" // Referential_con...
#include "sql/dd/impl/system_views/resource_groups.h" // Resource_groups
#include "sql/dd/impl/system_views/role_column_grants.h" // Role_column_grant
#include "sql/dd/impl/system_views/role_routine_grants.h" // Role_routine_gran
#include "sql/dd/impl/system_views/role_table_grants.h" // Role_table_grants
#include "sql/dd/impl/system_views/routines.h" // Routines
#include "sql/dd/impl/system_views/schemata.h" // Schemata
#include "sql/dd/impl/system_views/schemata_extensions.h" //Schemata_extensions
#include "sql/dd/impl/system_views/st_geometry_columns.h" // st_geometry_columns
#include "sql/dd/impl/system_views/st_spatial_reference_systems.h" // St_spatial...
#include "sql/dd/impl/system_views/st_units_of_measure.h" // St_units_of_measure
#include "sql/dd/impl/system_views/statistics.h" // Statistics
#include "sql/dd/impl/system_views/table_constraints.h" // Table_constraints
#include "sql/dd/impl/system_views/tables.h" // Tables
#include "sql/dd/impl/system_views/triggers.h" // Triggers
#include "sql/dd/impl/system_views/user_attributes.h"
#include "sql/dd/impl/system_views/view_routine_usage.h" // View_routine_usage
#include "sql/dd/impl/system_views/view_table_usage.h" // View_table_usage
#include "sql/dd/impl/system_views/views.h" // Views
#include "sql/dd/impl/system_views/table_constraints_extensions.h" // Table_constraints_extensions
#include "sql/dd/impl/system_views/tables_extensions.h" // Tables_extensions
#include "sql/dd/impl/system_views/tablespaces_extensions.h" // Tablespaces_extensions
#include "sql/dd/impl/tables/catalogs.h" // Catalog
#include "sql/dd/impl/tables/character_sets.h" // Character_sets
#include "sql/dd/impl/tables/check_constraints.h" // Check_constraints
#include "sql/dd/impl/tables/collations.h" // Collations
#include "sql/dd/impl/tables/column_statistics.h" // Column_statistics
#include "sql/dd/impl/tables/column_type_elements.h" // Column_type_elements
#include "sql/dd/impl/tables/columns.h" // Columns
#include "sql/dd/impl/tables/dd_properties.h" // DD_properties
#include "sql/dd/impl/tables/events.h" // Events
#include "sql/dd/impl/tables/foreign_key_column_usage.h" // Foreign_key_column_usage
#include "sql/dd/impl/tables/foreign_keys.h" // Foreign_keys
#include "sql/dd/impl/tables/index_column_usage.h" // Index_column_usage
#include "sql/dd/impl/tables/index_partitions.h" // Index_partitions
#include "sql/dd/impl/tables/index_stats.h" // Index_stats
#include "sql/dd/impl/tables/indexes.h" // Indexes
#include "sql/dd/impl/tables/parameter_type_elements.h" // Parameter_type_elements
#include "sql/dd/impl/tables/parameters.h" // Parameters
#include "sql/dd/impl/tables/resource_groups.h" // Resource_groups
#include "sql/dd/impl/tables/routines.h" // Routines
#include "sql/dd/impl/tables/schemata.h" // Schemata
#include "sql/dd/impl/tables/spatial_reference_systems.h" // Spatial_reference_systems
#include "sql/dd/impl/tables/table_partition_values.h" // Table_partition_values
#include "sql/dd/impl/tables/table_partitions.h" // Table_partitions
#include "sql/dd/impl/tables/table_stats.h" // Table_stats
#include "sql/dd/impl/tables/tables.h" // Tables
#include "sql/dd/impl/tables/tablespace_files.h" // Tablespace_files
#include "sql/dd/impl/tables/tablespaces.h" // Tablespaces
#include "sql/dd/impl/tables/triggers.h" // Triggers
#include "sql/dd/impl/tables/view_routine_usage.h" // View_routine_usage
#include "sql/dd/impl/tables/view_table_usage.h" // View_table_usage
#include "sql/table.h" // MYSQL_SYSTEM_SCHEMA
using namespace dd::tables;
///////////////////////////////////////////////////////////////////////////
namespace {
template <typename X>
void register_table(dd::System_tables::Types type) {
dd::System_tables::instance()->add(
MYSQL_SCHEMA_NAME.str, X::instance().name(), type, &X::instance());
}
void register_table(const dd::String_type table,
dd::System_tables::Types type) {
dd::System_tables::instance()->add(MYSQL_SCHEMA_NAME.str, table, type,
nullptr);
}
template <typename X>
void register_view(dd::System_views::Types type) {
DBUG_EXECUTE_IF("test_i_s_metadata_version", {
if (X::view_name() == "EVENTS") return;
});
dd::System_views::instance()->add(INFORMATION_SCHEMA_NAME.str,
X::instance().name(), type, &X::instance());
}
} // namespace
namespace dd {
System_tables *System_tables::instance() {
static System_tables s_instance;
return &s_instance;
}
System_views *System_views::instance() {
static System_views s_instance;
return &s_instance;
}
System_tablespaces *System_tablespaces::instance() {
static System_tablespaces s_instance;
return &s_instance;
}
/*
Initialize the System_tables registry with the INERT DD
tables.
*/
void System_tables::add_inert_dd_tables() {
// Se header file for explanation of table categories.
dd::System_tables::Types inert = dd::System_tables::Types::INERT;
register_table<DD_properties>(inert);
}
/*
Initialize the System_tables registry with the non-INERT DD
tables. All actual tables should have an entry in the
System_tables registry, except in the case of a minor
downgrade. Thus, the System_tables registry should contain
all tables from all supported versions. Tables that are
abandoned should be marked as such, see below.
*/
void System_tables::add_remaining_dd_tables() {
// Se header file for explanation of table categories.
dd::System_tables::Types core = dd::System_tables::Types::CORE;
dd::System_tables::Types second = dd::System_tables::Types::SECOND;
dd::System_tables::Types system = dd::System_tables::Types::SYSTEM;
register_table<Catalogs>(core);
register_table<Character_sets>(core);
register_table<Check_constraints>(core);
register_table<Collations>(core);
register_table<dd::tables::Column_statistics>(core);
register_table<Column_type_elements>(core);
register_table<Columns>(core);
register_table<Events>(second);
register_table<Foreign_key_column_usage>(core);
register_table<Foreign_keys>(core);
register_table<Index_column_usage>(core);
register_table<Index_partitions>(core);
register_table<Index_stats>(second);
register_table<Indexes>(core);
register_table<Parameter_type_elements>(second);
register_table<Parameters>(second);
register_table<Resource_groups>(core);
register_table<Routines>(second);
register_table<Schemata>(core);
register_table<Spatial_reference_systems>(second);
register_table<Table_partition_values>(core);
register_table<Table_partitions>(core);
register_table<Table_stats>(second);
register_table<Tables>(core);
register_table<Tablespace_files>(core);
register_table<Tablespaces>(core);
register_table<Triggers>(core);
register_table<View_routine_usage>(core);
register_table<View_table_usage>(core);
/*
Mark abandoned tables. E.g., if done as shown below, note that when
the last version becomes unsupported, we will get a build error here
that makes sure the abandoned table will not be left unnoticed. When
that happens, the source code for the table can be removed:
Collations::instance().set_abandoned(bootstrap::DD_VERSION_80004);
*/
register_table("backup_history", system);
register_table("backup_progress", system);
register_table("backup_sbt_history", system);
register_table("columns_priv", system);
register_table("component", system);
register_table("db", system);
register_table("default_roles", system);
register_table("engine_cost", system);
register_table("func", system);
register_table("global_grants", system);
register_table("gtid_executed", system);
register_table("help_category", system);
register_table("help_keyword", system);
register_table("help_relation", system);
register_table("help_topic", system);
register_table("ndb_binlog_index", system);
register_table("plugin", system);
register_table("password_history", system);
register_table("procs_priv", system);
register_table("proxies_priv", system);
register_table("replication_asynchronous_connection_failover", system);
register_table("replication_asynchronous_connection_failover_managed",
system);
register_table("replication_group_member_actions", system);
register_table("replication_group_configuration_version", system);
register_table("role_edges", system);
register_table("servers", system);
register_table("server_cost", system);
register_table("slave_master_info", system);
register_table("slave_master_info_backup", system);
register_table("slave_worker_info", system);
register_table("slave_relay_log_info", system);
register_table("tables_priv", system);
register_table("time_zone", system);
register_table("time_zone_name", system);
register_table("time_zone_leap_second", system);
register_table("time_zone_transition", system);
register_table("time_zone_transition_type", system);
register_table("user", system);
/*
MTR tests expects following tables to be created in the 'mysql' tablespace.
So tables are listed here.
TODO: Try to re-write test cases and remove these tables from here.
*/
register_table("temp_user", system);
register_table("tmp_user", system);
register_table("user_backup", system);
}
void System_views::init() {
// Register system views with the server.
dd::System_views::Types is = dd::System_views::Types::INFORMATION_SCHEMA;
dd::System_views::Types non_dd_based_is =
dd::System_views::Types::NON_DD_BASED_INFORMATION_SCHEMA;
register_view<dd::system_views::Enabled_roles>(non_dd_based_is);
register_view<dd::system_views::Applicable_roles>(non_dd_based_is);
register_view<dd::system_views::Administrable_role_authorizations>(
non_dd_based_is);
register_view<dd::system_views::Character_sets>(is);
register_view<dd::system_views::Check_constraints>(is);
register_view<dd::system_views::Collations>(is);
register_view<dd::system_views::Collation_charset_applicability>(is);
register_view<dd::system_views::Columns>(is);
register_view<dd::system_views::Columns_extensions>(is);
register_view<dd::system_views::Column_statistics>(is);
register_view<dd::system_views::Events>(is);
register_view<dd::system_views::Files>(is);
register_view<dd::system_views::Innodb_datafiles>(is);
register_view<dd::system_views::Innodb_foreign>(is);
register_view<dd::system_views::Innodb_foreign_cols>(is);
register_view<dd::system_views::Innodb_fields>(is);
register_view<dd::system_views::Innodb_tablespaces_brief>(is);
register_view<dd::system_views::Key_column_usage>(is);
register_view<dd::system_views::Keywords>(is);
register_view<dd::system_views::Parameters>(is);
register_view<dd::system_views::Partitions>(is);
register_view<dd::system_views::Referential_constraints>(is);
register_view<dd::system_views::Resource_groups>(is);
register_view<dd::system_views::Role_column_grants>(non_dd_based_is);
register_view<dd::system_views::Role_routine_grants>(non_dd_based_is);
register_view<dd::system_views::Role_table_grants>(non_dd_based_is);
register_view<dd::system_views::Routines>(is);
register_view<dd::system_views::Schemata>(is);
register_view<dd::system_views::Schemata_extensions>(is);
register_view<dd::system_views::Show_statistics>(is);
register_view<dd::system_views::St_spatial_reference_systems>(is);
register_view<dd::system_views::St_units_of_measure>(is);
register_view<dd::system_views::St_geometry_columns>(is);
register_view<dd::system_views::Statistics>(is);
register_view<dd::system_views::Table_constraints>(is);
register_view<dd::system_views::Table_constraints_extensions>(is);
register_view<dd::system_views::Tables>(is);
register_view<dd::system_views::Tables_extensions>(is);
register_view<dd::system_views::Tablespaces_extensions>(is);
register_view<dd::system_views::Triggers>(is);
register_view<dd::system_views::View_routine_usage>(is);
register_view<dd::system_views::View_table_usage>(is);
register_view<dd::system_views::Views>(is);
register_view<dd::system_views::User_attributes>(non_dd_based_is);
}
} // namespace dd
|