MySQL  8.0.19
Source Code Documentation
sql_cmd_ddl_table.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, 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 SQL_CMD_CREATE_TABLE_INCLUDED
24 #define SQL_CMD_CREATE_TABLE_INCLUDED
25 
26 #include "lex_string.h"
27 #include "my_sqlcommand.h"
28 #include "sql/sql_cmd_ddl.h"
29 
30 class Alter_info;
31 class THD;
32 struct TABLE_LIST;
33 
34 /**
35  A base class for CREATE/ALTER TABLE commands and friends.
36 
37  Child classes deal with SQL statements:
38  * ALTER TABLE
39  * ANALYZE TABLE
40  * CACHE INDEX
41  * CHECK TABLE
42  * CREATE INDEX
43  * CREATE TABLE
44  * DROP INDEX
45  * LOAD INDEX
46  * OPTIMIZE TABLE
47  * REPAIR TABLE
48 */
49 class Sql_cmd_ddl_table : public Sql_cmd {
50  public:
51  explicit Sql_cmd_ddl_table(Alter_info *alter_info);
52 
53  virtual ~Sql_cmd_ddl_table() = 0; // force abstract class
54 
55  protected:
57 };
58 
60 
62  public:
65  : Sql_cmd_ddl_table(alter_info),
67 
69  return SQLCOM_CREATE_TABLE;
70  }
71 
72  bool execute(THD *thd) override;
73  bool prepare(THD *thd) override;
74 
75  private:
77 };
78 
80  public:
82 
83  ~Sql_cmd_create_or_drop_index_base() override = 0; // force abstract class
84 
85  bool execute(THD *thd) override;
86 };
87 
89 }
90 
92  public:
93  using Sql_cmd_create_or_drop_index_base::Sql_cmd_create_or_drop_index_base;
94 
96  return SQLCOM_CREATE_INDEX;
97  }
98 };
99 
101  public:
102  using Sql_cmd_create_or_drop_index_base::Sql_cmd_create_or_drop_index_base;
103 
105  return SQLCOM_DROP_INDEX;
106  }
107 };
108 
110  public:
111  Sql_cmd_cache_index(Alter_info *alter_info, const LEX_CSTRING &key_cache_name)
112  : Sql_cmd_ddl_table(alter_info), m_key_cache_name(key_cache_name) {}
113 
116  }
117 
118  bool execute(THD *thd) override;
119 
120  private:
121  bool assign_to_keycache(THD *thd, TABLE_LIST *tables);
122 
123  private:
125 };
126 
128  public:
130 
132  return SQLCOM_PRELOAD_KEYS;
133  }
134 
135  bool execute(THD *thd) override;
136 
137  private:
138  bool preload_keys(THD *thd, TABLE_LIST *tables);
139 };
140 
141 #endif /* SQL_CMD_CREATE_TABLE_INCLUDED */
Sql_cmd_create_index
Definition: sql_cmd_ddl_table.h:91
MYSQL_LEX_CSTRING
Definition: mysql_lex_string.h:39
THD
Definition: sql_class.h:764
Sql_cmd_cache_index::m_key_cache_name
const LEX_CSTRING m_key_cache_name
Definition: sql_cmd_ddl_table.h:124
Sql_cmd_ddl_table
A base class for CREATE/ALTER TABLE commands and friends.
Definition: sql_cmd_ddl_table.h:49
sql_cmd_ddl.h
Sql_cmd_cache_index
Definition: sql_cmd_ddl_table.h:109
Alter_info
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:189
my_sqlcommand.h
Sql_cmd_load_index::execute
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:392
Sql_cmd_load_index::preload_keys
bool preload_keys(THD *thd, TABLE_LIST *tables)
Definition: sql_admin.cc:1420
Sql_cmd_create_table::sql_command_code
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:68
Sql_cmd_cache_index::Sql_cmd_cache_index
Sql_cmd_cache_index(Alter_info *alter_info, const LEX_CSTRING &key_cache_name)
Definition: sql_cmd_ddl_table.h:111
Sql_cmd_create_or_drop_index_base
Definition: sql_cmd_ddl_table.h:79
Sql_cmd_cache_index::execute
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:384
Sql_cmd_create_index::sql_command_code
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:95
Sql_cmd_create_or_drop_index_base::execute
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:338
Sql_cmd_load_index
Definition: sql_cmd_ddl_table.h:127
Sql_cmd_ddl_table::Sql_cmd_ddl_table
Sql_cmd_ddl_table(Alter_info *alter_info)
Definition: sql_cmd_ddl_table.cc:65
enum_sql_command
enum_sql_command
Definition: my_sqlcommand.h:45
lex_string.h
Sql_cmd_create_table::execute
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl_table.cc:84
Sql_cmd
Representation of an SQL command.
Definition: sql_cmd.h:63
Sql_cmd_create_table::prepare
bool prepare(THD *thd) override
Validate and prepare for execution CREATE TABLE statement.
Definition: sql_prepare.cc:1118
Sql_cmd_drop_index
Definition: sql_cmd_ddl_table.h:100
Sql_cmd_drop_index::sql_command_code
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:104
SQLCOM_ASSIGN_TO_KEYCACHE
@ SQLCOM_ASSIGN_TO_KEYCACHE
Definition: my_sqlcommand.h:93
TABLE_LIST
Definition: table.h:2467
SQLCOM_CREATE_TABLE
@ SQLCOM_CREATE_TABLE
Definition: my_sqlcommand.h:47
SQLCOM_PRELOAD_KEYS
@ SQLCOM_PRELOAD_KEYS
Definition: my_sqlcommand.h:94
Sql_cmd_create_table::query_expression_tables
TABLE_LIST * query_expression_tables
Definition: sql_cmd_ddl_table.h:76
Sql_cmd_load_index::sql_command_code
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:131
Sql_cmd_ddl_table::~Sql_cmd_ddl_table
virtual ~Sql_cmd_ddl_table()=0
Definition: sql_cmd_ddl_table.h:59
Sql_cmd_create_table
Definition: sql_cmd_ddl_table.h:61
SQLCOM_CREATE_INDEX
@ SQLCOM_CREATE_INDEX
Definition: my_sqlcommand.h:48
Sql_cmd_cache_index::sql_command_code
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl_table.h:114
Sql_cmd_ddl_table::m_alter_info
Alter_info *const m_alter_info
Definition: sql_cmd_ddl_table.h:56
Sql_cmd_cache_index::assign_to_keycache
bool assign_to_keycache(THD *thd, TABLE_LIST *tables)
Definition: sql_admin.cc:1382
SQLCOM_DROP_INDEX
@ SQLCOM_DROP_INDEX
Definition: my_sqlcommand.h:56
final
#define final(a, b, c)
Definition: hash.c:109
Sql_cmd_create_table::Sql_cmd_create_table
Sql_cmd_create_table(Alter_info *alter_info, TABLE_LIST *query_expression_tables)
Definition: sql_cmd_ddl_table.h:63
Sql_cmd_create_or_drop_index_base::~Sql_cmd_create_or_drop_index_base
~Sql_cmd_create_or_drop_index_base() override=0
Definition: sql_cmd_ddl_table.h:88