MySQL  8.0.18
Source Code Documentation
dictionary_impl.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2018, 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 {
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 
93 
94  virtual uint get_actual_I_S_version(THD *thd);
95 
97 
98  virtual uint get_actual_P_S_version(THD *thd);
99 
101 
103 
104  virtual const Object_table *get_dd_table(const String_type &schema_name,
105  const String_type &table_name) const;
106 
107  public:
108  virtual bool is_dd_schema_name(const String_type &schema_name) const {
109  return (schema_name == MYSQL_SCHEMA_NAME.str);
110  }
111 
112  virtual bool is_dd_table_name(const String_type &schema_name,
113  const String_type &table_name) const;
114 
115  virtual bool is_system_table_name(const String_type &schema_name,
116  const String_type &table_name) const;
117 
118  virtual int table_type_error_code(const String_type &schema_name,
119  const String_type &table_name) const;
120 
121  virtual bool is_dd_table_access_allowed(bool is_dd_internal_thread,
122  bool is_ddl_statement,
123  const char *schema_name,
124  size_t schema_length,
125  const char *table_name) const;
126 
127  virtual bool is_system_view_name(const char *schema_name,
128  const char *table_name, bool *hidden) const;
129 
130  virtual bool is_system_view_name(const char *schema_name,
131  const char *table_name) const {
132  bool hidden;
133  return is_system_view_name(schema_name, table_name, &hidden);
134  }
135 
136  public:
138 
140 
142  return DEFAULT_CATALOG_NAME;
143  }
144 
145  private:
149 };
150 
151 ///////////////////////////////////////////////////////////////////////////
152 
153 } // namespace dd
154 
155 #endif // DD__DICTIONARY_IMPL_INCLUDED
virtual bool is_dd_table_name(const String_type &schema_name, const String_type &table_name) const
Check if given table name is a dictionary table name.
Definition: dictionary_impl.cc:263
static Dictionary_impl * s_instance
Definition: dictionary_impl.h:73
friend class dd_schema_unittest::SchemaTest
Definition: dictionary_impl.h:63
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:108
virtual uint get_actual_dd_version(THD *thd)
Definition: dictionary_impl.cc:196
static Object_id default_catalog_id()
Definition: dictionary_impl.h:137
static Dictionary_impl * instance()
Definition: dictionary_impl.cc:90
const char * str
Definition: mysql_lex_string.h:40
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
static bool init(enum_dd_init_type dd_init)
Definition: dictionary_impl.cc:98
static Object_id DD_TABLESPACE_ID
Definition: dictionary_impl.h:147
enum_dd_init_type
Definition: dd.h:31
friend class my_testing::DD_initializer
Definition: dictionary_impl.h:64
Definition: dictionary_impl.h:50
Definition: dictionary_impl.h:46
static const String_type DEFAULT_CATALOG_NAME
Definition: dictionary_impl.h:148
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:130
virtual bool is_dd_table_access_allowed(bool is_dd_internal_thread, bool is_ddl_statement, const char *schema_name, size_t schema_length, const char *table_name) const
Check if given table name can be accessed by the given thread type.
Definition: dictionary_impl.cc:303
virtual uint get_actual_I_S_version(THD *thd)
Definition: dictionary_impl.cc:214
static uint get_target_dd_version()
Definition: dictionary_impl.cc:192
Main interface class enabling users to operate on data dictionary.
Definition: dictionary.h:51
uint set_I_S_version(THD *thd, uint version)
Definition: dictionary_impl.cc:226
Definition: dictionary_impl.h:42
static uint get_target_I_S_version()
Definition: dictionary_impl.cc:208
virtual int table_type_error_code(const String_type &schema_name, const String_type &table_name) const
Get the error code representing the type name string for a dictionary or system table.
Definition: dictionary_impl.cc:293
unsigned int uint
Definition: uca-dump.cc:29
virtual ~Dictionary_impl()
Definition: dictionary_impl.h:85
static uint get_target_P_S_version()
Definition: dictionary_impl.cc:232
unsigned long long Object_id
Definition: object_id.h:30
const string version("\ersion\)
static Object_id dd_tablespace_id()
Definition: dictionary_impl.h:139
static bool shutdown()
Definition: dictionary_impl.cc:179
This class represents all data dictionary table like mysql.tables, mysql.columns and more...
Definition: object_table.h:71
Definition: dictionary_impl.h:62
virtual const Object_table * get_dd_table(const String_type &schema_name, const String_type &table_name) const
Get dictionary object for a given dictionary table name.
Definition: dictionary_impl.cc:254
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
static Object_id DEFAULT_CATALOG_ID
Definition: dictionary_impl.h:146
static const String_type & default_catalog_name()
Definition: dictionary_impl.h:141
virtual uint get_actual_P_S_version(THD *thd)
Definition: dictionary_impl.cc:236
uint set_P_S_version(THD *thd, uint version)
Definition: dictionary_impl.cc:248
virtual bool is_system_view_name(const char *schema_name, const char *table_name, bool *hidden) const
Check if given table name is a system view name.
Definition: dictionary_impl.cc:357
virtual bool is_system_table_name(const String_type &schema_name, const String_type &table_name) const
Check if given table name is a system table name.
Definition: dictionary_impl.cc:280
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
LEX_CSTRING MYSQL_SCHEMA_NAME
Definition: table.cc:130
const char * table_name
Definition: rules_table_service.cc:55