MySQL 8.0.31
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, 2022, 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 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*/
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 virtual ~Plugin_table() = default;
58
59 const char *get_schema_name() const { return m_schema_name; }
60
61 const char *get_name() const { return m_table_name; }
62
63 const char *get_table_definition() const { return m_table_definition; }
64
65 const char *get_table_options() const { return m_table_options; }
66
67 const char *get_tablespace_name() const { return m_tablespace_name; }
68
69 virtual const char *get_object_type() const { return "TABLE"; }
70
73 if (m_schema_name != nullptr) ss << m_schema_name << ".";
74 ss << m_table_name;
75
76 return ss.str();
77 }
78
79 virtual dd::String_type get_ddl() const {
81 ss << "CREATE TABLE " << get_qualified_name();
82 ss << "(\n" << m_table_definition << ")";
83 ss << m_table_options;
84
85 if (m_tablespace_name != nullptr)
86 ss << " "
87 << "TABLESPACE=" << m_tablespace_name;
88
89 return ss.str();
90 }
91};
92
93/**
94 Class to hold information regarding a view to be created on behalf of
95 a plugin. The class stores the name, definition, and view options.
96 The definition should not contain the 'CREATE VIEW name' prefix.
97
98 @note The data members are not owned by the class, and will not
99 be deleted when this instance is deleted.
100*/
101class Plugin_view : public Plugin_table {
102 public:
103 Plugin_view(const char *schema_name, const char *table_name,
104 const char *definition, const char *options)
105 : Plugin_table(schema_name, table_name, definition, options, nullptr) {}
106
107 const char *get_object_type() const override { return "VIEW"; }
108
109 dd::String_type get_ddl() const override {
111 ss << "CREATE " << get_table_options();
112 ss << " VIEW " << get_qualified_name();
113 ss << " AS " << get_table_definition();
114
115 return ss.str();
116 }
117};
118
119/**
120 Class to hold information regarding a predefined tablespace
121 created by a storage engine. The class stores the name, options,
122 se_private_data, comment and engine of the tablespace. A list of
123 of the tablespace files is also stored.
124
125 @note The data members are not owned by the class, and will not
126 be deleted when this instance is deleted.
127*/
129 public:
131 private:
132 const char *m_name;
133 const char *m_se_private_data;
134
135 public:
136 Plugin_tablespace_file(const char *name, const char *se_private_data)
137 : m_name(name), m_se_private_data(se_private_data) {}
138
139 const char *get_name() const { return m_name; }
140
141 const char *get_se_private_data() const { return m_se_private_data; }
142 };
143
144 private:
145 const char *m_name;
146 const char *m_options;
147 const char *m_se_private_data;
148 const char *m_comment;
149 const char *m_engine;
151
152 public:
153 Plugin_tablespace(const char *name, const char *options,
154 const char *se_private_data, const char *comment,
155 const char *engine)
156 : m_name(name),
158 m_se_private_data(se_private_data),
160 m_engine(engine) {}
161
162 void add_file(const Plugin_tablespace_file *file) { m_files.push_back(file); }
163
164 const char *get_name() const { return m_name; }
165
166 const char *get_options() const { return m_options; }
167
168 const char *get_se_private_data() const { return m_se_private_data; }
169
170 const char *get_comment() const { return m_comment; }
171
172 const char *get_engine() const { return m_engine; }
173
175 return m_files;
176 }
177};
178
179#endif // PLUGIN_TABLE_INCLUDED
Definition: sql_list.h:433
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:39
virtual ~Plugin_table()=default
const char * get_name() const
Definition: plugin_table.h:61
virtual const char * get_object_type() const
Definition: plugin_table.h:69
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
const char * m_table_name
Definition: plugin_table.h:42
const char * m_tablespace_name
Definition: plugin_table.h:45
const char * get_table_options() const
Definition: plugin_table.h:65
const char * m_schema_name
Definition: plugin_table.h:41
dd::String_type get_qualified_name() const
Definition: plugin_table.h:71
virtual dd::String_type get_ddl() const
Definition: plugin_table.h:79
const char * get_table_definition() const
Definition: plugin_table.h:63
const char * get_tablespace_name() const
Definition: plugin_table.h:67
const char * m_table_definition
Definition: plugin_table.h:43
const char * get_schema_name() const
Definition: plugin_table.h:59
const char * m_table_options
Definition: plugin_table.h:44
Definition: plugin_table.h:130
const char * m_name
Definition: plugin_table.h:132
const char * m_se_private_data
Definition: plugin_table.h:133
const char * get_name() const
Definition: plugin_table.h:139
const char * get_se_private_data() const
Definition: plugin_table.h:141
Plugin_tablespace_file(const char *name, const char *se_private_data)
Definition: plugin_table.h:136
Class to hold information regarding a predefined tablespace created by a storage engine.
Definition: plugin_table.h:128
const char * get_name() const
Definition: plugin_table.h:164
void add_file(const Plugin_tablespace_file *file)
Definition: plugin_table.h:162
const char * get_engine() const
Definition: plugin_table.h:172
const char * m_engine
Definition: plugin_table.h:149
Plugin_tablespace(const char *name, const char *options, const char *se_private_data, const char *comment, const char *engine)
Definition: plugin_table.h:153
const List< const Plugin_tablespace_file > & get_files() const
Definition: plugin_table.h:174
const char * m_name
Definition: plugin_table.h:145
const char * get_options() const
Definition: plugin_table.h:166
const char * m_se_private_data
Definition: plugin_table.h:147
const char * get_comment() const
Definition: plugin_table.h:170
const char * get_se_private_data() const
Definition: plugin_table.h:168
List< const Plugin_tablespace_file > m_files
Definition: plugin_table.h:150
const char * m_options
Definition: plugin_table.h:146
const char * m_comment
Definition: plugin_table.h:148
Class to hold information regarding a view to be created on behalf of a plugin.
Definition: plugin_table.h:101
Plugin_view(const char *schema_name, const char *table_name, const char *definition, const char *options)
Definition: plugin_table.h:103
dd::String_type get_ddl() const override
Definition: plugin_table.h:109
const char * get_object_type() const override
Definition: plugin_table.h:107
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
#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:71
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Definition: os0file.h:85
Definition: options.cc:48
const char * table_name
Definition: rules_table_service.cc:55
case opt name
Definition: sslopt-case.h:32