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