MySQL 8.0.30
Source Code Documentation
view_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2022, 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 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__VIEW_IMPL_INCLUDED
24#define DD__VIEW_IMPL_INCLUDED
25
26#include <sys/types.h>
27#include <memory>
28#include <new>
29
30#include "my_inttypes.h"
33#include "sql/dd/impl/types/abstract_table_impl.h" // dd::Abstract_table_impl
36#include "sql/dd/object_id.h"
37#include "sql/dd/string_type.h"
39#include "sql/dd/types/view.h" // dd::View
40#include "sql/dd/types/view_routine.h" // IWYU pragma: keep
41#include "sql/dd/types/view_table.h" // IWYU pragma: keep
42
43namespace dd {
44class Column;
45class Open_dictionary_tables_ctx;
46class Weak_object;
47class Object_table;
48} // namespace dd
49
50struct CHARSET_INFO;
51
52namespace dd {
53
54///////////////////////////////////////////////////////////////////////////
55
56class View_impl : public Abstract_table_impl, public View {
57 public:
58 View_impl();
59
60 ~View_impl() override = default;
61
62 public:
64
65 bool validate() const override;
66
68
70
71 bool drop_children(Open_dictionary_tables_ctx *otx) const override;
72
73 void remove_children() override;
74
75 bool restore_attributes(const Raw_record &r) override;
76
77 bool store_attributes(Raw_record *r) override;
78
79 void debug_print(String_type &outb) const override;
80
81 public:
82 /////////////////////////////////////////////////////////////////////////
83 // enum_table_type.
84 /////////////////////////////////////////////////////////////////////////
85
86 enum_table_type type() const override { return m_type; }
87
88 /////////////////////////////////////////////////////////////////////////
89 // regular/system view flag.
90 /////////////////////////////////////////////////////////////////////////
91
92 void set_system_view(bool system_view) override {
93 m_type =
95 }
96
97 /////////////////////////////////////////////////////////////////////////
98 // collation.
99 /////////////////////////////////////////////////////////////////////////
100
103 }
104
107 }
108
111 }
112
115 }
116
117 /////////////////////////////////////////////////////////////////////////
118 // definition/utf8.
119 /////////////////////////////////////////////////////////////////////////
120
121 const String_type &definition() const override { return m_definition; }
122
123 void set_definition(const String_type &definition) override {
125 }
126
127 const String_type &definition_utf8() const override {
128 return m_definition_utf8;
129 }
130
133 }
134
135 /////////////////////////////////////////////////////////////////////////
136 // check_option.
137 /////////////////////////////////////////////////////////////////////////
138
139 enum_check_option check_option() const override { return m_check_option; }
140
143 }
144
145 /////////////////////////////////////////////////////////////////////////
146 // is_updatable.
147 /////////////////////////////////////////////////////////////////////////
148
149 bool is_updatable() const override { return m_is_updatable; }
150
151 void set_updatable(bool updatable) override { m_is_updatable = updatable; }
152
153 /////////////////////////////////////////////////////////////////////////
154 // algorithm.
155 /////////////////////////////////////////////////////////////////////////
156
157 enum_algorithm algorithm() const override { return m_algorithm; }
158
161 }
162
163 /////////////////////////////////////////////////////////////////////////
164 // security_type.
165 /////////////////////////////////////////////////////////////////////////
166
168
171 }
172
173 /////////////////////////////////////////////////////////////////////////
174 // definer.
175 /////////////////////////////////////////////////////////////////////////
176
177 const String_type &definer_user() const override { return m_definer_user; }
178
179 const String_type &definer_host() const override { return m_definer_host; }
180
181 void set_definer(const String_type &username,
182 const String_type &hostname) override {
183 m_definer_user = username;
184 m_definer_host = hostname;
185 }
186
187 /////////////////////////////////////////////////////////////////////////
188 // Explicit list of column names.
189 /////////////////////////////////////////////////////////////////////////
190
191 const Properties &column_names() const override { return m_column_names; }
192
193 Properties &column_names() override { return m_column_names; }
194
195 /////////////////////////////////////////////////////////////////////////
196 // View_table collection.
197 /////////////////////////////////////////////////////////////////////////
198
199 View_table *add_table() override;
200
201 const View_tables &tables() const override { return m_tables; }
202
203 /////////////////////////////////////////////////////////////////////////
204 // View_routine collection.
205 /////////////////////////////////////////////////////////////////////////
206
207 View_routine *add_routine() override;
208
209 const View_routines &routines() const override { return m_routines; }
210
211 // Fix "inherits ... via dominance" warnings
213 const Entity_object_impl *impl() const override {
215 }
216 Object_id id() const override { return Entity_object_impl::id(); }
217 bool is_persistent() const override {
219 }
220 const String_type &name() const override {
222 }
223 void set_name(const String_type &name) override {
225 }
226 Object_id schema_id() const override {
228 }
231 }
232 uint mysql_version_id() const override {
234 }
235 const Properties &options() const override {
237 }
239 bool set_options(const Properties &options) override {
241 }
242 bool set_options(const String_type &options_raw) override {
243 return Abstract_table_impl::set_options(options_raw);
244 }
245 ulonglong created(bool convert_time) const override {
246 return Abstract_table_impl::created(convert_time);
247 }
250 }
251 ulonglong last_altered(bool convert_time) const override {
252 return Abstract_table_impl::last_altered(convert_time);
253 }
256 }
258 bool drop_column(const String_type &name) override {
260 }
261 const Column_collection &columns() const override {
263 }
266 }
267 const Column *get_column(const String_type &name) const override {
269 }
272 }
273 enum_hidden_type hidden() const override {
275 }
278 }
279
280 private:
286
291
293
294 // Collections.
295
298
299 // References.
300
303
304 View_impl(const View_impl &src);
305 View_impl *clone() const override { return new View_impl(*this); }
306
307 // N.B.: returning dd::View from this function confuses MSVC compiler
308 // thanks to diamond inheritance.
310 View_impl *placeholder = new View_impl();
311 placeholder->set_id(id());
312 placeholder->set_schema_id(schema_id());
313 placeholder->set_name(name());
314 return placeholder;
315 }
316};
317
318///////////////////////////////////////////////////////////////////////////
319
320} // namespace dd
321
322#endif // DD__VIEW_IMPL_INCLUDED
Definition: abstract_table_impl.h:57
void set_created(ulonglong created) override
Definition: abstract_table_impl.h:131
Object_id schema_id() const override
Definition: abstract_table_impl.h:88
void set_hidden(enum_hidden_type hidden) override
Definition: abstract_table_impl.h:152
ulonglong last_altered(bool convert_time) const override
Definition: abstract_table_impl.h:137
void set_schema_id(Object_id schema_id) override
Definition: abstract_table_impl.h:90
void set_last_altered(ulonglong last_altered) override
Definition: abstract_table_impl.h:142
Column * add_column() override
Definition: abstract_table_impl.cc:268
const Column_collection & columns() const override
Definition: abstract_table_impl.h:161
const Properties & options() const override
Definition: abstract_table_impl.h:111
uint mysql_version_id() const override
Definition: abstract_table_impl.h:99
bool drop_column(const String_type &name) override
Definition: abstract_table_impl.cc:274
bool set_options(const Properties &options) override
Definition: abstract_table_impl.h:115
const Column * get_column(Object_id column_id) const
Definition: abstract_table_impl.cc:298
enum_hidden_type hidden() const override
Definition: abstract_table_impl.h:150
ulonglong created(bool convert_time) const override
Definition: abstract_table_impl.h:127
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:102
Definition: collection.h:43
Definition: column.h:86
Definition: entity_object_impl.h:43
void set_name(const String_type &name) override
Definition: entity_object_impl.h:61
void set_id(Object_id id)
Definition: entity_object_impl.h:50
Object_id id() const override
The unique dictionary object id.
Definition: entity_object_impl.h:48
const String_type & name() const override
Definition: entity_object_impl.h:59
Entity_object_impl * impl() override
Definition: entity_object_impl.h:67
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: entity_object_impl.h:56
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:75
The Properties_impl class implements the Properties interface.
Definition: properties_impl.h:76
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:73
Definition: raw_record.h:45
Definition: view_impl.h:56
String_type m_definition
Definition: view_impl.h:287
const String_type & definition_utf8() const override
Definition: view_impl.h:127
View_impl()
Definition: view_impl.cc:63
Properties & column_names() override
Definition: view_impl.h:193
void set_updatable(bool updatable) override
Definition: view_impl.h:151
Column * add_column() override
Definition: view_impl.h:257
String_type m_definer_user
Definition: view_impl.h:289
bool is_updatable() const override
Definition: view_impl.h:149
Object_id id() const override
The unique dictionary object id.
Definition: view_impl.h:216
String_type m_definer_host
Definition: view_impl.h:290
bool m_is_updatable
Definition: view_impl.h:282
void set_system_view(bool system_view) override
Definition: view_impl.h:92
bool restore_children(Open_dictionary_tables_ctx *otx) override
Definition: view_impl.cc:97
static void register_tables(Open_dictionary_tables_ctx *otx)
Definition: view_impl.cc:274
enum_table_type type() const override
Definition: view_impl.h:86
void set_definition(const String_type &definition) override
Definition: view_impl.h:123
bool drop_children(Open_dictionary_tables_ctx *otx) const override
Definition: view_impl.cc:116
const Properties & column_names() const override
Definition: view_impl.h:191
enum_hidden_type hidden() const override
Definition: view_impl.h:273
const String_type & name() const override
Definition: view_impl.h:220
void set_client_collation_id(Object_id client_collation_id) override
Definition: view_impl.h:105
bool drop_column(const String_type &name) override
Definition: view_impl.h:258
bool store_attributes(Raw_record *r) override
Definition: view_impl.cc:190
void set_security_type(enum_security_type security_type) override
Definition: view_impl.h:169
Column_collection * columns() override
Definition: view_impl.h:264
const String_type & definer_host() const override
Definition: view_impl.h:179
const Properties & options() const override
Definition: view_impl.h:235
void set_check_option(enum_check_option check_option) override
Definition: view_impl.h:141
const Column_collection & columns() const override
Definition: view_impl.h:261
Column * get_column(const String_type &name)
Definition: view_impl.h:270
String_type m_definition_utf8
Definition: view_impl.h:288
enum_check_option m_check_option
Definition: view_impl.h:283
void set_last_altered(ulonglong last_altered) override
Definition: view_impl.h:254
bool validate() const override
Definition: view_impl.cc:77
View_table * add_table() override
Definition: view_impl.cc:258
View_impl * clone() const override
Allocate a new object graph and invoke the copy constructor for each object.
Definition: view_impl.h:305
enum_check_option check_option() const override
Definition: view_impl.h:139
ulonglong created(bool convert_time) const override
Definition: view_impl.h:245
const String_type & definition() const override
Definition: view_impl.h:121
bool restore_attributes(const Raw_record &r) override
Definition: view_impl.cc:137
const Column * get_column(const String_type &name) const override
Definition: view_impl.h:267
Object_id m_connection_collation_id
Definition: view_impl.h:302
uint mysql_version_id() const override
Definition: view_impl.h:232
View_routines m_routines
Definition: view_impl.h:297
bool set_options(const String_type &options_raw) override
Definition: view_impl.h:242
Object_id client_collation_id() const override
Definition: view_impl.h:101
void set_algorithm(enum_algorithm algorithm) override
Definition: view_impl.h:159
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:309
View_routine * add_routine() override
Definition: view_impl.cc:266
enum_security_type security_type() const override
Definition: view_impl.h:167
const String_type & definer_user() const override
Definition: view_impl.h:177
void set_hidden(enum_hidden_type hidden) override
Definition: view_impl.h:276
Object_id m_client_collation_id
Definition: view_impl.h:301
const View_routines & routines() const override
Definition: view_impl.h:209
ulonglong last_altered(bool convert_time) const override
Definition: view_impl.h:251
enum_algorithm m_algorithm
Definition: view_impl.h:284
void remove_children() override
Clear View columns, View_tables and View_routines collections.
Definition: view_impl.cc:128
const View_tables & tables() const override
Definition: view_impl.h:201
enum_security_type m_security_type
Definition: view_impl.h:285
Object_id connection_collation_id() const override
Definition: view_impl.h:109
enum_table_type m_type
Definition: view_impl.h:281
Entity_object_impl * impl() override
Definition: view_impl.h:212
bool is_persistent() const override
Is dictionary object persistent in dictionary tables ?
Definition: view_impl.h:217
void set_schema_id(Object_id schema_id) override
Definition: view_impl.h:229
bool set_options(const Properties &options) override
Definition: view_impl.h:239
void set_definer(const String_type &username, const String_type &hostname) override
Definition: view_impl.h:181
Object_id schema_id() const override
Definition: view_impl.h:226
bool store_children(Open_dictionary_tables_ctx *otx) override
Definition: view_impl.cc:109
Properties & options() override
Definition: view_impl.h:238
Properties_impl m_column_names
Definition: view_impl.h:292
enum_algorithm algorithm() const override
Definition: view_impl.h:157
const Entity_object_impl * impl() const override
Definition: view_impl.h:213
void set_created(ulonglong created) override
Definition: view_impl.h:248
void set_name(const String_type &name) override
Definition: view_impl.h:223
~View_impl() override=default
View_tables m_tables
Definition: view_impl.h:296
void set_definition_utf8(const String_type &definition_utf8) override
Definition: view_impl.h:131
void debug_print(String_type &outb) const override
Definition: view_impl.cc:217
void set_connection_collation_id(Object_id connection_collation_id) override
Definition: view_impl.h:113
Definition: view_routine.h:41
Definition: view_table.h:41
Definition: view.h:38
enum_algorithm
Definition: view.h:53
enum_check_option
Definition: view.h:47
enum_security_type
Definition: view.h:57
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
unsigned long long Object_id
Definition: object_id.h:30
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
enum_table_type
Definition: abstract_table.h:52
Definition: options.cc:48
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:85
Definition: m_ctype.h:354
unsigned int uint
Definition: uca-dump.cc:29