MySQL 9.1.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 Parse statement corresponding to this instruction and return a new LEX.
296
297 @param thd Thread context.
298 @param sp The stored program.
299
300 @return new LEX-object or NULL in case of failure.
301 */
302 LEX *parse_statement(THD *thd, sp_head *sp);
303
304 /**
305 Set LEX-object.
306
307 Previously assigned LEX-object (if any) will be properly cleaned up
308 and destroyed.
309
310 @param lex LEX-object to be used by this instance of sp_lex_instr.
311 @param is_lex_owner the flag specifying if this instance sp_lex_instr
312 owns (and thus deletes when needed) passed LEX-object.
313 */
314 void set_lex(LEX *lex, bool is_lex_owner);
315
316 /**
317 Cleanup and destroy assigned LEX-object if needed.
318 */
319 void free_lex();
320
321 public:
322 /////////////////////////////////////////////////////////////////////////
323 // sp_instr implementation.
324 /////////////////////////////////////////////////////////////////////////
325
326 bool execute(THD *thd, uint *nextp) override {
327 /*
328 SP instructions with expressions should clear DA before execution.
329 Note that sp_instr_stmt will override execute(), but it clears DA
330 during normal mysql_execute_command().
331 */
332 clear_da(thd);
333 return validate_lex_and_execute_core(thd, nextp, true);
334 }
335
336 protected:
337 /////////////////////////////////////////////////////////////////////////
338 // Interface (virtual) methods.
339 /////////////////////////////////////////////////////////////////////////
340
341 /**
342 Execute core function of instruction after all preparations
343 (e.g. setting of proper LEX, saving part of the thread context).
344
345 @param thd Thread context.
346 @param [out] nextp next instruction pointer
347
348 @return Error flag.
349 */
350 virtual bool exec_core(THD *thd, uint *nextp) = 0;
351
352 /**
353 @retval false if the object (i.e. LEX-object) is valid and exec_core() can
354 be just called.
355
356 @retval true if the object is not valid any longer, exec_core() can not be
357 called. The original query string should be re-parsed and a new LEX-object
358 should be used.
359 */
360 virtual bool is_invalid() const = 0;
361
362 /**
363 Invalidate the object.
364 */
365 virtual void invalidate() = 0;
366
367 /**
368 Return the query string, which can be passed to the parser. I.e. the
369 operation should return a valid SQL-statement query string.
370
371 @param[out] sql_query SQL-statement query string.
372 */
373 virtual void get_query(String *sql_query) const;
374
375 /**
376 Some expressions may be re-parsed as SELECT statements, but need to be
377 adjusted to another SQL command. This function facilitates that change.
378 */
379 virtual void adjust_sql_command(LEX *) {}
380
381 /**
382 @return the expression query string. This string can not be passed directly
383 to the parser as it is most likely not a valid SQL-statement.
384
385 @note as it can be seen in the get_query() implementation, get_expr_query()
386 might return EMPTY_CSTR. EMPTY_CSTR means that no query-expression is
387 available. That happens when class provides different implementation of
388 get_query(). Strictly speaking, this is a drawback of the current class
389 hierarchy.
390 */
391 virtual LEX_CSTRING get_expr_query() const { return EMPTY_CSTR; }
392
393 /**
394 Callback function which is called after the statement query string is
395 successfully parsed, and the thread context has not been switched to the
396 outer context. The thread context contains new LEX-object corresponding to
397 the parsed query string.
398
399 @param thd Thread context.
400
401 @return Error flag.
402 */
403 virtual bool on_after_expr_parsing(THD *thd [[maybe_unused]]) {
404 return false;
405 }
406
407 /**
408 Destroy items in the free list before re-parsing the statement query
409 string (and thus, creating new items).
410
411 @param thd Thread context.
412 */
413 virtual void cleanup_before_parsing(THD *thd);
414
415 /// LEX-object.
417
418 private:
419 /**
420 Mem-root for storing the LEX-tree during reparse. This
421 mem-root is freed when a reparse is triggered or the stored
422 routine is dropped.
423 */
425
426 /**
427 Indicates whether this sp_lex_instr instance is responsible for
428 LEX-object deletion.
429 */
431
432 /**
433 Indicates whether exec_core() has not been already called on the current
434 LEX-object.
435 */
437
438 /*****************************************************************************
439 Support for being able to execute this statement in two modes:
440 a) inside prelocked mode set by the calling procedure or its ancestor.
441 b) outside of prelocked mode, when this statement enters/leaves
442 prelocked mode itself.
443 *****************************************************************************/
444
445 /**
446 List of additional tables this statement needs to lock when it
447 enters/leaves prelocked mode on its own.
448 */
450
451 /**
452 The value m_lex->query_tables_own_last should be set to this when the
453 statement enters/leaves prelocked mode on its own.
454 */
456
457 /**
458 List of all the Item_trigger_field's of instruction.
459 */
461};
462
463///////////////////////////////////////////////////////////////////////////
464
465/**
466 sp_instr_stmt represents almost all conventional SQL-statements, which are
467 supported outside stored programs.
468
469 SET-statements, which deal with SP-variable or NEW/OLD trigger pseudo-rows are
470 not represented by this instruction.
471*/
473 public:
475 : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, true),
476 m_query(query),
477 m_valid(true) {}
478
479 /////////////////////////////////////////////////////////////////////////
480 // sp_instr implementation.
481 /////////////////////////////////////////////////////////////////////////
482
483 bool execute(THD *thd, uint *nextp) override;
484
485 /////////////////////////////////////////////////////////////////////////
486 // sp_printable implementation.
487 /////////////////////////////////////////////////////////////////////////
488
489 void print(const THD *thd, String *str) override;
490
491 /////////////////////////////////////////////////////////////////////////
492 // sp_lex_instr implementation.
493 /////////////////////////////////////////////////////////////////////////
494
495 bool exec_core(THD *thd, uint *nextp) override;
496
497 bool is_invalid() const override { return !m_valid; }
498
499 void invalidate() override { m_valid = false; }
500
501 void get_query(String *sql_query) const override {
502 sql_query->append(m_query.str, m_query.length);
503 }
504
505 bool on_after_expr_parsing(THD *) override {
506 m_valid = true;
507 return false;
508 }
509
510 private:
511 /// Complete query of the SQL-statement.
513
514 /// Specify if the stored LEX-object is up-to-date.
516
517#ifdef HAVE_PSI_INTERFACE
518 public:
519 PSI_statement_info *get_psi_info() override { return &psi_info; }
520
522#endif
523};
524
525///////////////////////////////////////////////////////////////////////////
526
527/**
528 sp_instr_set represents SET-statements, which deal with SP-variables.
529*/
531 public:
532 sp_instr_set(uint ip, LEX *lex, uint offset, Item *value_item,
533 LEX_CSTRING value_query, bool is_lex_owner)
534 : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, is_lex_owner),
535 m_offset(offset),
536 m_value_item(value_item),
537 m_value_query(value_query) {}
538
539 /////////////////////////////////////////////////////////////////////////
540 // sp_printable implementation.
541 /////////////////////////////////////////////////////////////////////////
542
543 void print(const THD *thd, String *str) override;
544
545 /////////////////////////////////////////////////////////////////////////
546 // sp_lex_instr implementation.
547 /////////////////////////////////////////////////////////////////////////
548
549 bool exec_core(THD *thd, uint *nextp) override;
550
551 bool is_invalid() const override { return m_value_item == nullptr; }
552
553 void invalidate() override { m_value_item = nullptr; }
554
555 bool on_after_expr_parsing(THD *thd) override {
557 assert(m_value_item != nullptr);
558
559 return false;
560 }
561
562 LEX_CSTRING get_expr_query() const override { return m_value_query; }
563
564 void adjust_sql_command(LEX *lex) override {
565 assert(lex->sql_command == SQLCOM_SELECT);
567 }
568
569 private:
570 /// Frame offset.
572
573 /// Value expression item of the SET-statement.
575
576 /// SQL-query corresponding to the value expression.
578
579#ifdef HAVE_PSI_INTERFACE
580 public:
582 PSI_statement_info *get_psi_info() override { return &psi_info; }
583#endif
584};
585
586///////////////////////////////////////////////////////////////////////////
587
588/**
589 sp_instr_set_trigger_field represents SET-statements, which deal with NEW/OLD
590 trigger pseudo-rows.
591*/
593 public:
594 sp_instr_set_trigger_field(uint ip, LEX *lex, LEX_CSTRING trigger_field_name,
595 Item_trigger_field *trigger_field,
596 Item *value_item, LEX_CSTRING value_query)
597 : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, true),
598 m_trigger_field_name(trigger_field_name),
599 m_trigger_field(trigger_field),
600 m_value_item(value_item),
601 m_value_query(value_query) {}
602
603 /////////////////////////////////////////////////////////////////////////
604 // sp_printable implementation.
605 /////////////////////////////////////////////////////////////////////////
606
607 void print(const THD *thd, String *str) override;
608
609 /////////////////////////////////////////////////////////////////////////
610 // sp_lex_instr implementation.
611 /////////////////////////////////////////////////////////////////////////
612
613 bool exec_core(THD *thd, uint *nextp) override;
614
615 bool is_invalid() const override { return m_value_item == nullptr; }
616
617 void invalidate() override { m_value_item = nullptr; }
618
619 bool on_after_expr_parsing(THD *thd) override;
620
621 void cleanup_before_parsing(THD *thd) override;
622
623 LEX_CSTRING get_expr_query() const override { return m_value_query; }
624
625 private:
626 /// Trigger field name ("field_name" of the "NEW.field_name").
628
629 /// Item corresponding to the NEW/OLD trigger field.
631
632 /// Value expression item of the SET-statement.
634
635 /// SQL-query corresponding to the value expression.
637
638#ifdef HAVE_PSI_INTERFACE
639 public:
640 PSI_statement_info *get_psi_info() override { return &psi_info; }
641
643#endif
644};
645
646///////////////////////////////////////////////////////////////////////////
647
648/**
649 sp_instr_freturn represents RETURN statement in stored functions.
650*/
652 public:
653 sp_instr_freturn(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query,
654 enum enum_field_types return_field_type)
655 : sp_lex_instr(ip, lex->get_sp_current_parsing_ctx(), lex, true),
656 m_expr_item(expr_item),
657 m_expr_query(expr_query),
658 m_return_field_type(return_field_type) {}
659
660 /////////////////////////////////////////////////////////////////////////
661 // sp_printable implementation.
662 /////////////////////////////////////////////////////////////////////////
663
664 void print(const THD *thd, String *str) override;
665
666 /////////////////////////////////////////////////////////////////////////
667 // sp_instr implementation.
668 /////////////////////////////////////////////////////////////////////////
669
670 uint opt_mark(sp_head *, List<sp_instr> *) override {
671 m_marked = true;
672 return UINT_MAX;
673 }
674
675 /////////////////////////////////////////////////////////////////////////
676 // sp_lex_instr implementation.
677 /////////////////////////////////////////////////////////////////////////
678
679 bool exec_core(THD *thd, uint *nextp) override;
680
681 bool is_invalid() const override { return m_expr_item == nullptr; }
682
683 void invalidate() override {
684 // it's already deleted.
685 m_expr_item = nullptr;
686 }
687
688 bool on_after_expr_parsing(THD *thd) override {
690 assert(m_expr_item != nullptr);
691 return false;
692 }
693
694 LEX_CSTRING get_expr_query() const override { return m_expr_query; }
695
696 void adjust_sql_command(LEX *lex) override {
697 assert(lex->sql_command == SQLCOM_SELECT);
698 lex->sql_command = SQLCOM_END;
699 }
700
701 private:
702 /// RETURN-expression item.
704
705 /// SQL-query corresponding to the RETURN-expression.
707
708 /// RETURN-field type code.
710
711#ifdef HAVE_PSI_INTERFACE
712 public:
713 PSI_statement_info *get_psi_info() override { return &psi_info; }
714
716#endif
717};
718
719///////////////////////////////////////////////////////////////////////////
720
721/**
722 This is base class for all kinds of jump instructions.
723
724 @note this is the only class, we directly construct instances of, that has
725 subclasses. We also redefine sp_instr_jump behavior in those subclasses.
726
727 @todo later we will consider introducing a new class, which will be the base
728 for sp_instr_jump, sp_instr_set_case_expr and sp_instr_jump_case_when.
729 Something like sp_regular_branch_instr (similar to sp_lex_branch_instr).
730*/
731class sp_instr_jump : public sp_instr, public sp_branch_instr {
732 public:
734 : sp_instr(ip, ctx), m_dest(0), m_optdest(nullptr) {}
735
736 sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest)
737 : sp_instr(ip, ctx), m_dest(dest), m_optdest(nullptr) {}
738
739 /////////////////////////////////////////////////////////////////////////
740 // sp_printable implementation.
741 /////////////////////////////////////////////////////////////////////////
742
743 void print(const THD *thd, String *str) override;
744
745 /////////////////////////////////////////////////////////////////////////
746 // sp_instr implementation.
747 /////////////////////////////////////////////////////////////////////////
748
749 bool execute(THD *, uint *nextp) override {
750 *nextp = m_dest;
751 return false;
752 }
753
754 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
755
756 uint opt_shortcut_jump(sp_head *sp, sp_instr *start) override;
757
758 void opt_move(uint dst, List<sp_branch_instr> *ibp) override;
759
760 /////////////////////////////////////////////////////////////////////////
761 // sp_branch_instr implementation.
762 /////////////////////////////////////////////////////////////////////////
763
764 void set_destination(uint old_dest, uint new_dest) override {
765 if (m_dest == old_dest) m_dest = new_dest;
766 }
767
768 void backpatch(uint dest) override {
769 /* Calling backpatch twice is a logic flaw in jump resolution. */
770 assert(m_dest == 0);
771 m_dest = dest;
772 }
773
774 protected:
775 /// Where we will go.
776 uint m_dest;
777
778 // The following attribute is used by SP-optimizer.
780
781#ifdef HAVE_PSI_INTERFACE
782 public:
783 PSI_statement_info *get_psi_info() override { return &psi_info; }
784
786#endif
787};
788
789///////////////////////////////////////////////////////////////////////////
790
791/**
792 sp_lex_branch_instr is a base class for SP-instructions, which might perform
793 conditional jump depending on the value of an SQL-expression.
794*/
796 protected:
797 sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item,
798 LEX_CSTRING expr_query)
799 : sp_lex_instr(ip, ctx, lex, true),
800 m_dest(0),
801 m_cont_dest(0),
804 m_expr_item(expr_item),
805 m_expr_query(expr_query) {}
806
807 sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item,
808 LEX_CSTRING expr_query, uint dest)
809 : sp_lex_instr(ip, ctx, lex, true),
810 m_dest(dest),
811 m_cont_dest(0),
814 m_expr_item(expr_item),
815 m_expr_query(expr_query) {}
816
817 public:
818 void set_cont_dest(uint cont_dest) { m_cont_dest = cont_dest; }
819
820 /////////////////////////////////////////////////////////////////////////
821 // sp_instr implementation.
822 /////////////////////////////////////////////////////////////////////////
823
824 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
825
826 void opt_move(uint dst, List<sp_branch_instr> *ibp) override;
827
828 uint get_cont_dest() const override { return m_cont_dest; }
829
830 /////////////////////////////////////////////////////////////////////////
831 // sp_lex_instr implementation.
832 /////////////////////////////////////////////////////////////////////////
833
834 bool is_invalid() const override { return m_expr_item == nullptr; }
835
836 void invalidate() override {
837 m_expr_item = nullptr; /* it's already deleted. */
838 }
839
840 LEX_CSTRING get_expr_query() const override { return m_expr_query; }
841
842 /////////////////////////////////////////////////////////////////////////
843 // sp_branch_instr implementation.
844 /////////////////////////////////////////////////////////////////////////
845
846 void set_destination(uint old_dest, uint new_dest) override {
847 if (m_dest == old_dest) m_dest = new_dest;
848
849 if (m_cont_dest == old_dest) m_cont_dest = new_dest;
850 }
851
852 void backpatch(uint dest) override {
853 /* Calling backpatch twice is a logic flaw in jump resolution. */
854 assert(m_dest == 0);
855 m_dest = dest;
856 }
857
858 void adjust_sql_command(LEX *lex) override {
859 assert(lex->sql_command == SQLCOM_SELECT);
860 lex->sql_command = SQLCOM_END;
861 }
862
863 protected:
864 /// Where we will go.
865 uint m_dest;
866
867 /// Where continue handlers will go.
869
870 // The following attributes are used by SP-optimizer.
873
874 /// Expression item.
876
877 /// SQL-query corresponding to the expression.
879};
880
881///////////////////////////////////////////////////////////////////////////
882
883/**
884 sp_instr_jump_if_not implements SP-instruction, which does the jump if its
885 SQL-expression is false.
886*/
888 public:
889 sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item,
890 LEX_CSTRING expr_query)
891 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
892 expr_item, expr_query) {}
893
894 sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item,
895 LEX_CSTRING expr_query, uint dest)
896 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
897 expr_item, expr_query, dest) {}
898
899 /////////////////////////////////////////////////////////////////////////
900 // sp_printable implementation.
901 /////////////////////////////////////////////////////////////////////////
902
903 void print(const THD *thd, String *str) override;
904
905 /////////////////////////////////////////////////////////////////////////
906 // sp_lex_instr implementation.
907 /////////////////////////////////////////////////////////////////////////
908
909 bool exec_core(THD *thd, uint *nextp) override;
910
911 bool on_after_expr_parsing(THD *thd) override {
913 assert(m_expr_item != nullptr);
914 return false;
915 }
916
917#ifdef HAVE_PSI_INTERFACE
918 public:
919 PSI_statement_info *get_psi_info() override { return &psi_info; }
920
922#endif
923};
924
925///////////////////////////////////////////////////////////////////////////
926// Instructions used for the "simple CASE" implementation.
927///////////////////////////////////////////////////////////////////////////
928
929/**
930 sp_instr_set_case_expr is used in the "simple CASE" implementation to evaluate
931 and store the CASE-expression in the runtime context.
932*/
934 public:
935 sp_instr_set_case_expr(uint ip, LEX *lex, uint case_expr_id,
936 Item *case_expr_item, LEX_CSTRING case_expr_query)
937 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
938 case_expr_item, case_expr_query),
939 m_case_expr_id(case_expr_id) {}
940
941 /////////////////////////////////////////////////////////////////////////
942 // sp_printable implementation.
943 /////////////////////////////////////////////////////////////////////////
944
945 void print(const THD *thd, String *str) override;
946
947 /////////////////////////////////////////////////////////////////////////
948 // sp_instr implementation.
949 /////////////////////////////////////////////////////////////////////////
950
951 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
952
953 void opt_move(uint dst, List<sp_branch_instr> *ibp) override;
954
955 /////////////////////////////////////////////////////////////////////////
956 // sp_branch_instr implementation.
957 /////////////////////////////////////////////////////////////////////////
958
959 /*
960 NOTE: set_destination() and backpatch() are overridden here just because the
961 m_dest attribute is not used by this class, so there is no need to do
962 anything about it.
963
964 @todo These operations probably should be left as they are (i.e. do not
965 override them here). The m_dest attribute would be set and not used, but
966 that should not be a big deal.
967
968 @todo This also indicates deficiency of the current SP-istruction class
969 hierarchy.
970 */
971
972 void set_destination(uint old_dest, uint new_dest) override {
973 if (m_cont_dest == old_dest) m_cont_dest = new_dest;
974 }
975
976 void backpatch(uint) override {}
977
978 /////////////////////////////////////////////////////////////////////////
979 // sp_lex_instr implementation.
980 /////////////////////////////////////////////////////////////////////////
981
982 bool exec_core(THD *thd, uint *nextp) override;
983
984 bool on_after_expr_parsing(THD *thd) override {
986 assert(m_expr_item != nullptr);
987 return false;
988 }
989
990 private:
991 /// Identifier (index) of the CASE-expression in the runtime context.
993
994#ifdef HAVE_PSI_INTERFACE
995 public:
996 PSI_statement_info *get_psi_info() override { return &psi_info; }
997
999#endif
1000};
1001
1002///////////////////////////////////////////////////////////////////////////
1003
1004/**
1005 sp_instr_jump_case_when instruction is used in the "simple CASE"
1006 implementation. It's a jump instruction with the following condition:
1007 (CASE-expression = WHEN-expression)
1008 CASE-expression is retrieved from sp_rcontext;
1009 WHEN-expression is kept by this instruction.
1010*/
1012 public:
1013 sp_instr_jump_case_when(uint ip, LEX *lex, int case_expr_id,
1014 Item *when_expr_item, LEX_CSTRING when_expr_query)
1015 : sp_lex_branch_instr(ip, lex->get_sp_current_parsing_ctx(), lex,
1016 when_expr_item, when_expr_query),
1017 m_case_expr_id(case_expr_id) {}
1018
1019 /////////////////////////////////////////////////////////////////////////
1020 // sp_printable implementation.
1021 /////////////////////////////////////////////////////////////////////////
1022
1023 void print(const THD *thd, String *str) override;
1024
1025 /////////////////////////////////////////////////////////////////////////
1026 // sp_lex_instr implementation.
1027 /////////////////////////////////////////////////////////////////////////
1028
1029 bool exec_core(THD *thd, uint *nextp) override;
1030
1031 void invalidate() override {
1032 // Items should be already deleted in lex-keeper.
1033 m_case_expr_item = nullptr;
1034 m_eq_item = nullptr;
1035 m_expr_item = nullptr; // it's a WHEN-expression.
1036 }
1037
1038 /**
1039 Build CASE-expression item tree:
1040 Item_func_eq(case-expression, when-i-expression)
1041
1042 This function is used for the following form of CASE statement:
1043 CASE case-expression
1044 WHEN when-1-expression THEN ...
1045 WHEN when-2-expression THEN ...
1046 ...
1047 WHEN when-n-expression THEN ...
1048 END CASE
1049
1050 The thing is that after the parsing we have an item (item tree) for the
1051 case-expression and for each when-expression. Here we build jump
1052 conditions: expressions like (case-expression = when-i-expression).
1053
1054 @param thd Thread context.
1055
1056 @return Error flag.
1057 */
1058 bool on_after_expr_parsing(THD *thd) override;
1059
1060 private:
1061 /// Identifier (index) of the CASE-expression in the runtime context.
1063
1064 /// Item representing the CASE-expression.
1066
1067 /**
1068 Item corresponding to the main item of the jump-condition-expression:
1069 it's the equal function (=) in the (case-expression = when-i-expression)
1070 expression.
1071 */
1073
1074#ifdef HAVE_PSI_INTERFACE
1075 public:
1077
1079#endif
1080};
1081
1082///////////////////////////////////////////////////////////////////////////
1083// SQL-condition handler instructions.
1084///////////////////////////////////////////////////////////////////////////
1085
1087 public:
1089
1090 ~sp_instr_hpush_jump() override;
1091
1092 void add_condition(sp_condition_value *condition_value);
1093
1095
1096 /////////////////////////////////////////////////////////////////////////
1097 // sp_printable implementation.
1098 /////////////////////////////////////////////////////////////////////////
1099
1100 void print(const THD *thd, String *str) override;
1101
1102 /////////////////////////////////////////////////////////////////////////
1103 // sp_instr implementation.
1104 /////////////////////////////////////////////////////////////////////////
1105
1106 bool execute(THD *thd, uint *nextp) override;
1107
1108 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
1109
1110 /** Override sp_instr_jump's shortcut; we stop here. */
1111 uint opt_shortcut_jump(sp_head *, sp_instr *) override { return get_ip(); }
1112
1113 /////////////////////////////////////////////////////////////////////////
1114 // sp_branch_instr implementation.
1115 /////////////////////////////////////////////////////////////////////////
1116
1117 void backpatch(uint dest) override {
1118 assert(!m_dest || !m_opt_hpop);
1119 if (!m_dest)
1120 m_dest = dest;
1121 else
1122 m_opt_hpop = dest;
1123 }
1124
1125 private:
1126 /// Handler.
1128
1129 /// hpop marking end of handler scope.
1131
1132 // This attribute is needed for SHOW PROCEDURE CODE only (i.e. it's needed in
1133 // debug version only). It's used in print().
1135
1136#ifdef HAVE_PSI_INTERFACE
1137 public:
1139
1141#endif
1142};
1143
1144///////////////////////////////////////////////////////////////////////////
1145
1146class sp_instr_hpop : public sp_instr {
1147 public:
1148 sp_instr_hpop(uint ip, sp_pcontext *ctx) : sp_instr(ip, ctx) {}
1149
1150 /////////////////////////////////////////////////////////////////////////
1151 // sp_printable implementation.
1152 /////////////////////////////////////////////////////////////////////////
1153
1154 void print(const THD *, String *str) override {
1155 str->append(STRING_WITH_LEN("hpop"));
1156 }
1157
1158 /////////////////////////////////////////////////////////////////////////
1159 // sp_instr implementation.
1160 /////////////////////////////////////////////////////////////////////////
1161
1162 bool execute(THD *thd, uint *nextp) override;
1163
1164#ifdef HAVE_PSI_INTERFACE
1165 public:
1167
1169#endif
1170};
1171
1172///////////////////////////////////////////////////////////////////////////
1173
1175 public:
1176 sp_instr_hreturn(uint ip, sp_pcontext *ctx);
1177
1178 /////////////////////////////////////////////////////////////////////////
1179 // sp_printable implementation.
1180 /////////////////////////////////////////////////////////////////////////
1181
1182 void print(const THD *thd, String *str) override;
1183
1184 /////////////////////////////////////////////////////////////////////////
1185 // sp_instr implementation.
1186 /////////////////////////////////////////////////////////////////////////
1187
1188 bool execute(THD *thd, uint *nextp) override;
1189
1190 /** Override sp_instr_jump's shortcut; we stop here. */
1191 uint opt_shortcut_jump(sp_head *, sp_instr *) override { return get_ip(); }
1192
1193 uint opt_mark(sp_head *sp, List<sp_instr> *leads) override;
1194
1195 private:
1196 // This attribute is needed for SHOW PROCEDURE CODE only (i.e. it's needed in
1197 // debug version only). It's used in print().
1199
1200#ifdef HAVE_PSI_INTERFACE
1201 public:
1203
1205#endif
1206};
1207
1208///////////////////////////////////////////////////////////////////////////
1209// Cursor implementation.
1210///////////////////////////////////////////////////////////////////////////
1211
1212/**
1213 sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and
1214 OPEN.
1215
1216 This is the most important instruction in cursor implementation. It is created
1217 and added to sp_head when DECLARE CURSOR is being parsed. The arena of this
1218 instruction contains LEX-object for the cursor's SELECT-statement.
1219
1220 This instruction is actually used to open the cursor.
1221
1222 execute() operation "implements" DECLARE CURSOR statement -- it merely pushes
1223 a new cursor object into the stack in sp_rcontext object.
1224
1225 exec_core() operation implements OPEN statement. It is important to implement
1226 OPEN statement in this instruction, because OPEN may lead to re-parsing of the
1227 SELECT-statement. So, the original Arena and parsing context must be used.
1228*/
1230 public:
1231 sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *cursor_lex,
1232 LEX_CSTRING cursor_query, int cursor_idx)
1233 : sp_lex_instr(ip, ctx, cursor_lex, true),
1234 m_cursor_query(cursor_query),
1235 m_valid(true),
1236 m_cursor_idx(cursor_idx) {
1237 /*
1238 Cursors cause queries to depend on external state, so they are
1239 noncacheable.
1240 */
1241 cursor_lex->safe_to_cache_query = false;
1242 }
1243
1244 /////////////////////////////////////////////////////////////////////////
1245 // sp_printable implementation.
1246 /////////////////////////////////////////////////////////////////////////
1247
1248 void print(const THD *thd, String *str) override;
1249
1250 /////////////////////////////////////////////////////////////////////////
1251 // sp_instr implementation.
1252 /////////////////////////////////////////////////////////////////////////
1253
1254 bool execute(THD *thd, uint *nextp) override;
1255
1256 /////////////////////////////////////////////////////////////////////////
1257 // sp_lex_instr implementation.
1258 /////////////////////////////////////////////////////////////////////////
1259
1260 bool exec_core(THD *thd, uint *nextp) override;
1261
1262 bool is_invalid() const override { return !m_valid; }
1263
1264 void invalidate() override { m_valid = false; }
1265
1266 void get_query(String *sql_query) const override {
1268 }
1269
1270 bool on_after_expr_parsing(THD *) override {
1271 m_valid = true;
1272 return false;
1273 }
1274
1275 private:
1276 /// This attribute keeps the cursor SELECT statement.
1278
1279 /// Flag if the LEX-object of this instruction is valid or not.
1280 /// The LEX-object is not valid when metadata have changed.
1282
1283 /// Used to identify the cursor in the sp_rcontext.
1285
1286#ifdef HAVE_PSI_INTERFACE
1287 public:
1289
1291#endif
1292};
1293
1294///////////////////////////////////////////////////////////////////////////
1295
1296/**
1297 sp_instr_cpop instruction is added at the end of BEGIN..END block.
1298 It's used to remove declared cursors so that they are not visible any longer.
1299*/
1300class sp_instr_cpop : public sp_instr {
1301 public:
1302 sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count)
1303 : sp_instr(ip, ctx), m_count(count) {}
1304
1305 /////////////////////////////////////////////////////////////////////////
1306 // sp_printable implementation.
1307 /////////////////////////////////////////////////////////////////////////
1308
1309 void print(const THD *thd, String *str) override;
1310
1311 /////////////////////////////////////////////////////////////////////////
1312 // sp_instr implementation.
1313 /////////////////////////////////////////////////////////////////////////
1314
1315 bool execute(THD *thd, uint *nextp) override;
1316
1317 private:
1319
1320#ifdef HAVE_PSI_INTERFACE
1321 public:
1323
1325#endif
1326};
1327
1328///////////////////////////////////////////////////////////////////////////
1329
1330/**
1331 sp_instr_copen represents OPEN statement (opens the cursor).
1332 However, the actual implementation is in sp_instr_cpush::exec_core().
1333*/
1334class sp_instr_copen : public sp_instr {
1335 public:
1336 sp_instr_copen(uint ip, sp_pcontext *ctx, int cursor_idx)
1337 : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1338
1339 /////////////////////////////////////////////////////////////////////////
1340 // sp_printable implementation.
1341 /////////////////////////////////////////////////////////////////////////
1342
1343 void print(const THD *thd, String *str) override;
1344
1345 /////////////////////////////////////////////////////////////////////////
1346 // sp_instr implementation.
1347 /////////////////////////////////////////////////////////////////////////
1348
1349 bool execute(THD *thd, uint *nextp) override;
1350
1351 private:
1352 /// Used to identify the cursor in the sp_rcontext.
1354
1355#ifdef HAVE_PSI_INTERFACE
1356 public:
1358
1360#endif
1361};
1362
1363///////////////////////////////////////////////////////////////////////////
1364
1365/**
1366 The instruction corresponds to the CLOSE statement.
1367 It just forwards the close-call to the appropriate sp_cursor object in the
1368 sp_rcontext.
1369*/
1371 public:
1372 sp_instr_cclose(uint ip, sp_pcontext *ctx, int cursor_idx)
1373 : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1374
1375 /////////////////////////////////////////////////////////////////////////
1376 // sp_printable implementation.
1377 /////////////////////////////////////////////////////////////////////////
1378
1379 void print(const THD *thd, String *str) override;
1380
1381 /////////////////////////////////////////////////////////////////////////
1382 // sp_instr implementation.
1383 /////////////////////////////////////////////////////////////////////////
1384
1385 bool execute(THD *thd, uint *nextp) override;
1386
1387 private:
1388 /// Used to identify the cursor in the sp_rcontext.
1390
1391#ifdef HAVE_PSI_INTERFACE
1392 public:
1394
1396#endif
1397};
1398
1399///////////////////////////////////////////////////////////////////////////
1400
1401/**
1402 The instruction corresponds to the FETCH statement.
1403 It just forwards the close-call to the appropriate sp_cursor object in the
1404 sp_rcontext.
1405*/
1407 public:
1408 sp_instr_cfetch(uint ip, sp_pcontext *ctx, int cursor_idx)
1409 : sp_instr(ip, ctx), m_cursor_idx(cursor_idx) {}
1410
1411 /////////////////////////////////////////////////////////////////////////
1412 // sp_printable implementation.
1413 /////////////////////////////////////////////////////////////////////////
1414
1415 void print(const THD *thd, String *str) override;
1416
1417 /////////////////////////////////////////////////////////////////////////
1418 // sp_instr implementation.
1419 /////////////////////////////////////////////////////////////////////////
1420
1421 bool execute(THD *thd, uint *nextp) override;
1422
1423 void add_to_varlist(sp_variable *var) { m_varlist.push_back(var); }
1424
1425 private:
1426 /// List of SP-variables to store fetched values.
1428
1429 /// Used to identify the cursor in the sp_rcontext.
1431
1432#ifdef HAVE_PSI_INTERFACE
1433 public:
1435
1437#endif
1438};
1439
1440///////////////////////////////////////////////////////////////////////////
1441///////////////////////////////////////////////////////////////////////////
1442
1443/**
1444 sp_instr_error just throws an SQL-condition if the execution flow comes to it.
1445 It's used in the CASE implementation to perform runtime-check that the
1446 CASE-expression is handled by some WHEN/ELSE clause.
1447*/
1448class sp_instr_error : public sp_instr {
1449 public:
1450 sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
1451 : sp_instr(ip, ctx), m_errcode(errcode) {}
1452
1453 /////////////////////////////////////////////////////////////////////////
1454 // sp_printable implementation.
1455 /////////////////////////////////////////////////////////////////////////
1456
1457 void print(const THD *thd, String *str) override;
1458
1459 /////////////////////////////////////////////////////////////////////////
1460 // sp_instr implementation.
1461 /////////////////////////////////////////////////////////////////////////
1462
1463 bool execute(THD *, uint *nextp) override {
1464 my_error(m_errcode, MYF(0));
1465 *nextp = get_ip() + 1;
1466 return true;
1467 }
1468
1469 uint opt_mark(sp_head *, List<sp_instr> *) override {
1470 m_marked = true;
1471 return UINT_MAX;
1472 }
1473
1474 private:
1475 /// The error code, which should be raised by this instruction.
1477
1478#ifdef HAVE_PSI_INTERFACE
1479 public:
1481
1483#endif
1484};
1485
1486///////////////////////////////////////////////////////////////////////////
1487
1488#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:4012
Represents NEW/OLD version of field of row which is changed/read in trigger.
Definition: item.h:6699
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Definition: sql_list.h:494
Definition: sql_class.h:348
void free_items()
Definition: sql_class.cc:2087
enum_sql_command sql_command
SQL command for this statement.
Definition: sql_lex.h:2628
Simple intrusive linked list.
Definition: sql_list.h:48
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:3308
Definition: table.h:2900
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4583
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:1370
static PSI_statement_info psi_info
Definition: sp_instr.h:1395
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1765
sp_instr_cclose(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1372
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1389
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1776
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1393
The instruction corresponds to the FETCH statement.
Definition: sp_instr.h:1406
List< sp_variable > m_varlist
List of SP-variables to store fetched values.
Definition: sp_instr.h:1427
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1434
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1802
sp_instr_cfetch(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1408
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1813
static PSI_statement_info psi_info
Definition: sp_instr.h:1436
void add_to_varlist(sp_variable *var)
Definition: sp_instr.h:1423
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1430
sp_instr_copen represents OPEN statement (opens the cursor).
Definition: sp_instr.h:1334
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1698
sp_instr_copen(uint ip, sp_pcontext *ctx, int cursor_idx)
Definition: sp_instr.h:1336
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1739
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1357
static PSI_statement_info psi_info
Definition: sp_instr.h:1359
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1353
sp_instr_cpop instruction is added at the end of BEGIN..END block.
Definition: sp_instr.h:1300
uint m_count
Definition: sp_instr.h:1318
static PSI_statement_info psi_info
Definition: sp_instr.h:1324
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1322
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1681
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1674
sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count)
Definition: sp_instr.h:1302
sp_instr_cpush corresponds to DECLARE CURSOR, implements DECLARE CURSOR and OPEN.
Definition: sp_instr.h:1229
bool is_invalid() const override
Definition: sp_instr.h:1262
bool on_after_expr_parsing(THD *) override
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.h:1270
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:1264
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1288
static PSI_statement_info psi_info
Definition: sp_instr.h:1290
int m_cursor_idx
Used to identify the cursor in the sp_rcontext.
Definition: sp_instr.h:1284
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1629
void get_query(String *sql_query) const override
Return the query string, which can be passed to the parser.
Definition: sp_instr.h:1266
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1646
LEX_CSTRING m_cursor_query
This attribute keeps the cursor SELECT statement.
Definition: sp_instr.h:1277
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1637
bool m_valid
Flag if the LEX-object of this instruction is valid or not.
Definition: sp_instr.h:1281
sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *cursor_lex, LEX_CSTRING cursor_query, int cursor_idx)
Definition: sp_instr.h:1231
sp_instr_error just throws an SQL-condition if the execution flow comes to it.
Definition: sp_instr.h:1448
bool execute(THD *, uint *nextp) override
Execute this instruction.
Definition: sp_instr.h:1463
sp_instr_error(uint ip, sp_pcontext *ctx, int errcode)
Definition: sp_instr.h:1450
int m_errcode
The error code, which should be raised by this instruction.
Definition: sp_instr.h:1476
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1480
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:1469
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1848
static PSI_statement_info psi_info
Definition: sp_instr.h:1482
sp_instr_freturn represents RETURN statement in stored functions.
Definition: sp_instr.h:651
LEX_CSTRING m_expr_query
SQL-query corresponding to the RETURN-expression.
Definition: sp_instr.h:706
static PSI_statement_info psi_info
Definition: sp_instr.h:715
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:683
Item * m_expr_item
RETURN-expression item.
Definition: sp_instr.h:703
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1433
LEX_CSTRING get_expr_query() const override
Definition: sp_instr.h:694
enum enum_field_types m_return_field_type
RETURN-field type code.
Definition: sp_instr.h:709
sp_instr_freturn(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, enum enum_field_types return_field_type)
Definition: sp_instr.h:653
bool on_after_expr_parsing(THD *thd) override
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.h:688
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:713
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1452
bool is_invalid() const override
Definition: sp_instr.h:681
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:696
uint opt_mark(sp_head *, List< sp_instr > *) override
Mark this instruction as reachable during optimization and return the index to the next instruction.
Definition: sp_instr.h:670
Definition: sp_instr.h:1146
void print(const THD *, String *str) override
Definition: sp_instr.h:1154
static PSI_statement_info psi_info
Definition: sp_instr.h:1168
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1166
sp_instr_hpop(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:1148
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1548
Definition: sp_instr.h:1086
sp_instr_hpush_jump(uint ip, sp_pcontext *ctx, sp_handler *handler)
Definition: sp_instr.cc:1472
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1496
uint opt_shortcut_jump(sp_head *, sp_instr *) override
Override sp_instr_jump's shortcut; we stop here.
Definition: sp_instr.h:1111
uint m_opt_hpop
hpop marking end of handler scope.
Definition: sp_instr.h:1130
sp_handler * m_handler
Handler.
Definition: sp_instr.h:1127
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:1117
~sp_instr_hpush_jump() override
Definition: sp_instr.cc:1481
uint m_frame
Definition: sp_instr.h:1134
static PSI_statement_info psi_info
Definition: sp_instr.h:1140
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1490
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:1508
void add_condition(sp_condition_value *condition_value)
Definition: sp_instr.cc:1486
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1138
sp_handler * get_handler()
Definition: sp_instr.h:1094
Definition: sp_instr.h:1174
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1202
uint m_frame
Definition: sp_instr.h:1198
static PSI_statement_info psi_info
Definition: sp_instr.h:1204
uint opt_shortcut_jump(sp_head *, sp_instr *) override
Override sp_instr_jump's shortcut; we stop here.
Definition: sp_instr.h:1191
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:1602
sp_instr_hreturn(uint ip, sp_pcontext *ctx)
Definition: sp_instr.cc:1564
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:1567
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1588
sp_instr_jump_case_when instruction is used in the "simple CASE" implementation.
Definition: sp_instr.h:1011
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1373
int m_case_expr_id
Identifier (index) of the CASE-expression in the runtime context.
Definition: sp_instr.h:1062
static PSI_statement_info psi_info
Definition: sp_instr.h:1078
Item_case_expr * m_case_expr_item
Item representing the CASE-expression.
Definition: sp_instr.h:1065
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:1386
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:1031
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:1072
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:1013
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:1076
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1361
sp_instr_jump_if_not implements SP-instruction, which does the jump if its SQL-expression is false.
Definition: sp_instr.h:887
sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
Definition: sp_instr.h:889
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:911
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1290
static PSI_statement_info psi_info
Definition: sp_instr.h:921
sp_instr_jump_if_not(uint ip, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
Definition: sp_instr.h:894
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:919
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1278
This is base class for all kinds of jump instructions.
Definition: sp_instr.h:731
sp_instr_jump(uint ip, sp_pcontext *ctx)
Definition: sp_instr.h:733
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:783
sp_instr * m_optdest
Definition: sp_instr.h:779
sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest)
Definition: sp_instr.h:736
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:1237
uint m_dest
Where we will go.
Definition: sp_instr.h:776
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:768
static PSI_statement_info psi_info
Definition: sp_instr.h:785
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1230
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:1260
uint opt_shortcut_jump(sp_head *sp, sp_instr *start) override
Short-cut jumps to jumps during optimization.
Definition: sp_instr.cc:1245
bool execute(THD *, uint *nextp) override
Execute this instruction.
Definition: sp_instr.h:749
void set_destination(uint old_dest, uint new_dest) override
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:764
sp_instr_set_case_expr is used in the "simple CASE" implementation to evaluate and store the CASE-exp...
Definition: sp_instr.h:933
void set_destination(uint old_dest, uint new_dest) override
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:972
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1888
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:1914
static PSI_statement_info psi_info
Definition: sp_instr.h:998
uint m_case_expr_id
Identifier (index) of the CASE-expression in the runtime context.
Definition: sp_instr.h:992
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:984
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:996
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1865
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:935
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:1900
void backpatch(uint) override
Update all instruction with the given label in the backpatch list to the specified instruction pointe...
Definition: sp_instr.h:976
sp_instr_set_trigger_field represents SET-statements, which deal with NEW/OLD trigger pseudo-rows.
Definition: sp_instr.h:592
sp_instr_set_trigger_field(uint ip, LEX *lex, LEX_CSTRING trigger_field_name, Item_trigger_field *trigger_field, Item *value_item, LEX_CSTRING value_query)
Definition: sp_instr.h:594
bool on_after_expr_parsing(THD *thd) override
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.cc:1194
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:640
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1168
bool is_invalid() const override
Definition: sp_instr.h:615
static PSI_statement_info psi_info
Definition: sp_instr.h:642
Item_trigger_field * m_trigger_field
Item corresponding to the NEW/OLD trigger field.
Definition: sp_instr.h:630
void cleanup_before_parsing(THD *thd) override
Destroy items in the free list before re-parsing the statement query string (and thus,...
Definition: sp_instr.cc:1214
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1187
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:617
LEX_CSTRING get_expr_query() const override
Definition: sp_instr.h:623
LEX_CSTRING m_trigger_field_name
Trigger field name ("field_name" of the "NEW.field_name").
Definition: sp_instr.h:627
LEX_CSTRING m_value_query
SQL-query corresponding to the value expression.
Definition: sp_instr.h:636
Item * m_value_item
Value expression item of the SET-statement.
Definition: sp_instr.h:633
sp_instr_set represents SET-statements, which deal with SP-variables.
Definition: sp_instr.h:530
LEX_CSTRING get_expr_query() const override
Definition: sp_instr.h:562
LEX_CSTRING m_value_query
SQL-query corresponding to the value expression.
Definition: sp_instr.h:577
bool on_after_expr_parsing(THD *thd) override
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.h:555
void adjust_sql_command(LEX *lex) override
Some expressions may be re-parsed as SELECT statements, but need to be adjusted to another SQL comman...
Definition: sp_instr.h:564
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1123
sp_instr_set(uint ip, LEX *lex, uint offset, Item *value_item, LEX_CSTRING value_query, bool is_lex_owner)
Definition: sp_instr.h:532
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1140
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:553
Item * m_value_item
Value expression item of the SET-statement.
Definition: sp_instr.h:574
bool is_invalid() const override
Definition: sp_instr.h:551
static PSI_statement_info psi_info
Definition: sp_instr.h:581
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:582
uint m_offset
Frame offset.
Definition: sp_instr.h:571
sp_instr_stmt represents almost all conventional SQL-statements, which are supported outside stored p...
Definition: sp_instr.h:472
bool is_invalid() const override
Definition: sp_instr.h:497
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:499
void print(const THD *thd, String *str) override
Definition: sp_instr.cc:1069
sp_instr_stmt(uint ip, LEX *lex, LEX_CSTRING query)
Definition: sp_instr.h:474
static PSI_statement_info psi_info
Definition: sp_instr.h:521
bool on_after_expr_parsing(THD *) override
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.h:505
bool exec_core(THD *thd, uint *nextp) override
Execute core function of instruction after all preparations (e.g.
Definition: sp_instr.cc:1093
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.cc:965
PSI_statement_info * get_psi_info() override
Definition: sp_instr.h:519
bool m_valid
Specify if the stored LEX-object is up-to-date.
Definition: sp_instr.h:515
LEX_CSTRING m_query
Complete query of the SQL-statement.
Definition: sp_instr.h:512
void get_query(String *sql_query) const override
Return the query string, which can be passed to the parser.
Definition: sp_instr.h:501
Base class for every SP-instruction.
Definition: sp_instr.h: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:795
sp_instr * m_cont_optdest
Definition: sp_instr.h:872
sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query, uint dest)
Definition: sp_instr.h:807
uint m_dest
Where we will go.
Definition: sp_instr.h:865
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:1331
sp_lex_branch_instr(uint ip, sp_pcontext *ctx, LEX *lex, Item *expr_item, LEX_CSTRING expr_query)
Definition: sp_instr.h:797
uint m_cont_dest
Where continue handlers will go.
Definition: sp_instr.h:868
bool is_invalid() const override
Definition: sp_instr.h:834
sp_instr * m_optdest
Definition: sp_instr.h:871
void set_destination(uint old_dest, uint new_dest) override
Update the destination; used by the SP-instruction-optimizer.
Definition: sp_instr.h:846
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:1307
LEX_CSTRING m_expr_query
SQL-query corresponding to the expression.
Definition: sp_instr.h:878
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:858
LEX_CSTRING get_expr_query() const override
Definition: sp_instr.h:840
Item * m_expr_item
Expression item.
Definition: sp_instr.h:875
void invalidate() override
Invalidate the object.
Definition: sp_instr.h:836
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:852
uint get_cont_dest() const override
Get the continuation destination (instruction pointer for the CONTINUE HANDLER) of this instruction.
Definition: sp_instr.h:828
void set_cont_dest(uint cont_dest)
Definition: sp_instr.h:818
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:455
void set_lex(LEX *lex, bool is_lex_owner)
Set LEX-object.
Definition: sp_instr.cc:905
virtual LEX_CSTRING get_expr_query() const
Definition: sp_instr.h:391
virtual bool is_invalid() const =0
Table_ref * m_prelocking_tables
List of additional tables this statement needs to lock when it enters/leaves prelocked mode on its ow...
Definition: sp_instr.h:449
LEX * m_lex
LEX-object.
Definition: sp_instr.h:416
virtual void get_query(String *sql_query) const
Return the query string, which can be passed to the parser.
Definition: sp_instr.cc:944
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:379
SQL_I_List< Item_trigger_field > m_trig_field_list
List of all the Item_trigger_field's of instruction.
Definition: sp_instr.h:460
bool validate_lex_and_execute_core(THD *thd, uint *nextp, bool open_tables)
Make a few attempts to execute the instruction.
Definition: sp_instr.cc:711
void free_lex()
Cleanup and destroy assigned LEX-object if needed.
Definition: sp_instr.cc:915
bool m_is_lex_owner
Indicates whether this sp_lex_instr instance is responsible for LEX-object deletion.
Definition: sp_instr.h:430
bool execute(THD *thd, uint *nextp) override
Execute this instruction.
Definition: sp_instr.h:326
virtual bool exec_core(THD *thd, uint *nextp)=0
Execute core function of instruction after all preparations (e.g.
bool m_first_execution
Indicates whether exec_core() has not been already called on the current LEX-object.
Definition: sp_instr.h:436
virtual bool on_after_expr_parsing(THD *thd)
Callback function which is called after the statement query string is successfully parsed,...
Definition: sp_instr.h:403
virtual void invalidate()=0
Invalidate the object.
virtual void cleanup_before_parsing(THD *thd)
Destroy items in the free list before re-parsing the statement query string (and thus,...
Definition: sp_instr.cc:931
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:424
LEX * parse_statement(THD *thd, sp_head *sp)
Parse statement corresponding to this instruction and return a new LEX.
Definition: sp_instr.cc:573
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:5891
#define alloc_root_inited(A)
Definition: my_sys.h:800
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:4868
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:1105
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:129
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:3844
bool safe_to_cache_query
Whether this query will return the same answer every time, given unchanged data.
Definition: sql_lex.h:4225
Query_block * query_block
First query block.
Definition: sql_lex.h:3849
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:44