MySQL 9.4.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
dd_view.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2025, 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_INCLUDED
25#define DD_VIEW_INCLUDED
26
27#include "sql/dd/string_type.h"
28
29struct MEM_ROOT;
30class THD;
31class Table_ref;
32enum class enum_view_type;
33
34namespace dd {
35class Schema;
36class View;
37
38/**
39 Store view metadata in the data-dictionary.
40
41 @param thd Thread handle.
42 @param schema Schema where the view should be created.
43 @param view Table_ref element describing the view.
44
45 @note The caller must rollback both statement and transaction on failure,
46 before any further accesses to DD. This is because such a failure
47 might be caused by a deadlock, which requires rollback before any
48 other operations on SE (including reads using attachable transactions)
49 can be done.
50
51 @retval false On Success.
52 @retval true On Failure.
53*/
54bool create_view(THD *thd, const dd::Schema &schema, Table_ref *view);
55
56/**
57 Update view metadata in dd.views.
58
59 @param thd Thread handle.
60 @param new_view View object that should be updated.
61 @param view Table_ref element describing the new view.
62
63 @note The caller must rollback both statement and transaction on failure,
64 before any further accesses to DD. This is because such a failure
65 might be caused by a deadlock, which requires rollback before any
66 other operations on SE (including reads using attachable transactions)
67 can be done.
68
69 @retval false On success.
70 @retval true On failure.
71*/
72bool update_view(THD *thd, dd::View *new_view, Table_ref *view);
73
74/** Read view metadata from dd.views into Table_ref */
75bool read_view(Table_ref *view, const dd::View &view_ref, MEM_ROOT *mem_root);
76
77/**
78 Update view status(valid/invalid) value in dd.views.options.
79
80 @param thd Thread handle.
81 @param schema_name Schema name.
82 @param view_name View name.
83 @param status View status(valid/invalid).
84 @param commit_dd_changes Indicates whether changes to DD need to be
85 committed.
86
87 @note In case when commit_dd_changes is false, the caller must rollback
88 both statement and transaction on failure, before any further
89 accesses to DD. This is because such a failure might be caused by
90 a deadlock, which requires rollback before any other operations on
91 SE (including reads using attachable transactions) can be done.
92 If case when commit_dd_changes is true this function will handle
93 transaction rollback itself.
94
95 @retval false On Success.
96 @retval true On Failure.
97*/
98bool update_view_status(THD *thd, const char *schema_name,
99 const char *view_name, bool status,
100 bool commit_dd_changes);
101
102/**
103 * @brief Get the view type from type stored in DD table.
104 *
105 * @param dd_view_type View type stored in the DD table.
106 *
107 * @return enum_view_type view type.
108 */
110} // namespace dd
111#endif // DD_VIEW_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2931
Definition: schema.h:64
Definition: view.h:39
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
borrowable::session_track::Schema< true > Schema
Definition: classic_protocol_session_track.h:288
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
bool update_view(THD *thd, dd::View *new_view, Table_ref *view)
Update view metadata in dd.views.
Definition: dd_view.cc:623
bool update_view_status(THD *thd, const char *schema_name, const char *view_name, bool status, bool commit_dd_changes)
Update view status(valid/invalid) value in dd.views.options.
Definition: dd_view.cc:750
enum_view_type get_sql_view_type(String_type dd_view_type)
Get the view type from type stored in DD table.
Definition: dd_view.cc:243
bool read_view(Table_ref *view, const dd::View &view_obj, MEM_ROOT *mem_root)
Read view metadata from dd.views into Table_ref.
Definition: dd_view.cc:658
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
bool create_view(THD *thd, const dd::Schema &schema, Table_ref *view)
Store view metadata in the data-dictionary.
Definition: dd_view.cc:638
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
enum_view_type
Definition: table.h:2611
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83