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