MySQL  8.0.17
Source Code Documentation
tablespace_id_owner_visitor.h
Go to the documentation of this file.
1 /* Copyright (c) 2019, 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__TABLESPACE_ID_OWNER_VISITOR_INCLUDED
24 #define DD__TABLESPACE_ID_OWNER_VISITOR_INCLUDED
25 
26 #include "sql/dd/types/index.h" // dd::Index
27 #include "sql/dd/types/partition.h" // dd::Partition
28 #include "sql/dd/types/partition_index.h" // dd::Partition_index
29 #include "sql/dd/types/table.h" // dd::Table
30 
31 namespace dd {
32 /**
33  Visitor function which invokes its visitor argument on any subobject
34  which holds a tablespace, that is, the table itself, its m_indexes,
35  its m_partitions, and m_indexes (Partition_index) of each
36  partition. Visitation is terminated when the vistor closure
37  returns true.
38 
39  @param t table to visit.
40 
41  @param visitor generic closure which can be applied to all
42  tablespace holding objects.
43 
44  @return value of last visitor invocation.
45 */
46 template <class VISITOR_TYPE>
47 bool visit_tablespace_id_owners(const Table &t, VISITOR_TYPE &&visitor) {
48  if (visitor(t)) {
49  return true;
50  }
51  for (const Index *i : t.indexes()) {
52  if (visitor(*i)) {
53  return true;
54  }
55  }
56  for (const Partition *p : t.partitions()) {
57  if (visitor(*p)) {
58  return true;
59  }
60  // Visit indexes for top-level partition
61  for (const Partition_index *pi : p->indexes()) {
62  if (visitor(*pi)) {
63  return true;
64  }
65  }
66 
67  // Visit subpartitions, if any
68  for (const Partition *sp : p->sub_partitions()) {
69  if (visitor(*sp)) {
70  return true;
71  }
72  // Visit indexes for subpartition
73  for (const Partition_index *spi : sp->indexes()) {
74  if (visitor(*spi)) {
75  return true;
76  }
77  }
78  }
79  }
80  return false;
81 }
82 } // namespace dd
83 
84 #endif
Definition: partition.h:50
Definition: index.h:49
t
Definition: dbug_analyze.cc:147
bool visit_tablespace_id_owners(const Table &t, VISITOR_TYPE &&visitor)
Visitor function which invokes its visitor argument on any subobject which holds a tablespace...
Definition: tablespace_id_owner_visitor.h:47
const char * p
Definition: ctype-mb.cc:1232
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
Definition: partition_index.h:46
Definition: table.h:43