MySQL 8.0.40
Source Code Documentation
view_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef DD__VIEW_IMPL_INCLUDED
25#define DD__VIEW_IMPL_INCLUDED
26
27#include <sys/types.h>
28#include <memory>
29#include <new>
30
31#include "my_inttypes.h"
34#include "sql/dd/impl/types/abstract_table_impl.h" // dd::Abstract_table_impl
37#include "sql/dd/object_id.h"
38#include "sql/dd/string_type.h"
40#include "sql/dd/types/view.h" // dd::View
41#include "sql/dd/types/view_routine.h" // IWYU pragma: keep
42#include "sql/dd/types/view_table.h" // IWYU pragma: keep
43
44namespace dd {
45class Column;
46class Open_dictionary_tables_ctx;
47class Weak_object;
48class Object_table;
49} // namespace dd
50
51struct CHARSET_INFO;
52
53namespace dd {
54
55///////////////////////////////////////////////////////////////////////////
56
57class View_impl : public Abstract_table_impl, public View {
58 public:
59 View_impl();
60
61 ~View_impl() override = default;
62
63 public:
65
66 bool validate() const override;
67
69
71
72 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
73
74 void remove_children() override;
75
76 bool restore_attributes(const Raw_record &r) override;
77
78 bool store_attributes(Raw_record *r) override;
79
80 void debug_print(String_type &outb) const override;
81
82 public:
83 /////////////////////////////////////////////////////////////////////////
84 // enum_table_type.
85 /////////////////////////////////////////////////////////////////////////
86
87 enum_table_type type() const override { return m_type; }
88
89 /////////////////////////////////////////////////////////////////////////
90 // regular/system view flag.
91 /////////////////////////////////////////////////////////////////////////
92
93 void set_system_view(bool system_view) override {
94 m_type =
96 }
97
98 /////////////////////////////////////////////////////////////////////////
99 // collation.
100 /////////////////////////////////////////////////////////////////////////
101
104 }
105
108 }
109
112 }
113
116 }
117
118 /////////////////////////////////////////////////////////////////////////
119 // definition/utf8.
120 /////////////////////////////////////////////////////////////////////////
121
122 const String_type &definition() const override { return m_definition; }
123
124 void set_definition(const String_type &definition) override {
126 }
127
128 const String_type &definition_utf8() const override {
129 return m_definition_utf8;
130 }
131
134 }
135
136 /////////////////////////////////////////////////////////////////////////
137 // check_option.
138 /////////////////////////////////////////////////////////////////////////
139
140 enum_check_option check_option() const override { return m_check_option; }
141
144 }
145
146 /////////////////////////////////////////////////////////////////////////
147 // is_updatable.
148 /////////////////////////////////////////////////////////////////////////
149
150 bool is_updatable() const override { return m_is_updatable; }
151
152 void set_updatable(bool updatable) override { m_is_updatable = updatable; }
153
154 /////////////////////////////////////////////////////////////////////////
155 // algorithm.
156 /////////////////////////////////////////////////////////////////////////
157
158 enum_algorithm algorithm() const override { return m_algorithm; }
159
162 }
163
164 /////////////////////////////////////////////////////////////////////////
165 // security_type.
166 /////////////////////////////////////////////////////////////////////////
167
169
172 }
173
174 /////////////////////////////////////////////////////////////////////////
175 // definer.
176 /////////////////////////////////////////////////////////////////////////
177
178 const String_type &definer_user() const override { return m_definer_user; }
179
180 const String_type &definer_host() const override { return m_definer_host; }
181
182 void set_definer(const String_type &username,
183 const String_type &hostname) override {
184 m_definer_user = username;
185 m_definer_host = hostname;
186 }
187
188 /////////////////////////////////////////////////////////////////////////
189 // Explicit list of column names.
190 /////////////////////////////////////////////////////////////////////////
191
192 const Properties &column_names() const override { return m_column_names; }
193
194 Properties &column_names() override { return m_column_names; }
195
196 /////////////////////////////////////////////////////////////////////////
197 // View_table collection.
198 /////////////////////////////////////////////////////////////////////////
199
200 View_table *add_table() override;
201
202 const View_tables &tables() const override { return m_tables; }
203
204 /////////////////////////////////////////////////////////////////////////
205 // View_routine collection.
206 /////////////////////////////////////////////////////////////////////////
207
208 View_routine *add_routine() override;
209
210 const View_routines &routines() const override { return m_routines; }
211
212 // Fix "inherits ... via dominance" warnings
214 const Entity_object_impl *impl() const override {
216 }
217 Object_id id() const override { return Entity_object_impl::id(); }
218 bool is_persistent() const override {
220 }
221 const String_type &name() const override {
223 }
224 void set_name(const String_type &name) override {
226 }
227 Object_id schema_id() const override {
229 }
232 }
233 uint mysql_version_id() const override {
235 }
236 const Properties &options() const override {
238 }
240 bool set_options(const Properties &options) override {
242 }
243 bool set_options(const String_type &options_raw) override {
244 return Abstract_table_impl::set_options(options_raw);
245 }
246 ulonglong created(bool convert_time) const override {
247 return Abstract_table_impl::created(convert_time);
248 }
251 }
252 ulonglong last_altered(bool convert_time) const override {
253 return Abstract_table_impl::last_altered(convert_time);
254 }
257 }
259 bool drop_column(const String_type &name) override {
261 }
262 const Column_collection &columns() const override {
264 }
267 }
268 const Column *get_column(const String_type &name) const override {
270 }
273 }
274 enum_hidden_type hidden() const override {
276 }
279 }
280
281 private:
287
292
294
295 // Collections.
296
299
300 // References.
301
304
305 View_impl(const View_impl &src);
306 View_impl *clone() const override { return new View_impl(*this); }
307
308 // N.B.: returning dd::View from this function confuses MSVC compiler
309 // thanks to diamond inheritance.
311 View_impl *placeholder = new View_impl();
312 placeholder->set_id(id());
313 placeholder->set_schema_id(schema_id());
314 placeholder->set_name(name());
315 return placeholder;
316 }
317};
318
319///////////////////////////////////////////////////////////////////////////
320
321} // namespace dd
322
323#endif // DD__VIEW_IMPL_INCLUDED
Definition: abstract_table_impl.h:58
void set_created(ulonglong created) override
Definition: abstract_table_impl.h:132
Object_id schema_id() const override
Definition: abstract_table_impl.h:89
void set_hidden(enum_hidden_type hidden) override
Definition: abstract_table_impl.h:153
ulonglong last_altered(bool convert_time) const override
Definition: abstract_table_impl.h:138
void set_schema_id(Object_id schema_id) override
Definition: abstract_table_impl.h:91
void set_last_altered(ulonglong last_altered) override
Definition: abstract_table_impl.h:143
Column * add_column() override
Definition: abstract_table_impl.cc:269
const Column_collection & columns() const override
Definition: abstract_table_impl.h:162
const Properties & options() const override
Definition: abstract_table_impl.h:112
uint mysql_version_id() const override
Definition: abstract_table_impl.h:100
bool drop_column(const String_type &name) override
Definition: abstract_table_impl.cc:275
bool set_options(const Properties &options) override
Definition: abstract_table_impl.h:116
const Column * get_column(Object_id column_id) const
Definition: abstract_table_impl.cc:299
enum_hidden_type hidden() const override
Definition: abstract_table_impl.h:151
ulonglong created(bool convert_time) const override
Definition: abstract_table_impl.h:128
enum_hidden_type
Enumeration type which indicates whether the table is hidden, and if yes then which type of hidden ta...
Definition: abstract_table.h:103
Definition: collection.h:44
Definition: column.h:87
Definition: entity_object_impl.h:44
void set_name(const String_type &name) override
Definition: entity_object_impl.h:62
void set_id(Object_id id)
Definition: entity_object_impl.h:51
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:49
const String_type & name() const override
Definition: entity_object_impl.h:60
Entity_object_impl * impl() override
Definition: entity_object_impl.h:68
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:57
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:76
The Properties_impl class implements the Properties interface.
Definition: properties_impl.h:77
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
Definition: raw_record.h:46
Definition: view_impl.h:57
String_type m_definition
Definition: view_impl.h:288
const String_type & definition_utf8() const override
Definition: view_impl.h:128
View_impl()
Definition: view_impl.cc:64
Properties & column_names() override
Definition: view_impl.h:194
void set_updatable(bool updatable) override
Definition: view_impl.h:152
Column * add_column() override
Definition: view_impl.h:258
String_type m_definer_user
Definition: view_impl.h:290
bool is_updatable() const override
Definition: view_impl.h:150
Object_id id() const override
The unique dictionary object id.
Definition: view_impl.h:217
String_type m_definer_host
Definition: view_impl.h:291
bool m_is_updatable
Definition: view_impl.h:283
void set_system_view(bool system_view) override
Definition: view_impl.h:93
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: view_impl.cc:98
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: view_impl.cc:275
enum_table_type type() const override
Definition: view_impl.h:87
void set_definition(const String_type &definition) override
Definition: view_impl.h:124
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: view_impl.cc:117
const Properties & column_names() const override
Definition: view_impl.h:192
enum_hidden_type hidden() const override
Definition: view_impl.h:274
const String_type & name() const override
Definition: view_impl.h:221
void set_client_collation_id(Object_id client_collation_id) override
Definition: view_impl.h:106
bool drop_column(const String_type &name) override
Definition: view_impl.h:259
bool store_attributes(Raw_record *r) override
Definition: view_impl.cc:191
void set_security_type(enum_security_type security_type) override
Definition: view_impl.h:170
Column_collection * columns() override
Definition: view_impl.h:265
const String_type & definer_host() const override
Definition: view_impl.h:180
const Properties & options() const override
Definition: view_impl.h:236
void set_check_option(enum_check_option check_option) override
Definition: view_impl.h:142
const Column_collection & columns() const override
Definition: view_impl.h:262
Column * get_column(const String_type &name)
Definition: view_impl.h:271
String_type m_definition_utf8
Definition: view_impl.h:289
enum_check_option m_check_option
Definition: view_impl.h:284
void set_last_altered(ulonglong last_altered) override
Definition: view_impl.h:255
bool validate() const override
Definition: view_impl.cc:78
View_table * add_table() override
Definition: view_impl.cc:259
View_impl * clone() const override
Allocate a new object graph and invoke the copy constructor for each object.
Definition: view_impl.h:306
enum_check_option check_option() const override
Definition: view_impl.h:140
ulonglong created(bool convert_time) const override
Definition: view_impl.h:246
const String_type & definition() const override
Definition: view_impl.h:122
bool restore_attributes(const Raw_record &r) override
Definition: view_impl.cc:138
const Column * get_column(const String_type &name) const override
Definition: view_impl.h:268
Object_id m_connection_collation_id
Definition: view_impl.h:303
uint mysql_version_id() const override
Definition: view_impl.h:233
View_routines m_routines
Definition: view_impl.h:298
bool set_options(const String_type &options_raw) override
Definition: view_impl.h:243
Object_id client_collation_id() const override
Definition: view_impl.h:102
void set_algorithm(enum_algorithm algorithm) override
Definition: view_impl.h:160
View_impl * clone_dropped_object_placeholder() const override
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
Definition: view_impl.h:310
View_routine * add_routine() override
Definition: view_impl.cc:267
enum_security_type security_type() const override
Definition: view_impl.h:168
const String_type & definer_user() const override
Definition: view_impl.h:178
void set_hidden(enum_hidden_type hidden) override
Definition: view_impl.h:277
Object_id m_client_collation_id
Definition: view_impl.h:302
const View_routines & routines() const override
Definition: view_impl.h:210
ulonglong last_altered(bool convert_time) const override
Definition: view_impl.h:252
enum_algorithm m_algorithm
Definition: view_impl.h:285
void remove_children() override
Clear View columns, View_tables and View_routines collections.
Definition: view_impl.cc:129
const View_tables & tables() const override
Definition: view_impl.h:202
enum_security_type m_security_type
Definition: view_impl.h:286
Object_id connection_collation_id() const override
Definition: view_impl.h:110
enum_table_type m_type
Definition: view_impl.h:282
Entity_object_impl * impl() override
Definition: view_impl.h:213
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: view_impl.h:218
void set_schema_id(Object_id schema_id) override
Definition: view_impl.h:230
bool set_options(const Properties &options) override
Definition: view_impl.h:240
void set_definer(const String_type &username, const String_type &hostname) override
Definition: view_impl.h:182
Object_id schema_id() const override
Definition: view_impl.h:227
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: view_impl.cc:110
Properties & options() override
Definition: view_impl.h:239
Properties_impl m_column_names
Definition: view_impl.h:293
enum_algorithm algorithm() const override
Definition: view_impl.h:158
const Entity_object_impl * impl() const override
Definition: view_impl.h:214
void set_created(ulonglong created) override
Definition: view_impl.h:249
void set_name(const String_type &name) override
Definition: view_impl.h:224
~View_impl() override=default
View_tables m_tables
Definition: view_impl.h:297
void set_definition_utf8(const String_type &definition_utf8) override
Definition: view_impl.h:132
void debug_print(String_type &outb) const override
Definition: view_impl.cc:218
void set_connection_collation_id(Object_id connection_collation_id) override
Definition: view_impl.h:114
Definition: view_routine.h:42
Definition: view_table.h:42
Definition: view.h:39
enum_algorithm
Definition: view.h:56
enum_check_option
Definition: view.h:48
enum_security_type
Definition: view.h:62
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
enum_table_type
Definition: abstract_table.h:53
Definition: options.cc:49
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
Definition: m_ctype.h:385
unsigned int uint
Definition: uca9-dump.cc:75