MySQL 8.0.40
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, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
17 the program or referenced in the documentation.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License, version 2.0, for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
27
28#include "sql/dd/string_type.h" // String_type
29#include "sql/sql_list.h" // List
30
31/**
32 Class to hold information regarding a table to be created on
33 behalf of a plugin. The class stores the name, definition, options
34 and optional tablespace of the table. The definition should not contain the
35 'CREATE TABLE name' prefix.
36
37 @note The data members are not owned by the class, and will not
38 be deleted when this instance is deleted.
39*/
41 private:
42 const char *m_schema_name;
43 const char *m_table_name;
44 const char *m_table_definition;
45 const char *m_table_options;
46 const char *m_tablespace_name;
47
48 public:
49 Plugin_table(const char *schema_name, const char *table_name,
50 const char *definition, const char *options,
51 const char *tablespace_name)
52 : m_schema_name(schema_name),
54 m_table_definition(definition),
56 m_tablespace_name(tablespace_name) {}
57
58 virtual ~Plugin_table() = default;
59
60 const char *get_schema_name() const { return m_schema_name; }
61
62 const char *get_name() const { return m_table_name; }
63
64 const char *get_table_definition() const { return m_table_definition; }
65
66 const char *get_table_options() const { return m_table_options; }
67
68 const char *get_tablespace_name() const { return m_tablespace_name; }
69
70 virtual const char *get_object_type() const { return "TABLE"; }
71
74 if (m_schema_name != nullptr) ss << m_schema_name << ".";
75 ss << m_table_name;
76
77 return ss.str();
78 }
79
80 virtual dd::String_type get_ddl() const {
82 ss << "CREATE TABLE " << get_qualified_name();
83 ss << "(\n" << m_table_definition << ")";
84 ss << m_table_options;
85
86 if (m_tablespace_name != nullptr)
87 ss << " "
88 << "TABLESPACE=" << m_tablespace_name;
89
90 return ss.str();
91 }
92};
93
94/**
95 Class to hold information regarding a view to be created on behalf of
96 a plugin. The class stores the name, definition, and view options.
97 The definition should not contain the 'CREATE VIEW name' prefix.
98
99 @note The data members are not owned by the class, and will not
100 be deleted when this instance is deleted.
101*/
102class Plugin_view : public Plugin_table {
103 public:
104 Plugin_view(const char *schema_name, const char *table_name,
105 const char *definition, const char *options)
106 : Plugin_table(schema_name, table_name, definition, options, nullptr) {}
107
108 const char *get_object_type() const override { return "VIEW"; }
109
110 dd::String_type get_ddl() const override {
112 ss << "CREATE " << get_table_options();
113 ss << " VIEW " << get_qualified_name();
114 ss << " AS " << get_table_definition();
115
116 return ss.str();
117 }
118};
119
120/**
121 Class to hold information regarding a predefined tablespace
122 created by a storage engine. The class stores the name, options,
123 se_private_data, comment and engine of the tablespace. A list of
124 of the tablespace files is also stored.
125
126 @note The data members are not owned by the class, and will not
127 be deleted when this instance is deleted.
128*/
130 public:
132 private:
133 const char *m_name;
134 const char *m_se_private_data;
135
136 public:
137 Plugin_tablespace_file(const char *name, const char *se_private_data)
138 : m_name(name), m_se_private_data(se_private_data) {}
139
140 const char *get_name() const { return m_name; }
141
142 const char *get_se_private_data() const { return m_se_private_data; }
143 };
144
145 private:
146 const char *m_name;
147 const char *m_options;
148 const char *m_se_private_data;
149 const char *m_comment;
150 const char *m_engine;
152
153 public:
154 Plugin_tablespace(const char *name, const char *options,
155 const char *se_private_data, const char *comment,
156 const char *engine)
157 : m_name(name),
159 m_se_private_data(se_private_data),
161 m_engine(engine) {}
162
163 void add_file(const Plugin_tablespace_file *file) { m_files.push_back(file); }
164
165 const char *get_name() const { return m_name; }
166
167 const char *get_options() const { return m_options; }
168
169 const char *get_se_private_data() const { return m_se_private_data; }
170
171 const char *get_comment() const { return m_comment; }
172
173 const char *get_engine() const { return m_engine; }
174
176 return m_files;
177 }
178};
179
180#endif // PLUGIN_TABLE_INCLUDED
Definition: sql_list.h:434
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
virtual ~Plugin_table()=default
const char * get_name() const
Definition: plugin_table.h:62
virtual const char * get_object_type() const
Definition: plugin_table.h:70
Plugin_table(const char *schema_name, const char *table_name, const char *definition, const char *options, const char *tablespace_name)
Definition: plugin_table.h:49
const char * m_table_name
Definition: plugin_table.h:43
const char * m_tablespace_name
Definition: plugin_table.h:46
const char * get_table_options() const
Definition: plugin_table.h:66
const char * m_schema_name
Definition: plugin_table.h:42
dd::String_type get_qualified_name() const
Definition: plugin_table.h:72
virtual dd::String_type get_ddl() const
Definition: plugin_table.h:80
const char * get_table_definition() const
Definition: plugin_table.h:64
const char * get_tablespace_name() const
Definition: plugin_table.h:68
const char * m_table_definition
Definition: plugin_table.h:44
const char * get_schema_name() const
Definition: plugin_table.h:60
const char * m_table_options
Definition: plugin_table.h:45
Definition: plugin_table.h:131
const char * m_name
Definition: plugin_table.h:133
const char * m_se_private_data
Definition: plugin_table.h:134
const char * get_name() const
Definition: plugin_table.h:140
const char * get_se_private_data() const
Definition: plugin_table.h:142
Plugin_tablespace_file(const char *name, const char *se_private_data)
Definition: plugin_table.h:137
Class to hold information regarding a predefined tablespace created by a storage engine.
Definition: plugin_table.h:129
const char * get_name() const
Definition: plugin_table.h:165
void add_file(const Plugin_tablespace_file *file)
Definition: plugin_table.h:163
const char * get_engine() const
Definition: plugin_table.h:173
const char * m_engine
Definition: plugin_table.h:150
Plugin_tablespace(const char *name, const char *options, const char *se_private_data, const char *comment, const char *engine)
Definition: plugin_table.h:154
const List< const Plugin_tablespace_file > & get_files() const
Definition: plugin_table.h:175
const char * m_name
Definition: plugin_table.h:146
const char * get_options() const
Definition: plugin_table.h:167
const char * m_se_private_data
Definition: plugin_table.h:148
const char * get_comment() const
Definition: plugin_table.h:171
const char * get_se_private_data() const
Definition: plugin_table.h:169
List< const Plugin_tablespace_file > m_files
Definition: plugin_table.h:151
const char * m_options
Definition: plugin_table.h:147
const char * m_comment
Definition: plugin_table.h:149
Class to hold information regarding a view to be created on behalf of a plugin.
Definition: plugin_table.h:102
Plugin_view(const char *schema_name, const char *table_name, const char *definition, const char *options)
Definition: plugin_table.h:104
dd::String_type get_ddl() const override
Definition: plugin_table.h:110
const char * get_object_type() const override
Definition: plugin_table.h:108
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
#define comment
Definition: lexyy.cc:959
Char_stringstream_template< String_type_allocator > Stringstream_type
Instantiation of std::basic_stringstream with the same allocator as String_type.
Definition: string_type.h:72
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: os0file.h:86
Definition: options.cc:49
const char * table_name
Definition: rules_table_service.cc:56
case opt name
Definition: sslopt-case.h:33