MySQL  8.0.18
Source Code Documentation
sp_instr.h
Go to the documentation of this file.
1 /* Copyright (c) 2012, 2019, 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 _SP_INSTR_H_
24 #define _SP_INSTR_H_
25 
26 #include <limits.h>
27 #include <string.h>
28 #include <sys/types.h>
29 
30 #include "field_types.h"
31 #include "lex_string.h"
32 #include "m_string.h"
33 #include "my_alloc.h"
34 #include "my_compiler.h"
35 #include "my_dbug.h"
36 #include "my_inttypes.h"
37 #include "my_psi_config.h"
38 #include "my_sys.h"
40 #include "sql/sql_class.h" // Query_arena
41 #include "sql/sql_error.h"
42 #include "sql/sql_lex.h"
43 #include "sql/sql_list.h"
44 #include "sql_string.h"
45 
46 class Item;
47 class Item_case_expr;
48 class Item_trigger_field;
49 class sp_condition_value;
50 class sp_handler;
51 class sp_head;
52 class sp_pcontext;
53 class sp_variable;
54 struct TABLE_LIST;
55 
56 ///////////////////////////////////////////////////////////////////////////
57 // This file contains SP-instruction classes.
58 ///////////////////////////////////////////////////////////////////////////
59 
60 /**
61  sp_printable defines an interface which should be implemented if a class wants
62  report some internal information about its state.
63 */
64 class sp_printable {
65  public:
66  virtual void print(const THD *thd, String *str) = 0;
67 
68  virtual ~sp_printable() {}
69 };
70 
71 /**
72  An interface for all SP-instructions with destinations that
73  need to be updated by the SP-optimizer.
74 */
76  public:
77  /**
78  Update the destination; used by the SP-instruction-optimizer.
79 
80  @param old_dest current (old) destination (instruction pointer).
81  @param new_dest new destination (instruction pointer).
82  */
83  virtual void set_destination(uint old_dest, uint new_dest) = 0;
84 
85  /**
86  Update all instruction with the given label in the backpatch list to
87  the specified instruction pointer.
88 
89  @param dest destination instruction pointer.
90  */
91  virtual void backpatch(uint dest) = 0;
92 
93  virtual ~sp_branch_instr() {}
94 };
95 
96 ///////////////////////////////////////////////////////////////////////////
97 
98 /**
99  Base class for every SP-instruction. sp_instr defines interface and provides
100  base implementation.
101 */
102 class sp_instr : public sp_printable {
103  public:
105  : m_arena(nullptr, Query_arena::STMT_INITIALIZED_FOR_SP),
106  m_marked(false),
107  m_ip(ip),
108  m_parsing_ctx(ctx) {}
109 
110  virtual ~sp_instr() { m_arena.free_items(); }
111 
112  /**
113  Execute this instruction
114 
115  @param thd Thread context
116  @param[out] nextp index of the next instruction to execute. (For most
117  instructions this will be the instruction following this
118  one). Note that this parameter is undefined in case of
119  errors, use get_cont_dest() to find the continuation
120  instruction for CONTINUE error handlers.
121 
122  @return Error status.
123  */
124  virtual bool execute(THD *thd, uint *nextp) = 0;
125 #ifdef HAVE_PSI_INTERFACE
126  virtual PSI_statement_info *get_psi_info() = 0;
127 #endif
128 
129  uint get_ip() const { return m_ip; }
130 
131  /**
132  Get the continuation destination (instruction pointer for the CONTINUE
133  HANDLER) of this instruction.
134  @return the continuation destination
135  */
136  virtual uint get_cont_dest() const { return get_ip() + 1; }
137 
139 
140  protected:
141  /**
142  Clear diagnostics area.
143  @param thd Thread context
144  */
145  void clear_da(THD *thd) const {
147  thd->get_stmt_da()->reset_condition_info(thd);
148  }
149 
150  ///////////////////////////////////////////////////////////////////////////
151  // The following operations are used solely for SP-code-optimizer.
152  ///////////////////////////////////////////////////////////////////////////
153 
154  public:
155  /**
156  Mark this instruction as reachable during optimization and return the
157  index to the next instruction. Jump instruction will add their
158  destination to the leads list.
159  */
160  virtual uint opt_mark(sp_head *,
161  List<sp_instr> *leads MY_ATTRIBUTE((unused))) {
162  m_marked = true;
163  return get_ip() + 1;
164  }
165 
166  /**
167  Short-cut jumps to jumps during optimization. This is used by the
168  jump instructions' opt_mark() methods. 'start' is the starting point,
169  used to prevent the mark sweep from looping for ever. Return the
170  end destination.
171  */
173  sp_instr *start MY_ATTRIBUTE((unused))) {
174  return get_ip();
175  }
176 
177  /**
178  Inform the instruction that it has been moved during optimization.
179  Most instructions will simply update its index, but jump instructions
180  must also take care of their destination pointers. Forward jumps get
181  pushed to the backpatch list 'ibp'.
182  */
183  virtual void opt_move(uint dst,
184  List<sp_branch_instr> *ibp MY_ATTRIBUTE((unused))) {
185  m_ip = dst;
186  }
187 
188  bool opt_is_marked() const { return m_marked; }
189 
191  return NULL;
192  }
193 
195 
196  protected:
197  /// Show if this instruction is reachable within the SP
198  /// (used by SP-optimizer).
199  bool m_marked;
200 
201  /// Instruction pointer.
203 
204  /// Instruction parsing context.
206 
207  private:
208  // Prevent use of copy constructor and assignment operator.
209  sp_instr(const sp_instr &);
210  void operator=(sp_instr &);
211 };
212 
213 ///////////////////////////////////////////////////////////////////////////
214 
215 /**
216  sp_lex_instr is a class providing the interface and base implementation
217  for SP-instructions, whose execution is based on expression evaluation.
218 
219  sp_lex_instr keeps LEX-object to be able to evaluate the expression.
220 
221  sp_lex_instr also provides possibility to re-parse the original query
222  string if for some reason the LEX-object is not valid any longer.
223 */
224 class sp_lex_instr : public sp_instr {
225  public:
226  sp_lex_instr(uint ip, sp_pcontext *ctx, LEX *lex, bool is_lex_owner)
227  : sp_instr(ip, ctx),
228  m_lex(NULL),
233  set_lex(lex, is_lex_owner);
234  }
235 
236  virtual ~sp_lex_instr() {
237  free_lex();
238  /*
239  If the instruction is reparsed, m_lex_mem_root was used to allocate
240  the items, then freeing the memroot, frees the items. Also free the
241  items allocated on heap as well.
242  */
244  }
245 
246  /**
247  Make a few attempts to execute the instruction.
248 
249  Basically, this operation does the following things:
250  - install Reprepare_observer to catch metadata changes (if any);
251  - calls reset_lex_and_exec_core() to execute the instruction;
252  - if the execution fails due to a change in metadata, re-parse the
253  instruction's SQL-statement and repeat execution.
254 
255  @param thd Thread context.
256  @param[out] nextp Next instruction pointer
257  @param open_tables Flag to specify if the function should check read
258  access to tables in LEX's table list and open and
259  lock them (used in instructions which need to
260  calculate some expression and don't execute
261  complete statement).
262 
263  @return Error status.
264  */
266 
268  return &m_trig_field_list;
269  }
270 
271  private:
272  /**
273  Prepare LEX and thread for execution of instruction, if requested open
274  and lock LEX's tables, execute instruction's core function, perform
275  cleanup afterwards.
276 
277  @param thd thread context
278  @param [out] nextp next instruction pointer
279  @param open_tables if true then check read access to tables in LEX's table
280  list and open and lock them (used in instructions which
281  need to calculate some expression and don't execute
282  complete statement).
283 
284  @note
285  We are not saving/restoring some parts of THD which may need this because
286  we do this once for whole routine execution in sp_head::execute().
287 
288  @return Error status.
289  */
290  bool reset_lex_and_exec_core(THD *thd, uint *nextp, bool open_tables);
291 
292  /**
293  (Re-)parse the query corresponding to this instruction and return a new
294  LEX-object.
295 
296  @param thd Thread context.
297  @param sp The stored program.
298 
299  @return new LEX-object or NULL in case of failure.
300  */
301  LEX *parse_expr(THD *thd, sp_head *sp);
302 
303  /**
304  Set LEX-object.
305 
306  Previously assigned LEX-object (if any) will be properly cleaned up
307  and destroyed.
308 
309  @param lex LEX-object to be used by this instance of sp_lex_instr.
310  @param is_lex_owner the flag specifying if this instance sp_lex_instr
311  owns (and thus deletes when needed) passed LEX-object.
312  */
313  void set_lex(LEX *lex, bool is_lex_owner);
314 
315  /**
316  Cleanup and destroy assigned LEX-object if needed.
317  */
318  void free_lex();
319 
320  public:
321  /////////////////////////////////////////////////////////////////////////
322  // sp_instr implementation.
323  /////////////////////////////////////////////////////////////////////////
324 
325  virtual bool execute(THD *thd, uint *nextp) {
326  /*
327  SP instructions with expressions should clear DA before execution.
328  Note that sp_instr_stmt will override execute(), but it clears DA
329  during normal mysql_execute_command().
330  */
331  clear_da(thd);
332  return validate_lex_and_execute_core(thd, nextp, true);
333  }
334 
335  protected:
336  /////////////////////////////////////////////////////////////////////////
337  // Interface (virtual) methods.
338  /////////////////////////////////////////////////////////////////////////
339 
340  /**
341  Execute core function of instruction after all preparations
342  (e.g. setting of proper LEX, saving part of the thread context).
343 
344  @param thd Thread context.
345  @param [out] nextp next instruction pointer
346 
347  @return Error flag.
348  */
349  virtual bool exec_core(THD *thd, uint *nextp) = 0;
350 
351  /**
352  @retval false if the object (i.e. LEX-object) is valid and exec_core() can
353  be just called.
354 
355  @retval true if the object is not valid any longer, exec_core() can not be
356  called. The original query string should be re-parsed and a new LEX-object
357  should be used.
358  */
359  virtual bool is_invalid() const = 0;
360 
361  /**
362  Invalidate the object.
363  */
364  virtual void invalidate() = 0;
365 
366  /**
367  Return the query string, which can be passed to the parser. I.e. the
368  operation should return a valid SQL-statement query string.
369 
370  @param[out] sql_query SQL-statement query string.
371  */
372  virtual void get_query(String *sql_query) const;
373 
374  /**
375  @return the expression query string. This string can not be passed directly
376  to the parser as it is most likely not a valid SQL-statement.
377 
378  @note as it can be seen in the get_query() implementation, get_expr_query()
379  might return EMPTY_CSTR. EMPTY_CSTR means that no query-expression is
380  available. That happens when class provides different implementation of
381  get_query(). Strictly speaking, this is a drawback of the current class
382  hierarchy.
383  */
384  virtual LEX_CSTRING get_expr_query() const { return EMPTY_CSTR; }
385 
386  /**
387  Callback function which is called after the statement query string is
388  successfully parsed, and the thread context has not been switched to the
389  outer context. The thread context contains new LEX-object corresponding to
390  the parsed query string.
391 
392  @param thd Thread context.
393 
394  @return Error flag.
395  */
396  virtual bool on_after_expr_parsing(THD *thd MY_ATTRIBUTE((unused))) {
397  return false;
398  }
399 
400  /**
401  Destroy items in the free list before re-parsing the statement query
402  string (and thus, creating new items).
403 
404  @param thd Thread context.
405  */
406  virtual void cleanup_before_parsing(THD *thd);
407 
408  /// LEX-object.
410 
411  private:
412  /**
413  Mem-root for storing the LEX-tree during reparse. This
414  mem-root is freed when a reparse is triggered or the stored
415  routine is dropped.
416  */
418 
419  /**
420  Indicates whether this sp_lex_instr instance is responsible for
421  LEX-object deletion.
422  */
424 
425  /**
426  Indicates whether exec_core() has not been already called on the current
427  LEX-object.
428  */
430 
431  /*****************************************************************************
432  Support for being able to execute this statement in two modes:
433  a) inside prelocked mode set by the calling procedure or its ancestor.
434  b) outside of prelocked mode, when this statement enters/leaves
435  prelocked mode itself.
436  *****************************************************************************/
437 
438  /**
439  List of additional tables this statement needs to lock when it
440  enters/leaves prelocked mode on its own.
441  */
443 
444  /**
445  The value m_lex->query_tables_own_last should be set to this when the
446  statement enters/leaves prelocked mode on its own.
447  */
449 
450  /**
451  List of all the Item_trigger_field's of instruction.
452  */
454 };
455 
456 ///////////////////////////////////////////////////////////////////////////
457 
458 /**
459  sp_instr_stmt represents almost all conventional SQL-statements, which are
460  supported outside stored programs.
461 
462  SET-statements, which deal with SP-variable or NEW/OLD trigger pseudo-rows are
463  not represented by this instruction.
464 */
465 class sp_instr_stmt : public sp_lex_instr {
466  public:
468  : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, true),
469  m_query(query),
470  m_valid(true) {}
471 
472  /////////////////////////////////////////////////////////////////////////
473  // sp_instr implementation.
474  /////////////////////////////////////////////////////////////////////////
475 
476  virtual bool execute(THD *thd, uint *nextp);
477 
478  /////////////////////////////////////////////////////////////////////////
479  // sp_printable implementation.
480  /////////////////////////////////////////////////////////////////////////
481 
482  virtual void print(const THD *thd, String *str);
483 
484  /////////////////////////////////////////////////////////////////////////
485  // sp_lex_instr implementation.
486  /////////////////////////////////////////////////////////////////////////
487 
488  virtual bool exec_core(THD *thd, uint *nextp);
489 
490  virtual bool is_invalid() const { return !m_valid; }
491 
492  virtual void invalidate() { m_valid = false; }
493 
494  virtual void get_query(String *sql_query) const {
495  sql_query->append(m_query.str, m_query.length);
496  }
497 
498  virtual bool on_after_expr_parsing(THD *) {
499  m_valid = true;
500  return false;
501  }
502 
503  private:
504  /// Complete query of the SQL-statement.
506 
507  /// Specify if the stored LEX-object is up-to-date.
508  bool m_valid;
509 
510 #ifdef HAVE_PSI_INTERFACE
511  public:
512  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
513 
515 #endif
516 };
517 
518 ///////////////////////////////////////////////////////////////////////////
519 
520 /**
521  sp_instr_set represents SET-statements, which deal with SP-variables.
522 */
523 class sp_instr_set : public sp_lex_instr {
524  public:
525  sp_instr_set(uint ip, LEX *lex, uint offset, Item *value_item,
526  LEX_CSTRING value_query, bool is_lex_owner)
527  : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, is_lex_owner),
528  m_offset(offset),
529  m_value_item(value_item),
530  m_value_query(value_query) {}
531 
532  /////////////////////////////////////////////////////////////////////////
533  // sp_printable implementation.
534  /////////////////////////////////////////////////////////////////////////
535 
536  virtual void print(const THD *thd, String *str);
537 
538  /////////////////////////////////////////////////////////////////////////
539  // sp_lex_instr implementation.
540  /////////////////////////////////////////////////////////////////////////
541 
542  virtual bool exec_core(THD *thd, uint *nextp);
543 
544  virtual bool is_invalid() const { return m_value_item == NULL; }
545 
546  virtual void invalidate() { m_value_item = NULL; }
547 
548  virtual bool on_after_expr_parsing(THD *thd) {
550 
552 
553  return false;
554  }
555 
556  virtual LEX_CSTRING get_expr_query() const { return m_value_query; }
557 
558  private:
559  /// Frame offset.
561 
562  /// Value expression item of the SET-statement.
564 
565  /// SQL-query corresponding to the value expression.
567 
568 #ifdef HAVE_PSI_INTERFACE
569  public:
571  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
572 #endif
573 };
574 
575 ///////////////////////////////////////////////////////////////////////////
576 
577 /**
578  sp_instr_set_trigger_field represents SET-statements, which deal with NEW/OLD
579  trigger pseudo-rows.
580 */
582  public:
583  sp_instr_set_trigger_field(uint ip, LEX *lex, LEX_CSTRING trigger_field_name,
584  Item_trigger_field *trigger_field,
585  Item *value_item, LEX_CSTRING value_query)
586  : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, true),
587  m_trigger_field_name(trigger_field_name),
588  m_trigger_field(trigger_field),
589  m_value_item(value_item),
590  m_value_query(value_query) {}
591 
592  /////////////////////////////////////////////////////////////////////////
593  // sp_printable implementation.
594  /////////////////////////////////////////////////////////////////////////
595 
596  virtual void print(const THD *thd, String *str);
597 
598  /////////////////////////////////////////////////////////////////////////
599  // sp_lex_instr implementation.
600  /////////////////////////////////////////////////////////////////////////
601 
602  virtual bool exec_core(THD *thd, uint *nextp);
603 
604  virtual bool is_invalid() const { return m_value_item == NULL; }
605 
606  virtual void invalidate() { m_value_item = NULL; }
607 
608  virtual bool on_after_expr_parsing(THD *thd);
609 
610  virtual void cleanup_before_parsing(THD *thd);
611 
612  virtual LEX_CSTRING get_expr_query() const { return m_value_query; }
613 
614  private:
615  /// Trigger field name ("field_name" of the "NEW.field_name").
617 
618  /// Item corresponding to the NEW/OLD trigger field.
620 
621  /// Value expression item of the SET-statement.
623 
624  /// SQL-query corresponding to the value expression.
626 
627 #ifdef HAVE_PSI_INTERFACE
628  public:
629  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
630 
632 #endif
633 };
634 
635 ///////////////////////////////////////////////////////////////////////////
636 
637 /**
638  sp_instr_freturn represents RETURN statement in stored functions.
639 */
641  public:
642  sp_instr_freturn(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query,
643  enum enum_field_types return_field_type)
644  : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, true),
645  m_expr_item(expr_item),
646  m_expr_query(expr_query),
647  m_return_field_type(return_field_type) {}
648 
649  /////////////////////////////////////////////////////////////////////////
650  // sp_printable implementation.
651  /////////////////////////////////////////////////////////////////////////
652 
653  virtual void print(const THD *thd, String *str);
654 
655  /////////////////////////////////////////////////////////////////////////
656  // sp_instr implementation.
657  /////////////////////////////////////////////////////////////////////////
658 
660  m_marked = true;
661  return UINT_MAX;
662  }
663 
664  /////////////////////////////////////////////////////////////////////////
665  // sp_lex_instr implementation.
666  /////////////////////////////////////////////////////////////////////////
667 
668  virtual bool exec_core(THD *thd, uint *nextp);
669 
670  virtual bool is_invalid() const { return m_expr_item == NULL; }
671 
672  virtual void invalidate() {
673  // it's already deleted.
674  m_expr_item = NULL;
675  }
676 
677  virtual bool on_after_expr_parsing(THD *thd) {
679 
681 
682  return false;
683  }
684 
685  virtual LEX_CSTRING get_expr_query() const { return m_expr_query; }
686 
687  private:
688  /// RETURN-expression item.
690 
691  /// SQL-query corresponding to the RETURN-expression.
693 
694  /// RETURN-field type code.
696 
697 #ifdef HAVE_PSI_INTERFACE
698  public:
699  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
700 
702 #endif
703 };
704 
705 ///////////////////////////////////////////////////////////////////////////
706 
707 /**
708  This is base class for all kinds of jump instructions.
709 
710  @note this is the only class, we directly construct instances of, that has
711  subclasses. We also redefine sp_instr_jump behavior in those subclasses.
712 
713  @todo later we will consider introducing a new class, which will be the base
714  for sp_instr_jump, sp_instr_set_case_expr and sp_instr_jump_case_when.
715  Something like sp_regular_branch_instr (similar to sp_lex_branch_instr).
716 */
717 class sp_instr_jump : public sp_instr, public sp_branch_instr {
718  public:
720  : sp_instr(ip, ctx), m_dest(0), m_optdest(NULL) {}
721 
723  : sp_instr(ip, ctx), m_dest(dest), m_optdest(NULL) {}
724 
725  /////////////////////////////////////////////////////////////////////////
726  // sp_printable implementation.
727  /////////////////////////////////////////////////////////////////////////
728 
729  virtual void print(const THD *thd, String *str);
730 
731  /////////////////////////////////////////////////////////////////////////
732  // sp_instr implementation.
733  /////////////////////////////////////////////////////////////////////////
734 
735  virtual bool execute(THD *, uint *nextp) {
736  *nextp = m_dest;
737  return false;
738  }
739 
740  virtual uint opt_mark(sp_head *sp, List<sp_instr> *leads);
741 
743 
744  virtual void opt_move(uint dst, List<sp_branch_instr> *ibp);
745 
746  /////////////////////////////////////////////////////////////////////////
747  // sp_branch_instr implementation.
748  /////////////////////////////////////////////////////////////////////////
749 
750  virtual void set_destination(uint old_dest, uint new_dest) {
751  if (m_dest == old_dest) m_dest = new_dest;
752  }
753 
754  virtual void backpatch(uint dest) {
755  /* Calling backpatch twice is a logic flaw in jump resolution. */
756  DBUG_ASSERT(m_dest == 0);
757  m_dest = dest;
758  }
759 
760  protected:
761  /// Where we will go.
763 
764  // The following attribute is used by SP-optimizer.
766 
767 #ifdef HAVE_PSI_INTERFACE
768  public:
769  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
770 
772 #endif
773 };
774 
775 ///////////////////////////////////////////////////////////////////////////
776 
777 /**
778  sp_lex_branch_instr is a base class for SP-instructions, which might perform
779  conditional jump depending on the value of an SQL-expression.
780 */
782  protected:
783  sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item,
784  LEX_CSTRING expr_query)
785  : sp_lex_instr(ip, ctx, lex, true),
786  m_dest(0),
787  m_cont_dest(0),
788  m_optdest(NULL),
790  m_expr_item(expr_item),
791  m_expr_query(expr_query) {}
792 
793  sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item,
794  LEX_CSTRING expr_query, uint dest)
795  : sp_lex_instr(ip, ctx, lex, true),
796  m_dest(dest),
797  m_cont_dest(0),
798  m_optdest(NULL),
800  m_expr_item(expr_item),
801  m_expr_query(expr_query) {}
802 
803  public:
804  void set_cont_dest(uint cont_dest) { m_cont_dest = cont_dest; }
805 
806  /////////////////////////////////////////////////////////////////////////
807  // sp_instr implementation.
808  /////////////////////////////////////////////////////////////////////////
809 
810  virtual uint opt_mark(sp_head *sp, List<sp_instr> *leads);
811 
812  virtual void opt_move(uint dst, List<sp_branch_instr> *ibp);
813 
814  virtual uint get_cont_dest() const { return m_cont_dest; }
815 
816  /////////////////////////////////////////////////////////////////////////
817  // sp_lex_instr implementation.
818  /////////////////////////////////////////////////////////////////////////
819 
820  virtual bool is_invalid() const { return m_expr_item == NULL; }
821 
822  virtual void invalidate() { m_expr_item = NULL; /* it's already deleted. */ }
823 
824  virtual LEX_CSTRING get_expr_query() const { return m_expr_query; }
825 
826  /////////////////////////////////////////////////////////////////////////
827  // sp_branch_instr implementation.
828  /////////////////////////////////////////////////////////////////////////
829 
830  virtual void set_destination(uint old_dest, uint new_dest) {
831  if (m_dest == old_dest) m_dest = new_dest;
832 
833  if (m_cont_dest == old_dest) m_cont_dest = new_dest;
834  }
835 
836  virtual void backpatch(uint dest) {
837  /* Calling backpatch twice is a logic flaw in jump resolution. */
838  DBUG_ASSERT(m_dest == 0);
839  m_dest = dest;
840  }
841 
842  protected:
843  /// Where we will go.
845 
846  /// Where continue handlers will go.
848 
849  // The following attributes are used by SP-optimizer.
852 
853  /// Expression item.
855 
856  /// SQL-query corresponding to the expression.
858 };
859 
860 ///////////////////////////////////////////////////////////////////////////
861 
862 /**
863  sp_instr_jump_if_not implements SP-instruction, which does the jump if its
864  SQL-expression is false.
865 */
867  public:
868  sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item,
869  LEX_CSTRING expr_query)
870  : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
871  expr_item, expr_query) {}
872 
873  sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item,
874  LEX_CSTRING expr_query, uint dest)
875  : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
876  expr_item, expr_query, dest) {}
877 
878  /////////////////////////////////////////////////////////////////////////
879  // sp_printable implementation.
880  /////////////////////////////////////////////////////////////////////////
881 
882  virtual void print(const THD *thd, String *str);
883 
884  /////////////////////////////////////////////////////////////////////////
885  // sp_lex_instr implementation.
886  /////////////////////////////////////////////////////////////////////////
887 
888  virtual bool exec_core(THD *thd, uint *nextp);
889 
890  virtual bool on_after_expr_parsing(THD *thd) {
892 
894 
895  return false;
896  }
897 
898 #ifdef HAVE_PSI_INTERFACE
899  public:
900  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
901 
903 #endif
904 };
905 
906 ///////////////////////////////////////////////////////////////////////////
907 // Instructions used for the "simple CASE" implementation.
908 ///////////////////////////////////////////////////////////////////////////
909 
910 /**
911  sp_instr_set_case_expr is used in the "simple CASE" implementation to evaluate
912  and store the CASE-expression in the runtime context.
913 */
915  public:
916  sp_instr_set_case_expr(uint ip, LEX *lex, uint case_expr_id,
917  Item *case_expr_item, LEX_CSTRING case_expr_query)
918  : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
919  case_expr_item, case_expr_query),
920  m_case_expr_id(case_expr_id) {}
921 
922  /////////////////////////////////////////////////////////////////////////
923  // sp_printable implementation.
924  /////////////////////////////////////////////////////////////////////////
925 
926  virtual void print(const THD *thd, String *str);
927 
928  /////////////////////////////////////////////////////////////////////////
929  // sp_instr implementation.
930  /////////////////////////////////////////////////////////////////////////
931 
932  virtual uint opt_mark(sp_head *sp, List<sp_instr> *leads);
933 
934  virtual void opt_move(uint dst, List<sp_branch_instr> *ibp);
935 
936  /////////////////////////////////////////////////////////////////////////
937  // sp_branch_instr implementation.
938  /////////////////////////////////////////////////////////////////////////
939 
940  /*
941  NOTE: set_destination() and backpatch() are overriden here just because the
942  m_dest attribute is not used by this class, so there is no need to do
943  anything about it.
944 
945  @todo These operations probably should be left as they are (i.e. do not
946  override them here). The m_dest attribute would be set and not used, but
947  that should not be a big deal.
948 
949  @todo This also indicates deficiency of the current SP-istruction class
950  hierarchy.
951  */
952 
953  virtual void set_destination(uint old_dest, uint new_dest) {
954  if (m_cont_dest == old_dest) m_cont_dest = new_dest;
955  }
956 
957  virtual void backpatch(uint) {}
958 
959  /////////////////////////////////////////////////////////////////////////
960  // sp_lex_instr implementation.
961  /////////////////////////////////////////////////////////////////////////
962 
963  virtual bool exec_core(THD *thd, uint *nextp);
964 
965  virtual bool on_after_expr_parsing(THD *thd) {
967 
969 
970  return false;
971  }
972 
973  private:
974  /// Identifier (index) of the CASE-expression in the runtime context.
976 
977 #ifdef HAVE_PSI_INTERFACE
978  public:
979  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
980 
982 #endif
983 };
984 
985 ///////////////////////////////////////////////////////////////////////////
986 
987 /**
988  sp_instr_jump_case_when instruction is used in the "simple CASE"
989  implementation. It's a jump instruction with the following condition:
990  (CASE-expression = WHEN-expression)
991  CASE-expression is retrieved from sp_rcontext;
992  WHEN-expression is kept by this instruction.
993 */
995  public:
996  sp_instr_jump_case_when(uint ip, LEX *lex, int case_expr_id,
997  Item *when_expr_item, LEX_CSTRING when_expr_query)
998  : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
999  when_expr_item, when_expr_query),
1000  m_case_expr_id(case_expr_id) {}
1001 
1002  /////////////////////////////////////////////////////////////////////////
1003  // sp_printable implementation.
1004  /////////////////////////////////////////////////////////////////////////
1005 
1006  virtual void print(const THD *thd, String *str);
1007 
1008  /////////////////////////////////////////////////////////////////////////
1009  // sp_lex_instr implementation.
1010  /////////////////////////////////////////////////////////////////////////
1011 
1012  virtual bool exec_core(THD *thd, uint *nextp);
1013 
1014  virtual void invalidate() {
1015  // Items should be already deleted in lex-keeper.
1017  m_eq_item = NULL;
1018  m_expr_item = NULL; // it's a WHEN-expression.
1019  }
1020 
1021  /**
1022  Build CASE-expression item tree:
1023  Item_func_eq(case-expression, when-i-expression)
1024 
1025  This function is used for the following form of CASE statement:
1026  CASE case-expression
1027  WHEN when-1-expression THEN ...
1028  WHEN when-2-expression THEN ...
1029  ...
1030  WHEN when-n-expression THEN ...
1031  END CASE
1032 
1033  The thing is that after the parsing we have an item (item tree) for the
1034  case-expression and for each when-expression. Here we build jump
1035  conditions: expressions like (case-expression = when-i-expression).
1036 
1037  @param thd Thread context.
1038 
1039  @return Error flag.
1040  */
1041  virtual bool on_after_expr_parsing(THD *thd);
1042 
1043  private:
1044  /// Identifier (index) of the CASE-expression in the runtime context.
1046 
1047  /// Item representing the CASE-expression.
1049 
1050  /**
1051  Item corresponding to the main item of the jump-condition-expression:
1052  it's the equal function (=) in the (case-expression = when-i-expression)
1053  expression.
1054  */
1056 
1057 #ifdef HAVE_PSI_INTERFACE
1058  public:
1059  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1060 
1062 #endif
1063 };
1064 
1065 ///////////////////////////////////////////////////////////////////////////
1066 // SQL-condition handler instructions.
1067 ///////////////////////////////////////////////////////////////////////////
1068 
1070  public:
1072 
1073  virtual ~sp_instr_hpush_jump();
1074 
1075  void add_condition(sp_condition_value *condition_value);
1076 
1078 
1079  /////////////////////////////////////////////////////////////////////////
1080  // sp_printable implementation.
1081  /////////////////////////////////////////////////////////////////////////
1082 
1083  virtual void print(const THD *thd, String *str);
1084 
1085  /////////////////////////////////////////////////////////////////////////
1086  // sp_instr implementation.
1087  /////////////////////////////////////////////////////////////////////////
1088 
1089  virtual bool execute(THD *thd, uint *nextp);
1090 
1091  virtual uint opt_mark(sp_head *sp, List<sp_instr> *leads);
1092 
1093  /** Override sp_instr_jump's shortcut; we stop here. */
1094  virtual uint opt_shortcut_jump(sp_head *, sp_instr *) { return get_ip(); }
1095 
1096  /////////////////////////////////////////////////////////////////////////
1097  // sp_branch_instr implementation.
1098  /////////////////////////////////////////////////////////////////////////
1099 
1100  virtual void backpatch(uint dest) {
1102  if (!m_dest)
1103  m_dest = dest;
1104  else
1105  m_opt_hpop = dest;
1106  }
1107 
1108  private:
1109  /// Handler.
1111 
1112  /// hpop marking end of handler scope.
1114 
1115  // This attribute is needed for SHOW PROCEDURE CODE only (i.e. it's needed in
1116  // debug version only). It's used in print().
1118 
1119 #ifdef HAVE_PSI_INTERFACE
1120  public:
1121  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1122 
1124 #endif
1125 };
1126 
1127 ///////////////////////////////////////////////////////////////////////////
1128 
1129 class sp_instr_hpop : public sp_instr {
1130  public:
1131  sp_instr_hpop(uint ip, sp_pcontext *ctx) : sp_instr(ip, ctx) {}
1132 
1133  /////////////////////////////////////////////////////////////////////////
1134  // sp_printable implementation.
1135  /////////////////////////////////////////////////////////////////////////
1136 
1137  virtual void print(const THD *, String *str) {
1138  str->append(STRING_WITH_LEN("hpop"));
1139  }
1140 
1141  /////////////////////////////////////////////////////////////////////////
1142  // sp_instr implementation.
1143  /////////////////////////////////////////////////////////////////////////
1144 
1145  virtual bool execute(THD *thd, uint *nextp);
1146 
1147 #ifdef HAVE_PSI_INTERFACE
1148  public:
1149  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1150 
1152 #endif
1153 };
1154 
1155 ///////////////////////////////////////////////////////////////////////////
1156 
1158  public:
1159  sp_instr_hreturn(uint ip, sp_pcontext *ctx);
1160 
1161  /////////////////////////////////////////////////////////////////////////
1162  // sp_printable implementation.
1163  /////////////////////////////////////////////////////////////////////////
1164 
1165  virtual void print(const THD *thd, String *str);
1166 
1167  /////////////////////////////////////////////////////////////////////////
1168  // sp_instr implementation.
1169  /////////////////////////////////////////////////////////////////////////
1170 
1171  virtual bool execute(THD *thd, uint *nextp);
1172 
1173  /** Override sp_instr_jump's shortcut; we stop here. */
1174  virtual uint opt_shortcut_jump(sp_head *, sp_instr *) { return get_ip(); }
1175 
1176  virtual uint opt_mark(sp_head *sp, List<sp_instr> *leads);
1177 
1178  private:
1179  // This attribute is needed for SHOW PROCEDURE CODE only (i.e. it's needed in
1180  // debug version only). It's used in print().
1182 
1183 #ifdef HAVE_PSI_INTERFACE
1184  public:
1185  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1186 
1188 #endif
1189 };
1190 
1191 ///////////////////////////////////////////////////////////////////////////
1192 // Cursor implementation.
1193 ///////////////////////////////////////////////////////////////////////////
1194 
1195 /**
1196  sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and
1197  OPEN.
1198 
1199  This is the most important instruction in cursor implementation. It is created
1200  and added to sp_head when DECLARE CURSOR is being parsed. The arena of this
1201  instruction contains LEX-object for the cursor's SELECT-statement.
1202 
1203  This instruction is actually used to open the cursor.
1204 
1205  execute() operation "implements" DECLARE CURSOR statement -- it merely pushes
1206  a new cursor object into the stack in sp_rcontext object.
1207 
1208  exec_core() operation implements OPEN statement. It is important to implement
1209  OPEN statement in this instruction, because OPEN may lead to re-parsing of the
1210  SELECT-statement. So, the original Arena and parsing context must be used.
1211 */
1213  public:
1214  sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *cursor_lex,
1215  LEX_CSTRING cursor_query, int cursor_idx)
1216  : sp_lex_instr(ip, ctx, cursor_lex, true),
1217  m_cursor_query(cursor_query),
1218  m_valid(true),
1219  m_cursor_idx(cursor_idx) {
1220  /*
1221  Cursors cause queries to depend on external state, so they are
1222  noncacheable.
1223  */
1224  cursor_lex->safe_to_cache_query = false;
1225  }
1226 
1227  /////////////////////////////////////////////////////////////////////////
1228  // sp_printable implementation.
1229  /////////////////////////////////////////////////////////////////////////
1230 
1231  virtual void print(const THD *thd, String *str);
1232 
1233  /////////////////////////////////////////////////////////////////////////
1234  // sp_instr implementation.
1235  /////////////////////////////////////////////////////////////////////////
1236 
1237  virtual bool execute(THD *thd, uint *nextp);
1238 
1239  /////////////////////////////////////////////////////////////////////////
1240  // sp_lex_instr implementation.
1241  /////////////////////////////////////////////////////////////////////////
1242 
1243  virtual bool exec_core(THD *thd, uint *nextp);
1244 
1245  virtual bool is_invalid() const { return !m_valid; }
1246 
1247  virtual void invalidate() { m_valid = false; }
1248 
1249  virtual void get_query(String *sql_query) const {
1251  }
1252 
1253  virtual bool on_after_expr_parsing(THD *) {
1254  m_valid = true;
1255  return false;
1256  }
1257 
1258  private:
1259  /// This attribute keeps the cursor SELECT statement.
1261 
1262  /// Flag if the LEX-object of this instruction is valid or not.
1263  /// The LEX-object is not valid when metadata have changed.
1264  bool m_valid;
1265 
1266  /// Used to identify the cursor in the sp_rcontext.
1268 
1269 #ifdef HAVE_PSI_INTERFACE
1270  public:
1271  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1272 
1274 #endif
1275 };
1276 
1277 ///////////////////////////////////////////////////////////////////////////
1278 
1279 /**
1280  sp_instr_cpop instruction is added at the end of BEGIN..END block.
1281  It's used to remove declared cursors so that they are not visible any longer.
1282 */
1283 class sp_instr_cpop : public sp_instr {
1284  public:
1286  : sp_instr(ip, ctx), m_count(count) {}
1287 
1288  /////////////////////////////////////////////////////////////////////////
1289  // sp_printable implementation.
1290  /////////////////////////////////////////////////////////////////////////
1291 
1292  virtual void print(const THD *thd, String *str);
1293 
1294  /////////////////////////////////////////////////////////////////////////
1295  // sp_instr implementation.
1296  /////////////////////////////////////////////////////////////////////////
1297 
1298  virtual bool execute(THD *thd, uint *nextp);
1299 
1300  private:
1302 
1303 #ifdef HAVE_PSI_INTERFACE
1304  public:
1305  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1306 
1308 #endif
1309 };
1310 
1311 ///////////////////////////////////////////////////////////////////////////
1312 
1313 /**
1314  sp_instr_copen represents OPEN statement (opens the cursor).
1315  However, the actual implementation is in sp_instr_cpush::exec_core().
1316 */
1317 class sp_instr_copen : public sp_instr {
1318  public:
1319  sp_instr_copen(uint ip, sp_pcontext *ctx, int cursor_idx)
1320  : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1321 
1322  /////////////////////////////////////////////////////////////////////////
1323  // sp_printable implementation.
1324  /////////////////////////////////////////////////////////////////////////
1325 
1326  virtual void print(const THD *thd, String *str);
1327 
1328  /////////////////////////////////////////////////////////////////////////
1329  // sp_instr implementation.
1330  /////////////////////////////////////////////////////////////////////////
1331 
1332  virtual bool execute(THD *thd, uint *nextp);
1333 
1334  private:
1335  /// Used to identify the cursor in the sp_rcontext.
1337 
1338 #ifdef HAVE_PSI_INTERFACE
1339  public:
1340  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1341 
1343 #endif
1344 };
1345 
1346 ///////////////////////////////////////////////////////////////////////////
1347 
1348 /**
1349  The instruction corresponds to the CLOSE statement.
1350  It just forwards the close-call to the appropriate sp_cursor object in the
1351  sp_rcontext.
1352 */
1353 class sp_instr_cclose : public sp_instr {
1354  public:
1355  sp_instr_cclose(uint ip, sp_pcontext *ctx, int cursor_idx)
1356  : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1357 
1358  /////////////////////////////////////////////////////////////////////////
1359  // sp_printable implementation.
1360  /////////////////////////////////////////////////////////////////////////
1361 
1362  virtual void print(const THD *thd, String *str);
1363 
1364  /////////////////////////////////////////////////////////////////////////
1365  // sp_instr implementation.
1366  /////////////////////////////////////////////////////////////////////////
1367 
1368  virtual bool execute(THD *thd, uint *nextp);
1369 
1370  private:
1371  /// Used to identify the cursor in the sp_rcontext.
1373 
1374 #ifdef HAVE_PSI_INTERFACE
1375  public:
1376  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1377 
1379 #endif
1380 };
1381 
1382 ///////////////////////////////////////////////////////////////////////////
1383 
1384 /**
1385  The instruction corresponds to the FETCH statement.
1386  It just forwards the close-call to the appropriate sp_cursor object in the
1387  sp_rcontext.
1388 */
1389 class sp_instr_cfetch : public sp_instr {
1390  public:
1391  sp_instr_cfetch(uint ip, sp_pcontext *ctx, int cursor_idx)
1392  : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1393 
1394  /////////////////////////////////////////////////////////////////////////
1395  // sp_printable implementation.
1396  /////////////////////////////////////////////////////////////////////////
1397 
1398  virtual void print(const THD *thd, String *str);
1399 
1400  /////////////////////////////////////////////////////////////////////////
1401  // sp_instr implementation.
1402  /////////////////////////////////////////////////////////////////////////
1403 
1404  virtual bool execute(THD *thd, uint *nextp);
1405 
1407 
1408  private:
1409  /// List of SP-variables to store fetched values.
1411 
1412  /// Used to identify the cursor in the sp_rcontext.
1414 
1415 #ifdef HAVE_PSI_INTERFACE
1416  public:
1417  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1418 
1420 #endif
1421 };
1422 
1423 ///////////////////////////////////////////////////////////////////////////
1424 ///////////////////////////////////////////////////////////////////////////
1425 
1426 /**
1427  sp_instr_error just throws an SQL-condition if the execution flow comes to it.
1428  It's used in the CASE implementation to perform runtime-check that the
1429  CASE-expression is handled by some WHEN/ELSE clause.
1430 */
1431 class sp_instr_error : public sp_instr {
1432  public:
1433  sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
1434  : sp_instr(ip, ctx), m_errcode(errcode) {}
1435 
1436  /////////////////////////////////////////////////////////////////////////
1437  // sp_printable implementation.
1438  /////////////////////////////////////////////////////////////////////////
1439 
1440  virtual void print(const THD *thd, String *str);
1441 
1442  /////////////////////////////////////////////////////////////////////////
1443  // sp_instr implementation.
1444  /////////////////////////////////////////////////////////////////////////
1445 
1446  virtual bool execute(THD *, uint *nextp) {
1447  my_error(m_errcode, MYF(0));
1448  *nextp = get_ip() + 1;
1449  return true;
1450  }
1451 
1453  m_marked = true;
1454  return UINT_MAX;
1455  }
1456 
1457  private:
1458  /// The error code, which should be raised by this instruction.
1460 
1461 #ifdef HAVE_PSI_INTERFACE
1462  public:
1463  virtual PSI_statement_info *get_psi_info() { return &psi_info; }
1464 
1466 #endif
1467 };
1468 
1469 ///////////////////////////////////////////////////////////////////////////
1470 
1471 #endif // _SP_INSTR_H_
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:672
virtual bool on_after_expr_parsing(THD *thd)
Build CASE-expression item tree: Item_func_eq(case-expression, when-i-expression) ...
Definition: sp_instr.cc:1231
sp_instr_hpop(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:1131
int m_case_expr_id
Identifier (index) of the CASE-expression in the runtime context.
Definition: sp_instr.h:1045
This file contains the field type.
This is base class for all kinds of jump instructions.
Definition: sp_instr.h:717
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:769
Our own string classes, used pervasively throughout the executor.
bool safe_to_cache_query
Whether this query will return the same answer every time, given unchanged data.
Definition: sql_lex.h:3415
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1149
Base class for every SP-instruction.
Definition: sp_instr.h:102
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1463
virtual uint opt_mark(sp_head *, List< sp_instr > *)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.h:659
virtual void backpatch(uint dest)
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
Definition: sp_instr.h:754
The instruction corresponds to the FETCH statement.
Definition: sp_instr.h:1389
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1429
static PSI_statement_info psi_info
Definition: sp_instr.h:631
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1518
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1340
virtual void get_query(String *sql_query) const
Return the query string, which can be passed to the parser.
Definition: sp_instr.h:1249
virtual bool execute(THD *, uint *nextp)
Execute this instruction.
Definition: sp_instr.h:1446
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1390
sp_instr_stmt represents almost all conventional SQL-statements, which are supported outside stored p...
Definition: sp_instr.h:465
Definition: sql_lex.h:3192
virtual bool is_invalid() const
Definition: sp_instr.h:604
ssize_t count
Definition: memcached.c:386
virtual uint opt_mark(sp_head *sp, List< sp_instr > *leads)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.cc:1443
static char * query
Definition: myisam_ftdump.cc:44
sp_instr_jump(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:719
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1476
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1646
virtual uint get_cont_dest() const
Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction...
Definition: sp_instr.h:136
bool validate_lex_and_execute_core(THD *thd, uint *nextp, bool open_tables)
Make a few attempts to execute the instruction.
Definition: sp_instr.cc:671
sp_instr_copen(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1319
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1185
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:822
MEM_ROOT m_lex_mem_root
Mem-root for storing the LEX-tree during reparse.
Definition: sp_instr.h:417
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:699
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:948
Some integer typedefs for easier portability.
uint m_ip
Instruction pointer.
Definition: sp_instr.h:202
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:215
virtual LEX_CSTRING get_expr_query() const
Definition: sp_instr.h:685
virtual bool is_invalid() const
Definition: sp_instr.h:490
virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
Short-cut jumps to jumps during optimization.
Definition: sp_instr.cc:1092
virtual LEX_CSTRING get_expr_query() const
Definition: sp_instr.h:556
LEX * parse_expr(THD *thd, sp_head *sp)
(Re-)parse the query corresponding to this instruction and return a new LEX-object.
Definition: sp_instr.cc:538
virtual PSI_statement_info * get_psi_info()=0
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1278
LEX * m_lex
LEX-object.
Definition: sp_instr.h:409
sp_instr_error just throws an SQL-condition if the execution flow comes to it.
Definition: sp_instr.h:1431
sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count)
Definition: sp_instr.h:1285
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1574
The instruction corresponds to the CLOSE statement.
Definition: sp_instr.h:1353
virtual bool is_invalid() const
Definition: sp_instr.h:544
virtual bool on_after_expr_parsing(THD *)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:498
const char * str
Definition: mysql_lex_string.h:40
sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
Definition: sp_instr.h:868
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1271
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:924
virtual void opt_move(uint dst, List< sp_branch_instr > *ibp)
Inform the instruction that it has been moved during optimization.
Definition: sp_instr.cc:1177
virtual uint opt_shortcut_jump(sp_head *, sp_instr *)
Override sp_instr_jump&#39;s shortcut; we stop here.
Definition: sp_instr.h:1174
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1679
sp_handler * m_handler
Handler.
Definition: sp_instr.h:1110
bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy)
Open all tables in list.
Definition: sql_base.cc:5538
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1372
uint m_count
Definition: sp_instr.h:1301
Definition: mysql_lex_string.h:39
sp_lex_instr is a class providing the interface and base implementation for SP-instructions, whose execution is based on expression evaluation.
Definition: sp_instr.h:224
virtual ~sp_instr_hpush_jump()
Definition: sp_instr.cc:1325
static app_data_list nextp(app_data_list l)
Return next element in list of app_data.
Definition: app_data.c:319
sp_handler * get_handler()
Definition: sp_instr.h:1077
virtual bool on_after_expr_parsing(THD *)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:1253
This class represents &#39;DECLARE HANDLER&#39; statement.
Definition: sp_pcontext.h:191
sp_instr_set(uint ip, LEX *lex, uint offset, Item *value_item, LEX_CSTRING value_query, bool is_lex_owner)
Definition: sp_instr.h:525
SELECT_LEX * select_lex
First query block.
Definition: sql_lex.h:3197
LEX_CSTRING m_expr_query
SQL-query corresponding to the expression.
Definition: sp_instr.h:857
static PSI_statement_info psi_info
Definition: sp_instr.h:981
LEX_CSTRING m_value_query
SQL-query corresponding to the value expression.
Definition: sp_instr.h:625
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:677
sp_instr_stmt(uint ip, LEX *lex, LEX_CSTRING query)
Definition: sp_instr.h:467
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:900
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1334
void free_items()
Definition: sql_class.cc:1647
sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest)
Definition: sp_instr.h:722
sp_instr_cclose(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1355
sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *cursor_lex, LEX_CSTRING cursor_query, int cursor_idx)
Definition: sp_instr.h:1214
List< Item > item_list
List of columns and expressions: SELECT: Columns and expressions in the SELECT list.
Definition: sql_lex.h:1165
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4009
virtual void cleanup_before_parsing(THD *thd)
Destroy items in the free list before re-parsing the statement query string (and thus, creating new items).
Definition: sp_instr.cc:1063
sp_instr * m_cont_optdest
Definition: sp_instr.h:851
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:973
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:161
virtual bool is_invalid() const
Definition: sp_instr.h:820
virtual void print(const THD *thd, String *str)=0
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:548
Item_case_expr * m_case_expr_item
Item representing the CASE-expression.
Definition: sp_instr.h:1048
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1206
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1124
sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
Definition: sp_instr.h:873
Item_trigger_field * m_trigger_field
Item corresponding to the NEW/OLD trigger field.
Definition: sp_instr.h:619
sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and OPEN. ...
Definition: sp_instr.h:1212
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1511
Diagnostics_area * get_stmt_da()
Returns first Diagnostics Area for the current statement.
Definition: sql_class.h:2823
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1059
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1485
Item * m_expr_item
RETURN-expression item.
Definition: sp_instr.h:689
sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
Definition: sp_instr.h:1433
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
sp_instr_set_case_expr(uint ip, LEX *lex, uint case_expr_id, Item *case_expr_item, LEX_CSTRING case_expr_query)
Definition: sp_instr.h:916
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1077
static PSI_statement_info psi_info
Definition: sp_instr.h:1342
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:1247
void add_to_varlist(sp_variable *var)
Definition: sp_instr.h:1406
uint m_cont_dest
Where continue handlers will go.
Definition: sp_instr.h:847
void clear_da(THD *thd) const
Clear diagnostics area.
Definition: sp_instr.h:145
virtual void opt_move(uint dst, List< sp_branch_instr > *ibp)
Inform the instruction that it has been moved during optimization.
Definition: sp_instr.cc:1107
bool append(const String &s)
Definition: sql_string.cc:447
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:989
virtual void get_query(String *sql_query) const
Return the query string, which can be passed to the parser.
Definition: sp_instr.cc:800
List< sp_variable > m_varlist
List of SP-variables to store fetched values.
Definition: sp_instr.h:1410
sp_pcontext * get_parsing_ctx() const
Definition: sp_instr.h:138
Definition: sql_class.h:229
static PSI_statement_info psi_info
Definition: sp_instr.h:1187
LEX_CSTRING m_value_query
SQL-query corresponding to the value expression.
Definition: sp_instr.h:566
virtual ~sp_branch_instr()
Definition: sp_instr.h:93
virtual bool is_invalid() const
Definition: sp_instr.h:670
uint m_opt_hpop
hpop marking end of handler scope.
Definition: sp_instr.h:1113
static PSI_statement_info psi_info
Definition: sp_instr.h:1378
static PSI_statement_info psi_info
Definition: sp_instr.h:1307
sp_instr_set_case_expr is used in the "simple CASE" implementation to evaluate and store the CASE-exp...
Definition: sp_instr.h:914
Definition: sp_instr.h:1129
Definition: aggregate_check.h:523
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:890
int m_errcode
The error code, which should be raised by this instruction.
Definition: sp_instr.h:1459
virtual bool execute(THD *thd, uint *nextp)=0
Execute this instruction.
virtual void invalidate()=0
Invalidate the object.
static PSI_statement_info psi_info
Definition: sp_instr.h:1151
size_t length
Definition: mysql_lex_string.h:41
Item * m_expr_item
Expression item.
Definition: sp_instr.h:854
sp_instr_set_trigger_field represents SET-statements, which deal with NEW/OLD trigger pseudo-rows...
Definition: sp_instr.h:581
virtual void opt_move(uint dst, List< sp_branch_instr > *ibp)
Inform the instruction that it has been moved during optimization.
Definition: sp_instr.cc:1744
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
Definition: sp_instr.h:1157
sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
Definition: sp_instr.h:793
sp_instr_jump_case_when instruction is used in the "simple CASE" implementation.
Definition: sp_instr.h:994
Header for compiler-dependent features.
LEX_CSTRING m_query
Complete query of the SQL-statement.
Definition: sp_instr.h:505
sp_instr * m_optdest
Definition: sp_instr.h:850
virtual bool exec_core(THD *thd, uint *nextp)=0
Execute core function of instruction after all preparations (e.g.
enum enum_field_types m_return_field_type
RETURN-field type code.
Definition: sp_instr.h:695
static PSI_statement_info psi_info
Definition: sp_instr.h:570
virtual void backpatch(uint dest)=0
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
enum_field_types
Column types for MySQL.
Definition: field_types.h:52
An interface for all SP-instructions with destinations that need to be updated by the SP-optimizer...
Definition: sp_instr.h:75
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Statement instrument information.
Definition: psi_statement_bits.h:108
This class represents a stored program variable or a parameter (also referenced as &#39;SP-variable&#39;)...
Definition: sp_pcontext.h:47
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1610
bool opt_is_marked() const
Definition: sp_instr.h:188
Definition: item.h:668
unsigned int uint
Definition: uca-dump.cc:29
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:965
virtual uint opt_mark(sp_head *, List< sp_instr > *)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.h:1452
sp_instr_jump_if_not implements SP-instruction, which does the jump if its SQL-expression is false...
Definition: sp_instr.h:866
#define true
Definition: config_static.h:44
virtual bool execute(THD *, uint *nextp)
Execute this instruction.
Definition: sp_instr.h:735
virtual ~sp_lex_instr()
Definition: sp_instr.h:236
#define MYF(v)
Definition: my_inttypes.h:114
static PSI_statement_info psi_info
Definition: sp_instr.h:1123
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1340
Performance schema instrumentation interface.
static PSI_statement_info psi_info
Definition: sp_instr.h:1273
LEX_CSTRING m_expr_query
SQL-query corresponding to the RETURN-expression.
Definition: sp_instr.h:692
virtual void cleanup_before_parsing(THD *thd)
Destroy items in the free list before re-parsing the statement query string (and thus, creating new items).
Definition: sp_instr.cc:787
static PSI_statement_info psi_info
Definition: sp_instr.h:1419
sp_instr_hreturn(uint ip, sp_pcontext *ctx)
Definition: sp_instr.cc:1405
bool m_first_execution
Indicates whether exec_core() has not been already called on the current LEX-object.
Definition: sp_instr.h:429
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1136
static PSI_statement_info psi_info
Definition: sp_instr.h:1465
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1695
virtual SQL_I_List< Item_trigger_field > * get_instr_trig_field_list()
Definition: sp_instr.h:267
sp_instr * m_optdest
Definition: sp_instr.h:765
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:820
sp_instr_cpop instruction is added at the end of BEGIN..END block.
Definition: sp_instr.h:1283
static PSI_statement_info psi_info
Definition: sp_instr.h:701
virtual uint opt_shortcut_jump(sp_head *, sp_instr *)
Override sp_instr_jump&#39;s shortcut; we stop here.
Definition: sp_instr.h:1094
void reset_condition_info(THD *thd)
Reset the current condition information stored in the Diagnostics Area.
Definition: sql_error.cc:482
uint m_dest
Where we will go.
Definition: sp_instr.h:762
virtual void print(const THD *, String *str)
Definition: sp_instr.h:1137
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1035
sp_head represents one instance of a stored program.
Definition: sp_head.h:405
Common header for many mysys elements.
bool m_is_lex_owner
Indicates whether this sp_lex_instr instance is responsible for LEX-object deletion.
Definition: sp_instr.h:423
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:979
Item * m_value_item
Value expression item of the SET-statement.
Definition: sp_instr.h:622
virtual void set_destination(uint old_dest, uint new_dest)=0
Update the destination; used by the SP-instruction-optimizer.
virtual void set_destination(uint old_dest, uint new_dest)
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:953
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.h:396
void operator=(sp_instr &)
LEX * lex
Definition: sql_class.h:838
sp_instr_set_trigger_field(uint ip, LEX *lex, LEX_CSTRING trigger_field_name, Item_trigger_field *trigger_field, Item *value_item, LEX_CSTRING value_query)
Definition: sp_instr.h:583
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:546
bool reset_lex_and_exec_core(THD *thd, uint *nextp, bool open_tables)
Prepare LEX and thread for execution of instruction, if requested open and lock LEX&#39;s tables...
Definition: sp_instr.cc:303
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1305
virtual bool is_invalid() const =0
Definition: sp_instr.h:1069
sp_instr_jump_case_when(uint ip, LEX *lex, int case_expr_id, Item *when_expr_item, LEX_CSTRING when_expr_query)
Definition: sp_instr.h:996
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1376
void free_lex()
Cleanup and destroy assigned LEX-object if needed.
Definition: sp_instr.cc:774
uint m_frame
Definition: sp_instr.h:1181
virtual uint get_cont_dest() const
Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction...
Definition: sp_instr.h:814
LEX_CSTRING m_trigger_field_name
Trigger field name ("field_name" of the "NEW.field_name").
Definition: sp_instr.h:616
static PSI_statement_info psi_info
Definition: sp_instr.h:902
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:629
virtual ~sp_printable()
Definition: sp_instr.h:68
LEX_CSTRING EMPTY_CSTR
Definition: sql_class.cc:107
#define alloc_root_inited(A)
Definition: my_sys.h:814
uint elements
Definition: sql_list.h:135
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1297
TABLE_LIST ** m_lex_query_tables_own_last
The value m_lex->query_tables_own_last should be set to this when the statement enters/leaves prelock...
Definition: sp_instr.h:448
virtual uint opt_shortcut_jump(sp_head *, sp_instr *start)
Short-cut jumps to jumps during optimization.
Definition: sp_instr.h:172
static PSI_statement_info psi_info
Definition: sp_instr.h:771
TABLE_LIST * m_prelocking_tables
List of additional tables this statement needs to lock when it enters/leaves prelocked mode on its ow...
Definition: sp_instr.h:442
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1218
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1413
sp_instr_copen represents OPEN statement (opens the cursor).
Definition: sp_instr.h:1317
sp_printable defines an interface which should be implemented if a class wants report some internal i...
Definition: sp_instr.h:64
sp_instr_freturn(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, enum enum_field_types return_field_type)
Definition: sp_instr.h:642
LEX_CSTRING m_cursor_query
This attribute keeps the cursor SELECT statement.
Definition: sp_instr.h:1260
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1121
sp_pcontext * m_parsing_ctx
Instruction parsing context.
Definition: sp_instr.h:205
sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
Definition: sp_instr.h:783
virtual uint opt_mark(sp_head *sp, List< sp_instr > *leads)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.cc:1352
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:512
virtual uint opt_mark(sp_head *sp, List< sp_instr > *leads)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.cc:1153
#define NULL
Definition: types.h:55
void set_cont_dest(uint cont_dest)
Definition: sp_instr.h:804
uint m_case_expr_id
Identifier (index) of the CASE-expression in the runtime context.
Definition: sp_instr.h:975
uint get_ip() const
Definition: sp_instr.h:129
static void start(PluginFuncEnv *env)
Definition: http_server_plugin.cc:572
void add_condition(sp_condition_value *condition_value)
Definition: sp_instr.cc:1330
static PSI_statement_info psi_info
Definition: sp_instr.h:514
virtual LEX_CSTRING get_expr_query() const
Definition: sp_instr.h:384
sp_instr_cfetch(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1391
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed...
Definition: sp_instr.cc:1042
virtual void print(const THD *thd, String *str)
Definition: sp_instr.cc:1718
Item * m_eq_item
Item corresponding to the main item of the jump-condition-expression: it&#39;s the equal function (=) in ...
Definition: sp_instr.h:1055
bool m_marked
Show if this instruction is reachable within the SP (used by SP-optimizer).
Definition: sp_instr.h:199
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:1014
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1635
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1267
sp_lex_branch_instr is a base class for SP-instructions, which might perform conditional jump dependi...
Definition: sp_instr.h:781
sp_instr(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:104
Represents NEW/OLD version of field of row which is changed/read in trigger.
Definition: item.h:5581
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.h:325
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1408
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
bool m_valid
Specify if the stored LEX-object is up-to-date.
Definition: sp_instr.h:508
uint m_offset
Frame offset.
Definition: sp_instr.h:560
Definition: table.h:2468
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1533
bool push_back(T *a)
Definition: sql_list.h:442
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:571
uint m_frame
Definition: sp_instr.h:1117
virtual void set_destination(uint old_dest, uint new_dest)
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:750
sp_instr_hpush_jump(uint ip, sp_pcontext *ctx, sp_handler *handler)
Definition: sp_instr.cc:1316
virtual LEX_CSTRING get_expr_query() const
Definition: sp_instr.h:612
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:606
static PSI_statement_info psi_info
Definition: sp_instr.h:1061
virtual void invalidate()
Invalidate the object.
Definition: sp_instr.h:492
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1599
void set_lex(LEX *lex, bool is_lex_owner)
Set LEX-object.
Definition: sp_instr.cc:764
virtual uint opt_mark(sp_head *sp, List< sp_instr > *leads)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.cc:1084
sp_instr_set represents SET-statements, which deal with SP-variables.
Definition: sp_instr.h:523
Item * m_value_item
Value expression item of the SET-statement.
Definition: sp_instr.h:563
uint m_dest
Where we will go.
Definition: sp_instr.h:844
void reset_diagnostics_area()
Clear this Diagnostics Area.
Definition: sql_error.cc:357
virtual void set_destination(uint old_dest, uint new_dest)
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:830
T * head()
Definition: sql_list.h:454
Query_arena m_arena
Definition: sp_instr.h:194
SQL_I_List< Item_trigger_field > m_trig_field_list
List of all the Item_trigger_field&#39;s of instruction.
Definition: sp_instr.h:453
virtual void opt_move(uint dst, List< sp_branch_instr > *ibp)
Inform the instruction that it has been moved during optimization.
Definition: sp_instr.h:183
#define false
Definition: config_static.h:43
sp_instr_freturn represents RETURN statement in stored functions.
Definition: sp_instr.h:640
virtual bool exec_core(THD *thd, uint *nextp)
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1016
virtual bool is_invalid() const
Definition: sp_instr.h:1245
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1336
virtual bool execute(THD *thd, uint *nextp)
Execute this instruction.
Definition: sp_instr.cc:1468
virtual PSI_statement_info * get_psi_info()
Definition: sp_instr.h:1417
bool m_valid
Flag if the LEX-object of this instruction is valid or not.
Definition: sp_instr.h:1264
virtual void backpatch(uint dest)
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
Definition: sp_instr.h:1100
virtual uint opt_mark(sp_head *sp, List< sp_instr > *leads)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.cc:1730
virtual uint opt_mark(sp_head *, List< sp_instr > *leads)
Mark this instruction as reachable during optimization and return the index to the next instruction...
Definition: sp_instr.h:160
virtual ~sp_instr()
Definition: sp_instr.h:110
virtual SQL_I_List< Item_trigger_field > * get_instr_trig_field_list()
Definition: sp_instr.h:190
Definition: item.h:3005
sp_lex_instr(uint ip, sp_pcontext *ctx, LEX *lex, bool is_lex_owner)
Definition: sp_instr.h:226
virtual void backpatch(uint)
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
Definition: sp_instr.h:957
virtual void get_query(String *sql_query) const
Return the query string, which can be passed to the parser.
Definition: sp_instr.h:494
virtual void backpatch(uint dest)
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
Definition: sp_instr.h:836
#define STRING_WITH_LEN(X)
Definition: m_string.h:315
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
virtual LEX_CSTRING get_expr_query() const
Definition: sp_instr.h:824