MySQL  8.0.20
Source Code Documentation
dictionary_impl.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
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__DICTIONARY_IMPL_INCLUDED
24 #define DD__DICTIONARY_IMPL_INCLUDED
25 
26 #include <stddef.h>
27 #include <sys/types.h>
28 #include <string>
29 
30 #include "lex_string.h"
31 #include "sql/dd/dictionary.h" // dd::Dictionary
32 #include "sql/dd/object_id.h" // dd::Object_id
33 #include "sql/dd/string_type.h" // dd::String_type
34 #include "sql/table.h" // MYSQL_SCHEMA_NAME
35 
36 class THD;
37 
38 namespace dd {
39 class Object_table;
40 } // namespace dd
41 
42 namespace dd_schema_unittest {
43 class SchemaTest;
44 }
45 
46 namespace my_testing {
47 class DD_initializer;
48 }
49 
51 template <typename T>
53 }
54 namespace dd {
55 
56 ///////////////////////////////////////////////////////////////////////////
57 
58 enum class enum_dd_init_type;
59 
60 ///////////////////////////////////////////////////////////////////////////
61 
62 class Dictionary_impl : public Dictionary {
63  friend class dd_schema_unittest::SchemaTest;
64  friend class my_testing::DD_initializer;
65  template <typename T>
67 
68  /////////////////////////////////////////////////////////////////////////
69  // Implementation details.
70  /////////////////////////////////////////////////////////////////////////
71 
72  private:
74 
75  public:
76  static bool init(enum_dd_init_type dd_init);
77  static bool shutdown();
78 
79  static Dictionary_impl *instance();
80 
81  private:
83 
84  public:
85  virtual ~Dictionary_impl() {}
86 
87  public:
88  static uint get_target_dd_version();
89 
90  virtual uint get_actual_dd_version(THD *thd);
91 
92  static uint get_target_I_S_version();
93 
94  virtual uint get_actual_I_S_version(THD *thd);
95 
96  static uint get_target_P_S_version();
97 
98  virtual uint get_actual_P_S_version(THD *thd);
99 
100  virtual bool get_actual_ndbinfo_schema_version(THD *thd, uint *version);
101 
102  uint set_I_S_version(THD *thd, uint version);
103 
104  uint set_P_S_version(THD *thd, uint version);
105 
106  uint set_ndbinfo_schema_version(THD *thd, uint version);
107 
108  virtual const Object_table *get_dd_table(const String_type &schema_name,
109  const String_type &table_name) const;
110 
111  public:
112  virtual bool is_dd_schema_name(const String_type &schema_name) const {
113  return (schema_name == MYSQL_SCHEMA_NAME.str);
114  }
115 
116  virtual bool is_dd_table_name(const String_type &schema_name,
117  const String_type &table_name) const;
118 
119  virtual bool is_system_table_name(const String_type &schema_name,
120  const String_type &table_name) const;
121 
122  virtual int table_type_error_code(const String_type &schema_name,
123  const String_type &table_name) const;
124 
125  virtual bool is_dd_table_access_allowed(bool is_dd_internal_thread,
126  bool is_ddl_statement,
127  const char *schema_name,
128  size_t schema_length,
129  const char *table_name) const;
130 
131  virtual bool is_system_view_name(const char *schema_name,
132  const char *table_name, bool *hidden) const;
133 
134  virtual bool is_system_view_name(const char *schema_name,
135  const char *table_name) const {
136  bool hidden;
137  return is_system_view_name(schema_name, table_name, &hidden);
138  }
139 
140  public:
141  static Object_id default_catalog_id() { return DEFAULT_CATALOG_ID; }
142 
143  static Object_id dd_tablespace_id() { return DD_TABLESPACE_ID; }
144 
146  return DEFAULT_CATALOG_NAME;
147  }
148 
149  private:
153 };
154 
155 ///////////////////////////////////////////////////////////////////////////
156 
157 } // namespace dd
158 
159 #endif // DD__DICTIONARY_IMPL_INCLUDED
static Dictionary_impl * s_instance
Definition: dictionary_impl.h:73
virtual bool is_dd_schema_name(const String_type &schema_name) const
Check if the given schema name is &#39;mysql&#39;, which where the DD tables are stored.
Definition: dictionary_impl.h:112
static Object_id default_catalog_id()
Definition: dictionary_impl.h:141
const char * str
Definition: mysql_lex_string.h:40
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
bool init(enum_dd_init_type dd_init)
Initialize data dictionary upon server startup, server startup on old data directory or install data ...
Definition: dd.cc:57
static Object_id DD_TABLESPACE_ID
Definition: dictionary_impl.h:151
enum_dd_init_type
Definition: dd.h:31
Definition: dictionary_impl.h:50
Definition: dictionary_impl.h:46
static const String_type DEFAULT_CATALOG_NAME
Definition: dictionary_impl.h:152
Dictionary_impl()
Definition: dictionary_impl.h:82
virtual bool is_system_view_name(const char *schema_name, const char *table_name) const
Check if given table name is a system view name.
Definition: dictionary_impl.h:134
Main interface class enabling users to operate on data dictionary.
Definition: dictionary.h:51
bool shutdown()
Shuts down the data dictionary instance by deleting the instance of dd::Dictionary_impl* upon server ...
Definition: dd.cc:70
Definition: dictionary_impl.h:42
unsigned int uint
Definition: uca-dump.cc:29
virtual ~Dictionary_impl()
Definition: dictionary_impl.h:85
unsigned long long Object_id
Definition: object_id.h:30
bool is_system_table_name(const char *name, size_t length)
Return true if a table name matches one of the system table names.
Definition: table.cc:635
const string version("\ersion\)
static Object_id dd_tablespace_id()
Definition: dictionary_impl.h:143
This class represents all data dictionary table like mysql.tables, mysql.columns and more...
Definition: object_table.h:71
Definition: dictionary_impl.h:62
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
static Object_id DEFAULT_CATALOG_ID
Definition: dictionary_impl.h:150
static const String_type & default_catalog_name()
Definition: dictionary_impl.h:145
const Object_table & get_dd_table()
Get the Object_table instance storing the given entity object type.
Definition: dictionary_impl.cc:719
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:765
LEX_CSTRING MYSQL_SCHEMA_NAME
Definition: table.cc:130
const char * table_name
Definition: rules_table_service.cc:55