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