MySQL  8.0.18
Source Code Documentation
sql_signal.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2017, 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_SIGNAL_H
24 #define SQL_SIGNAL_H
25 
26 #include <string.h>
27 
28 #include "my_sqlcommand.h"
29 #include "sql/sql_cmd.h" // Sql_cmd
30 #include "sql/sql_error.h" // Sql_condition
31 
32 class Item;
33 class THD;
34 class sp_condition_value;
35 
36 /**
37  This enumeration list all the condition item names of a condition in the
38  SQL condition area.
39 */
41  /*
42  Conditions that can be set by the user (SIGNAL/RESIGNAL),
43  and by the server implementation.
44  */
45 
60 };
61 
62 /**
63  Set_signal_information is a container used in the parsed tree to represent
64  the collection of assignments to condition items in the SIGNAL and RESIGNAL
65  statements.
66 */
68  public:
69  Set_signal_information() { memset(m_item, 0, sizeof(m_item)); }
70 
72 
74 
75  /**
76  For each condition item assignment, m_item[] contains the parsed tree
77  that represents the expression assigned, if any.
78  m_item[] is an array indexed by enum_condition_item_name.
79  */
81 };
82 
83 /**
84  Sql_cmd_common_signal represents the common properties of the
85  SIGNAL and RESIGNAL statements.
86 */
88  protected:
89  /**
90  Constructor.
91  @param cond the condition signaled if any, or NULL.
92  @param set collection of signal condition item assignments.
93  */
97 
99 
100  /**
101  Assign the condition items 'MYSQL_ERRNO', 'level' and 'MESSAGE_TEXT'
102  default values of a condition.
103  @param thd the current thread.
104  @param cond the condition to update.
105  @param set_level_code true if 'level' and 'MYSQL_ERRNO' needs to be
106  overwritten
107  @param level the level to assign
108  @param sqlcode the sql code to assign
109  */
110  static void assign_defaults(THD *thd, Sql_condition *cond,
111  bool set_level_code,
113  int sqlcode);
114 
115  /**
116  Evaluate the condition items 'SQLSTATE', 'MYSQL_ERRNO', 'level' and
117  'MESSAGE_TEXT' default values for this statement.
118  @param thd the current thread.
119  @param cond the condition to update.
120  */
121  void eval_defaults(THD *thd, Sql_condition *cond);
122 
123  /**
124  Evaluate each signal condition items for this statement.
125  @param thd the current thread.
126  @param cond the condition to update.
127  @return 0 on success.
128  */
129  int eval_signal_informations(THD *thd, Sql_condition *cond);
130 
131  /**
132  The condition to signal or resignal.
133  This member is optional and can be NULL (RESIGNAL).
134  */
136 
137  /**
138  Collection of 'SET item = value' assignments in the
139  SIGNAL/RESIGNAL statement.
140  */
142 };
143 
144 /**
145  Sql_cmd_signal represents a SIGNAL statement.
146 */
148  public:
149  /**
150  Constructor, used to represent a SIGNAL statement.
151  @param cond the SQL condition to signal (required).
152  @param set the collection of signal informations to signal.
153  */
155  : Sql_cmd_common_signal(cond, set) {}
156 
157  virtual ~Sql_cmd_signal() {}
158 
159  virtual enum_sql_command sql_command_code() const { return SQLCOM_SIGNAL; }
160 
161  virtual bool execute(THD *thd);
162 };
163 
164 /**
165  Sql_cmd_resignal represents a RESIGNAL statement.
166 */
168  public:
169  /**
170  Constructor, used to represent a RESIGNAL statement.
171  @param cond the SQL condition to resignal (optional, may be NULL).
172  @param set the collection of signal informations to resignal.
173  */
175  : Sql_cmd_common_signal(cond, set) {}
176 
177  virtual ~Sql_cmd_resignal() {}
178 
180 
181  virtual bool execute(THD *thd);
182 };
183 
184 #endif
Sql_cmd_signal(const sp_condition_value *cond, Set_signal_information *set)
Constructor, used to represent a SIGNAL statement.
Definition: sql_signal.h:154
const sp_condition_value * m_cond
The condition to signal or resignal.
Definition: sql_signal.h:135
Representation of an SQL command.
Definition: sql_cmd.h:63
Definition: sql_signal.h:59
void set(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1)
Definition: suite_stubs.c:105
Definition: sql_signal.h:55
virtual enum_sql_command sql_command_code() const
Return the command code for this statement.
Definition: sql_signal.h:159
Definition: sql_signal.h:53
Set_signal_information is a container used in the parsed tree to represent the collection of assignme...
Definition: sql_signal.h:67
const string name("\ame\)
Sql_cmd_resignal(const sp_condition_value *cond, Set_signal_information *set)
Constructor, used to represent a RESIGNAL statement.
Definition: sql_signal.h:174
Item * m_item[CIN_LAST_PROPERTY+1]
For each condition item assignment, m_item[] contains the parsed tree that represents the expression ...
Definition: sql_signal.h:80
Definition: sql_signal.h:57
virtual bool execute(THD *thd)
Execute RESIGNAL SQL-statement.
Definition: sql_signal.cc:418
enum_sql_command
Definition: my_sqlcommand.h:45
Sql_cmd_signal represents a SIGNAL statement.
Definition: sql_signal.h:147
Definition: sql_signal.h:52
Sql_cmd_resignal represents a RESIGNAL statement.
Definition: sql_signal.h:167
Representation of an SQL command.
Sql_cmd_common_signal represents the common properties of the SIGNAL and RESIGNAL statements...
Definition: sql_signal.h:87
Set_signal_information * m_set_signal_information
Collection of &#39;SET item = value&#39; assignments in the SIGNAL/RESIGNAL statement.
Definition: sql_signal.h:141
Definition: my_sqlcommand.h:177
Definition: sql_signal.h:48
~Set_signal_information()
Definition: sql_signal.h:71
virtual bool execute(THD *thd)
Execute this SQL statement.
Definition: sql_signal.cc:363
This class represents condition-value term in DECLARE CONDITION or DECLARE HANDLER statements...
Definition: sp_pcontext.h:131
Definition: sql_signal.h:46
Definition: my_sqlcommand.h:176
Definition: item.h:668
Sql_cmd_common_signal(const sp_condition_value *cond, Set_signal_information *set)
Constructor.
Definition: sql_signal.h:94
Representation of a SQL condition.
Definition: sql_error.h:53
void eval_defaults(THD *thd, Sql_condition *cond)
Evaluate the condition items &#39;SQLSTATE&#39;, &#39;MYSQL_ERRNO&#39;, &#39;level&#39; and &#39;MESSAGE_TEXT&#39; default values for...
Definition: sql_signal.cc:108
Definition: sql_signal.h:54
enum_condition_item_name
This enumeration list all the condition item names of a condition in the SQL condition area...
Definition: sql_signal.h:40
Definition: sql_signal.h:47
Definition: sql_signal.h:50
int eval_signal_informations(THD *thd, Sql_condition *cond)
Evaluate each signal condition items for this statement.
Definition: sql_signal.cc:234
Definition: sql_signal.h:56
virtual enum_sql_command sql_command_code() const
Return the command code for this statement.
Definition: sql_signal.h:179
Definition: sql_signal.h:49
Definition: sql_signal.h:58
static void assign_defaults(THD *thd, Sql_condition *cond, bool set_level_code, Sql_condition::enum_severity_level level, int sqlcode)
Assign the condition items &#39;MYSQL_ERRNO&#39;, &#39;level&#39; and &#39;MESSAGE_TEXT&#39; default values of a condition...
Definition: sql_signal.cc:97
Definition: sql_signal.h:51
Set_signal_information()
Definition: sql_signal.h:69
enum_severity_level
Enumeration value describing the severity of the condition.
Definition: sql_error.h:58
virtual ~Sql_cmd_common_signal()
Definition: sql_signal.h:98
virtual ~Sql_cmd_signal()
Definition: sql_signal.h:157
virtual ~Sql_cmd_resignal()
Definition: sql_signal.h:177
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
bool set_item(enum_condition_item_name name, Item *item)
Definition: sql_signal.cc:87