MySQL 8.4.3
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 void adjust_sql_command(LEX *lex) override {
698 assert(lex->sql_command == SQLCOM_SELECT);
699 lex->sql_command = SQLCOM_END;
700 }
701
702 private:
703 /// RETURN-expression item.
705
706 /// SQL-query corresponding to the RETURN-expression.
708
709 /// RETURN-field type code.
711
712#ifdef HAVE_PSI_INTERFACE
713 public:
714 PSI_statement_info *get_psi_info() override { return &psi_info; }
715
717#endif
718};
719
720///////////////////////////////////////////////////////////////////////////
721
722/**
723 This is base class for all kinds of jump instructions.
724
725 @note this is the only class, we directly construct instances of, that has
726 subclasses. We also redefine sp_instr_jump behavior in those subclasses.
727
728 @todo later we will consider introducing a new class, which will be the base
729 for sp_instr_jump, sp_instr_set_case_expr and sp_instr_jump_case_when.
730 Something like sp_regular_branch_instr (similar to sp_lex_branch_instr).
731*/
732class sp_instr_jump : public sp_instr, public sp_branch_instr {
733 public:
735 : sp_instr(ip, ctx), m_dest(0), m_optdest(nullptr) {}
736
737 sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest)
738 : sp_instr(ip, ctx), m_dest(dest), m_optdest(nullptr) {}
739
740 /////////////////////////////////////////////////////////////////////////
741 // sp_printable implementation.
742 /////////////////////////////////////////////////////////////////////////
743
744 void print(const THD *thd, String *str) override;
745
746 /////////////////////////////////////////////////////////////////////////
747 // sp_instr implementation.
748 /////////////////////////////////////////////////////////////////////////
749
750 bool execute(THD *, uint *nextp) override {
751 *nextp = m_dest;
752 return false;
753 }
754
755 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
756
757 uint opt_shortcut_jump(sp_head *sp, sp_instr *start) override;
758
759 void opt_move(uint dst, List<sp_branch_instr> *ibp) override;
760
761 /////////////////////////////////////////////////////////////////////////
762 // sp_branch_instr implementation.
763 /////////////////////////////////////////////////////////////////////////
764
765 void set_destination(uint old_dest, uint new_dest) override {
766 if (m_dest == old_dest) m_dest = new_dest;
767 }
768
769 void backpatch(uint dest) override {
770 /* Calling backpatch twice is a logic flaw in jump resolution. */
771 assert(m_dest == 0);
772 m_dest = dest;
773 }
774
775 protected:
776 /// Where we will go.
777 uint m_dest;
778
779 // The following attribute is used by SP-optimizer.
781
782#ifdef HAVE_PSI_INTERFACE
783 public:
784 PSI_statement_info *get_psi_info() override { return &psi_info; }
785
787#endif
788};
789
790///////////////////////////////////////////////////////////////////////////
791
792/**
793 sp_lex_branch_instr is a base class for SP-instructions, which might perform
794 conditional jump depending on the value of an SQL-expression.
795*/
797 protected:
798 sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item,
799 LEX_CSTRING expr_query)
800 : sp_lex_instr(ip, ctx, lex, true),
801 m_dest(0),
802 m_cont_dest(0),
805 m_expr_item(expr_item),
806 m_expr_query(expr_query) {}
807
808 sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item,
809 LEX_CSTRING expr_query, uint dest)
810 : sp_lex_instr(ip, ctx, lex, true),
811 m_dest(dest),
812 m_cont_dest(0),
815 m_expr_item(expr_item),
816 m_expr_query(expr_query) {}
817
818 public:
819 void set_cont_dest(uint cont_dest) { m_cont_dest = cont_dest; }
820
821 /////////////////////////////////////////////////////////////////////////
822 // sp_instr implementation.
823 /////////////////////////////////////////////////////////////////////////
824
825 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
826
827 void opt_move(uint dst, List<sp_branch_instr> *ibp) override;
828
829 uint get_cont_dest() const override { return m_cont_dest; }
830
831 /////////////////////////////////////////////////////////////////////////
832 // sp_lex_instr implementation.
833 /////////////////////////////////////////////////////////////////////////
834
835 bool is_invalid() const override { return m_expr_item == nullptr; }
836
837 void invalidate() override {
838 m_expr_item = nullptr; /* it's already deleted. */
839 }
840
841 LEX_CSTRING get_expr_query() const override { return m_expr_query; }
842
843 /////////////////////////////////////////////////////////////////////////
844 // sp_branch_instr implementation.
845 /////////////////////////////////////////////////////////////////////////
846
847 void set_destination(uint old_dest, uint new_dest) override {
848 if (m_dest == old_dest) m_dest = new_dest;
849
850 if (m_cont_dest == old_dest) m_cont_dest = new_dest;
851 }
852
853 void backpatch(uint dest) override {
854 /* Calling backpatch twice is a logic flaw in jump resolution. */
855 assert(m_dest == 0);
856 m_dest = dest;
857 }
858
859 void adjust_sql_command(LEX *lex) override {
860 assert(lex->sql_command == SQLCOM_SELECT);
861 lex->sql_command = SQLCOM_END;
862 }
863
864 protected:
865 /// Where we will go.
866 uint m_dest;
867
868 /// Where continue handlers will go.
870
871 // The following attributes are used by SP-optimizer.
874
875 /// Expression item.
877
878 /// SQL-query corresponding to the expression.
880};
881
882///////////////////////////////////////////////////////////////////////////
883
884/**
885 sp_instr_jump_if_not implements SP-instruction, which does the jump if its
886 SQL-expression is false.
887*/
889 public:
890 sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item,
891 LEX_CSTRING expr_query)
892 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
893 expr_item, expr_query) {}
894
895 sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item,
896 LEX_CSTRING expr_query, uint dest)
897 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
898 expr_item, expr_query, dest) {}
899
900 /////////////////////////////////////////////////////////////////////////
901 // sp_printable implementation.
902 /////////////////////////////////////////////////////////////////////////
903
904 void print(const THD *thd, String *str) override;
905
906 /////////////////////////////////////////////////////////////////////////
907 // sp_lex_instr implementation.
908 /////////////////////////////////////////////////////////////////////////
909
910 bool exec_core(THD *thd, uint *nextp) override;
911
912 bool on_after_expr_parsing(THD *thd) override {
914 assert(m_expr_item != nullptr);
915 return false;
916 }
917
918#ifdef HAVE_PSI_INTERFACE
919 public:
920 PSI_statement_info *get_psi_info() override { return &psi_info; }
921
923#endif
924};
925
926///////////////////////////////////////////////////////////////////////////
927// Instructions used for the "simple CASE" implementation.
928///////////////////////////////////////////////////////////////////////////
929
930/**
931 sp_instr_set_case_expr is used in the "simple CASE" implementation to evaluate
932 and store the CASE-expression in the runtime context.
933*/
935 public:
936 sp_instr_set_case_expr(uint ip, LEX *lex, uint case_expr_id,
937 Item *case_expr_item, LEX_CSTRING case_expr_query)
938 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
939 case_expr_item, case_expr_query),
940 m_case_expr_id(case_expr_id) {}
941
942 /////////////////////////////////////////////////////////////////////////
943 // sp_printable implementation.
944 /////////////////////////////////////////////////////////////////////////
945
946 void print(const THD *thd, String *str) override;
947
948 /////////////////////////////////////////////////////////////////////////
949 // sp_instr implementation.
950 /////////////////////////////////////////////////////////////////////////
951
952 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
953
954 void opt_move(uint dst, List<sp_branch_instr> *ibp) override;
955
956 /////////////////////////////////////////////////////////////////////////
957 // sp_branch_instr implementation.
958 /////////////////////////////////////////////////////////////////////////
959
960 /*
961 NOTE: set_destination() and backpatch() are overridden here just because the
962 m_dest attribute is not used by this class, so there is no need to do
963 anything about it.
964
965 @todo These operations probably should be left as they are (i.e. do not
966 override them here). The m_dest attribute would be set and not used, but
967 that should not be a big deal.
968
969 @todo This also indicates deficiency of the current SP-istruction class
970 hierarchy.
971 */
972
973 void set_destination(uint old_dest, uint new_dest) override {
974 if (m_cont_dest == old_dest) m_cont_dest = new_dest;
975 }
976
977 void backpatch(uint) override {}
978
979 /////////////////////////////////////////////////////////////////////////
980 // sp_lex_instr implementation.
981 /////////////////////////////////////////////////////////////////////////
982
983 bool exec_core(THD *thd, uint *nextp) override;
984
985 bool on_after_expr_parsing(THD *thd) override {
987 assert(m_expr_item != nullptr);
988 return false;
989 }
990
991 private:
992 /// Identifier (index) of the CASE-expression in the runtime context.
994
995#ifdef HAVE_PSI_INTERFACE
996 public:
997 PSI_statement_info *get_psi_info() override { return &psi_info; }
998
1000#endif
1001};
1002
1003///////////////////////////////////////////////////////////////////////////
1004
1005/**
1006 sp_instr_jump_case_when instruction is used in the "simple CASE"
1007 implementation. It's a jump instruction with the following condition:
1008 (CASE-expression = WHEN-expression)
1009 CASE-expression is retrieved from sp_rcontext;
1010 WHEN-expression is kept by this instruction.
1011*/
1013 public:
1014 sp_instr_jump_case_when(uint ip, LEX *lex, int case_expr_id,
1015 Item *when_expr_item, LEX_CSTRING when_expr_query)
1016 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
1017 when_expr_item, when_expr_query),
1018 m_case_expr_id(case_expr_id) {}
1019
1020 /////////////////////////////////////////////////////////////////////////
1021 // sp_printable implementation.
1022 /////////////////////////////////////////////////////////////////////////
1023
1024 void print(const THD *thd, String *str) override;
1025
1026 /////////////////////////////////////////////////////////////////////////
1027 // sp_lex_instr implementation.
1028 /////////////////////////////////////////////////////////////////////////
1029
1030 bool exec_core(THD *thd, uint *nextp) override;
1031
1032 void invalidate() override {
1033 // Items should be already deleted in lex-keeper.
1034 m_case_expr_item = nullptr;
1035 m_eq_item = nullptr;
1036 m_expr_item = nullptr; // it's a WHEN-expression.
1037 }
1038
1039 /**
1040 Build CASE-expression item tree:
1041 Item_func_eq(case-expression, when-i-expression)
1042
1043 This function is used for the following form of CASE statement:
1044 CASE case-expression
1045 WHEN when-1-expression THEN ...
1046 WHEN when-2-expression THEN ...
1047 ...
1048 WHEN when-n-expression THEN ...
1049 END CASE
1050
1051 The thing is that after the parsing we have an item (item tree) for the
1052 case-expression and for each when-expression. Here we build jump
1053 conditions: expressions like (case-expression = when-i-expression).
1054
1055 @param thd Thread context.
1056
1057 @return Error flag.
1058 */
1059 bool on_after_expr_parsing(THD *thd) override;
1060
1061 private:
1062 /// Identifier (index) of the CASE-expression in the runtime context.
1064
1065 /// Item representing the CASE-expression.
1067
1068 /**
1069 Item corresponding to the main item of the jump-condition-expression:
1070 it's the equal function (=) in the (case-expression = when-i-expression)
1071 expression.
1072 */
1074
1075#ifdef HAVE_PSI_INTERFACE
1076 public:
1078
1080#endif
1081};
1082
1083///////////////////////////////////////////////////////////////////////////
1084// SQL-condition handler instructions.
1085///////////////////////////////////////////////////////////////////////////
1086
1088 public:
1090
1091 ~sp_instr_hpush_jump() override;
1092
1093 void add_condition(sp_condition_value *condition_value);
1094
1096
1097 /////////////////////////////////////////////////////////////////////////
1098 // sp_printable implementation.
1099 /////////////////////////////////////////////////////////////////////////
1100
1101 void print(const THD *thd, String *str) override;
1102
1103 /////////////////////////////////////////////////////////////////////////
1104 // sp_instr implementation.
1105 /////////////////////////////////////////////////////////////////////////
1106
1107 bool execute(THD *thd, uint *nextp) override;
1108
1109 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
1110
1111 /** Override sp_instr_jump's shortcut; we stop here. */
1112 uint opt_shortcut_jump(sp_head *, sp_instr *) override { return get_ip(); }
1113
1114 /////////////////////////////////////////////////////////////////////////
1115 // sp_branch_instr implementation.
1116 /////////////////////////////////////////////////////////////////////////
1117
1118 void backpatch(uint dest) override {
1119 assert(!m_dest || !m_opt_hpop);
1120 if (!m_dest)
1121 m_dest = dest;
1122 else
1123 m_opt_hpop = dest;
1124 }
1125
1126 private:
1127 /// Handler.
1129
1130 /// hpop marking end of handler scope.
1132
1133 // This attribute is needed for SHOW PROCEDURE CODE only (i.e. it's needed in
1134 // debug version only). It's used in print().
1136
1137#ifdef HAVE_PSI_INTERFACE
1138 public:
1140
1142#endif
1143};
1144
1145///////////////////////////////////////////////////////////////////////////
1146
1147class sp_instr_hpop : public sp_instr {
1148 public:
1149 sp_instr_hpop(uint ip, sp_pcontext *ctx) : sp_instr(ip, ctx) {}
1150
1151 /////////////////////////////////////////////////////////////////////////
1152 // sp_printable implementation.
1153 /////////////////////////////////////////////////////////////////////////
1154
1155 void print(const THD *, String *str) override {
1156 str->append(STRING_WITH_LEN("hpop"));
1157 }
1158
1159 /////////////////////////////////////////////////////////////////////////
1160 // sp_instr implementation.
1161 /////////////////////////////////////////////////////////////////////////
1162
1163 bool execute(THD *thd, uint *nextp) override;
1164
1165#ifdef HAVE_PSI_INTERFACE
1166 public:
1168
1170#endif
1171};
1172
1173///////////////////////////////////////////////////////////////////////////
1174
1176 public:
1177 sp_instr_hreturn(uint ip, sp_pcontext *ctx);
1178
1179 /////////////////////////////////////////////////////////////////////////
1180 // sp_printable implementation.
1181 /////////////////////////////////////////////////////////////////////////
1182
1183 void print(const THD *thd, String *str) override;
1184
1185 /////////////////////////////////////////////////////////////////////////
1186 // sp_instr implementation.
1187 /////////////////////////////////////////////////////////////////////////
1188
1189 bool execute(THD *thd, uint *nextp) override;
1190
1191 /** Override sp_instr_jump's shortcut; we stop here. */
1192 uint opt_shortcut_jump(sp_head *, sp_instr *) override { return get_ip(); }
1193
1194 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
1195
1196 private:
1197 // This attribute is needed for SHOW PROCEDURE CODE only (i.e. it's needed in
1198 // debug version only). It's used in print().
1200
1201#ifdef HAVE_PSI_INTERFACE
1202 public:
1204
1206#endif
1207};
1208
1209///////////////////////////////////////////////////////////////////////////
1210// Cursor implementation.
1211///////////////////////////////////////////////////////////////////////////
1212
1213/**
1214 sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and
1215 OPEN.
1216
1217 This is the most important instruction in cursor implementation. It is created
1218 and added to sp_head when DECLARE CURSOR is being parsed. The arena of this
1219 instruction contains LEX-object for the cursor's SELECT-statement.
1220
1221 This instruction is actually used to open the cursor.
1222
1223 execute() operation "implements" DECLARE CURSOR statement -- it merely pushes
1224 a new cursor object into the stack in sp_rcontext object.
1225
1226 exec_core() operation implements OPEN statement. It is important to implement
1227 OPEN statement in this instruction, because OPEN may lead to re-parsing of the
1228 SELECT-statement. So, the original Arena and parsing context must be used.
1229*/
1231 public:
1232 sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *cursor_lex,
1233 LEX_CSTRING cursor_query, int cursor_idx)
1234 : sp_lex_instr(ip, ctx, cursor_lex, true),
1235 m_cursor_query(cursor_query),
1236 m_valid(true),
1237 m_cursor_idx(cursor_idx) {
1238 /*
1239 Cursors cause queries to depend on external state, so they are
1240 noncacheable.
1241 */
1242 cursor_lex->safe_to_cache_query = false;
1243 }
1244
1245 /////////////////////////////////////////////////////////////////////////
1246 // sp_printable implementation.
1247 /////////////////////////////////////////////////////////////////////////
1248
1249 void print(const THD *thd, String *str) override;
1250
1251 /////////////////////////////////////////////////////////////////////////
1252 // sp_instr implementation.
1253 /////////////////////////////////////////////////////////////////////////
1254
1255 bool execute(THD *thd, uint *nextp) override;
1256
1257 /////////////////////////////////////////////////////////////////////////
1258 // sp_lex_instr implementation.
1259 /////////////////////////////////////////////////////////////////////////
1260
1261 bool exec_core(THD *thd, uint *nextp) override;
1262
1263 bool is_invalid() const override { return !m_valid; }
1264
1265 void invalidate() override { m_valid = false; }
1266
1267 void get_query(String *sql_query) const override {
1269 }
1270
1271 bool on_after_expr_parsing(THD *) override {
1272 m_valid = true;
1273 return false;
1274 }
1275
1276 private:
1277 /// This attribute keeps the cursor SELECT statement.
1279
1280 /// Flag if the LEX-object of this instruction is valid or not.
1281 /// The LEX-object is not valid when metadata have changed.
1283
1284 /// Used to identify the cursor in the sp_rcontext.
1286
1287#ifdef HAVE_PSI_INTERFACE
1288 public:
1290
1292#endif
1293};
1294
1295///////////////////////////////////////////////////////////////////////////
1296
1297/**
1298 sp_instr_cpop instruction is added at the end of BEGIN..END block.
1299 It's used to remove declared cursors so that they are not visible any longer.
1300*/
1301class sp_instr_cpop : public sp_instr {
1302 public:
1303 sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count)
1304 : sp_instr(ip, ctx), m_count(count) {}
1305
1306 /////////////////////////////////////////////////////////////////////////
1307 // sp_printable implementation.
1308 /////////////////////////////////////////////////////////////////////////
1309
1310 void print(const THD *thd, String *str) override;
1311
1312 /////////////////////////////////////////////////////////////////////////
1313 // sp_instr implementation.
1314 /////////////////////////////////////////////////////////////////////////
1315
1316 bool execute(THD *thd, uint *nextp) override;
1317
1318 private:
1320
1321#ifdef HAVE_PSI_INTERFACE
1322 public:
1324
1326#endif
1327};
1328
1329///////////////////////////////////////////////////////////////////////////
1330
1331/**
1332 sp_instr_copen represents OPEN statement (opens the cursor).
1333 However, the actual implementation is in sp_instr_cpush::exec_core().
1334*/
1335class sp_instr_copen : public sp_instr {
1336 public:
1337 sp_instr_copen(uint ip, sp_pcontext *ctx, int cursor_idx)
1338 : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1339
1340 /////////////////////////////////////////////////////////////////////////
1341 // sp_printable implementation.
1342 /////////////////////////////////////////////////////////////////////////
1343
1344 void print(const THD *thd, String *str) override;
1345
1346 /////////////////////////////////////////////////////////////////////////
1347 // sp_instr implementation.
1348 /////////////////////////////////////////////////////////////////////////
1349
1350 bool execute(THD *thd, uint *nextp) override;
1351
1352 private:
1353 /// Used to identify the cursor in the sp_rcontext.
1355
1356#ifdef HAVE_PSI_INTERFACE
1357 public:
1359
1361#endif
1362};
1363
1364///////////////////////////////////////////////////////////////////////////
1365
1366/**
1367 The instruction corresponds to the CLOSE statement.
1368 It just forwards the close-call to the appropriate sp_cursor object in the
1369 sp_rcontext.
1370*/
1372 public:
1373 sp_instr_cclose(uint ip, sp_pcontext *ctx, int cursor_idx)
1374 : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1375
1376 /////////////////////////////////////////////////////////////////////////
1377 // sp_printable implementation.
1378 /////////////////////////////////////////////////////////////////////////
1379
1380 void print(const THD *thd, String *str) override;
1381
1382 /////////////////////////////////////////////////////////////////////////
1383 // sp_instr implementation.
1384 /////////////////////////////////////////////////////////////////////////
1385
1386 bool execute(THD *thd, uint *nextp) override;
1387
1388 private:
1389 /// Used to identify the cursor in the sp_rcontext.
1391
1392#ifdef HAVE_PSI_INTERFACE
1393 public:
1395
1397#endif
1398};
1399
1400///////////////////////////////////////////////////////////////////////////
1401
1402/**
1403 The instruction corresponds to the FETCH statement.
1404 It just forwards the close-call to the appropriate sp_cursor object in the
1405 sp_rcontext.
1406*/
1408 public:
1409 sp_instr_cfetch(uint ip, sp_pcontext *ctx, int cursor_idx)
1410 : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1411
1412 /////////////////////////////////////////////////////////////////////////
1413 // sp_printable implementation.
1414 /////////////////////////////////////////////////////////////////////////
1415
1416 void print(const THD *thd, String *str) override;
1417
1418 /////////////////////////////////////////////////////////////////////////
1419 // sp_instr implementation.
1420 /////////////////////////////////////////////////////////////////////////
1421
1422 bool execute(THD *thd, uint *nextp) override;
1423
1424 void add_to_varlist(sp_variable *var) { m_varlist.push_back(var); }
1425
1426 private:
1427 /// List of SP-variables to store fetched values.
1429
1430 /// Used to identify the cursor in the sp_rcontext.
1432
1433#ifdef HAVE_PSI_INTERFACE
1434 public:
1436
1438#endif
1439};
1440
1441///////////////////////////////////////////////////////////////////////////
1442///////////////////////////////////////////////////////////////////////////
1443
1444/**
1445 sp_instr_error just throws an SQL-condition if the execution flow comes to it.
1446 It's used in the CASE implementation to perform runtime-check that the
1447 CASE-expression is handled by some WHEN/ELSE clause.
1448*/
1449class sp_instr_error : public sp_instr {
1450 public:
1451 sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
1452 : sp_instr(ip, ctx), m_errcode(errcode) {}
1453
1454 /////////////////////////////////////////////////////////////////////////
1455 // sp_printable implementation.
1456 /////////////////////////////////////////////////////////////////////////
1457
1458 void print(const THD *thd, String *str) override;
1459
1460 /////////////////////////////////////////////////////////////////////////
1461 // sp_instr implementation.
1462 /////////////////////////////////////////////////////////////////////////
1463
1464 bool execute(THD *, uint *nextp) override {
1465 my_error(m_errcode, MYF(0));
1466 *nextp = get_ip() + 1;
1467 return true;
1468 }
1469
1470 uint opt_mark(sp_head *, List<sp_instr> *) override {
1471 m_marked = true;
1472 return UINT_MAX;
1473 }
1474
1475 private:
1476 /// The error code, which should be raised by this instruction.
1478
1479#ifdef HAVE_PSI_INTERFACE
1480 public:
1482
1484#endif
1485};
1486
1487///////////////////////////////////////////////////////////////////////////
1488
1489#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:3969
Represents NEW/OLD version of field of row which is changed/read in trigger.
Definition: item.h:6756
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
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:2607
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:3302
Definition: table.h:2864
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4571
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:1371
static PSI_statement_info psi_info
Definition: sp_instr.h:1396
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1732
sp_instr_cclose(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1373
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1390
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1743
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1394
The instruction corresponds to the FETCH statement.
Definition: sp_instr.h:1407
List< sp_variable > m_varlist
List of SP-variables to store fetched values.
Definition: sp_instr.h:1428
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1435
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1769
sp_instr_cfetch(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1409
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1780
static PSI_statement_info psi_info
Definition: sp_instr.h:1437
void add_to_varlist(sp_variable *var)
Definition: sp_instr.h:1424
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1431
sp_instr_copen represents OPEN statement (opens the cursor).
Definition: sp_instr.h:1335
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1665
sp_instr_copen(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1337
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1706
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1358
static PSI_statement_info psi_info
Definition: sp_instr.h:1360
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1354
sp_instr_cpop instruction is added at the end of BEGIN..END block.
Definition: sp_instr.h:1301
uint m_count
Definition: sp_instr.h:1319
static PSI_statement_info psi_info
Definition: sp_instr.h:1325
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1323
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1648
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1641
sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count)
Definition: sp_instr.h:1303
sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and OPEN.
Definition: sp_instr.h:1230
bool is_invalid() const override
Definition: sp_instr.h:1263
bool on_after_expr_parsing(THD *) override
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.h:1271
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:1265
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1289
static PSI_statement_info psi_info
Definition: sp_instr.h:1291
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1285
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1596
void get_query(String *sql_query) const override
Return the query string, which can be passed to the parser.
Definition: sp_instr.h:1267
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1613
LEX_CSTRING m_cursor_query
This attribute keeps the cursor SELECT statement.
Definition: sp_instr.h:1278
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1604
bool m_valid
Flag if the LEX-object of this instruction is valid or not.
Definition: sp_instr.h:1282
sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *cursor_lex, LEX_CSTRING cursor_query, int cursor_idx)
Definition: sp_instr.h:1232
sp_instr_error just throws an SQL-condition if the execution flow comes to it.
Definition: sp_instr.h:1449
bool execute(THD *, uint *nextp) override
Execute this instruction.
Definition: sp_instr.h:1464
sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
Definition: sp_instr.h:1451
int m_errcode
The error code, which should be raised by this instruction.
Definition: sp_instr.h:1477
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1481
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:1470
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1815
static PSI_statement_info psi_info
Definition: sp_instr.h:1483
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:707
static PSI_statement_info psi_info
Definition: sp_instr.h:716
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:684
Item * m_expr_item
RETURN-expression item.
Definition: sp_instr.h:704
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1400
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:710
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:714
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1419
bool is_invalid() const override
Definition: sp_instr.h:682
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:697
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:1147
void print(const THD *, String *str) override
Definition: sp_instr.h:1155
static PSI_statement_info psi_info
Definition: sp_instr.h:1169
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1167
sp_instr_hpop(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:1149
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1515
Definition: sp_instr.h:1087
sp_instr_hpush_jump(uint ip, sp_pcontext *ctx, sp_handler *handler)
Definition: sp_instr.cc:1439
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1463
uint opt_shortcut_jump(sp_head *, sp_instr *) override
Override sp_instr_jump's shortcut; we stop here.
Definition: sp_instr.h:1112
uint m_opt_hpop
hpop marking end of handler scope.
Definition: sp_instr.h:1131
sp_handler * m_handler
Handler.
Definition: sp_instr.h:1128
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:1118
~sp_instr_hpush_jump() override
Definition: sp_instr.cc:1448
uint m_frame
Definition: sp_instr.h:1135
static PSI_statement_info psi_info
Definition: sp_instr.h:1141
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1457
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:1475
void add_condition(sp_condition_value *condition_value)
Definition: sp_instr.cc:1453
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1139
sp_handler * get_handler()
Definition: sp_instr.h:1095
Definition: sp_instr.h:1175
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1203
uint m_frame
Definition: sp_instr.h:1199
static PSI_statement_info psi_info
Definition: sp_instr.h:1205
uint opt_shortcut_jump(sp_head *, sp_instr *) override
Override sp_instr_jump's shortcut; we stop here.
Definition: sp_instr.h:1192
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:1569
sp_instr_hreturn(uint ip, sp_pcontext *ctx)
Definition: sp_instr.cc:1531
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1534
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1555
sp_instr_jump_case_when instruction is used in the "simple CASE" implementation.
Definition: sp_instr.h:1012
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1340
int m_case_expr_id
Identifier (index) of the CASE-expression in the runtime context.
Definition: sp_instr.h:1063
static PSI_statement_info psi_info
Definition: sp_instr.h:1079
Item_case_expr * m_case_expr_item
Item representing the CASE-expression.
Definition: sp_instr.h:1066
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:1353
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:1032
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:1073
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:1014
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1077
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1328
sp_instr_jump_if_not implements SP-instruction, which does the jump if its SQL-expression is false.
Definition: sp_instr.h:888
sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
Definition: sp_instr.h:890
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:912
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1257
static PSI_statement_info psi_info
Definition: sp_instr.h:922
sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
Definition: sp_instr.h:895
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:920
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1245
This is base class for all kinds of jump instructions.
Definition: sp_instr.h:732
sp_instr_jump(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:734
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:784
sp_instr * m_optdest
Definition: sp_instr.h:780
sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest)
Definition: sp_instr.h:737
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:1204
uint m_dest
Where we will go.
Definition: sp_instr.h:777
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:769
static PSI_statement_info psi_info
Definition: sp_instr.h:786
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1197
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:1227
uint opt_shortcut_jump(sp_head *sp, sp_instr *start) override
Short-cut jumps to jumps during optimization.
Definition: sp_instr.cc:1212
bool execute(THD *, uint *nextp) override
Execute this instruction.
Definition: sp_instr.h:750
void set_destination(uint old_dest, uint new_dest) override
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:765
sp_instr_set_case_expr is used in the "simple CASE" implementation to evaluate and store the CASE-exp...
Definition: sp_instr.h:934
void set_destination(uint old_dest, uint new_dest) override
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:973
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1855
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:1881
static PSI_statement_info psi_info
Definition: sp_instr.h:999
uint m_case_expr_id
Identifier (index) of the CASE-expression in the runtime context.
Definition: sp_instr.h:993
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:985
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:997
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1832
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:936
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:1867
void backpatch(uint) override
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
Definition: sp_instr.h:977
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:1161
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:1135
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:1181
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1154
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:1090
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:1107
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:1036
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:1060
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:932
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:796
sp_instr * m_cont_optdest
Definition: sp_instr.h:873
sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
Definition: sp_instr.h:808
uint m_dest
Where we will go.
Definition: sp_instr.h:866
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:1298
sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
Definition: sp_instr.h:798
uint m_cont_dest
Where continue handlers will go.
Definition: sp_instr.h:869
bool is_invalid() const override
Definition: sp_instr.h:835
sp_instr * m_optdest
Definition: sp_instr.h:872
void set_destination(uint old_dest, uint new_dest) override
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:847
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:1274
LEX_CSTRING m_expr_query
SQL-query corresponding to the expression.
Definition: sp_instr.h:879
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:859
LEX_CSTRING get_expr_query() const override
Definition: sp_instr.h:841
Item * m_expr_item
Expression item.
Definition: sp_instr.h:876
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:837
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:853
uint get_cont_dest() const override
Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction.
Definition: sp_instr.h:829
void set_cont_dest(uint cont_dest)
Definition: sp_instr.h:819
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:872
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:911
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:882
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:898
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:4772
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:1081
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:29
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3823
bool safe_to_cache_query
Whether this query will return the same answer every time, given unchanged data.
Definition: sql_lex.h:4183
Query_block * query_block
First query block.
Definition: sql_lex.h:3828
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