| 1 | /* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. |
| 2 | Use is subject to license terms. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 16 | |
| 17 | #ifndef SQL_SIGNAL_H |
| 18 | #define SQL_SIGNAL_H |
| 19 | |
| 20 | /** |
| 21 | Sql_cmd_common_signal represents the common properties of the |
| 22 | SIGNAL and RESIGNAL statements. |
| 23 | */ |
| 24 | class Sql_cmd_common_signal : public Sql_cmd |
| 25 | { |
| 26 | protected: |
| 27 | /** |
| 28 | Constructor. |
| 29 | @param cond the condition signaled if any, or NULL. |
| 30 | @param set collection of signal condition item assignments. |
| 31 | */ |
| 32 | Sql_cmd_common_signal(const sp_condition_value *cond, |
| 33 | const Set_signal_information& set) |
| 34 | : Sql_cmd(), |
| 35 | m_cond(cond), |
| 36 | m_set_signal_information(set) |
| 37 | {} |
| 38 | |
| 39 | virtual ~Sql_cmd_common_signal() |
| 40 | {} |
| 41 | |
| 42 | /** |
| 43 | Evaluate each signal condition items for this statement. |
| 44 | @param thd the current thread. |
| 45 | @param cond the condition to update. |
| 46 | @return 0 on success. |
| 47 | */ |
| 48 | int eval_signal_informations(THD *thd, Sql_condition *cond); |
| 49 | |
| 50 | /** |
| 51 | Raise a SQL condition. |
| 52 | @param thd the current thread. |
| 53 | @param cond the condition to raise. |
| 54 | @return false on success. |
| 55 | */ |
| 56 | bool raise_condition(THD *thd, Sql_condition *cond); |
| 57 | |
| 58 | /** |
| 59 | The condition to signal or resignal. |
| 60 | This member is optional and can be NULL (RESIGNAL). |
| 61 | */ |
| 62 | const sp_condition_value *m_cond; |
| 63 | |
| 64 | /** |
| 65 | Collection of 'SET item = value' assignments in the |
| 66 | SIGNAL/RESIGNAL statement. |
| 67 | */ |
| 68 | Set_signal_information m_set_signal_information; |
| 69 | }; |
| 70 | |
| 71 | /** |
| 72 | Sql_cmd_signal represents a SIGNAL statement. |
| 73 | */ |
| 74 | class Sql_cmd_signal : public Sql_cmd_common_signal |
| 75 | { |
| 76 | public: |
| 77 | /** |
| 78 | Constructor, used to represent a SIGNAL statement. |
| 79 | @param cond the SQL condition to signal (required). |
| 80 | @param set the collection of signal informations to signal. |
| 81 | */ |
| 82 | Sql_cmd_signal(const sp_condition_value *cond, |
| 83 | const Set_signal_information& set) |
| 84 | : Sql_cmd_common_signal(cond, set) |
| 85 | {} |
| 86 | |
| 87 | virtual ~Sql_cmd_signal() |
| 88 | {} |
| 89 | |
| 90 | virtual enum_sql_command sql_command_code() const |
| 91 | { |
| 92 | return SQLCOM_SIGNAL; |
| 93 | } |
| 94 | |
| 95 | virtual bool execute(THD *thd); |
| 96 | }; |
| 97 | |
| 98 | /** |
| 99 | Sql_cmd_resignal represents a RESIGNAL statement. |
| 100 | */ |
| 101 | class Sql_cmd_resignal : public Sql_cmd_common_signal |
| 102 | { |
| 103 | public: |
| 104 | /** |
| 105 | Constructor, used to represent a RESIGNAL statement. |
| 106 | @param cond the SQL condition to resignal (optional, may be NULL). |
| 107 | @param set the collection of signal informations to resignal. |
| 108 | */ |
| 109 | Sql_cmd_resignal(const sp_condition_value *cond, |
| 110 | const Set_signal_information& set) |
| 111 | : Sql_cmd_common_signal(cond, set) |
| 112 | {} |
| 113 | |
| 114 | virtual ~Sql_cmd_resignal() |
| 115 | {} |
| 116 | |
| 117 | virtual enum_sql_command sql_command_code() const |
| 118 | { |
| 119 | return SQLCOM_RESIGNAL; |
| 120 | } |
| 121 | |
| 122 | virtual bool execute(THD *thd); |
| 123 | }; |
| 124 | |
| 125 | #endif |
| 126 | |
| 127 | |