MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sql_get_diagnostics.h
1 /* Copyright (c) 2013, 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 as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef SQL_GET_DIAGNOSTICS_H
17 #define SQL_GET_DIAGNOSTICS_H
18 
21 
22 
31 {
32 public:
39  : m_info(info)
40  {}
41 
42  virtual enum_sql_command sql_command_code() const
43  {
44  return SQLCOM_GET_DIAGNOSTICS;
45  }
46 
47  virtual bool execute(THD *thd);
48 
49 private:
52 };
53 
54 
62 {
63 public:
69  {
72  };
73 
76  { m_area= area; }
77 
80  { return m_area; }
81 
91  virtual bool aggregate(THD *thd, const Diagnostics_area *da) = 0;
92 
93 protected:
99  {
100  DBUG_ASSERT(false);
101  }
102 
113  template <typename Diag_item, typename Context>
114  bool evaluate(THD *thd, Diag_item *diag_item, Context ctx)
115  {
116  Item *value;
117 
118  /* Get this item's value. */
119  if (! (value= diag_item->get_value(thd, ctx)))
120  return true;
121 
122  /* Set variable/parameter value. */
123  return diag_item->set_value(thd, &value);
124  }
125 
126 private:
128  Which_area m_area;
129 };
130 
131 
137 {
138 public:
148  bool set_value(THD *thd, Item **value);
149 
150 protected:
157  : m_target(target)
158  {}
159 
165  {
166  DBUG_ASSERT(false);
167  }
168 
169 private:
171  Item *m_target;
172 };
173 
174 
179 {
180 public:
182  enum Name
183  {
184  NUMBER,
185  ROW_COUNT
186  };
187 
195  : Diagnostics_information_item(target), m_name(name)
196  {}
197 
199  Item *get_value(THD *thd, const Diagnostics_area *da);
200 
201 private:
203  Name m_name;
204 };
205 
206 
213 {
214 public:
222  : m_items(items)
223  {}
224 
226  bool aggregate(THD *thd, const Diagnostics_area *da);
227 
228 private:
229  /* List of statement information items. */
231 };
232 
233 
238 {
239 public:
243  enum Name
244  {
245  CLASS_ORIGIN,
246  SUBCLASS_ORIGIN,
247  CONSTRAINT_CATALOG,
248  CONSTRAINT_SCHEMA,
249  CONSTRAINT_NAME,
250  CATALOG_NAME,
251  SCHEMA_NAME,
252  TABLE_NAME,
253  COLUMN_NAME,
254  CURSOR_NAME,
255  MESSAGE_TEXT,
256  MYSQL_ERRNO,
257  RETURNED_SQLSTATE
258  };
259 
267  : Diagnostics_information_item(target), m_name(name)
268  {}
269 
271  Item *get_value(THD *thd, const Sql_condition *cond);
272 
273 private:
275  Name m_name;
276 
278  Item *make_utf8_string_item(THD *thd, const String *str);
279 };
280 
281 
289 {
290 public:
298  Condition_information(Item *cond_number_expr,
300  : m_cond_number_expr(cond_number_expr), m_items(items)
301  {}
302 
304  bool aggregate(THD *thd, const Diagnostics_area *da);
305 
306 private:
311  Item *m_cond_number_expr;
312 
315 };
316 
317 #endif
318