MySQL 9.3.0
Source Code Documentation
sql_cmd_ddl.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2025, 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_DDL_INCLUDED
25#define SQL_CMD_DDL_INCLUDED
26
27#include "lex_string.h"
28#include "my_sqlcommand.h"
29#include "sql/sql_cmd.h"
30
31class THD;
32
33class Sql_cmd_ddl : public Sql_cmd {
34 public:
35 enum enum_sql_cmd_type sql_cmd_type() const override {
36 /*
37 Somewhat unsurprisingly, anything sub-classed to Sql_cmd_ddl
38 identifies as DDL by default.
39 */
40 return SQL_CMD_DDL;
41 }
42};
43
44/**
45 This is a dummy class for old-style commands whose code is in sql_parse.cc,
46 not in the execute() function. This Sql_cmd sub-class presently exists
47 solely to provide a correct sql_cmd_type() for the command; it does nothing
48 else.
49*/
50class Sql_cmd_ddl_dummy final : public Sql_cmd_ddl {
51 private:
53
54 public:
56 assert(my_sql_command == SQLCOM_END); // ensure value was not set up yet
57 my_sql_command = scc;
58 }
59
61 assert(my_sql_command != SQLCOM_END); // ensure value was set up
62 return my_sql_command;
63 }
64
65 // Error: we should never get here! (see explanation above)
66 bool execute(THD *thd [[maybe_unused]]) override {
67 assert(false);
68 return false;
69 }
70};
71
72class sp_name;
73
74class Sql_cmd_create_library final : public Sql_cmd_ddl {
75 public:
76 Sql_cmd_create_library(THD *thd, bool if_not_exists, sp_name *name,
78 LEX_STRING source_code);
79
82 }
83
84 bool execute(THD *thd) override;
85
86 private:
90 // In order to support prepare of routines that contain CREATE LIBRARY
91 // statements, we need to keep a copy of the source code and the comment.
94};
95
96class Sql_cmd_alter_library final : public Sql_cmd_ddl {
97 public:
99
102 }
103
104 bool execute(THD *thd) override;
105
106 private:
108 // In order to support prepare of routines that contain CREATE and ALTER
109 // LIBRARY statements, we need to keep a copy of the comment.
111};
112
113class Sql_cmd_drop_library final : public Sql_cmd_ddl {
114 public:
115 Sql_cmd_drop_library(bool if_exists, sp_name *lib_name)
116 : m_if_exists(if_exists), m_name(lib_name) {}
117
119 return SQLCOM_DROP_LIBRARY;
120 }
121
122 bool execute(THD *thd) override;
123
124 private:
127};
128
129#endif // SQL_CMD_DDL_INCLUDED
Definition: sql_cmd_ddl.h:96
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl.h:100
sp_name * m_name
Definition: sql_cmd_ddl.h:107
LEX_STRING m_comment
Definition: sql_cmd_ddl.h:110
Sql_cmd_alter_library(THD *thd, sp_name *name, LEX_STRING comment)
Definition: sql_cmd_ddl.cc:153
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl.cc:158
Definition: sql_cmd_ddl.h:74
LEX_CSTRING m_comment
Definition: sql_cmd_ddl.h:93
LEX_CSTRING m_source
Definition: sql_cmd_ddl.h:92
LEX_CSTRING m_language
Definition: sql_cmd_ddl.h:89
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl.h:80
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl.cc:73
sp_name * m_name
Definition: sql_cmd_ddl.h:88
bool m_if_not_exists
Definition: sql_cmd_ddl.h:87
Sql_cmd_create_library(THD *thd, bool if_not_exists, sp_name *name, LEX_CSTRING language, LEX_CSTRING comment, LEX_STRING source_code)
Definition: sql_cmd_ddl.cc:61
This is a dummy class for old-style commands whose code is in sql_parse.cc, not in the execute() func...
Definition: sql_cmd_ddl.h:50
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl.h:66
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl.h:60
enum_sql_command my_sql_command
Definition: sql_cmd_ddl.h:52
void set_sql_command_code(enum_sql_command scc)
Definition: sql_cmd_ddl.h:55
Definition: sql_cmd_ddl.h:33
enum enum_sql_cmd_type sql_cmd_type() const override
Definition: sql_cmd_ddl.h:35
Definition: sql_cmd_ddl.h:113
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_ddl.cc:174
bool m_if_exists
Definition: sql_cmd_ddl.h:125
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_ddl.h:118
sp_name * m_name
Definition: sql_cmd_ddl.h:126
Sql_cmd_drop_library(bool if_exists, sp_name *lib_name)
Definition: sql_cmd_ddl.h:115
Representation of an SQL command.
Definition: sql_cmd.h:83
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: sp_head.h:124
#define comment
Definition: lexyy.cc:959
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_ALTER_LIBRARY
Definition: my_sqlcommand.h:210
@ SQLCOM_CREATE_LIBRARY
Definition: my_sqlcommand.h:207
@ SQLCOM_END
Definition: my_sqlcommand.h:213
@ SQLCOM_DROP_LIBRARY
Definition: my_sqlcommand.h:208
Representation of an SQL command.
enum_sql_cmd_type
What type of Sql_cmd we're dealing with (DML, DDL, ...).
Definition: sql_cmd.h:53
@ SQL_CMD_DDL
Definition: sql_cmd.h:55
case opt name
Definition: sslopt-case.h:29
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35