MySQL  8.0.19
Source Code Documentation
plugin_table.h
Go to the documentation of this file.
1 #ifndef PLUGIN_TABLE_INCLUDED
2 #define PLUGIN_TABLE_INCLUDED
3 
4 /*
5  Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License, version 2.0,
9  as published by the Free Software Foundation.
10 
11  This program is also distributed with certain software (including
12  but not limited to OpenSSL) that is licensed under separate terms,
13  as designated in a particular file or component or in included license
14  documentation. The authors of MySQL hereby grant you an additional
15  permission to link the program and your derivative works with the
16  separately licensed software that they have included with MySQL.
17 
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License, version 2.0, for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26 
27 #include "sql/dd/string_type.h" // String_type
28 #include "sql/sql_list.h" // List
29 
30 /**
31  Class to hold information regarding a table to be created on
32  behalf of a plugin. The class stores the name, definition, options
33  and optional tablespace of the table. The definition should not contain the
34  'CREATE TABLE name' prefix.
35 
36  @note The data members are not owned by the class, and will not
37  be deleted when this instance is deleted.
38 */
39 class Plugin_table {
40  private:
41  const char *m_schema_name;
42  const char *m_table_name;
43  const char *m_table_definition;
44  const char *m_table_options;
45  const char *m_tablespace_name;
46 
47  public:
48  Plugin_table(const char *schema_name, const char *table_name,
49  const char *definition, const char *options,
50  const char *tablespace_name)
51  : m_schema_name(schema_name),
53  m_table_definition(definition),
55  m_tablespace_name(tablespace_name) {}
56 
57  const char *get_schema_name() const { return m_schema_name; }
58 
59  const char *get_name() const { return m_table_name; }
60 
61  const char *get_table_definition() const { return m_table_definition; }
62 
63  const char *get_table_options() const { return m_table_options; }
64 
65  const char *get_tablespace_name() const { return m_tablespace_name; }
66 
69  ss << "CREATE TABLE ";
70 
71  if (m_schema_name != nullptr) ss << m_schema_name << ".";
72 
73  ss << m_table_name << "(\n";
74  ss << m_table_definition << ")";
75  ss << m_table_options;
76 
77  if (m_tablespace_name != nullptr)
78  ss << " "
79  << "TABLESPACE=" << m_tablespace_name;
80 
81  return ss.str();
82  }
83 };
84 
85 /**
86  Class to hold information regarding a predefined tablespace
87  created by a storage engine. The class stores the name, options,
88  se_private_data, comment and engine of the tablespace. A list of
89  of the tablespace files is also stored.
90 
91  @note The data members are not owned by the class, and will not
92  be deleted when this instance is deleted.
93 */
95  public:
97  private:
98  const char *m_name;
99  const char *m_se_private_data;
100 
101  public:
102  Plugin_tablespace_file(const char *name, const char *se_private_data)
103  : m_name(name), m_se_private_data(se_private_data) {}
104 
105  const char *get_name() const { return m_name; }
106 
107  const char *get_se_private_data() const { return m_se_private_data; }
108  };
109 
110  private:
111  const char *m_name;
112  const char *m_options;
113  const char *m_se_private_data;
114  const char *m_comment;
115  const char *m_engine;
117 
118  public:
119  Plugin_tablespace(const char *name, const char *options,
120  const char *se_private_data, const char *comment,
121  const char *engine)
122  : m_name(name),
124  m_se_private_data(se_private_data),
126  m_engine(engine) {}
127 
128  void add_file(const Plugin_tablespace_file *file) { m_files.push_back(file); }
129 
130  const char *get_name() const { return m_name; }
131 
132  const char *get_options() const { return m_options; }
133 
134  const char *get_se_private_data() const { return m_se_private_data; }
135 
136  const char *get_comment() const { return m_comment; }
137 
138  const char *get_engine() const { return m_engine; }
139 
141  return m_files;
142  }
143 };
144 
145 #endif // PLUGIN_TABLE_INCLUDED
Plugin_tablespace::Plugin_tablespace
Plugin_tablespace(const char *name, const char *options, const char *se_private_data, const char *comment, const char *engine)
Definition: plugin_table.h:119
Plugin_tablespace::m_files
List< const Plugin_tablespace_file > m_files
Definition: plugin_table.h:116
rules_table_service::table_name
const char * table_name
Definition: rules_table_service.cc:55
dd::String_type
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Plugin_tablespace::Plugin_tablespace_file::m_name
const char * m_name
Definition: plugin_table.h:98
Plugin_tablespace::get_comment
const char * get_comment() const
Definition: plugin_table.h:136
Plugin_table::m_table_name
const char * m_table_name
Definition: plugin_table.h:42
Plugin_tablespace::add_file
void add_file(const Plugin_tablespace_file *file)
Definition: plugin_table.h:128
Plugin_table::m_tablespace_name
const char * m_tablespace_name
Definition: plugin_table.h:45
Plugin_tablespace::m_name
const char * m_name
Definition: plugin_table.h:111
Plugin_table::Plugin_table
Plugin_table(const char *schema_name, const char *table_name, const char *definition, const char *options, const char *tablespace_name)
Definition: plugin_table.h:48
Plugin_table
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:39
dd::Stringstream_type
Char_stringstream_template< String_type_allocator > Stringstream_type
Instantiation of std::basic_stringstream with the same allocator as String_type.
Definition: string_type.h:71
Plugin_tablespace::Plugin_tablespace_file
Definition: plugin_table.h:96
Plugin_tablespace::get_files
const List< const Plugin_tablespace_file > & get_files() const
Definition: plugin_table.h:140
Plugin_table::get_name
const char * get_name() const
Definition: plugin_table.h:59
Plugin_tablespace::get_se_private_data
const char * get_se_private_data() const
Definition: plugin_table.h:134
Plugin_tablespace::Plugin_tablespace_file::get_name
const char * get_name() const
Definition: plugin_table.h:105
Plugin_tablespace::get_name
const char * get_name() const
Definition: plugin_table.h:130
dd::info_schema::options
static const Query_options options
Definition: show_query_builder.cc:48
Plugin_tablespace::get_engine
const char * get_engine() const
Definition: plugin_table.h:138
comment
#define comment
Definition: lexyy.cc:959
Plugin_tablespace::m_options
const char * m_options
Definition: plugin_table.h:112
string_type.h
Plugin_tablespace::get_options
const char * get_options() const
Definition: plugin_table.h:132
Plugin_table::get_tablespace_name
const char * get_tablespace_name() const
Definition: plugin_table.h:65
Plugin_tablespace::Plugin_tablespace_file::Plugin_tablespace_file
Plugin_tablespace_file(const char *name, const char *se_private_data)
Definition: plugin_table.h:102
engine
ENGINE_HANDLE * engine
Definition: mock_server.c:28
Plugin_tablespace::m_se_private_data
const char * m_se_private_data
Definition: plugin_table.h:113
Plugin_tablespace::m_engine
const char * m_engine
Definition: plugin_table.h:115
name
const string name("\"Name\"")
sql_list.h
Plugin_table::m_table_options
const char * m_table_options
Definition: plugin_table.h:44
Plugin_tablespace::m_comment
const char * m_comment
Definition: plugin_table.h:114
Plugin_table::get_schema_name
const char * get_schema_name() const
Definition: plugin_table.h:57
Plugin_table::m_schema_name
const char * m_schema_name
Definition: plugin_table.h:41
Plugin_tablespace::Plugin_tablespace_file::get_se_private_data
const char * get_se_private_data() const
Definition: plugin_table.h:107
List
Definition: aggregate_check.h:523
Plugin_table::get_ddl
dd::String_type get_ddl() const
Definition: plugin_table.h:67
Plugin_tablespace::Plugin_tablespace_file::m_se_private_data
const char * m_se_private_data
Definition: plugin_table.h:99
Plugin_table::get_table_options
const char * get_table_options() const
Definition: plugin_table.h:63
Plugin_table::get_table_definition
const char * get_table_definition() const
Definition: plugin_table.h:61
Plugin_tablespace
Class to hold information regarding a predefined tablespace created by a storage engine.
Definition: plugin_table.h:94
Plugin_table::m_table_definition
const char * m_table_definition
Definition: plugin_table.h:43