MySQL  8.0.18
Source Code Documentation
sp_pcontext.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 /* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
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, version 2.0,
6  as published by the Free Software Foundation.
7 
8  This program is also distributed with certain software (including
9  but not limited to OpenSSL) that is licensed under separate terms,
10  as designated in a particular file or component or in included license
11  documentation. The authors of MySQL hereby grant you an additional
12  permission to link the program and your derivative works with the
13  separately licensed software that they have included with MySQL.
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 _SP_PCONTEXT_H_
25 #define _SP_PCONTEXT_H_
26 
27 #include <string.h>
28 #include <sys/types.h>
29 
30 #include "field_types.h" // enum_field_types
31 #include "lex_string.h"
32 #include "my_dbug.h"
33 #include "mysql_com.h"
34 #include "sql/create_field.h" // Create_field
35 #include "sql/mem_root_array.h" // Mem_root_array
36 #include "sql/sql_error.h"
37 #include "sql/sql_list.h"
38 
39 class Item;
40 class String;
41 class THD;
42 class sp_pcontext;
43 
44 /// This class represents a stored program variable or a parameter
45 /// (also referenced as 'SP-variable').
46 
47 class sp_variable {
48  public:
50 
51  /// Name of the SP-variable.
53 
54  /// Field-type of the SP-variable.
56 
57  /// Mode of the SP-variable.
59 
60  /// The index to the variable's value in the runtime frame.
61  ///
62  /// It is calculated during parsing and used when creating sp_instr_set
63  /// instructions and Item_splocal items. I.e. values are set/referred by
64  /// array indexing in runtime.
66 
67  /// Default value of the SP-variable (if any).
69 
70  /// Full type information (field meta-data) of the SP-variable.
72 
73  public:
75  uint _offset)
76  : name(_name),
77  type(_type),
78  mode(_mode),
79  offset(_offset),
81 };
82 
83 ///////////////////////////////////////////////////////////////////////////
84 
85 /// This class represents an SQL/PSM label. Can refer to the identifier
86 /// used with the "label_name:" construct which may precede some SQL/PSM
87 /// statements, or to an implicit implementation-dependent identifier which
88 /// the parser inserts before a high-level flow control statement such as
89 /// IF/WHILE/REPEAT/LOOP, when such statement is rewritten into a
90 /// combination of low-level jump/jump_if instructions and labels.
91 
92 class sp_label {
93  public:
94  enum enum_type {
95  /// Implicit label generated by parser.
97 
98  /// Label at BEGIN.
100 
101  /// Label at iteration control
103  };
104 
105  /// Name of the label.
107 
108  /// Instruction pointer of the label.
110 
111  /// Type of the label.
113 
114  /// Scope of the label.
115  class sp_pcontext *ctx;
116 
117  public:
118  sp_label(LEX_CSTRING _name, uint _ip, enum_type _type, sp_pcontext *_ctx)
119  : name(_name), ip(_ip), type(_type), ctx(_ctx) {}
120 };
121 
122 ///////////////////////////////////////////////////////////////////////////
123 
124 /// This class represents condition-value term in DECLARE CONDITION or
125 /// DECLARE HANDLER statements. sp_condition_value has little to do with
126 /// SQL-conditions.
127 ///
128 /// In some sense, this class is a union -- a set of filled attributes
129 /// depends on the sp_condition_value::type value.
130 
132  public:
134 
135  /// Type of the condition value.
137 
138  /// SQLSTATE of the condition value.
140 
141  /// MySQL error code of the condition value.
143 
144  public:
145  sp_condition_value(uint _mysqlerr) : type(ERROR_CODE), mysqlerr(_mysqlerr) {}
146 
147  sp_condition_value(const char *_sql_state) : type(SQLSTATE) {
148  memcpy(sql_state, _sql_state, SQLSTATE_LENGTH);
150  }
151 
154  }
155 
156  /// Print a condition_value in human-readable form.
157  ///
158  /// @param str The variable to print to.
159  void print(String *str) const;
160 
161  /// Check if two instances of sp_condition_value are equal or not.
162  ///
163  /// @param cv another instance of sp_condition_value to check.
164  ///
165  /// @return true if the instances are equal, false otherwise.
166  bool equals(const sp_condition_value *cv) const;
167 };
168 
169 ///////////////////////////////////////////////////////////////////////////
170 
171 /// This class represents 'DECLARE CONDITION' statement.
172 /// sp_condition has little to do with SQL-conditions.
173 
175  public:
176  /// Name of the condition.
178 
179  /// Value of the condition.
181 
182  public:
184  : name(_name), value(_value) {}
185 };
186 
187 ///////////////////////////////////////////////////////////////////////////
188 
189 /// This class represents 'DECLARE HANDLER' statement.
190 
191 class sp_handler {
192  public:
193  /// Enumeration of possible handler types.
194  /// Note: UNDO handlers are not (and have never been) supported.
196 
197  /// Handler type.
199 
200  /// BEGIN..END block of the handler.
202 
203  /// Conditions caught by this handler.
205 
206  public:
207  /// The constructor.
208  ///
209  /// @param _type SQL-handler type.
210  /// @param _scope Handler scope.
212  : type(_type), scope(_scope) {}
213 
214  /// Print all conditions of a handler in human-readable form.
215  ///
216  /// @param str The variable to print to.
217  void print_conditions(String *str) const;
218 
219  /// Print type and conditions (but not body) of a handler.
220  ///
221  /// @param str The variable to print to.
222  void print(String *str) const;
223 };
224 
225 ///////////////////////////////////////////////////////////////////////////
226 
227 /// The class represents parse-time context, which keeps track of declared
228 /// variables/parameters, conditions, handlers, cursors and labels.
229 ///
230 /// sp_context objects are organized in a tree according to the following
231 /// rules:
232 /// - one sp_pcontext object corresponds for for each BEGIN..END block;
233 /// - one sp_pcontext object corresponds for each exception handler;
234 /// - one additional sp_pcontext object is created to contain
235 /// Stored Program parameters.
236 ///
237 /// sp_pcontext objects are used both at parse-time and at runtime.
238 ///
239 /// During the parsing stage sp_pcontext objects are used:
240 /// - to look up defined names (e.g. declared variables and visible
241 /// labels);
242 /// - to check for duplicates;
243 /// - for error checking;
244 /// - to calculate offsets to be used at runtime.
245 ///
246 /// During the runtime phase, a tree of sp_pcontext objects is used:
247 /// - for error checking (e.g. to check correct number of parameters);
248 /// - to resolve SQL-handlers.
249 
250 class sp_pcontext {
251  public:
252  enum enum_scope {
253  /// REGULAR_SCOPE designates regular BEGIN ... END blocks.
255 
256  /// HANDLER_SCOPE designates SQL-handler blocks.
258  };
259 
260  public:
261  sp_pcontext(THD *thd);
262  ~sp_pcontext();
263 
264  /// Create and push a new context in the tree.
265 
266  /// @param thd thread context.
267  /// @param scope scope of the new parsing context.
268  /// @return the node created.
269  sp_pcontext *push_context(THD *thd, enum_scope scope);
270 
271  /// Pop a node from the parsing context tree.
272  /// @return the parent node.
274 
275  sp_pcontext *parent_context() const { return m_parent; }
276 
277  int get_level() const { return m_level; }
278 
279  /// Calculate and return the number of handlers to pop between the given
280  /// context and this one.
281  ///
282  /// @param ctx the other parsing context.
283  /// @param exclusive specifies if the last scope should be excluded.
284  ///
285  /// @return the number of handlers to pop between the given context and
286  /// this one. If 'exclusive' is true, don't count the last scope we are
287  /// leaving; this is used for LEAVE where we will jump to the hpop
288  /// instructions.
289  size_t diff_handlers(const sp_pcontext *ctx, bool exclusive) const;
290 
291  /// Calculate and return the number of cursors to pop between the given
292  /// context and this one.
293  ///
294  /// @param ctx the other parsing context.
295  /// @param exclusive specifies if the last scope should be excluded.
296  ///
297  /// @return the number of cursors to pop between the given context and
298  /// this one. If 'exclusive' is true, don't count the last scope we are
299  /// leaving; this is used for LEAVE where we will jump to the cpop
300  /// instructions.
301  size_t diff_cursors(const sp_pcontext *ctx, bool exclusive) const;
302 
303  /////////////////////////////////////////////////////////////////////////
304  // SP-variables (parameters and variables).
305  /////////////////////////////////////////////////////////////////////////
306 
307  /// @return the maximum number of variables used in this and all child
308  /// contexts. For the root parsing context, this gives us the number of
309  /// slots needed for variables during the runtime phase.
310  uint max_var_index() const { return m_max_var_index; }
311 
312  /// @return the current number of variables used in the parent contexts
313  /// (from the root), including this context.
315  return m_var_offset + static_cast<uint>(m_vars.size());
316  }
317 
318  /// @return the number of variables in this context alone.
319  uint context_var_count() const { return static_cast<uint>(m_vars.size()); }
320 
321  /// @return map index in this parsing context to runtime offset.
322  uint var_context2runtime(uint i) const { return m_var_offset + i; }
323 
324  /// Add SP-variable to the parsing context.
325  ///
326  /// @param thd Thread context.
327  /// @param name Name of the SP-variable.
328  /// @param type Type of the SP-variable.
329  /// @param mode Mode of the SP-variable.
330  ///
331  /// @return instance of newly added SP-variable.
333  enum enum_field_types type,
335 
336  /// Retrieve full type information about SP-variables in this parsing
337  /// context and its children.
338  ///
339  /// @param [out] field_def_lst Container to store type information.
340  void retrieve_field_definitions(List<Create_field> *field_def_lst) const;
341 
342  /// Find SP-variable by name.
343  ///
344  /// The function does a linear search (from newer to older variables,
345  /// in case we have shadowed names).
346  ///
347  /// The function is called only at parsing time.
348  ///
349  /// @param name Variable name.
350  /// @param name_len Variable name length.
351  /// @param current_scope_only A flag if we search only in current scope.
352  ///
353  /// @return instance of found SP-variable, or NULL if not found.
354  sp_variable *find_variable(const char *name, size_t name_len,
355  bool current_scope_only) const;
356 
357  /// Find SP-variable by the offset in the root parsing context.
358  ///
359  /// The function is used for two things:
360  /// - When evaluating parameters at the beginning, and setting out parameters
361  /// at the end, of invocation. (Top frame only, so no recursion then.)
362  /// - For printing of sp_instr_set. (Debug mode only.)
363  ///
364  /// @param offset Variable offset in the root parsing context.
365  ///
366  /// @return instance of found SP-variable, or NULL if not found.
367  sp_variable *find_variable(uint offset) const;
368 
369  /// Set the current scope boundary (for default values).
370  ///
371  /// @param n The number of variables to skip.
373 
374  /////////////////////////////////////////////////////////////////////////
375  // CASE expressions.
376  /////////////////////////////////////////////////////////////////////////
377 
378  int get_num_case_exprs() const { return m_num_case_exprs; }
379 
382 
383  return m_num_case_exprs++;
384  }
385 
387 
389 
390  /////////////////////////////////////////////////////////////////////////
391  // Labels.
392  /////////////////////////////////////////////////////////////////////////
393 
395 
397 
399  sp_label *label = m_labels.head();
400 
401  if (!label && m_parent) label = m_parent->last_label();
402 
403  return label;
404  }
405 
406  sp_label *pop_label() { return m_labels.pop(); }
407 
408  /////////////////////////////////////////////////////////////////////////
409  // Conditions.
410  /////////////////////////////////////////////////////////////////////////
411 
413 
414  /// See comment for find_variable() above.
416  bool current_scope_only) const;
417 
418  /////////////////////////////////////////////////////////////////////////
419  // Handlers.
420  /////////////////////////////////////////////////////////////////////////
421 
423 
424  /// This is an auxilary parsing-time function to check if an SQL-handler
425  /// exists in the current parsing context (current scope) for the given
426  /// SQL-condition. This function is used to check for duplicates during
427  /// the parsing phase.
428  ///
429  /// This function can not be used during the runtime phase to check
430  /// SQL-handler existence because it searches for the SQL-handler in the
431  /// current scope only (during runtime, current and parent scopes
432  /// should be checked according to the SQL-handler resolution rules).
433  ///
434  /// @param cond_value the handler condition value
435  /// (not SQL-condition!).
436  ///
437  /// @retval true if such SQL-handler exists.
438  /// @retval false otherwise.
439  bool check_duplicate_handler(const sp_condition_value *cond_value) const;
440 
441  /// Find an SQL handler for the given SQL condition according to the
442  /// SQL-handler resolution rules. This function is used at runtime.
443  ///
444  /// @param sql_state The SQL condition state
445  /// @param sql_errno The error code
446  /// @param severity The SQL condition severity level
447  ///
448  /// @return a pointer to the found SQL-handler or NULL.
449  sp_handler *find_handler(const char *sql_state, uint sql_errno,
450  Sql_condition::enum_severity_level severity) const;
451 
452  /////////////////////////////////////////////////////////////////////////
453  // Cursors.
454  /////////////////////////////////////////////////////////////////////////
455 
456  bool add_cursor(LEX_STRING name);
457 
458  /// See comment for find_variable() above.
459  bool find_cursor(LEX_STRING name, uint *poff, bool current_scope_only) const;
460 
461  /// Find cursor by offset (for debugging only).
462  const LEX_STRING *find_cursor(uint offset) const;
463 
465  return m_max_cursor_index + static_cast<uint>(m_cursors.size());
466  }
467 
469  return m_cursor_offset + static_cast<uint>(m_cursors.size());
470  }
471 
472  private:
473  /// Constructor for a tree node.
474  /// @param thd thread context
475  /// @param prev the parent parsing context
476  /// @param scope scope of this parsing context
477  sp_pcontext(THD *thd, sp_pcontext *prev, enum_scope scope);
478 
479  void init(uint var_offset, uint cursor_offset, int num_case_expressions);
480 
481  /* Prevent use of these */
482  sp_pcontext(const sp_pcontext &);
483  void operator=(sp_pcontext &);
484 
485  private:
486  /// Level of the corresponding BEGIN..END block (0 means the topmost block).
487  int m_level;
488 
489  /// m_max_var_index -- number of variables (including all types of arguments)
490  /// in this context including all children contexts.
491  ///
492  /// m_max_var_index >= m_vars.size().
493  ///
494  /// m_max_var_index of the root parsing context contains number of all
495  /// variables (including arguments) in all enclosed contexts.
497 
498  /// The maximum sub context's framesizes.
500 
501  /// Parent context.
503 
504  /// An index of the first SP-variable in this parsing context. The index
505  /// belongs to a runtime table of SP-variables.
506  ///
507  /// Note:
508  /// - m_var_offset is 0 for root parsing context;
509  /// - m_var_offset is different for all nested parsing contexts.
511 
512  /// Cursor offset for this context.
514 
515  /// Boundary for finding variables in this context. This is the number of
516  /// variables currently "invisible" to default clauses. This is normally 0,
517  /// but will be larger during parsing of DECLARE ... DEFAULT, to get the
518  /// scope right for DEFAULT values.
520 
522 
523  /// SP parameters/variables.
525 
526  /// Stack of CASE expression ids.
528 
529  /// Stack of SQL-conditions.
531 
532  /// Stack of cursors.
534 
535  /// Stack of SQL-handlers.
537 
538  /// List of labels.
540 
541  /// Children contexts, used for destruction.
543 
544  /// Scope of this parsing context.
546 };
547 
548 #endif /* _SP_PCONTEXT_H_ */
Definition: sp_pcontext.h:195
~sp_pcontext()
Definition: sp_pcontext.cc:149
uint current_cursor_count() const
Definition: sp_pcontext.h:468
This file contains the field type.
sp_label * last_label()
Definition: sp_pcontext.h:398
Item * default_value
Default value of the SP-variable (if any).
Definition: sp_pcontext.h:68
sp_pcontext * parent_context() const
Definition: sp_pcontext.h:275
void print(String *str) const
Print type and conditions (but not body) of a handler.
Definition: sp_pcontext.cc:90
Definition: mysql_lex_string.h:34
bool add_condition(THD *thd, LEX_STRING name, sp_condition_value *value)
Definition: sp_pcontext.cc:276
sp_pcontext * scope
BEGIN..END block of the handler.
Definition: sp_pcontext.h:201
Definition: sp_pcontext.h:49
Element_type & back()
Definition: mem_root_array.h:110
const string name("\ame\)
sp_handler * add_handler(THD *thd, sp_handler::enum_type type)
Definition: sp_pcontext.cc:303
sp_condition(LEX_STRING _name, sp_condition_value *_value)
Definition: sp_pcontext.h:183
Definition: sp_pcontext.h:49
void pop_back()
Removes the last element in the array, effectively reducing the container size by one...
Definition: mem_root_array.h:223
bool check_duplicate_handler(const sp_condition_value *cond_value) const
This is an auxilary parsing-time function to check if an SQL-handler exists in the current parsing co...
Definition: sp_pcontext.cc:311
This class represents an SQL/PSM label.
Definition: sp_pcontext.h:92
uint context_var_count() const
Definition: sp_pcontext.h:319
uint m_max_cursor_index
The maximum sub context&#39;s framesizes.
Definition: sp_pcontext.h:499
bool find_cursor(LEX_STRING name, uint *poff, bool current_scope_only) const
See comment for find_variable() above.
Definition: sp_pcontext.cc:427
Definition: mysql_lex_string.h:39
int push_case_expr_id()
Definition: sp_pcontext.h:380
Definition: sp_pcontext.h:133
This class represents &#39;DECLARE HANDLER&#39; statement.
Definition: sp_pcontext.h:191
This class represents &#39;DECLARE CONDITION&#39; statement.
Definition: sp_pcontext.h:174
Mem_root_array< LEX_STRING > m_cursors
Stack of cursors.
Definition: sp_pcontext.h:533
sp_pcontext * m_parent
Parent context.
Definition: sp_pcontext.h:502
int get_level() const
Definition: sp_pcontext.h:277
size_t diff_cursors(const sp_pcontext *ctx, bool exclusive) const
Calculate and return the number of cursors to pop between the given context and this one...
Definition: sp_pcontext.cc:190
List< const sp_condition_value > condition_values
Conditions caught by this handler.
Definition: sp_pcontext.h:204
bool equals(const sp_condition_value *cv) const
Check if two instances of sp_condition_value are equal or not.
Definition: sp_pcontext.cc:33
Definition: sp_pcontext.h:133
void init(uint var_offset, uint cursor_offset, int num_case_expressions)
Definition: sp_pcontext.cc:106
REGULAR_SCOPE designates regular BEGIN ... END blocks.
Definition: sp_pcontext.h:254
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:161
enum_type type
Handler type.
Definition: sp_pcontext.h:198
Label at BEGIN.
Definition: sp_pcontext.h:99
void print_conditions(String *str) const
Print all conditions of a handler in human-readable form.
Definition: sp_pcontext.cc:77
Common definition between mysql server & client.
List< sp_label > m_labels
List of labels.
Definition: sp_pcontext.h:539
uint var_context2runtime(uint i) const
Definition: sp_pcontext.h:322
LEX_CSTRING name
Name of the label.
Definition: sp_pcontext.h:106
void print(String *str) const
Print a condition_value in human-readable form.
Definition: sp_pcontext.cc:52
uint m_max_var_index
m_max_var_index – number of variables (including all types of arguments) in this context including a...
Definition: sp_pcontext.h:496
enum_type
Definition: sp_pcontext.h:94
bool add_cursor(LEX_STRING name)
Definition: sp_pcontext.cc:421
#define SQLSTATE_LENGTH
Definition: mysql_com.h:75
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
enum_type type
Type of the condition value.
Definition: sp_pcontext.h:136
sp_handler * find_handler(const char *sql_state, uint sql_errno, Sql_condition::enum_severity_level severity) const
Find an SQL handler for the given SQL condition according to the SQL-handler resolution rules...
Definition: sp_pcontext.cc:327
Mem_root_array< sp_variable * > m_vars
SP parameters/variables.
Definition: sp_pcontext.h:524
enum_type
Enumeration of possible handler types.
Definition: sp_pcontext.h:195
void declare_var_boundary(uint n)
Set the current scope boundary (for default values).
Definition: sp_pcontext.h:372
enum_mode
Definition: sp_pcontext.h:49
sp_label(LEX_CSTRING _name, uint _ip, enum_type _type, sp_pcontext *_ctx)
Definition: sp_pcontext.h:118
sp_condition_value * value
Value of the condition.
Definition: sp_pcontext.h:180
Definition: sp_pcontext.h:133
sp_variable * add_variable(THD *thd, LEX_STRING name, enum enum_field_types type, sp_variable::enum_mode mode)
Add SP-variable to the parsing context.
Definition: sp_pcontext.cc:231
Mem_root_array< int > m_case_expr_ids
Stack of CASE expression ids.
Definition: sp_pcontext.h:527
This class represents condition-value term in DECLARE CONDITION or DECLARE HANDLER statements...
Definition: sp_pcontext.h:131
The class represents parse-time context, which keeps track of declared variables/parameters, conditions, handlers, cursors and labels.
Definition: sp_pcontext.h:250
uint offset
The index to the variable&#39;s value in the runtime frame.
Definition: sp_pcontext.h:65
sp_variable(LEX_STRING _name, enum_field_types _type, enum_mode _mode, uint _offset)
Definition: sp_pcontext.h:74
sp_label * find_label(LEX_CSTRING name)
Definition: sp_pcontext.cc:255
sp_pcontext * push_context(THD *thd, enum_scope scope)
Create and push a new context in the tree.
Definition: sp_pcontext.cc:153
enum_field_types
Column types for MySQL.
Definition: field_types.h:52
sp_label * push_label(THD *thd, LEX_CSTRING name, uint ip)
Definition: sp_pcontext.cc:244
This class represents a stored program variable or a parameter (also referenced as &#39;SP-variable&#39;)...
Definition: sp_pcontext.h:47
Definition: item.h:668
unsigned int uint
Definition: uca-dump.cc:29
LEX_STRING name
Name of the SP-variable.
Definition: sp_pcontext.h:52
Definition: sp_pcontext.h:133
int get_current_case_expr_id() const
Definition: sp_pcontext.h:388
uint m_cursor_offset
Cursor offset for this context.
Definition: sp_pcontext.h:513
Implicit label generated by parser.
Definition: sp_pcontext.h:96
size_t size() const
Definition: mem_root_array.h:379
class sp_pcontext * ctx
Scope of the label.
Definition: sp_pcontext.h:115
sp_condition_value(const char *_sql_state)
Definition: sp_pcontext.h:147
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:398
uint max_var_index() const
Definition: sp_pcontext.h:310
void pop_case_expr_id()
Definition: sp_pcontext.h:386
sp_pcontext(THD *thd)
Definition: sp_pcontext.cc:115
Mem_root_array< sp_condition * > m_conditions
Stack of SQL-conditions.
Definition: sp_pcontext.h:530
Label at iteration control.
Definition: sp_pcontext.h:102
int n
Definition: xcom_base.c:425
T * pop()
Definition: sql_list.h:459
enum enum_field_types type
Field-type of the SP-variable.
Definition: sp_pcontext.h:55
void retrieve_field_definitions(List< Create_field > *field_def_lst) const
Retrieve full type information about SP-variables in this parsing context and its children...
Definition: sp_pcontext.cc:446
Definition: sp_pcontext.h:49
sp_handler(enum_type _type, sp_pcontext *_scope)
The constructor.
Definition: sp_pcontext.h:211
int m_num_case_exprs
Definition: sp_pcontext.h:521
enum_type
Definition: sp_pcontext.h:133
int type
Definition: http_common.h:411
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:50
char sql_state[64]
Definition: test_sql_9_sessions.cc:297
Definition: sp_pcontext.h:133
enum_mode mode
Mode of the SP-variable.
Definition: sp_pcontext.h:58
bool push_back(const Element_type &element)
Adds a new element at the end of the array, after its current last element.
Definition: mem_root_array.h:189
sp_variable * find_variable(const char *name, size_t name_len, bool current_scope_only) const
Find SP-variable by name.
Definition: sp_pcontext.cc:204
sp_condition_value(uint _mysqlerr)
Definition: sp_pcontext.h:145
enum_scope m_scope
Scope of this parsing context.
Definition: sp_pcontext.h:545
sp_condition_value * find_condition(LEX_STRING name, bool current_scope_only) const
See comment for find_variable() above.
Definition: sp_pcontext.cc:285
sp_condition_value(enum_type _type)
Definition: sp_pcontext.h:152
char sql_state[SQLSTATE_LENGTH+1]
SQLSTATE of the condition value.
Definition: sp_pcontext.h:139
#define NULL
Definition: types.h:55
enum_scope
Definition: sp_pcontext.h:252
const string value("\alue\)
Mem_root_array< sp_pcontext * > m_children
Children contexts, used for destruction.
Definition: sp_pcontext.h:542
uint mysqlerr
MySQL error code of the condition value.
Definition: sp_pcontext.h:142
enum_severity_level
Enumeration value describing the severity of the condition.
Definition: sql_error.h:58
Mem_root_array< sp_handler * > m_handlers
Stack of SQL-handlers.
Definition: sp_pcontext.h:536
Definition: sp_pcontext.h:195
enum_type type
Type of the label.
Definition: sp_pcontext.h:112
LEX_STRING name
Name of the condition.
Definition: sp_pcontext.h:177
T * head()
Definition: sql_list.h:454
uint current_var_count() const
Definition: sp_pcontext.h:314
int m_level
Level of the corresponding BEGIN..END block (0 means the topmost block).
Definition: sp_pcontext.h:487
uint ip
Instruction pointer of the label.
Definition: sp_pcontext.h:109
uint m_var_offset
An index of the first SP-variable in this parsing context.
Definition: sp_pcontext.h:510
sp_label * pop_label()
Definition: sp_pcontext.h:406
void operator=(sp_pcontext &)
uint max_cursor_index() const
Definition: sp_pcontext.h:464
sp_pcontext * pop_context()
Pop a node from the parsing context tree.
Definition: sp_pcontext.cc:161
size_t diff_handlers(const sp_pcontext *ctx, bool exclusive) const
Calculate and return the number of handlers to pop between the given context and this one...
Definition: sp_pcontext.cc:174
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
uint m_pboundary
Boundary for finding variables in this context.
Definition: sp_pcontext.h:519
int get_num_case_exprs() const
Definition: sp_pcontext.h:378
Create_field field_def
Full type information (field meta-data) of the SP-variable.
Definition: sp_pcontext.h:71
HANDLER_SCOPE designates SQL-handler blocks.
Definition: sp_pcontext.h:257