MySQL 9.1.0
Source Code Documentation
sql_cmd_ddl_table.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SQL_CMD_CREATE_TABLE_INCLUDED
25#define SQL_CMD_CREATE_TABLE_INCLUDED
26
27#include "lex_string.h"
28#include "my_sqlcommand.h"
29#include "sql/sql_cmd_ddl.h"
30
31class Alter_info;
32class THD;
33class Table_ref;
34
35/**
36 A base class for CREATE/ALTER TABLE commands and friends.
37
38 Child classes deal with SQL statements:
39 * ALTER TABLE
40 * ANALYZE TABLE
41 * CACHE INDEX
42 * CHECK TABLE
43 * CREATE INDEX
44 * CREATE TABLE
45 * DROP INDEX
46 * LOAD INDEX
47 * OPTIMIZE TABLE
48 * REPAIR TABLE
49*/
51 public:
52 explicit Sql_cmd_ddl_table(Alter_info *alter_info);
53
54 ~Sql_cmd_ddl_table() override = 0; // force abstract class
55
56 protected:
58};
59
61
63 public:
66 : Sql_cmd_ddl_table(alter_info),
68
71 }
72
73 /// Need to allow this for CREATE ... AS SELECT ...
74 bool are_dynamic_parameters_allowed() const override { return true; }
75
77 THD *thd) const override;
78
79 bool execute(THD *thd) override;
80 bool prepare(THD *thd) override;
81 bool reprepare_on_execute_required() const override;
82
83 private:
85};
86
88 public:
90
91 ~Sql_cmd_create_or_drop_index_base() override = 0; // force abstract class
92
93 bool execute(THD *thd) override;
94};
95
97 default;
98
100 public:
101 using Sql_cmd_create_or_drop_index_base::Sql_cmd_create_or_drop_index_base;
102
104 return SQLCOM_CREATE_INDEX;
105 }
106 bool reprepare_on_execute_required() const override;
107};
108
109class Sql_cmd_drop_table final : public Sql_cmd_ddl {
110 public:
112 return SQLCOM_DROP_TABLE;
113 }
114
115 bool execute(THD *thd [[maybe_unused]]) override { return false; }
116};
117
119 public:
120 using Sql_cmd_create_or_drop_index_base::Sql_cmd_create_or_drop_index_base;
121
123 return SQLCOM_DROP_INDEX;
124 }
125};
126
128 public:
129 Sql_cmd_cache_index(Alter_info *alter_info, const LEX_CSTRING &key_cache_name)
130 : Sql_cmd_ddl_table(alter_info), m_key_cache_name(key_cache_name) {}
131
134 }
135
136 bool execute(THD *thd) override;
137
138 private:
139 bool assign_to_keycache(THD *thd, Table_ref *tables);
140
141 private:
143};
144
146 public:
148
150 return SQLCOM_PRELOAD_KEYS;
151 }
152
153 bool execute(THD *thd) override;
154
155 private:
156 bool preload_keys(THD *thd, Table_ref *tables);
157};
158
159#endif /* SQL_CMD_CREATE_TABLE_INCLUDED */
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:205
Definition: sql_cmd_ddl_table.h:127
bool assign_to_keycache(THD *thd, Table_ref *tables)
Definition: sql_admin.cc:1604
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:132
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:591
Sql_cmd_cache_index(Alter_info *alter_info, const LEX_CSTRING &key_cache_name)
Definition: sql_cmd_ddl_table.h:129
const LEX_CSTRING m_key_cache_name
Definition: sql_cmd_ddl_table.h:142
Definition: sql_cmd_ddl_table.h:99
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:103
bool reprepare_on_execute_required() const override
Some SQL commands currently require re-preparation on re-execution of a prepared statement or stored ...
Definition: sql_cmd_ddl_table.cc:579
Definition: sql_cmd_ddl_table.h:87
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:533
~Sql_cmd_create_or_drop_index_base() override=0
Definition: sql_cmd_ddl_table.h:62
bool are_dynamic_parameters_allowed() const override
Need to allow this for CREATE ... AS SELECT ...
Definition: sql_cmd_ddl_table.h:74
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:69
Table_ref * query_expression_tables
Definition: sql_cmd_ddl_table.h:84
const MYSQL_LEX_CSTRING * eligible_secondary_storage_engine(THD *thd) const override
Is this statement of a type and on a form that makes it eligible for execution in a secondary storage...
Definition: sql_cmd_ddl_table.cc:495
bool prepare(THD *thd) override
Validate and prepare for execution CREATE TABLE statement.
Definition: sql_prepare.cc:1057
bool reprepare_on_execute_required() const override
Some SQL commands currently require re-preparation on re-execution of a prepared statement or stored ...
Definition: sql_cmd_ddl_table.cc:482
Sql_cmd_create_table(Alter_info *alter_info, Table_ref *query_expression_tables)
Definition: sql_cmd_ddl_table.h:64
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:132
A base class for CREATE/ALTER TABLE commands and friends.
Definition: sql_cmd_ddl_table.h:50
~Sql_cmd_ddl_table() override=0
Alter_info *const m_alter_info
Definition: sql_cmd_ddl_table.h:57
Sql_cmd_ddl_table(Alter_info *alter_info)
Definition: sql_cmd_ddl_table.cc:68
Definition: sql_cmd_ddl.h:29
Definition: sql_cmd_ddl_table.h:118
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:122
Definition: sql_cmd_ddl_table.h:109
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.h:115
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:111
Definition: sql_cmd_ddl_table.h:145
bool preload_keys(THD *thd, Table_ref *tables)
Definition: sql_admin.cc:1641
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:599
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:149
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2900
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_DROP_TABLE
Definition: my_sqlcommand.h:56
@ SQLCOM_ASSIGN_TO_KEYCACHE
Definition: my_sqlcommand.h:94
@ SQLCOM_CREATE_INDEX
Definition: my_sqlcommand.h:49
@ SQLCOM_PRELOAD_KEYS
Definition: my_sqlcommand.h:95
@ SQLCOM_CREATE_TABLE
Definition: my_sqlcommand.h:48
@ SQLCOM_DROP_INDEX
Definition: my_sqlcommand.h:57
Definition: mysql_lex_string.h:40