MySQL  8.0.17
Source Code Documentation
dd_sql_view.h
Go to the documentation of this file.
1 #ifndef DD_SQL_VIEW_INCLUDED
2 #define DD_SQL_VIEW_INCLUDED
3 /* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License, version 2.0,
7  as published by the Free Software Foundation.
8 
9  This program is also distributed with certain software (including
10  but not limited to OpenSSL) that is licensed under separate terms,
11  as designated in a particular file or component or in included license
12  documentation. The authors of MySQL hereby grant you an additional
13  permission to link the program and your derivative works with the
14  separately licensed software that they have included with MySQL.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License, version 2.0, for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24 
25 #include "mysql/psi/psi_base.h"
26 #include "prealloced_array.h"
27 
28 class THD;
29 class sp_name;
30 struct TABLE_LIST;
31 
32 /**
33  Guard class which allows to invalidate TDC entries for specific tables/views.
34 
35  We use it to get rid of TABLE_SHARE objects corresponding to tables/views
36  which definitions are not committed yet (and possibly won't be!).
37 */
38 
40  public:
44 
46 
47  private:
50 };
51 
52 /**
53  Update metadata of views referencing the table.
54 
55  @param thd Thread handle.
56  @param db_name Database name.
57  @param table_name Update metadata of views referencing
58  this table.
59  @param commit_dd_changes Indicates whether changes to DD need
60  to be committed.
61  @param[in,out] uncommitted_tables Helper class to store list of views
62  which shares need to be removed from
63  TDC if we fail to commit changes to
64  DD. Only used if commit_dd_changes
65  is false.
66 
67  @note In case when commit_dd_changes is false, the caller must rollback
68  both statement and transaction on failure, before any further
69  accesses to DD. This is because such a failure might be caused by
70  a deadlock, which requires rollback before any other operations on
71  SE (including reads using attachable transactions) can be done.
72  If case when commit_dd_changes is true this function will handle
73  transaction rollback itself.
74 
75  @retval false Success.
76  @retval true Failure.
77 */
78 
80  THD *thd, const char *db_name, const char *table_name,
81  bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables);
82 
83 /**
84  Update metadata of views referencing the table.
85 
86  @param thd Thread handle.
87  @param table Update metadata of views referencing
88  this table.
89  @param commit_dd_changes Indicates whether changes to DD need
90  to be committed.
91  @param[in,out] uncommitted_tables Helper class to store list of views
92  which shares need to be removed from
93  TDC if we fail to commit changes to
94  DD. Only used if commit_dd_changes
95  is false.
96 
97  @note In case when commit_dd_changes is false, the caller must rollback
98  both statement and transaction on failure, before any further
99  accesses to DD. This is because such a failure might be caused by
100  a deadlock, which requires rollback before any other operations on
101  SE (including reads using attachable transactions) can be done.
102  If case when commit_dd_changes is true this function will handle
103  transaction rollback itself.
104 
105  @retval false Success.
106  @retval true Failure.
107 */
108 
110  THD *thd, const TABLE_LIST *table, bool commit_dd_changes,
111  Uncommitted_tables_guard *uncommitted_tables);
112 
113 /**
114  Update metadata of views referencing "table" being renamed and views
115  referencing (if there any) new table name "new_db.new_table_name".
116 
117  @param thd Thread handle.
118  @param table Update metadata of views referencing this
119  table.
120  @param new_db New db name set in the rename operation.
121  @param new_table_name New table name set in the rename
122  @param commit_dd_changes Indicates whether changes to DD need
123  to be committed.
124  @param[in,out] uncommitted_tables Helper class to store list of views
125  which shares need to be removed from
126  TDC if we fail to commit changes to
127  DD. Only used if commit_dd_changes
128  is false.
129 
130  @note In case when commit_dd_changes is false, the caller must rollback
131  both statement and transaction on failure, before any further
132  accesses to DD. This is because such a failure might be caused by
133  a deadlock, which requires rollback before any other operations on
134  SE (including reads using attachable transactions) can be done.
135  If case when commit_dd_changes is true this function will handle
136  transaction rollback itself.
137  operation.
138 
139  @retval false Success.
140  @retval true Failure.
141 */
142 
144  THD *thd, const TABLE_LIST *table, const char *new_db,
145  const char *new_table_name, bool commit_dd_changes,
146  Uncommitted_tables_guard *uncommitted_tables);
147 
148 /**
149  Method to update metadata of views using stored function.
150 
151  @param thd Thread handle.
152  @param spname Name of the stored function.
153 
154  @retval false Success.
155  @retval true Failure.
156 */
157 
158 bool update_referencing_views_metadata(THD *thd, const sp_name *spname);
159 
160 /**
161  Push error or warnings in case a view is invalid and return
162  the error message to the caller.
163 
164  @param thd Thread handle.
165  @param db Database name.
166  @param view_name View name.
167 
168  returns The error/warning message string.
169 */
170 std::string push_view_warning_or_error(THD *thd, const char *db,
171  const char *view_name);
172 
173 #endif // DD_SQL_VIEW_INCLUDED
const char * db_name
Definition: rules_table_service.cc:54
void add_table(TABLE_LIST *table)
Definition: dd_sql_view.h:45
bool update_referencing_views_metadata(THD *thd, const char *db_name, const char *table_name, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables)
Update metadata of views referencing the table.
Definition: dd_sql_view.cc:711
std::string push_view_warning_or_error(THD *thd, const char *db, const char *view_name)
Push error or warnings in case a view is invalid and return the error message to the caller...
Definition: dd_sql_view.cc:738
~Uncommitted_tables_guard()
Definition: dd_sql_view.cc:174
Uncommitted_tables_guard(THD *thd)
Definition: dd_sql_view.h:41
#define PSI_INSTRUMENT_ME
Definition: psi_base.h:44
Performance schema instrumentation interface.
Prealloced_array< TABLE_LIST *, 1 > m_uncommitted_tables
Definition: dd_sql_view.h:49
THD * m_thd
Definition: dd_sql_view.h:48
Guard class which allows to invalidate TDC entries for specific tables/views.
Definition: dd_sql_view.h:39
bool push_back(const Element_type &element)
Copies an element into the back of the array.
Definition: prealloced_array.h:271
Definition: table.h:2442
Definition: sp_head.h:125
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:777
const char * table_name
Definition: rules_table_service.cc:55