MySQL 8.4.8
Source Code Documentation
sql_class.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2025, 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 SQL_CLASS_INCLUDED
25#define SQL_CLASS_INCLUDED
26
27/*
28 This file contains the declaration of the THD class and classes which THD
29 depends on. It should contain as little else as possible to increase
30 cohesion and reduce coupling. Since THD is used in many places, many files
31 are dependent on this header and thus require recompilation if it changes.
32 Historically this file contained "Classes in mysql".
33*/
34
35#include "my_config.h"
36
37#include <limits.h>
38#include <stdarg.h>
39#include <stdio.h>
40#include <string.h>
41#ifdef HAVE_SYS_TIME_H
42#include <sys/time.h>
43#endif
44#include <sys/types.h>
45#include <atomic>
46#include <bitset>
47#include <concepts> // invocable
48#include <functional> // function
49#include <list> // list
50#include <memory>
51#include <new>
52#include <stack>
53#include <string>
54#include <unordered_map>
55
56#include "dur_prop.h" // durability_properties
57#include "lex_string.h"
58#include "map_helpers.h"
59#include "my_alloc.h"
60#include "my_base.h"
61#include "my_command.h"
62#include "my_compiler.h"
63#include "my_dbug.h"
64#include "my_inttypes.h"
65#include "my_io.h"
66#include "my_psi_config.h"
67#include "my_sqlcommand.h"
68#include "my_sys.h"
69#include "my_table_map.h"
70#include "my_thread_local.h"
71#include "my_time_t.h"
81#include "mysql/plugin_audit.h"
86#include "mysql/thread_type.h"
87#include "mysql_com_server.h" // NET_SERVER
88#include "mysqld_error.h"
89#include "pfs_thread_provider.h"
90#include "prealloced_array.h"
91#include "scope_guard.h" // Scope_guard
92#include "sql/auth/sql_security_ctx.h" // Security_context
93#include "sql/current_thd.h"
94#include "sql/dd/string_type.h" // dd::string_type
95#include "sql/discrete_interval.h" // Discrete_interval
96#include "sql/locked_tables_list.h" // enum_locked_tables_mode
97#include "sql/mdl.h"
98#include "sql/opt_costmodel.h"
99#include "sql/opt_trace_context.h" // Opt_trace_context
100#include "sql/parse_location.h"
101#include "sql/psi_memory_key.h"
102#include "sql/query_options.h"
105#include "sql/rpl_context.h" // Rpl_thd_context
106#include "sql/rpl_gtid.h"
107#include "sql/session_tracker.h" // Session_tracker
108#include "sql/sql_audit.h"
109#include "sql/sql_connect.h"
110#include "sql/sql_const.h"
111#include "sql/sql_digest_stream.h" // sql_digest_state
112#include "sql/sql_error.h"
113#include "sql/sql_list.h"
114#include "sql/sql_plugin_ref.h"
115#include "sql/sys_vars_resource_mgr.h" // Session_sysvar_resource_manager
116#include "sql/system_variables.h" // system_variables
117#include "sql/transaction_info.h" // Ha_trx_info
118#include "sql/xa.h"
120#include "sql_string.h"
121#include "template_utils.h"
122#include "thr_lock.h"
123#include "violite.h"
124
125enum enum_check_fields : int;
126enum enum_tx_isolation : int;
127enum ha_notification_type : int;
128class Item;
129class Parser_state;
130class PROFILING;
132class Relay_log_info;
133class THD;
134class partition_info;
135class Protocol;
136class Protocol_binary;
137class Protocol_classic;
138class Protocol_text;
139template <class T>
140class mem_root_deque;
141class sp_rcontext;
142class user_var_entry;
143struct LEX;
144struct LEX_USER;
145struct TABLE;
146class Table_ref;
147struct timeval;
148struct User_level_lock;
149
150namespace dd {
151namespace cache {
152class Dictionary_client;
153}
154
155class DD_kill_immunizer;
156} // namespace dd
157
160class Query_result;
162class Rows_log_event;
163class Time_zone;
164class sp_cache;
166struct LOG_INFO;
167
168typedef struct user_conn USER_CONN;
169struct MYSQL_LOCK;
170
171extern "C" void thd_enter_cond(void *opaque_thd, mysql_cond_t *cond,
172 mysql_mutex_t *mutex,
173 const PSI_stage_info *stage,
174 PSI_stage_info *old_stage,
175 const char *src_function, const char *src_file,
176 int src_line);
177extern "C" void thd_exit_cond(void *opaque_thd, const PSI_stage_info *stage,
178 const char *src_function, const char *src_file,
179 int src_line);
180
181extern "C" void thd_enter_stage(void *opaque_thd,
182 const PSI_stage_info *new_stage,
183 PSI_stage_info *old_stage,
184 const char *src_function, const char *src_file,
185 int src_line);
186
187extern "C" void thd_set_waiting_for_disk_space(void *opaque_thd,
188 const bool waiting);
189
190#define THD_STAGE_INFO(thd, stage) \
191 (thd)->enter_stage(&stage, NULL, __func__, __FILE__, __LINE__)
192
193extern char empty_c_string[1];
194
195/*
196 We preallocate data for several storage engine plugins.
197 so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
198 example + csv + heap + blackhole + federated + 0
199 (yes, the sum is deliberately inaccurate)
200*/
201constexpr size_t PREALLOC_NUM_HA = 15;
202
203#ifndef NDEBUG
204// Used to sample certain debug flags when a query is read but before the reply
205// is sent.
206enum class TDM { ANY, ON, ZERO, NOT_AVAILABLE };
208#endif /* not defined NDEBUG */
209
210/**
211 To be used for pool-of-threads (implemented differently on various OSs)
212*/
214 public:
215 void *data; /* scheduler-specific data structure */
216
218
219 ~thd_scheduler() = default;
220};
221
223void thd_set_psi(THD *thd, PSI_thread *psi);
224
225/**
226 Return @@session.terminology_use_previous for the current THD.
227
228 @return the integer value of one of the enumeration values in
229 terminology_use_previous::enum_compatibility_version.
230*/
231extern "C" unsigned int thd_get_current_thd_terminology_use_previous();
232
234 /**
235 Memory counter object doesn't update global memory counter and doesn't throw
236 OOM error.
237 */
239 /**
240 if MEM_CNT_UPDATE_GLOBAL_COUNTER is set, memory counter object updates
241 global memory counter.
242 */
244 /**
245 if MEM_CNT_GENERATE_ERROR is set, memory counter object generates OOM error if
246 any.
247*/
249 /**
250 if MEM_CNT_GENERATE_LOG_ERROR is set, memory counter object generates OOM
251 error to error log if any.
252*/
255
257 private:
258 bool m_enabled{false};
259 THD *m_thd{nullptr}; // Pointer to THD object.
260 Diagnostics_area m_da{false}; // Diagnostics area.
261 ulonglong mem_counter{0}; // Amount of memory consumed by thread.
262 ulonglong max_conn_mem{0}; // Max amount memory consumed by thread.
263 ulonglong glob_mem_counter{0}; // Amount of memory added to global
264 // memory counter.
265 uint curr_mode{MEM_CNT_DEFAULT}; // Current memory counter mode.
266 uint orig_mode{MEM_CNT_DEFAULT}; // Original memory counter mode
267 // (sets at init_mode() stage).
268 bool is_connection_stage{true}; // True on connection stage,
269 // resets to false after successful
270 // connection.
271 public:
274 assert(!m_enabled);
275 assert(glob_mem_counter == 0);
276 }
277 void set_thd(THD *thd) { m_thd = thd; }
278 void enable() { m_enabled = true; }
279 void disable();
280
281 void alloc_cnt(size_t size);
282 void free_cnt(size_t size);
283 int reset();
284 void flush();
285 /**
286 Restore original memory counter mode.
287 */
289 /**
290 Set NO ERROR memory counter mode.
291 */
294 }
295 /**
296 Function sets current memory counter mode.
297
298 @param mode_arg current memory counter mode.
299 */
300 void set_curr_mode(uint mode_arg) { curr_mode = mode_arg; }
301 /**
302 Function sets original memory counter mode.
303
304 @param mode_arg original memory counter mode.
305 */
306 void set_orig_mode(uint mode_arg) { orig_mode = mode_arg; }
307 /**
308 Check if memory counter error is issued.
309
310 @retval true if memory counter error is issued, false otherwise.
311 */
312 bool is_error() const { return m_da.is_error(); }
313 void set_thd_error_status() const;
314
315 private:
316 int generate_error(int err_no, ulonglong mem_limit, ulonglong mem_size);
317 /**
318 Check if memory counter is in error mode.
319
320 @retval true if memory counter is in error mode, false otherwise.
321 */
322 bool is_error_mode() const { return (curr_mode & MEM_CNT_GENERATE_ERROR); }
323 /**
324 Check if memory counter is in error log mode.
325
326 @retval true if memory counter is in error log mode, false otherwise.
327 */
328 bool is_error_log_mode() const {
330 }
331};
332
333/**
334 the struct aggregates two parameters that identify an event
335 uniquely in scope of communication of a particular master and slave couple.
336 I.e there can not be 2 events from the same staying connected master which
337 have the same coordinates.
338 @note
339 Such identifier is not yet unique generally as the event originating master
340 is resettable. Also the crashed master can be replaced with some other.
341*/
342typedef struct rpl_event_coordinates {
343 char *file_name; // binlog file name (directories stripped)
344 my_off_t pos; // event's position in the binlog file
346
347#define THD_SENTRY_MAGIC 0xfeedd1ff
348#define THD_SENTRY_GONE 0xdeadbeef
349
350#define THD_CHECK_SENTRY(thd) assert(thd->dbug_sentry == THD_SENTRY_MAGIC)
351
353 private:
354 /*
355 List of items created for this query. Every item adds itself to the list
356 on creation (see Item::Item() for details)
357 */
359
360 public:
361 MEM_ROOT *mem_root; // Pointer to current memroot
362 /// To check whether a reprepare operation is active
363 bool is_repreparing{false};
364 /*
365 The states reflects three different life cycles for three
366 different types of statements:
367 Prepared statement: STMT_INITIALIZED -> STMT_PREPARED -> STMT_EXECUTED.
368 Stored procedure: STMT_INITIALIZED_FOR_SP -> STMT_EXECUTED.
369 Other statements: STMT_REGULAR_EXECUTION never changes.
370 */
377 STMT_ERROR = -1
378 };
379
380 /*
381 State and state changes in SP:
382 1) When state is STMT_INITIALIZED_FOR_SP, objects in the item tree are
383 created on the statement memroot. This is enforced through
384 ps_arena_holder checking the state.
385 2) After the first execute (call p1()), this state should change to
386 STMT_EXECUTED. Objects will be created on the execution memroot and will
387 be destroyed at the end of each execution.
388 3) In case an ER_NEED_REPREPARE error occurs, state should be changed to
389 STMT_INITIALIZED_FOR_SP and objects will again be created on the
390 statement memroot. At the end of this execution, state should change to
391 STMT_EXECUTED.
392 */
393 private:
395
396 public:
397 Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg)
398 : m_item_list(nullptr), mem_root(mem_root_arg), state(state_arg) {}
399
400 /*
401 This constructor is used only when Query_arena is created as
402 backup storage for another instance of Query_arena.
403 */
406
407 virtual ~Query_arena() = default;
408
409 Item *item_list() const { return m_item_list; }
410 void reset_item_list() { m_item_list = nullptr; }
411 void set_item_list(Item *item) { m_item_list = item; }
412 void add_item(Item *item);
413 void free_items();
414 void set_state(enum_state state_arg) { state = state_arg; }
415 enum_state get_state() const { return state; }
416 bool is_stmt_prepare() const { return state == STMT_INITIALIZED; }
418 return (int)state < (int)STMT_PREPARED;
419 }
421 return (int)state <= (int)STMT_PREPARED;
422 }
423 /// @returns true if a regular statement, ie not prepared and not stored proc
424 bool is_regular() const { return state == STMT_REGULAR_EXECUTION; }
425
426 void *alloc(size_t size) { return mem_root->Alloc(size); }
427 void *mem_calloc(size_t size) {
428 void *ptr;
429 if ((ptr = mem_root->Alloc(size))) memset(ptr, 0, size);
430 return ptr;
431 }
432 template <typename T>
434 void *m = alloc(sizeof(T));
435 return m == nullptr ? nullptr : new (m) T;
436 }
437 template <typename T>
438 T *memdup_typed(const T *mem) {
439 return static_cast<T *>(memdup_root(mem_root, mem, sizeof(T)));
440 }
441 char *mem_strdup(const char *str) { return strdup_root(mem_root, str); }
442 char *strmake(const char *str, size_t size) const {
443 return strmake_root(mem_root, str, size);
444 }
446 LEX_CSTRING ret;
447 ret.str = strmake(str.str, str.length);
448 ret.length = ret.str ? str.length : 0;
449 return ret;
450 }
451 void *memdup(const void *str, size_t size) {
452 return memdup_root(mem_root, str, size);
453 }
454
455 /**
456 Copies memory-managing members from `set`. No references are kept to it.
457
458 @param set A Query_arena from which members are copied.
459 */
460 void set_query_arena(const Query_arena &set);
461
462 /**
463 Copy the current arena to `backup` and set the current
464 arena to match `source`
465
466 @param source A Query_arena from which members are copied.
467 @param backup A Query_arena to which members are first saved.
468 */
470};
471
473
474/**
475 Container for all prepared statements created/used in a connection.
476
477 Prepared statements in Prepared_statement_map have unique id
478 (guaranteed by id assignment in Prepared_statement::Prepared_statement).
479
480 Non-empty statement names are unique too: attempt to insert a new statement
481 with duplicate name causes older statement to be deleted.
482
483 Prepared statements are auto-deleted when they are removed from the map
484 and when the map is deleted.
485*/
486
488 public:
490
491 /**
492 Insert a new statement to the thread-local prepared statement map.
493
494 If there was an old statement with the same name, replace it with the
495 new one. Otherwise, check if max_prepared_stmt_count is not reached yet,
496 increase prepared_stmt_count, and insert the new statement. It's okay
497 to delete an old statement and fail to insert the new one.
498
499 All named prepared statements are also present in names_hash.
500 Prepared statement names in names_hash are unique.
501 The statement is added only if prepared_stmt_count < max_prepard_stmt_count
502 m_last_found_statement always points to a valid statement or is 0
503
504 @retval 0 success
505 @retval 1 error: out of resources or max_prepared_stmt_count limit has been
506 reached. An error is sent to the client, the statement
507 is deleted.
508 */
510
511 /** Find prepared statement by name. */
513
514 /** Find prepared statement by ID. */
515 Prepared_statement *find(ulong id);
516
517 /** Erase all prepared statements (calls Prepared_statement destructor). */
519
520 void claim_memory_ownership(bool claim);
521
522 void reset();
523
525
526 private:
530};
531
532/**
533 A registry for item tree transformations performed during
534 query optimization. We register only those changes which require
535 a rollback to re-execute a prepared statement or stored procedure
536 yet another time.
537*/
538
539class Item_change_record : public ilink<Item_change_record> {
540 private:
541 // not used
543
544 public:
550 bool m_cancel{false};
551};
552
554
555/**
556 Class that holds information about tables which were opened and locked
557 by the thread. It is also used to save/restore this information in
558 push_open_tables_state()/pop_open_tables_state().
559*/
560
562 private:
563 /**
564 A stack of Reprepare_observer-instances. The top most instance is the
565 currently active one. This stack is used during execution of prepared
566 statements and stored programs in order to detect metadata changes.
567 The locking subsystem reports a metadata change if the top-most item is not
568 NULL.
569
570 When Open_tables_state part of THD is reset to open a system or
571 INFORMATION_SCHEMA table, NULL is temporarily pushed to avoid spurious
572 ER_NEED_REPREPARE errors -- system and INFORMATION_SCHEMA tables are not
573 subject to metadata version tracking.
574
575 A stack is used here for the convenience -- in some cases we need to
576 temporarily override/disable current Reprepare_observer-instance.
577
578 NOTE: This is not a list of observers, only the top-most element will be
579 notified in case of a metadata change.
580
581 @sa check_and_update_table_version()
582 */
584
585 public:
587 return m_reprepare_observers.size() > 0 ? m_reprepare_observers.back()
588 : nullptr;
589 }
590
592 m_reprepare_observers.push_back(o);
593 }
594
597 m_reprepare_observers.pop_back();
598 return retval;
599 }
600
602
603 public:
604 /**
605 List of regular tables in use by this thread. Contains persistent base
606 tables that were opened with @see open_tables().
607 */
609 /**
610 List of temporary tables used by this thread. Contains user-level
611 temporary tables, created with CREATE TEMPORARY TABLE, and
612 intermediate tables used in ALTER TABLE implementation.
613 */
615 /*
616 During a MySQL session, one can lock tables in two modes: automatic
617 or manual. In automatic mode all necessary tables are locked just before
618 statement execution, and all acquired locks are stored in 'lock'
619 member. Unlocking takes place automatically as well, when the
620 statement ends.
621 Manual mode comes into play when a user issues a 'LOCK TABLES'
622 statement. In this mode the user can only use the locked tables.
623 Trying to use any other tables will give an error.
624 The locked tables are also stored in this member, however,
625 thd->locked_tables_mode is turned on. Manual locking is described in
626 the 'LOCK_TABLES' chapter of the MySQL manual.
627 See also lock_tables() for details.
628 */
630
631 /*
632 CREATE-SELECT keeps an extra lock for the table being
633 created. This field is used to keep the extra lock available for
634 lower level routines, which would otherwise miss that lock.
635 */
637
638 /*
639 Enum enum_locked_tables_mode and locked_tables_mode member are
640 used to indicate whether the so-called "locked tables mode" is on,
641 and what kind of mode is active.
642
643 Locked tables mode is used when it's necessary to open and
644 lock many tables at once, for usage across multiple
645 (sub-)statements.
646 This may be necessary either for queries that use stored functions
647 and triggers, in which case the statements inside functions and
648 triggers may be executed many times, or for implementation of
649 LOCK TABLES, in which case the opened tables are reused by all
650 subsequent statements until a call to UNLOCK TABLES.
651
652 The kind of locked tables mode employed for stored functions and
653 triggers is also called "prelocked mode".
654 In this mode, first open_tables() call to open the tables used
655 in a statement analyses all functions used by the statement
656 and adds all indirectly used tables to the list of tables to
657 open and lock.
658 It also marks the parse tree of the statement as requiring
659 prelocking. After that, lock_tables() locks the entire list
660 of tables and changes THD::locked_tables_modeto LTM_PRELOCKED.
661 All statements executed inside functions or triggers
662 use the prelocked tables, instead of opening their own ones.
663 Prelocked mode is turned off automatically once close_thread_tables()
664 of the main statement is called.
665 */
667
669 BACKUPS_AVAIL = (1U << 0), /* There are backups available. */
670 SYSTEM_TABLES = (1U << 1) /* We are opening system tables. */
671 };
672
673 /*
674 Flags with information about the open tables state.
675 */
677 /**
678 This constructor initializes Open_tables_state instance which can only
679 be used as backup storage. To prepare Open_tables_state instance for
680 operations which open/lock/close tables (e.g. open_table()) one has to
681 call init_open_tables_state().
682 */
685
687
689};
690
691/**
692 Storage for backup of Open_tables_state. Must
693 be used only to open system tables (TABLE_CATEGORY_SYSTEM
694 and TABLE_CATEGORY_LOG).
695*/
696
698 public:
699 /**
700 When we backup the open tables state to open a system
701 table or tables, we want to save state of metadata
702 locks which were acquired before the backup. It is used
703 to release metadata locks on system tables after they are
704 no longer used.
705 */
707};
708
709/**
710 Enum that represents which phase of secondary engine optimization
711 the current statement is in.
712*/
714 /**
715 The current statement should only use tables from primary storage
716 engines. Use of secondary storage engines is disabled.
717 */
719
720 /**
721 The current statement should only use tables from the primary
722 storage engine. However, use of secondary storage engines is not
723 disabled, so the optimizer may choose to trigger a repreparation
724 against the secondary storage engine if it believes that use of a
725 secondary storage engine is beneficial.
726 */
728
729 /**
730 The current statement should use tables from a secondary storage
731 engine if possible. Otherwise, fall back to using tables from
732 primary storage engine only.
733 */
734 SECONDARY,
735};
736
737/**
738 @class Sub_statement_state
739 @brief Used to save context when executing a function or trigger
740*/
741
742/* Defines used for Sub_statement_state::in_sub_stmt */
743
744#define SUB_STMT_TRIGGER 1
745#define SUB_STMT_FUNCTION 2
746
748 public:
761};
762
763inline char const *show_system_thread(enum_thread_type thread) {
764#define RETURN_NAME_AS_STRING(NAME) \
765 case (NAME): \
766 return #NAME
767 switch (thread) {
768 static char buf[64];
783 default:
784 sprintf(buf, "<UNKNOWN SYSTEM THREAD: %d>", thread);
785 return buf;
786 }
787#undef RETURN_NAME_AS_STRING
788}
789
790/**
791 Storage engine specific thread local data.
792*/
793
794struct Ha_data {
795 /**
796 Storage engine specific thread local data.
797 Lifetime: one user connection.
798 */
799 void *ha_ptr;
800 /**
801 A memorizer to engine specific "native" transaction object to provide
802 storage engine detach-re-attach facility.
803 The server level transaction object can dissociate from storage engine
804 transactions. The released "native" transaction reference
805 can be hold in the member until it is reconciled later.
806 Lifetime: Depends on caller of @c hton::replace_native_transaction_in_thd.
807 For instance in the case of slave server applier handling XA transaction
808 it is from XA START to XA PREPARE.
809 */
811 /**
812 0: Life time: one statement within a transaction. If @@autocommit is
813 on, also represents the entire transaction.
814 @sa trans_register_ha()
815
816 1: Life time: one transaction within a connection.
817 If the storage engine does not participate in a transaction,
818 this should not be used.
819 @sa trans_register_ha()
820 */
822
823 /**
824 NULL: engine is not bound to this thread
825 non-NULL: engine is bound to this thread, engine shutdown forbidden
826 */
828
830};
831
832/**
833 An instance of the global read lock in a connection.
834 Implemented in lock.cc.
835*/
836
838 public:
843 };
844
846 : m_state(GRL_NONE),
849
850 bool lock_global_read_lock(THD *thd);
851 void unlock_global_read_lock(THD *thd);
852
853 /**
854 Check if this connection can acquire protection against GRL and
855 emit error if otherwise.
856 */
858 if (m_state) {
859 my_error(ER_CANT_UPDATE_WITH_READLOCK, MYF(0));
860 return true;
861 }
862 return false;
863 }
865 bool is_acquired() const { return m_state != GRL_NONE; }
867
868 private:
870 /**
871 In order to acquire the global read lock, the connection must
872 acquire shared metadata lock in GLOBAL namespace, to prohibit
873 all DDL.
874 */
876 /**
877 Also in order to acquire the global read lock, the connection
878 must acquire a shared metadata lock in COMMIT namespace, to
879 prohibit commits.
880 */
882};
883
884extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
885
886/**
887 This class keeps the context of transactional DDL statements. Currently only
888 CREATE TABLE with START TRANSACTION uses this context.
889*/
891 public:
892 explicit Transactional_ddl_context(THD *thd) : m_thd(thd) {
893 assert(m_thd != nullptr);
894 }
895
897 assert(!m_hton);
898 post_ddl();
899 }
900
901 void init(dd::String_type db, dd::String_type tablename,
902 const handlerton *hton);
903
904 bool inited() { return m_hton != nullptr; }
905
906 void rollback();
907
908 void post_ddl();
909
910 private:
911 // The current thread.
912 THD *m_thd{nullptr};
913
914 // Handlerton pointer to table's engine begin created.
915 const handlerton *m_hton{nullptr};
916
917 // Schema and table name being created.
920};
921
922struct PS_PARAM;
923
925 std::pair<Event_tracking_class, Event_tracking_information *>;
926using Event_tracking_data_stack = std::stack<Event_tracking_data>;
927
928/**
929 Base class for secondary engine statement context objects. Secondary
930 storage engines may create classes derived from this one which
931 contain state they need to preserve in lifecycle of this query.
932*/
934 public:
935 /**
936 Destructs the secondary engine statement context object. It is
937 called after the query execution has completed. Secondary engines
938 may override the destructor in subclasses and add code that
939 performs cleanup tasks that are needed after query execution.
940 */
942
943 virtual bool is_primary_engine_optimal() const { return true; }
944};
945
946/**
947 @class THD
948 For each client connection we create a separate thread with THD serving as
949 a thread/connection descriptor
950*/
951
952class THD : public MDL_context_owner,
953 public Query_arena,
954 public Open_tables_state {
955 public:
956 /**
957 Controlled memory stats for this session.
958 This member is the first in THD,
959 to initialize Thd_mem_cnt() before allocating more memory.
960 */
962
963 private:
964 bool is_stmt_prepare() const = delete;
967 inline bool is_regular() const = delete;
968
969 public:
971
972 /**
973 MARK_COLUMNS_NONE: Means mark_used_columns is not set and no indicator to
974 handler of fields used is set
975 MARK_COLUMNS_READ: Means a bit in read set is set to inform handler
976 that the field is to be read. Update covering_keys
977 and merge_keys too.
978 MARK_COLUMNS_WRITE: Means a bit is set in write set to inform handler
979 that it needs to update this field in write_row
980 and update_row.
981 MARK_COLUMNS_TEMP: Mark bit in read set, but ignore key sets.
982 Used by filesort().
983 */
985 /**
986 Used by Item::check_column_privileges() to tell which privileges
987 to check for.
988 Set to ~0ULL before starting to resolve a statement.
989 Set to desired privilege mask before calling a resolver function that will
990 call Item::check_column_privileges().
991 After use, restore previous value as current value.
992 */
994
995 private:
996 /**
997 The lex to hold the parsed tree of conventional (non-prepared) queries.
998 Whereas for prepared and stored procedure statements we use an own lex
999 instance for each new query, for conventional statements we reuse
1000 the same lex. (@see dispatch_sql_command for details).
1001 */
1002 std::unique_ptr<LEX> main_lex;
1003
1004 public:
1005 LEX *lex; // parse tree descriptor
1006 dd::cache::Dictionary_client *dd_client() const // Get the dictionary client.
1007 {
1008 return m_dd_client.get();
1009 }
1010
1011 private:
1012 std::unique_ptr<dd::cache::Dictionary_client> m_dd_client;
1013
1014 /**
1015 The query associated with this statement.
1016 */
1019 std::atomic<bool> m_safe_to_display;
1020
1021 /**
1022 Currently selected catalog.
1023 */
1024
1026 /**
1027 Name of the current (default) database.
1028
1029 If there is the current (default) database, "db" contains its name. If
1030 there is no current (default) database, "db" is NULL and "db_length" is
1031 0. In other words, "db", "db_length" must either be NULL, or contain a
1032 valid database name.
1033
1034 @note this attribute is set and allocated by the slave SQL thread (for
1035 the THD of that thread); that thread is (and must remain, for now) the
1036 only responsible for freeing this member.
1037 */
1039
1040 /**
1041 Resource group context indicating the current resource group
1042 and the name of the resource group to switch to during execution
1043 of a query.
1044 */
1046
1047 /**
1048 In some cases, we may want to modify the query (i.e. replace
1049 passwords with their hashes before logging the statement etc.).
1050
1051 In case the query was rewritten, the original query will live in
1052 m_query_string, while the rewritten query lives in rewritten_query.
1053 If rewritten_query is empty, m_query_string should be logged.
1054 If rewritten_query is non-empty, the rewritten query it contains
1055 should be used in logs (general log, slow query log, binary log).
1056
1057 Currently, password obfuscation is the only rewriting we do; more
1058 may follow at a later date, both pre- and post parsing of the query.
1059 Rewriting of binloggable statements must preserve all pertinent
1060 information.
1061
1062 Similar restrictions as for m_query_string (see there) hold for locking:
1063 - Value may only be (re)set from owning thread (current_thd)
1064 - Value must be modified using (reset|swap)_rewritten_query().
1065 Doing so will protect the update with LOCK_thd_query.
1066 - The owner (current_thd) may read the value without holding the lock.
1067 - Other threads may read the value, but must hold LOCK_thd_query to do so.
1068 */
1070
1071 /**
1072 Current query's secondary engine statement context.
1073 */
1074 std::unique_ptr<Secondary_engine_statement_context>
1076
1077 public:
1078 /* Store a thread safe copy of protocol properties. */
1079 enum class cached_properties : int {
1080 NONE = 0, // No properties
1081 IS_ALIVE = 1, // protocol->is_connection_alive()
1082 RW_STATUS = 2, // protocol->get_rw_status()
1083 LAST = 4, // Next unused power of 2.
1084 ALL = (LAST - 1) // Mask selecting all properties.
1085 };
1088
1089 /* Used to execute base64 coded binlog events in MySQL server */
1091 /* Slave applier execution context */
1093
1094 /* Is transaction commit still pending */
1096
1097 /**
1098 The function checks whether the thread is processing queries from binlog,
1099 as automatically generated by mysqlbinlog.
1100
1101 @return true when the thread is a binlog applier
1102 */
1103 bool is_binlog_applier() const {
1104 return rli_fake && variables.pseudo_replica_mode;
1105 }
1106
1107 /**
1108 When the thread is a binlog or slave applier it detaches the engine
1109 ha_data associated with it and memorizes the fact of that.
1110 */
1112
1113 /*
1114 Set secondary_engine_statement_context to new context.
1115 This function assumes existing m_secondary_engine_statement_context is empty,
1116 such that there's only context throughout the query's lifecycle.
1117 */
1119 std::unique_ptr<Secondary_engine_statement_context> context);
1120
1123 }
1124
1125 /**
1126 When the thread is a binlog or slave applier it reattaches the engine
1127 ha_data associated with it and memorizes the fact of that.
1128 */
1130
1131 /**
1132 @return true when the current binlog (rli_fake) or slave (rli_slave)
1133 applier thread has detached the engine ha_data,
1134 see @c rpl_detach_engine_ha_data.
1135 @note The detached transaction applier resets a memo
1136 mark at once with this check.
1137 */
1138 bool is_engine_ha_data_detached() const;
1139
1141 /*
1142 Constant for THD::where initialization in the beginning of every query.
1143
1144 It's needed because we do not save/restore THD::where normally during
1145 primary (non subselect) query execution.
1146 */
1147 static const char *const DEFAULT_WHERE;
1148
1149 /** Additional network instrumentation for the server only. */
1151 /**
1152 Hash for user variables.
1153 User variables are per session,
1154 but can also be monitored outside of the session,
1155 so a lock is needed to prevent race conditions.
1156 Protected by @c LOCK_thd_data.
1157 */
1160 struct rand_struct rand; // used for authentication
1161 struct System_variables variables; // Changeable local variables
1162 struct System_status_var status_var; // Per thread statistic vars
1163 struct System_status_var
1164 *copy_status_var_ptr; // A copy of the statistic vars asof the start of
1165 // the query
1166 struct System_status_var *initial_status_var; /* used by show status */
1167 // has status_var already been added to global_status_var?
1169
1170 /**
1171 Session's connection attributes for the connected client
1172 */
1173 std::vector<char> m_connection_attributes;
1174
1175 /**
1176 Current query cost.
1177 @sa system_status_var::last_query_cost
1178 */
1180
1181 /**
1182 Current query partial plans.
1183 @sa system_status_var::last_query_partial_plans
1184 */
1186
1187 /**
1188 Clear the query costs attributes for the current query.
1189 */
1193 }
1194
1195 /**
1196 Save the current query costs attributes in
1197 the thread session status.
1198 Use this method only after the query execution is completed,
1199 so that
1200 @code SHOW SESSION STATUS like 'last_query_%' @endcode
1201 @code SELECT * from performance_schema.session_status
1202 WHERE VARIABLE_NAME like 'last_query_%' @endcode
1203 actually reports the previous query, not itself.
1204 */
1206 assert(!status_var_aggregated);
1209 }
1210
1211 /**
1212 Clear copy of the status variables.
1213 */
1215
1216 /**
1217 Copy status variables into a structure pointed by the specified pointer and
1218 keep track of the pointer internally.
1219
1220 @param dst_var status variable structure pointer, where internal status
1221 variables are copied into.
1222 */
1224 *dst_var = status_var;
1225 copy_status_var_ptr = dst_var;
1226 }
1227
1228 /**
1229 Copy status variables into a structure pointed by the specified pointer
1230 passed into copy_status_var method call.
1231 */
1233 if (copy_status_var_ptr) {
1234 /* Reset for values at start of next statement */
1236 }
1237 }
1238
1239 THR_LOCK_INFO lock_info; // Locking info of this thread
1240 /**
1241 Protects THD data accessed from other threads.
1242 The attributes protected are:
1243 - thd->is_killable (used by KILL statement and shutdown).
1244 - thd->user_vars (user variables, inspected by monitoring)
1245 Is locked when THD is deleted.
1246 */
1248
1249 /**
1250 Protects THD::m_query_string. No other mutexes should be locked
1251 while having this mutex locked.
1252 */
1254
1255 /**
1256 Protects THD::variables while being updated. This should be taken inside
1257 of LOCK_thd_data and outside of LOCK_global_system_variables.
1258 */
1260
1261#ifndef NDEBUG
1263#endif
1264
1265 /**
1266 Protects THD::m_protocol when it gets removed in x plugin.
1267 */
1269
1270 /**
1271 Protects THD::m_security_ctx from inspection (e.g. by old-style
1272 SHOW PROCESSLIST) while COM_CHANGE_USER changes the context.
1273 */
1275
1276 /**
1277 Protects query plan (SELECT/UPDATE/DELETE's) from being freed/changed
1278 while another thread explains it. Following structures are protected by
1279 this mutex:
1280 THD::Query_plan
1281 Modification_plan
1282 Query_block::join
1283 JOIN::plan_state
1284 Tree of Query_expression after THD::Query_plan was set till
1285 THD::Query_plan cleanup
1286 JOIN_TAB::select->quick
1287 Code that changes objects above should take this mutex.
1288 Explain code takes this mutex to block changes to named structures to
1289 avoid crashes in following functions:
1290 explain_single_table_modification
1291 explain_query
1292 Sql_cmd_explain_other_thread::execute
1293 When doing EXPLAIN CONNECTION:
1294 all explain code assumes that this mutex is already taken.
1295 When doing ordinary EXPLAIN:
1296 the mutex does need to be taken (no need to protect reading my own data,
1297 moreover EXPLAIN CONNECTION can't run on an ordinary EXPLAIN).
1298 */
1299 private:
1301
1302 /**
1303 Keep cached values of "connection alive" and "rw status". Update when
1304 pushing, popping or getting the protocol. Used by
1305 information_schema.processlist to avoid locking mutexes that might
1306 affect performance.
1307 */
1309 std::atomic<uint> m_cached_rw_status;
1310
1311 public:
1312 /// Locks the query plan of this THD
1315
1316 /** All prepared statements of this connection. */
1318 /*
1319 A pointer to the stack frame of handle_one_connection(),
1320 which is called first in the thread for handling a client
1321 */
1322 const char *thread_stack;
1323
1324 /**
1325 @note
1326 Some members of THD (currently 'Statement::db',
1327 'catalog' and 'query') are set and allocated by the slave SQL thread
1328 (for the THD of that thread); that thread is (and must remain, for now)
1329 the only responsible for freeing these 3 members. If you add members
1330 here, and you add code to set them in replication, don't forget to
1331 free_them_and_set_them_to_0 in replication properly. For details see
1332 the 'err:' label of the handle_slave_sql() in sql/slave.cc.
1333
1334 @see handle_slave_sql
1335 */
1336
1339
1342 if (sctx == m_security_ctx) return;
1343
1344 /*
1345 To prevent race conditions arising from concurrent threads executing
1346 I_S.PROCESSLIST, a mutex LOCK_thd_security_ctx safeguards the security
1347 context switch.
1348 */
1350 m_security_ctx = sctx;
1352 }
1354
1355 /**
1356 @note
1357 The optional password validation plugin doesn't have any API for
1358 temporally disable its functionality for a particular session.
1359 To get around this issue we introduce a boolean variable in the THD
1360 which we check before each call to the password validation plugin.
1361 Password validation is invoked from within the authentication plugin
1362 in the generate_authentication_string() method.
1363
1364 @see generate_authentication_string
1365 */
1367
1368 std::unique_ptr<Protocol_text> protocol_text; // Normal protocol
1369 std::unique_ptr<Protocol_binary> protocol_binary; // Binary protocol
1370
1371 const Protocol *get_protocol() const { return m_protocol; }
1372
1374
1376#ifndef NDEBUG
1377 if (current_thd != this) {
1378 /*
1379 When inspecting this thread from monitoring,
1380 the monitoring thread MUST lock LOCK_thd_data,
1381 to be allowed to safely inspect SSL status variables.
1382 */
1384 }
1385#endif
1386 return m_SSL;
1387 }
1388
1389 /**
1390 Asserts that the protocol is of type text or binary and then
1391 returns the m_protocol casted to Protocol_classic. This method
1392 is needed to prevent misuse of pluggable protocols by legacy code
1393 */
1395 assert(is_classic_protocol());
1396 return pointer_cast<const Protocol_classic *>(m_protocol);
1397 }
1398
1400
1401 private:
1402 Protocol *m_protocol; // Current protocol
1403 /**
1404 SSL data attached to this connection.
1405 This is an opaque pointer,
1406 When building with SSL, this pointer is non NULL
1407 only if the connection is using SSL.
1408 When building without SSL, this pointer is always NULL.
1409 The SSL data can be inspected to read per thread
1410 status variables,
1411 and this can be inspected while the thread is running.
1412 */
1413 SSL_handle m_SSL = {nullptr};
1414
1415 public:
1416 /**
1417 Query plan for EXPLAINable commands, should be locked with
1418 LOCK_query_plan before using.
1419 */
1421 private:
1422 THD *const thd;
1423 /// Original sql_command;
1425 /// LEX of topmost statement
1427 /// Query plan for UPDATE/DELETE/INSERT/REPLACE
1429 /// True if query is run in prepared statement
1430 bool is_ps;
1431
1432 explicit Query_plan(const Query_plan &); ///< not defined
1433 Query_plan &operator=(const Query_plan &); ///< not defined
1434
1435 public:
1436 /// Asserts that current_thd has locked this plan, if it does not own it.
1438#ifdef NDEBUG
1439 {}
1440#else
1441 ;
1442#endif
1443
1444 explicit Query_plan(THD *thd_arg)
1445 : thd(thd_arg),
1447 lex(nullptr),
1449 is_ps(false) {
1450 }
1451
1452 /**
1453 Set query plan.
1454
1455 @note This function takes THD::LOCK_query_plan mutex.
1456 */
1457 void set_query_plan(enum_sql_command sql_cmd, LEX *lex_arg, bool ps);
1458
1459 /*
1460 The 4 getters below expect THD::LOCK_query_plan to be already taken
1461 if called from another thread.
1462 */
1465 return sql_command;
1466 }
1467 LEX *get_lex() const {
1469 return lex;
1470 }
1473 return modification_plan;
1474 }
1475 bool is_ps_query() const {
1477 return is_ps;
1478 }
1479 bool is_single_table_plan() const;
1481
1483
1484 const LEX_CSTRING &catalog() const { return m_catalog; }
1485
1487
1488 private:
1490
1491 /*
1492 Points to info-string that we show in SHOW PROCESSLIST
1493 You are supposed to update thd->proc_info only if you have coded
1494 a time-consuming piece that MySQL can get stuck in for a long time.
1495
1496 Set it using the thd_proc_info(THD *thread, const char *message)
1497 macro/function.
1498
1499 This member is accessed and assigned without any synchronization.
1500 Therefore, it may point only to constant (statically
1501 allocated) strings, which memory won't go away over time.
1502 */
1503 const char *m_proc_info;
1504 /**
1505 Return the m_proc_info, possibly using the string of an older
1506 server release, according to @@terminology_use_previous.
1507
1508 @param sysvars Use the value of
1509 @@terminology_use_previous stored in this
1510 System_variables object.
1511
1512 @return The "proc_info", also known as "stage", of this thread.
1513 */
1514 const char *proc_info(const System_variables &sysvars) const;
1515
1516 public:
1517 // See comment in THD::enter_cond about why SUPPRESS_TSAN is needed.
1518 void enter_stage(const PSI_stage_info *stage, PSI_stage_info *old_stage,
1519 const char *calling_func, const char *calling_file,
1520 const unsigned int calling_line) SUPPRESS_TSAN;
1521 const char *proc_info() const { return m_proc_info; }
1522 /**
1523 Return the m_proc_info, possibly using the string of an older
1524 server release, according to
1525 @@session.terminology_use_previous.
1526
1527 @param invoking_thd Use
1528 @@session.terminology_use_previous of this session.
1529
1530 @return The "proc_info", also known as "stage", of this thread.
1531 */
1532 const char *proc_info_session(THD *invoking_thd) const {
1533 return proc_info(invoking_thd->variables);
1534 }
1537
1538 /*
1539 Used in error messages to tell user in what part of MySQL we found an
1540 error. E. g. when where= "having clause", if fix_fields() fails, user
1541 will know that the error was in having clause.
1542 */
1543 const char *where;
1544
1546
1550 /*
1551 A thread can hold named user-level locks. This variable
1552 contains granted tickets if a lock is present. See item_func.cc and
1553 chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK.
1554 */
1557#ifndef NDEBUG
1558 uint dbug_sentry; // watch out for memory corruption
1559#endif
1561 /**
1562 Mutex protecting access to current_mutex and current_cond.
1563 */
1565 /**
1566 The mutex used with current_cond.
1567 @see current_cond
1568 */
1569 std::atomic<mysql_mutex_t *> current_mutex;
1570 /**
1571 Pointer to the condition variable the thread owning this THD
1572 is currently waiting for. If the thread is not waiting, the
1573 value is NULL. Set by THD::enter_cond().
1574
1575 If this thread is killed (shutdown or KILL stmt), another
1576 thread will broadcast on this condition variable so that the
1577 thread can be unstuck.
1578 */
1579 std::atomic<mysql_cond_t *> current_cond;
1580 /**
1581 Condition variable used for waiting by the THR_LOCK.c subsystem.
1582 */
1584
1585 /// @brief Enables ordering in ha_commit_low. Used in binlog::commit
1586 /// @note Additional requirements need to be met
1587 /// in order to invoke commit ordering in ha_commit_low
1588 /// @see is_ha_commit_low_invoking_commit_order
1590
1591 /// @brief Enables ordering in ha_commit_low. Used in binlog::commit
1592 /// @note Additional requirements need to be met
1593 /// in order to invoke commit ordering in ha_commit_low
1594 /// @see is_ha_commit_low_invoking_commit_order
1596
1597 /// @brief Obtains flag indicating whether additional ordering in the
1598 /// ha_commit_low function is enabled. If not, ordering will take place in
1599 /// binlog::commit
1600 /// @details Accessor for the m_is_low_level_commit_ordering_enabled
1601 /// @return When true, ha_commit_low may order this transaction
1603
1604 private:
1605 /// @brief Flag indicating whether additional ordering in the ha_commit_low
1606 /// function is enabled. If disabled, ordering will take place in
1607 /// binlog::commit. It is set up in binlog::commit
1609
1610 /**
1611 Type of current query: COM_STMT_PREPARE, COM_QUERY, etc.
1612 Set from first byte of the packet in do_command()
1613 */
1615
1616 private:
1618
1619 public:
1620 void set_admin_connection(bool admin) { m_is_admin_conn = admin; }
1621 bool is_admin_connection() const { return m_is_admin_conn; }
1622
1625 uint32 file_id; // for LOAD DATA INFILE
1626 /* remote (peer) port */
1628 struct timeval start_time;
1629 struct timeval user_time;
1630 /**
1631 Query start time, expressed in microseconds.
1632 */
1634
1635 private:
1636 /**
1637 Time spent waiting for TABLE locks and DATA locks.
1638 Expressed in microseconds.
1639 */
1641
1642 public:
1644 void inc_lock_usec(ulonglong usec);
1646 top = m_lock_usec;
1647 m_lock_usec = 0;
1648 }
1650
1651 /**
1652 Type of lock to be used for all DML statements, except INSERT, in cases
1653 when lock is not specified explicitly. Set to TL_WRITE or
1654 TL_WRITE_LOW_PRIORITY depending on whether low_priority_updates option is
1655 off or on.
1656 */
1658 /**
1659 Type of lock to be used for INSERT statement if lock is not specified
1660 explicitly. Set to TL_WRITE_CONCURRENT_INSERT or TL_WRITE_LOW_PRIORITY
1661 depending on whether low_priority_updates option is off or on.
1662 */
1664
1665 /* <> 0 if we are inside of trigger or stored function. */
1667
1668 /**
1669 Used by fill_status() to avoid acquiring LOCK_status mutex twice
1670 when this function is called recursively (e.g. queries
1671 that contains SELECT on I_S.GLOBAL_STATUS with subquery on the
1672 same I_S table).
1673 Incremented each time fill_status() function is entered and
1674 decremented each time before it returns from the function.
1675 */
1678
1679 private:
1680 /* container for handler's private per-connection data */
1682
1683 public:
1684 /**
1685 Retrieve Ha_data for a given slot. Each handler has a fixed slot nr.
1686 */
1687 Ha_data *get_ha_data(int slot) { return &ha_data[slot]; }
1688
1689 /**
1690 Copy ha_data into the provided argument. Used by Attachble_transaction.
1691 */
1693 /*
1694 Protect with LOCK_thd_data avoid accessing ha_data while it
1695 is being modified.
1696 */
1697 mysql_mutex_lock(&this->LOCK_thd_data);
1698 *backup = ha_data;
1699 mysql_mutex_unlock(&this->LOCK_thd_data);
1700 }
1701
1702 /**
1703 Restore ha_data from the provided backup copy.
1704 Used by Attachable_Transaction.
1705 */
1708 /*
1709 Protect with LOCK_thd_data to avoid e.g. KILL CONNECTION
1710 reading ha_data while it is being modified.
1711 */
1712 mysql_mutex_lock(&this->LOCK_thd_data);
1713 ha_data = backup;
1714 mysql_mutex_unlock(&this->LOCK_thd_data);
1715 }
1716
1717 /*
1718 Position of first event in Binlog
1719 *after* last event written by this
1720 thread.
1721 */
1723 void set_next_event_pos(const char *_filename, ulonglong _pos);
1724 void clear_next_event_pos();
1725
1726 /*
1727 Ptr to row event extra data to be written to Binlog /
1728 received from Binlog.
1729
1730 */
1732
1734
1735 /**
1736 * @brief Configure size of binlog transaction cache. Used to configure the
1737 * size of an individual cache, normally to a value that differs from the
1738 * default `binlog_cache_size` which controls the size otherwise.
1739 *
1740 * @note Assumes that the binlog cache manager already exist (i.e created
1741 * by call to binlog_setup_trx_data()) and is empty.
1742 *
1743 * @param new_size The new size of cache. Value exceeding
1744 * `max_binlog_cache_size` will be clamped and warning logged. Value must be
1745 * a multiple of IO_SIZE which is the block size for all binlog cache size
1746 * related variables.
1747 *
1748 * @return true if new cache size can't be configured, in that case the cache
1749 * is not usable.
1750 */
1751 bool binlog_configure_trx_cache_size(ulong new_size);
1752
1753 /*
1754 Public interface to write RBR events to the binlog
1755 */
1756 int binlog_write_table_map(TABLE *table, bool is_transactional,
1757 bool binlog_rows_query);
1758 int binlog_write_row(TABLE *table, bool is_transactional,
1759 const uchar *new_data,
1760 const unsigned char *extra_row_info);
1761 int binlog_delete_row(TABLE *table, bool is_transactional,
1762 const uchar *old_data,
1763 const unsigned char *extra_row_info);
1764 int binlog_update_row(TABLE *table, bool is_transactional,
1765 const uchar *old_data, const uchar *new_data,
1766 const uchar *extra_row_info);
1767 void set_server_id(uint32 sid) { server_id = sid; }
1768
1769 /*
1770 Member functions to handle pending event for row-level logging.
1771 */
1772 template <class RowsEventT>
1774 TABLE *table, uint32 serv_id, size_t needed, bool is_transactional,
1775 const unsigned char *extra_row_info, uint32 source_part_id = INT_MAX);
1776 Rows_log_event *binlog_get_pending_rows_event(bool is_transactional) const;
1777 inline int binlog_flush_pending_rows_event(bool stmt_end) {
1778 return (binlog_flush_pending_rows_event(stmt_end, false) ||
1779 binlog_flush_pending_rows_event(stmt_end, true));
1780 }
1781 int binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional);
1782
1783 /**
1784 Determine the binlog format of the current statement.
1785
1786 @retval 0 if the current statement will be logged in statement
1787 format.
1788 @retval nonzero if the current statement will be logged in row
1789 format.
1790 */
1795 }
1796
1797 /**
1798 Determine if binlogging is currently disabled for this session.
1799
1800 There are two ways that binlogging can be disabled:
1801
1802 1. The binary log file is closed (globally). This can happen for
1803 two reasons: either --skip-log-bin was used on the command line,
1804 or a binlog write error happened when binlog_error_action=IGNORE_ERROR.
1805
1806 2. The binary log is disabled on session level. This can happen for
1807 two reasons: either the user has set @@session.sql_log_bin = 0,
1808 or the server code has internally disabled the binary log (by
1809 either setting thd->variables.option_bits &= ~OPTION_BIN_LOG or
1810 creating a Disable_binlog_guard object).
1811
1812 Even if this function returns true and the binary log is disabled,
1813 it is possible that the statement will be written to the binary log,
1814 in the cases where the server has merely temporarily disabled binary
1815 logging.
1816
1817 And even if this function returns false and the binary log is
1818 enabled, it is possible that the statement will not be written to
1819 the binary log, e.g. in case it is a no-op, it fails, it gets rolled
1820 back, or some other session closes the binary log due to a write
1821 error when using binlog_error_action=IGNORE_ERROR.
1822
1823 @retval true The binary log is currently disabled for the statement.
1824
1825 @retval false The binary log is currently enabled for the statement.
1826 */
1828
1829 /**
1830 Determine if binlogging is currently disabled for this session.
1831 If the binary log is disabled for this thread (either by log_bin=0 or
1832 sql_log_bin=0 or by log_replica_updates=0 for a slave thread), then the
1833 statement will not be written to the binary log.
1834
1835 @retval true The binary log is currently disabled for the statement.
1836
1837 @retval false The binary log is currently enabled for the statement.
1838 */
1840
1841 /**
1842 Checks whether binlog caches are disabled (binlog does not cache data) or
1843 empty in case binloggging is enabled in the current call to this function.
1844 This function may be safely called in case binlogging is disabled.
1845 @retval true binlog local caches are empty or disabled and binlogging is
1846 enabled
1847 @retval false binlog local caches are enabled and contain data or binlogging
1848 is disabled
1849 */
1851
1852 /**
1853 Determine if binloging is enabled in row format and write set extraction is
1854 enabled for this session
1855 @retval true if is enable
1856 @retval false otherwise
1857 */
1859
1860 /** Tells whether the given optimizer_switch flag is on */
1862 return (variables.optimizer_switch & flag);
1863 }
1864
1870
1873 }
1874
1878 }
1879
1883 }
1884
1886 return m_binlog_filter_state;
1887 }
1888
1889 /** Holds active timer object */
1891 /**
1892 After resetting(cancelling) timer, current timer object is cached
1893 with timer_cache timer to reuse.
1894 */
1896
1897 private:
1898 /*
1899 Indicates that the command which is under execution should ignore the
1900 'read_only' and 'super_read_only' options.
1901 */
1903
1904 /*
1905 Indicates that the command which is under execution should ignore the
1906 read only transaction mode.
1907 */
1909 /**
1910 Indicate if the current statement should be discarded
1911 instead of written to the binlog.
1912 This is used to discard special statements, such as
1913 DML or DDL that affects only 'local' (non replicated)
1914 tables, such as performance_schema.*
1915 */
1917
1918 /**
1919 Indicates the format in which the current statement will be
1920 logged. This can only be set from @c decide_logging_format().
1921 */
1923
1924 /**
1925 Bit field for the state of binlog warnings.
1926
1927 The first Lex::BINLOG_STMT_UNSAFE_COUNT bits list all types of
1928 unsafeness that the current statement has.
1929
1930 This must be a member of THD and not of LEX, because warnings are
1931 detected and issued in different places (@c
1932 decide_logging_format() and @c binlog_query(), respectively).
1933 Between these calls, the THD->lex object may change; e.g., if a
1934 stored routine is invoked. Only THD persists between the calls.
1935 */
1937
1938 /*
1939 Number of outstanding table maps, i.e., table maps in the
1940 transaction cache.
1941 */
1943 /*
1944 MTS: db names listing to be updated by the query databases
1945 */
1947
1948 /**
1949 The binary log position of the transaction.
1950
1951 The file and position are zero if the current transaction has not
1952 been written to the binary log.
1953
1954 @see set_trans_pos
1955 @see get_trans_pos
1956
1957 @todo Similar information is kept in the patch for BUG#11762277
1958 and by the master/slave heartbeat implementation. We should merge
1959 these positions instead of maintaining three different ones.
1960 */
1961 /**@{*/
1962 const char *m_trans_log_file;
1965 /**@}*/
1966 // NOTE: Ideally those two should be in Protocol,
1967 // but currently its design doesn't allow that.
1968 NET net; // client connection descriptor
1969 String packet; // dynamic buffer for network I/O
1970 public:
1971 const NET *get_net() const { return &net; }
1972
1974 skip_readonly_check = true;
1975 // Make a transaction skip the read only check set via the command
1976 // SET SESSION TRANSACTION READ ONLY
1978 }
1981 }
1983
1986 }
1990 }
1991
1995 }
1996
1997 void issue_unsafe_warnings();
1998
2001
2002 /*
2003 MTS: accessor to binlog_accessed_db_names list
2004 */
2007 }
2008
2009 /* MTS: method inserts a new unique name into binlog_updated_dbs */
2010 void add_to_binlog_accessed_dbs(const char *db);
2011
2012 bool is_applier_thread() const {
2015 }
2016
2017 private:
2018 std::unique_ptr<Transaction_ctx> m_transaction;
2019
2020 /** An utility struct for @c Attachable_trx */
2024 void backup(THD *thd);
2025 void restore(THD *thd);
2026
2027 /// SQL-command.
2029
2031
2032 /// Open-tables state.
2034
2035 /// SQL_MODE.
2037
2038 /// Transaction isolation level.
2040
2041 /// Ha_data array.
2043
2044 /// Transaction_ctx instance.
2046
2047 /// Transaction read-only state.
2049
2050 /// THD options.
2052
2053 /// Current transaction instrumentation.
2055
2056 /// Server status flags.
2058
2059 /// THD::in_lock_tables value.
2061
2062 /**
2063 Current time zone (i.e. @@session.time_zone) usage indicator.
2064
2065 Saving it allows data-dictionary code to read timestamp values
2066 as datetimes from system tables without disturbing user's statement.
2067
2068 TODO: We need to change DD code not to use @@session.time_zone at all and
2069 stick to UTC for internal storage of timestamps in DD objects.
2070 */
2072
2073 /**
2074 Transaction rollback request flag.
2075
2076 InnoDB can try to access table definition while rolling back regular
2077 transaction. So we need to be able to start attachable transaction
2078 without being affected by, and affecting, the rollback state of regular
2079 transaction.
2080 */
2082 };
2083
2084 public:
2086
2087 private:
2088 /**
2089 Class representing read-only attachable transaction, encapsulates
2090 knowledge how to backup state of current transaction, start
2091 read-only attachable transaction in SE, finalize it and then restore
2092 state of original transaction back. Also serves as a base class for
2093 read-write attachable transaction implementation.
2094 */
2096 public:
2097 Attachable_trx(THD *thd, Attachable_trx *prev_trx);
2098 virtual ~Attachable_trx();
2100 return m_prev_attachable_trx;
2101 }
2102 virtual bool is_read_only() const { return true; }
2103
2104 protected:
2105 /// THD instance.
2107
2109
2110 /**
2111 Attachable_trx which was active for the THD before when this
2112 transaction was started (NULL in most cases).
2113 */
2115
2116 /// Transaction state data.
2118
2119 private:
2122 };
2123
2124 /**
2125 A derived from THD::Attachable_trx class allows updates in
2126 the attachable transaction. Callers of the class methods must
2127 make sure the attachable_rw won't cause deadlock with the main transaction.
2128 The destructor does not invoke ha_commit_{stmt,trans} nor ha_rollback_trans
2129 on purpose.
2130 Burden to terminate the read-write instance also lies on the caller!
2131 In order to use this interface it *MUST* prove that no side effect to
2132 the global transaction state can be inflicted by a chosen method.
2133
2134 This class is being used only by class Gtid_table_access_context by
2135 replication and by dd::info_schema::Table_statistics.
2136 */
2137
2139 public:
2140 bool is_read_only() const override { return false; }
2141 explicit Attachable_trx_rw(THD *thd);
2142
2143 private:
2146 };
2147
2149
2150 public:
2152
2153 const Transaction_ctx *get_transaction() const { return m_transaction.get(); }
2154
2155 /**
2156 Changes the Transaction_ctx instance within THD-object. The previous
2157 Transaction_ctx instance is destroyed.
2158
2159 @note this is a THD-internal operation which MUST NOT be used outside.
2160
2161 @param transaction_ctx new Transaction_ctx instance to be associated with
2162 the THD-object.
2163 */
2164 void set_transaction(Transaction_ctx *transaction_ctx);
2165
2167
2168 Vio *active_vio = {nullptr};
2169
2170 /* Active network vio for clone remote connection. */
2171 Vio *clone_vio = {nullptr};
2172
2173 /**
2174 This is used to track transient changes to items during optimization of a
2175 prepared statement/stored procedure. Change objects are created by
2176 change_item_tree() in memory root of THD, and freed by
2177 rollback_item_tree_changes(). Changes recorded here are rolled back at
2178 the end of execution.
2179
2180 Transient changes require the following conditions:
2181 - The statement is not regular (ie. it is prepared or part of SP).
2182 - The change is performed outside preparation code (ie. it is
2183 performed during the optimization phase).
2184 - The change is applied to non-transient items (ie. items that have
2185 been created before or during preparation, not items that have been
2186 created in the optimization phase. Notice that the tree of AND/OR
2187 conditions is always as transient objects during optimization.
2188 Doing this should be quite harmless, though.)
2189 change_item_tree() only records changes to non-regular statements.
2190 It is also ensured that no changes are applied in preparation phase by
2191 asserting that the list of items is empty (see Sql_cmd_dml::prepare()).
2192 Other constraints are not enforced, in particular care must be taken
2193 so that all changes made during optimization to non-transient Items in
2194 non-regular statements must be recorded.
2195 */
2197
2198 /*
2199 A permanent memory area of the statement. For conventional
2200 execution, the parsed tree and execution runtime reside in the same
2201 memory root. In this case stmt_arena points to THD. In case of
2202 a prepared statement or a stored procedure statement, thd->mem_root
2203 conventionally points to runtime memory, and thd->stmt_arena
2204 points to the memory of the PS/SP, where the parsed tree of the
2205 statement resides. Whenever you need to perform a permanent
2206 transformation of a parsed tree, you should allocate new memory in
2207 stmt_arena, to allow correct re-execution of PS/SP.
2208 Note: in the parser, stmt_arena == thd, even for PS/SP.
2209 */
2211
2212 /*
2213 map for tables that will be updated for a multi-table update query
2214 statement, for other query statements, this will be zero.
2215 */
2217
2218 /* Tells if LAST_INSERT_ID(#) was called for the current statement */
2220 /*
2221 ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
2222 insertion into an auto_increment column".
2223 */
2224 /*
2225 This is the first autogenerated insert id which was *successfully*
2226 inserted by the previous statement (exactly, if the previous statement
2227 didn't successfully insert an autogenerated insert id, then it's the one
2228 of the statement before, etc).
2229 It can also be set by SET LAST_INSERT_ID=# or SELECT LAST_INSERT_ID(#).
2230 It is returned by LAST_INSERT_ID().
2231 */
2233 /*
2234 Variant of the above, used for storing in statement-based binlog. The
2235 difference is that the one above can change as the execution of a stored
2236 function progresses, while the one below is set once and then does not
2237 change (which is the value which statement-based binlog needs).
2238 */
2240 /*
2241 This is the first autogenerated insert id which was *successfully*
2242 inserted by the current statement. It is maintained only to set
2243 first_successful_insert_id_in_prev_stmt when statement ends.
2244 */
2246 /*
2247 We follow this logic:
2248 - when stmt starts, first_successful_insert_id_in_prev_stmt contains the
2249 first insert id successfully inserted by the previous stmt.
2250 - as stmt makes progress, handler::insert_id_for_cur_row changes;
2251 every time get_auto_increment() is called,
2252 auto_inc_intervals_in_cur_stmt_for_binlog is augmented with the
2253 reserved interval (if statement-based binlogging).
2254 - at first successful insertion of an autogenerated value,
2255 first_successful_insert_id_in_cur_stmt is set to
2256 handler::insert_id_for_cur_row.
2257 - when stmt goes to binlog,
2258 auto_inc_intervals_in_cur_stmt_for_binlog is binlogged if
2259 non-empty.
2260 - when stmt ends, first_successful_insert_id_in_prev_stmt is set to
2261 first_successful_insert_id_in_cur_stmt.
2262 */
2263 /*
2264 stmt_depends_on_first_successful_insert_id_in_prev_stmt is set when
2265 LAST_INSERT_ID() is used by a statement.
2266 If it is set, first_successful_insert_id_in_prev_stmt_for_binlog will be
2267 stored in the statement-based binlog.
2268 This variable is CUMULATIVE along the execution of a stored function or
2269 trigger: if one substatement sets it to 1 it will stay 1 until the
2270 function/trigger ends, thus making sure that
2271 first_successful_insert_id_in_prev_stmt_for_binlog does not change anymore
2272 and is propagated to the caller for binlogging.
2273 */
2275 /*
2276 List of auto_increment intervals reserved by the thread so far, for
2277 storage in the statement-based binlog.
2278 Note that its minimum is not first_successful_insert_id_in_cur_stmt:
2279 assuming a table with an autoinc column, and this happens:
2280 INSERT INTO ... VALUES(3);
2281 SET INSERT_ID=3; INSERT IGNORE ... VALUES (NULL);
2282 then the latter INSERT will insert no rows
2283 (first_successful_insert_id_in_cur_stmt == 0), but storing "INSERT_ID=3"
2284 in the binlog is still needed; the list's minimum will contain 3.
2285 This variable is cumulative: if several statements are written to binlog
2286 as one (stored functions or triggers are used) this list is the
2287 concatenation of all intervals reserved by all statements.
2288 */
2290 /* Used by replication and SET INSERT_ID */
2292 /*
2293 There is BUG#19630 where statement-based replication of stored
2294 functions/triggers with two auto_increment columns breaks.
2295 We however ensure that it works when there is 0 or 1 auto_increment
2296 column; our rules are
2297 a) on master, while executing a top statement involving substatements,
2298 first top- or sub- statement to generate auto_increment values wins the
2299 exclusive right to see its values be written to binlog (the write
2300 will be done by the statement or its caller), and the losers won't see
2301 their values be written to binlog.
2302 b) on slave, while replicating a top statement involving substatements,
2303 first top- or sub- statement to need to read auto_increment values from
2304 the master's binlog wins the exclusive right to read them (so the losers
2305 won't read their values from binlog but instead generate on their own).
2306 a) implies that we mustn't backup/restore
2307 auto_inc_intervals_in_cur_stmt_for_binlog.
2308 b) implies that we mustn't backup/restore auto_inc_intervals_forced.
2309
2310 If there are more than 1 auto_increment columns, then intervals for
2311 different columns may mix into the
2312 auto_inc_intervals_in_cur_stmt_for_binlog list, which is logically wrong,
2313 but there is no point in preventing this mixing by preventing intervals
2314 from the secondly inserted column to come into the list, as such
2315 prevention would be wrong too.
2316 What will happen in the case of
2317 INSERT INTO t1 (auto_inc) VALUES(NULL);
2318 where t1 has a trigger which inserts into an auto_inc column of t2, is
2319 that in binlog we'll store the interval of t1 and the interval of t2 (when
2320 we store intervals, soon), then in slave, t1 will use both intervals, t2
2321 will use none; if t1 inserts the same number of rows as on master,
2322 normally the 2nd interval will not be used by t1, which is fine. t2's
2323 values will be wrong if t2's internal auto_increment counter is different
2324 from what it was on master (which is likely). In 5.1, in mixed binlogging
2325 mode, row-based binlogging is used for such cases where two
2326 auto_increment columns are inserted.
2327 */
2331 }
2334 /* It's the first time we read it */
2338 }
2340 }
2347 }
2348
2349 /*
2350 Used by Intvar_log_event::do_apply_event() and by "SET INSERT_ID=#"
2351 (mysqlbinlog). We'll soon add a variant which can take many intervals in
2352 argument.
2353 */
2355 auto_inc_intervals_forced.clear(); // in case of multiple SET INSERT_ID
2356 auto_inc_intervals_forced.append(next_id, ULLONG_MAX, 0);
2357 }
2358
2359 /**
2360 Stores the result of the FOUND_ROWS() function. Set at query end, stable
2361 throughout the query.
2362 */
2364 /**
2365 Dynamic, collected and set also in subqueries. Not stable throughout query.
2366 previous_found_rows is a snapshot of this take at query end making it
2367 stable throughout the next query, see update_previous_found_rows.
2368 */
2370
2371 /*
2372 Indicate if the gtid_executed table is being operated implicitly
2373 within current transaction. This happens because we are inserting
2374 a GTID specified through SET GTID_NEXT by user client or
2375 slave SQL thread/workers.
2376 */
2378 /*
2379 Indicate that a sub-statement is being operated implicitly
2380 within current transaction.
2381 As we don't want that this implicit sub-statement to consume the
2382 GTID of the actual transaction, we set it true at the beginning of
2383 the sub-statement and set it false again after "committing" the
2384 sub-statement.
2385 When it is true, the applier will not save the transaction owned
2386 gtid into mysql.gtid_executed table before transaction prepare, as
2387 it does when binlog is disabled, or binlog is enabled and
2388 log_replica_updates is disabled.
2389 Also the flag is made to defer updates to the slave info table from
2390 intermediate commits by non-atomic DDL.
2391 Rpl_info_table::do_flush_info(), rpl_rli.h::is_atomic_ddl_commit_on_slave()
2392 uses this flag.
2393 */
2395
2396 private:
2397 /**
2398 Stores the result of ROW_COUNT() function.
2399
2400 ROW_COUNT() function is a MySQL extension, but we try to keep it
2401 similar to ROW_COUNT member of the GET DIAGNOSTICS stack of the SQL
2402 standard (see SQL99, part 2, search for ROW_COUNT). Its value is
2403 implementation defined for anything except INSERT, DELETE, UPDATE.
2404
2405 ROW_COUNT is assigned according to the following rules:
2406
2407 - In my_ok():
2408 - for DML statements: to the number of affected rows;
2409 - for DDL statements: to 0.
2410
2411 - In my_eof(): to -1 to indicate that there was a result set.
2412
2413 We derive this semantics from the JDBC specification, where int
2414 java.sql.Statement.getUpdateCount() is defined to (sic) "return the
2415 current result as an update count; if the result is a ResultSet
2416 object or there are no more results, -1 is returned".
2417
2418 - In my_error(): to -1 to be compatible with the MySQL C API and
2419 MySQL ODBC driver.
2420
2421 - For SIGNAL statements: to 0 per WL#2110 specification (see also
2422 sql_signal.cc comment). Zero is used since that's the "default"
2423 value of ROW_COUNT in the Diagnostics Area.
2424 */
2425
2426 longlong m_row_count_func; /* For the ROW_COUNT() function */
2427
2428 public:
2430
2431 inline void set_row_count_func(longlong row_count_func) {
2432 m_row_count_func = row_count_func;
2433 }
2434
2436
2437 private:
2438 /**
2439 Number of rows we actually sent to the client, including "synthetic"
2440 rows in ROLLUP etc.
2441 */
2443
2444 /**
2445 Number of rows read and/or evaluated for a statement. Used for
2446 slow log reporting.
2447
2448 An examined row is defined as a row that is read and/or evaluated
2449 according to a statement condition, including in
2450 create_sort_index(). Rows may be counted more than once, e.g., a
2451 statement including ORDER BY could possibly evaluate the row in
2452 filesort() before reading it for e.g. update.
2453 */
2455
2456 private:
2458
2459 public:
2460 void set_user_connect(USER_CONN *uc);
2461 const USER_CONN *get_user_connect() const { return m_user_connect; }
2462
2465
2467
2469
2471
2473
2474 public:
2476
2478
2480
2483
2492 void inc_status_sort_range();
2494 void inc_status_sort_scan();
2497
2499#if defined(ENABLED_PROFILING)
2500 std::unique_ptr<PROFILING> profiling;
2501#endif
2502
2503 /** Current stage progress instrumentation. */
2505 /** Current statement digest. */
2507 /** Current statement digest token array. */
2508 unsigned char *m_token_array;
2509 /** Top level statement digest. */
2511
2512 /** Current statement instrumentation. */
2514#ifdef HAVE_PSI_STATEMENT_INTERFACE
2515 /** Current statement instrumentation state. */
2517#endif /* HAVE_PSI_STATEMENT_INTERFACE */
2518
2519 /** Current transaction instrumentation. */
2521#ifdef HAVE_PSI_TRANSACTION_INTERFACE
2522 /** Current transaction instrumentation state. */
2524#endif /* HAVE_PSI_TRANSACTION_INTERFACE */
2525
2526 /** Idle instrumentation. */
2528#ifdef HAVE_PSI_IDLE_INTERFACE
2529 /** Idle instrumentation state. */
2531#endif /* HAVE_PSI_IDLE_INTERFACE */
2532 /** True if the server code is IDLE for this connection. */
2534
2535 /*
2536 Id of current query. Statement can be reused to execute several queries
2537 query_id is global in context of the whole MySQL server.
2538 ID is automatically generated from mutex-protected counter.
2539 It's used in handler code for various purposes: to check which columns
2540 from table are necessary for this select, to check if it's necessary to
2541 update auto-updatable fields (like auto_increment and timestamp).
2542 */
2544
2545 /* Statement id is thread-wide. This counter is used to generate ids */
2549 /**
2550 This counter is 32 bit because of the client protocol.
2551
2552 @note It is not meant to be used for my_thread_self(), see @c real_id for
2553 this.
2554
2555 @note Set to reserved_thread_id on initialization. This is a magic
2556 value that is only to be used for temporary THDs not present in
2557 the global THD list.
2558 */
2559 private:
2561
2562 public:
2563 /**
2564 Assign a value to m_thread_id by calling
2565 Global_THD_manager::get_new_thread_id().
2566 */
2567 void set_new_thread_id();
2572
2573 // Check if this THD belongs to a system thread.
2575
2576 // Check if this THD belongs to a dd bootstrap system thread.
2577 bool is_dd_system_thread() const {
2580 }
2581
2582 // Check if this THD belongs to the initialize system thread. The
2583 // initialize thread executes statements that are compiled into the
2584 // server.
2587 }
2588
2589 // Check if this THD is executing statements passed through a init file.
2592 }
2593
2594 // Check if this THD belongs to a bootstrap system thread. Note that
2595 // this thread type may execute statements submitted by the user.
2599 }
2600
2601 // Check if this THD belongs to a server upgrade thread. Server upgrade
2602 // threads execute statements that are compiled into the server.
2605 }
2606
2607 /*
2608 Current or next transaction isolation level.
2609 When a connection is established, the value is taken from
2610 @@session.tx_isolation (default transaction isolation for
2611 the session), which is in turn taken from @@global.tx_isolation
2612 (the global value).
2613 If there is no transaction started, this variable
2614 holds the value of the next transaction's isolation level.
2615 When a transaction starts, the value stored in this variable
2616 becomes "actual".
2617 At transaction commit or rollback, we assign this variable
2618 again from @@session.tx_isolation.
2619 The only statement that can otherwise change the value
2620 of this variable is SET TRANSACTION ISOLATION LEVEL.
2621 Its purpose is to effect the isolation level of the next
2622 transaction in this session. When this statement is executed,
2623 the value in this variable is changed. However, since
2624 this statement is only allowed when there is no active
2625 transaction, this assignment (naturally) only affects the
2626 upcoming transaction.
2627 At the end of the current active transaction the value is
2628 be reset again from @@session.tx_isolation, as described
2629 above.
2630 */
2632 /*
2633 Current or next transaction access mode.
2634 See comment above regarding tx_isolation.
2635 */
2637 /*
2638 Transaction cannot be rolled back must be given priority.
2639 When two transactions conflict inside InnoDB, the one with
2640 greater priority wins.
2641 */
2643 /*
2644 All transactions executed by this thread will have high
2645 priority mode, independent of tx_priority value.
2646 */
2648
2650
2651 // For user variables replication
2653 MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
2654
2655 /**
2656 Used by MYSQL_BIN_LOG to maintain the commit queue for binary log
2657 group commit.
2658 */
2660
2661 /**
2662 The member is served for marking a query that CREATEs or ALTERs
2663 a table declared with a TIMESTAMP column as dependent on
2664 @@session.explicit_defaults_for_timestamp.
2665 Is set to true by parser, unset at the end of the query.
2666 Possible marking in checked by binary logger.
2667 */
2669
2670 /**
2671 Functions to set and get transaction position.
2672
2673 These functions are used to set the transaction position for the
2674 transaction written when committing this transaction.
2675 */
2676 /**@{*/
2677 void set_trans_pos(const char *file, my_off_t pos) {
2678 DBUG_TRACE;
2679 assert(((file == nullptr) && (pos == 0)) ||
2680 ((file != nullptr) && (pos != 0)));
2681 if (file) {
2682 DBUG_PRINT("enter", ("file: %s, pos: %llu", file, pos));
2683 // Only the file name should be used, not the full path
2687 assert(strlen(m_trans_log_file) <= FN_REFLEN);
2689 } else {
2690 m_trans_log_file = nullptr;
2691 m_trans_fixed_log_file = nullptr;
2692 }
2693
2694 m_trans_end_pos = pos;
2695 DBUG_PRINT("return",
2696 ("m_trans_log_file: %s, m_trans_fixed_log_file: %s, "
2697 "m_trans_end_pos: %llu",
2699 return;
2700 }
2701
2702 void get_trans_pos(const char **file_var, my_off_t *pos_var) const {
2703 DBUG_TRACE;
2704 if (file_var) *file_var = m_trans_log_file;
2705 if (pos_var) *pos_var = m_trans_end_pos;
2706 DBUG_PRINT("return",
2707 ("file: %s, pos: %llu", file_var ? *file_var : "<none>",
2708 pos_var ? *pos_var : 0));
2709 return;
2710 }
2711
2712 void get_trans_fixed_pos(const char **file_var, my_off_t *pos_var) const {
2713 DBUG_TRACE;
2714 if (file_var) *file_var = m_trans_fixed_log_file;
2715 if (pos_var) *pos_var = m_trans_end_pos;
2716 DBUG_PRINT("return",
2717 ("file: %s, pos: %llu", file_var ? *file_var : "<none>",
2718 pos_var ? *pos_var : 0));
2719 return;
2720 }
2721
2722 /**@}*/
2723
2724 /*
2725 Error code from committing or rolling back the transaction.
2726 */
2735
2736 /*
2737 Define durability properties that engines may check to
2738 improve performance.
2739 */
2741
2742 /*
2743 If checking this in conjunction with a wait condition, please
2744 include a check after enter_cond() if you want to avoid a race
2745 condition. For details see the implementation of awake(),
2746 especially the "broadcast" part.
2747 */
2750 KILL_CONNECTION = ER_SERVER_SHUTDOWN,
2751 KILL_QUERY = ER_QUERY_INTERRUPTED,
2752 KILL_TIMEOUT = ER_QUERY_TIMEOUT,
2753 KILLED_NO_VALUE /* means neither of the states */
2755 std::atomic<killed_state> killed;
2756
2757 /**
2758 Whether we are currently in the execution phase of an EXPLAIN ANALYZE query.
2759 If so, send_kill_message() won't actually set an error; we will add a
2760 warning near the end of the execution instead.
2761 */
2763
2764 /**
2765 When operation on DD tables is in progress then THD is set to kill immune
2766 mode.
2767 This member holds DD_kill_immunizer object created to make DD operations
2768 immune from the kill operations. Member also indicated whether THD is in
2769 kill immune mode or not.
2770 */
2772
2773 /* scramble - random string sent to client on handshake */
2775
2776 /// @todo: slave_thread is completely redundant, we should use 'system_thread'
2777 /// instead /sven
2779
2781
2782 private:
2783 /**
2784 Set to true if execution of the current compound statement
2785 can not continue. In particular, disables activation of
2786 CONTINUE or EXIT handlers of stored routines.
2787 Reset in the end of processing of the current user request, in
2788 @see mysql_reset_thd_for_next_command().
2789 */
2791
2792 public:
2793 /**
2794 Set by a storage engine to request the entire
2795 transaction (that possibly spans multiple engines) to
2796 rollback. Reset in ha_rollback.
2797 */
2799 /**
2800 true if we are in a sub-statement and the current error can
2801 not be safely recovered until we left the sub-statement mode.
2802 In particular, disables activation of CONTINUE and EXIT
2803 handlers inside sub-statements. E.g. if it is a deadlock
2804 error and requires a transaction-wide rollback, this flag is
2805 raised (traditionally, MySQL first has to close all the reads
2806 via @see handler::ha_index_or_rnd_end() and only then perform
2807 the rollback).
2808 Reset to false when we leave the sub-statement mode.
2809 */
2814 /**
2815 True if a slave error. Causes the slave to stop. Not the same
2816 as the statement execution error (is_error()), since
2817 a statement may be expected to return an error, e.g. because
2818 it returned an error on master, and this is OK on the slave.
2819 */
2821
2822 /** is set if some thread specific value(s) used in a statement. */
2824 /**
2825 is set if a statement accesses a temporary table created through
2826 CREATE TEMPORARY TABLE.
2827 */
2830 bool enable_slow_log; /* enable slow log for current statement */
2831 /* set during loop of derived table processing */
2833 // Set while parsing INFORMATION_SCHEMA system views.
2835
2836 /** Current SP-runtime context. */
2840
2841 /** number of name_const() substitutions, see sp_head.cc:subst_spvars() */
2843
2844 /* Used by the sys_var class to store temporary values */
2845 union {
2852
2853 struct {
2854 /*
2855 If true, mysql_bin_log::write(Log_event) call will not write events to
2856 binlog, and maintain 2 below variables instead (use
2857 mysql_bin_log.start_union_events to turn this on)
2858 */
2860 /*
2861 If true, at least one mysql_bin_log::write(Log_event) call has been
2862 made after last mysql_bin_log.start_union_events() call.
2863 */
2865 /*
2866 If true, at least one mysql_bin_log::write(Log_event e), where
2867 e.cache_stmt == true call has been made after last
2868 mysql_bin_log.start_union_events() call.
2869 */
2871
2872 /*
2873 'queries' (actually SP statements) that run under inside this binlog
2874 union have thd->query_id >= first_query_id.
2875 */
2878
2879 /**
2880 Internal parser state.
2881 Note that since the parser is not re-entrant, we keep only one parser
2882 state here. This member is valid only when executing code during parsing.
2883 */
2885
2887
2889
2890 /**
2891 Array of active audit plugins which have been used by this THD.
2892 This list is later iterated to invoke release_thd() on those
2893 plugins.
2894 */
2896 /**
2897 Array of bits indicating which audit classes have already been
2898 added to the list of audit plugins which are currently in use.
2899 */
2901
2902#if defined(ENABLED_DEBUG_SYNC)
2903 /* Debug Sync facility. See debug_sync.cc. */
2904 struct st_debug_sync_control *debug_sync_control;
2905#endif /* defined(ENABLED_DEBUG_SYNC) */
2906
2907 // We don't want to load/unload plugins for unit tests.
2909
2910 /*
2911 Audit API events are generated, when this flag is true. The flag
2912 is initially true, but it can be set false in some cases, e.g.
2913 Session Service's THDs are created with auditing disabled. Auditing
2914 is enabled on EVENT_TRACKING_CONNECTION_CONNECT event.
2915 */
2917
2918 explicit THD(bool enable_plugins = true);
2919
2920 /*
2921 The THD dtor is effectively split in two:
2922 THD::release_resources() and ~THD().
2923
2924 We want to minimize the time we hold LOCK_thd_list,
2925 so when destroying a global thread, do:
2926
2927 thd->release_resources()
2928 Global_THD_manager::get_instance()->remove_thd();
2929 delete thd;
2930 */
2931 ~THD() override;
2932
2933 void release_resources();
2934 /**
2935 @returns true if THD resources are released.
2936 */
2937 bool release_resources_done() const;
2938 /**
2939 Check if THD is being disposed (i.e. m_thd_life_cycle_stage >=
2940 SCHEDULED_FOR_DISPOSAL)
2941
2942 Non-owner thread should acquire LOCK_thd_data to check THD state without
2943 getting into races.
2944
2945 @returns true of THD is being disposed.
2946 */
2947 bool is_being_disposed() const;
2948
2949 private:
2950 /**
2951 Represents life cycle stages of THD instance.
2952 Stage transition in THD clean up:
2953 1. ACTIVE -> ACTIVE_AND_CLEAN
2954
2955 Stage transition in THD disposal:
2956 1. ACTIVE -> SCHEDULED_FOR_DISPOSAL -> CLEANED_UP -> RESOURCES_RELEASED
2957 -> DISPOSED.
2958 2. ACTIVE_AND_CLEAN -> CLEANED_UP -> RESOURCES_RELEASED -> DISPOSED.
2959 */
2966 DISPOSED
2969 enum_thd_life_cycle_stages::ACTIVE};
2970
2971 /**
2972 Set THD in ACTIVE life stage to disposal stage.
2973
2974 To avoid race conditions with non-owner thread checking THD disposal state,
2975 LOCK_thd_data should be acquired before changing THD stage to disposal
2976 stage.
2977 */
2978 void start_disposal();
2979
2980 /**
2981 @returns true if THD is cleaned up.
2982 */
2983 bool is_cleanup_done();
2984 void cleanup(void);
2985
2986 void init(void);
2987
2988 public:
2989 /**
2990 Initialize memory roots necessary for query processing and (!)
2991 pre-allocate memory for it. We can't do that in THD constructor because
2992 there are use cases (acl_init, watcher threads,
2993 killing mysqld) where it's vital to not allocate excessive and not used
2994 memory. Note, that we still don't return error from init_query_mem_roots()
2995 if preallocation fails, we should notice that at the first call to
2996 alloc_root.
2997 */
2998 void init_query_mem_roots();
2999 void cleanup_connection(void);
3000 void cleanup_after_query();
3001 void store_globals();
3002 void restore_globals();
3003
3004 inline void set_active_vio(Vio *vio) {
3006 active_vio = vio;
3008 }
3009
3010 inline void set_ssl(Vio *vio) {
3012 m_SSL = (SSL *)vio->ssl_arg;
3014 }
3015
3016 inline void clear_active_vio() {
3018 active_vio = nullptr;
3019 m_SSL = nullptr;
3021 }
3022
3023 /** Set active clone network Vio for remote clone.
3024 @param[in] vio network vio */
3025 inline void set_clone_vio(Vio *vio) {
3027 clone_vio = vio;
3029 }
3030
3031 /** Clear clone network Vio for remote clone. */
3032 inline void clear_clone_vio() {
3034 clone_vio = nullptr;
3036 }
3037
3038 /** Check if clone network Vio is active. */
3039 inline bool check_clone_vio() {
3041 const bool is_active = (clone_vio != nullptr);
3043 return (is_active);
3044 }
3045
3046 /** Shutdown clone vio, if active. */
3047 void shutdown_clone_vio();
3048
3050
3051 void shutdown_active_vio();
3052 void awake(THD::killed_state state_to_set);
3053
3054 /** Disconnect the associated communication endpoint. */
3055 void disconnect(bool server_shutdown = false);
3056
3058 /* The query can be logged in row format or in statement format. */
3060
3061 /* The query has to be logged in statement format. */
3063
3066
3067 int binlog_query(enum_binlog_query_type qtype, const char *query,
3068 size_t query_len, bool is_trans, bool direct,
3069 bool suppress_use, int errcode);
3070
3071 // Begin implementation of MDL_context_owner interface.
3072
3074 const PSI_stage_info *stage, PSI_stage_info *old_stage,
3075 const char *src_function, const char *src_file,
3076 int src_line) override {
3077 DBUG_TRACE;
3079 /*
3080 Sic: We don't lock LOCK_current_cond here.
3081 If we did, we could end up in deadlock with THD::awake()
3082 which locks current_mutex while LOCK_current_cond is locked.
3083 */
3084 current_mutex = mutex;
3085 current_cond = cond;
3086 enter_stage(stage, old_stage, src_function, src_file, src_line);
3087 return;
3088 }
3089
3090 void exit_cond(const PSI_stage_info *stage, const char *src_function,
3091 const char *src_file, int src_line) override {
3092 DBUG_TRACE;
3093 /*
3094 current_mutex must be unlocked _before_ LOCK_current_cond is
3095 locked (if that would not be the case, you'll get a deadlock if someone
3096 does a THD::awake() on you).
3097 */
3100 current_mutex = nullptr;
3101 current_cond = nullptr;
3103 enter_stage(stage, nullptr, src_function, src_file, src_line);
3104 return;
3105 }
3106
3107 int is_killed() const final { return killed; }
3109 /*
3110 We need to return if this thread can have any commit order waiters
3111 which are still accounted by MDL deadlock detector (even in absence
3112 of any MDL locks). We approximate this check by testing whether
3113 this thread is replication applier. Doing more precise check is going
3114 to be more expensive and possibly racy.
3115 */
3116 return slave_thread;
3117 }
3118
3119 THD *get_thd() override { return this; }
3120
3121 /**
3122 A callback to the server internals that is used to address
3123 special cases of the locking protocol.
3124 Invoked when acquiring an exclusive lock, for each thread that
3125 has a conflicting shared metadata lock.
3126
3127 This function aborts waiting of the thread on a data lock, to make
3128 it notice the pending exclusive lock and back off.
3129
3130 @note This function does not wait for the thread to give away its
3131 locks. Waiting is done outside for all threads at once.
3132
3133 @param ctx_in_use The MDL context owner (thread) to wake up.
3134 @param needs_thr_lock_abort Indicates that to wake up thread
3135 this call needs to abort its waiting
3136 on table-level lock.
3137 */
3138 void notify_shared_lock(MDL_context_owner *ctx_in_use,
3139 bool needs_thr_lock_abort) override;
3140
3141 bool notify_hton_pre_acquire_exclusive(const MDL_key *mdl_key,
3142 bool *victimized) override;
3143
3144 void notify_hton_post_release_exclusive(const MDL_key *mdl_key) override;
3145
3146 /**
3147 Provide thread specific random seed for MDL_context's PRNG.
3148
3149 Note that even if two connections will request seed during handling of
3150 statements which were started at exactly the same time, and thus will
3151 get the same values in PRNG at the start, they will naturally diverge
3152 soon, since calls to PRNG in MDL subsystem are affected by many factors
3153 making process quite random. OTOH the fact that we use time as a seed
3154 gives more randomness and thus better coverage in tests as opposed to
3155 using thread_id for the same purpose.
3156 */
3157 uint get_rand_seed() const override { return (uint)start_utime; }
3158
3159 // End implementation of MDL_context_owner interface.
3160
3161 inline bool is_strict_mode() const {
3162 return (variables.sql_mode &
3164 }
3165 inline const CHARSET_INFO *collation() {
3166 return variables.collation_server ? variables.collation_server
3168 }
3170 time_zone_used = true;
3171 return variables.time_zone;
3172 }
3173 time_t query_start_in_secs() const { return start_time.tv_sec; }
3175 void set_time();
3176 void set_time(const struct timeval *t) {
3177 user_time = *t;
3178 set_time();
3179 }
3180 inline bool is_fsp_truncate_mode() const {
3182 }
3183
3184 /**
3185 Evaluate the current time, and if it exceeds the long-query-time
3186 setting, mark the query as slow.
3187 */
3189
3191
3192 /*
3193 Call when it is clear that the query is ended and we have collected the
3194 right value for current_found_rows. Calling this method makes a snapshot of
3195 that value and makes it ready and stable for subsequent FOUND_ROWS() call
3196 in the next statement.
3197 */
3200 }
3201
3202 /**
3203 Returns true if session is in a multi-statement transaction mode.
3204
3205 OPTION_NOT_AUTOCOMMIT: When autocommit is off, a multi-statement
3206 transaction is implicitly started on the first statement after a
3207 previous transaction has been ended.
3208
3209 OPTION_BEGIN: Regardless of the autocommit status, a multi-statement
3210 transaction can be explicitly started with the statements "START
3211 TRANSACTION", "BEGIN [WORK]", "[COMMIT | ROLLBACK] AND CHAIN", etc.
3212
3213 Note: this doesn't tell you whether a transaction is active.
3214 A session can be in multi-statement transaction mode, and yet
3215 have no active transaction, e.g., in case of:
3216 set \@\@autocommit=0;
3217 set \@a= 3; <-- these statements don't
3218 set transaction isolation level serializable; <-- start an active
3219 flush tables; <-- transaction
3220
3221 I.e. for the above scenario this function returns true, even
3222 though no active transaction has begun.
3223 @sa in_active_multi_stmt_transaction()
3224 */
3226 return variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
3227 }
3228 /**
3229 true if the session is in a multi-statement transaction mode
3230 (@sa in_multi_stmt_transaction_mode()) *and* there is an
3231 active transaction, i.e. there is an explicit start of a
3232 transaction with BEGIN statement, or implicit with a
3233 statement that uses a transactional engine.
3234
3235 For example, these scenarios don't start an active transaction
3236 (even though the server is in multi-statement transaction mode):
3237
3238 @verbatim
3239 set @@autocommit=0;
3240 select * from nontrans_table;
3241 set @var = true;
3242 flush tables;
3243 @endverbatim
3244
3245 Note, that even for a statement that starts a multi-statement
3246 transaction (i.e. select * from trans_table), this
3247 flag won't be set until we open the statement's tables
3248 and the engines register themselves for the transaction
3249 (see trans_register_ha()),
3250 hence this method is reliable to use only after
3251 open_tables() has completed.
3252
3253 Why do we need a flag?
3254 ----------------------
3255 We need to maintain a (at first glance redundant)
3256 session flag, rather than looking at thd->transaction.all.ha_list
3257 because of explicit start of a transaction with BEGIN.
3258
3259 I.e. in case of
3260 BEGIN;
3261 select * from nontrans_t1; <-- in_active_multi_stmt_transaction() is true
3262 */
3265 }
3267 return !stmt_arena->is_stmt_prepare();
3268 }
3269
3271 const char *from, size_t from_length,
3272 const CHARSET_INFO *from_cs, bool report_error = false);
3273
3275
3276 /**
3277 Clear the current error, if any.
3278 We do not clear is_fatal_error or is_fatal_sub_stmt_error since we
3279 assume this is never called if the fatal error is set.
3280 @todo: To silence an error, one should use Internal_error_handler
3281 mechanism. In future this function will be removed.
3282 */
3283 inline void clear_error() {
3284 DBUG_TRACE;
3286 is_slave_error = false;
3287 return;
3288 }
3289
3290 bool is_classic_protocol() const;
3291
3292 /** Return false if connection to client is broken. */
3293 bool is_connected(bool use_cached_connection_alive = false) final;
3294
3295 /** Return the cached protocol rw status. */
3297
3298 /**
3299 Mark the current error as fatal. Warning: this does not
3300 set any error, it sets a property of the error, so must be
3301 followed or prefixed with my_error().
3302 */
3304 bool is_fatal_error() const { return m_is_fatal_error; }
3305 /**
3306 true if there is an error in the error stack.
3307
3308 Please use this method instead of direct access to
3309 net.report_error.
3310
3311 If true, the current (sub)-statement should be aborted.
3312 The main difference between this member and is_fatal_error
3313 is that a fatal error can not be handled by a stored
3314 procedure continue handler, whereas a normal error can.
3315
3316 To raise this flag, use my_error().
3317 */
3318 inline bool is_error() const { return get_stmt_da()->is_error(); }
3319
3320 /// Returns first Diagnostics Area for the current statement.
3322
3323 /// Returns first Diagnostics Area for the current statement.
3324 const Diagnostics_area *get_stmt_da() const { return m_stmt_da; }
3325
3326 /// Returns the second Diagnostics Area for the current statement.
3328 return get_stmt_da()->stacked_da();
3329 }
3330
3331 /**
3332 Returns thread-local Diagnostics Area for parsing.
3333 We need to have a clean DA in case errors or warnings are thrown
3334 during parsing, but we can't just reset the main DA in case we
3335 have a diagnostic statement on our hand that needs the old DA
3336 to answer questions about the previous execution.
3337 Keeping a static per-thread DA for parsing is less costly than
3338 allocating a temporary one for each statement we parse.
3339 */
3341
3342 /**
3343 Returns thread-local Diagnostics Area to be used by query rewrite plugins.
3344 Query rewrite plugins use their own diagnostics area. The reason is that
3345 they are invoked right before and right after parsing, and we don't want
3346 conditions raised by plugins in either statement nor parser DA until we
3347 know which type of statement we have parsed.
3348
3349 @note The diagnostics area is instantiated the first time it is asked for.
3350 */
3353 }
3354
3355 /**
3356 Push the given Diagnostics Area on top of the stack, making
3357 it the new first Diagnostics Area. Conditions in the new second
3358 Diagnostics Area will be copied to the new first Diagnostics Area.
3359
3360 @param da Diagnostics Area to be come the top of
3361 the Diagnostics Area stack.
3362 @param copy_conditions
3363 Copy the conditions from the new second Diagnostics Area
3364 to the new first Diagnostics Area, as per SQL standard.
3365 */
3367 bool copy_conditions = true) {
3368 get_stmt_da()->push_diagnostics_area(this, da, copy_conditions);
3369 m_stmt_da = da;
3370 }
3371
3372 /// Pop the top DA off the Diagnostics Area stack.
3375 }
3376
3377 /**
3378 Inserts the new protocol at the top of the protocol stack, and make it
3379 the current protocol for this thd.
3380
3381 @param protocol Protocol to be inserted.
3382 */
3383 void push_protocol(Protocol *protocol);
3384
3385 template <typename ProtocolClass>
3386 void push_protocol(const std::unique_ptr<ProtocolClass> &protocol) {
3387 push_protocol(protocol.get());
3388 }
3389
3390 /**
3391 Pops the top protocol of the Protocol stack and sets the previous one
3392 as the current protocol.
3393 */
3394 void pop_protocol();
3395
3396 public:
3398 void update_charset();
3399
3400 /**
3401 Record a transient change to a pointer to an Item within another Item.
3402 */
3403 void change_item_tree(Item **place, Item *new_value) {
3404 /* TODO: check for OOM condition here */
3405 if (!stmt_arena->is_regular()) {
3406 DBUG_PRINT("info", ("change_item_tree place %p old_value %p new_value %p",
3407 place, *place, new_value));
3408 nocheck_register_item_tree_change(place, new_value);
3409 }
3410 *place = new_value;
3411 }
3412
3413 /**
3414 Remember that place was updated with new_value so it can be restored
3415 by rollback_item_tree_changes().
3416
3417 @param[in] place the location that will change, and whose old value
3418 we need to remember for restoration
3419 @param[in] new_value new value about to be inserted into *place
3420 */
3421 void nocheck_register_item_tree_change(Item **place, Item *new_value);
3422
3423 /**
3424 Restore locations set by calls to nocheck_register_item_tree_change().
3425 Note that this needs to happen before Item::cleanup is called.
3426 */
3428
3429 /*
3430 Cleanup statement parse state (parse tree, lex) and execution
3431 state after execution of a non-prepared SQL statement.
3432 */
3433 void end_statement();
3434 void send_kill_message() const;
3435
3437 uint add_state_flags);
3441
3442 public:
3443 /**
3444 Start a read-only attachable transaction.
3445 There must be no active attachable transactions (in other words, there can
3446 be only one active attachable transaction at a time).
3447 */
3449
3450 /**
3451 Start a read-write attachable transaction.
3452 All the read-only class' requirements apply.
3453 Additional requirements are documented along the class
3454 declaration.
3455 */
3457
3458 /**
3459 End an active attachable transaction. Applies to both the read-only
3460 and the read-write versions.
3461 Note, that the read-write attachable transaction won't be terminated
3462 inside this method.
3463 To invoke the function there must be active attachable transaction.
3464 */
3466
3467 /**
3468 @return true if there is an active attachable transaction.
3469 */
3471 return m_attachable_trx != nullptr && m_attachable_trx->is_read_only();
3472 }
3473
3474 /**
3475 @return true if there is an active attachable transaction.
3476 */
3478 return m_attachable_trx != nullptr;
3479 }
3480
3481 /**
3482 @return true if there is an active rw attachable transaction.
3483 */
3485 return m_attachable_trx != nullptr && !m_attachable_trx->is_read_only();
3486 }
3487
3488 public:
3489 /*
3490 @todo Make these methods private or remove them completely. Only
3491 decide_logging_format should call them. /Sven
3492 */
3494 DBUG_TRACE;
3495 /*
3496 This should only be called from decide_logging_format.
3497
3498 @todo Once we have ensured this, uncomment the following
3499 statement, remove the big comment below that, and remove the
3500 in_sub_stmt==0 condition from the following 'if'.
3501 */
3502 /* assert(in_sub_stmt == 0); */
3503 /*
3504 If in a stored/function trigger, the caller should already have done the
3505 change. We test in_sub_stmt to prevent introducing bugs where people
3506 wouldn't ensure that, and would switch to row-based mode in the middle
3507 of executing a stored function/trigger (which is too late, see also
3508 reset_current_stmt_binlog_format_row()); this condition will make their
3509 tests fail and so force them to propagate the
3510 lex->binlog_row_based_if_mixed upwards to the caller.
3511 */
3512 if ((variables.binlog_format == BINLOG_FORMAT_MIXED) && (in_sub_stmt == 0))
3514
3515 return;
3516 }
3518 DBUG_TRACE;
3520 return;
3521 }
3523 DBUG_TRACE;
3525 return;
3526 }
3528 DBUG_TRACE;
3529 DBUG_PRINT("debug", ("in_sub_stmt: %d, system_thread: %s", in_sub_stmt != 0,
3531 if (in_sub_stmt == 0) {
3532 if (variables.binlog_format == BINLOG_FORMAT_ROW)
3534 else
3536 }
3537 return;
3538 }
3539
3540 /**
3541 Copies variables.original_commit_timestamp to
3542 ((Slave_worker *)rli_slave)->original_commit_timestamp,
3543 if this is a slave thread.
3544 */
3546
3547 /// Return the value of @@gtid_next_list: either a Gtid_set or NULL.
3549 return variables.gtid_next_list.is_non_null
3550 ? variables.gtid_next_list.gtid_set
3551 : nullptr;
3552 }
3553
3554 /// Return the value of @@gtid_next_list: either a Gtid_set or NULL.
3556 return const_cast<THD *>(this)->get_gtid_next_list();
3557 }
3558
3559 /**
3560 Return true if the statement/transaction cache is currently empty,
3561 false otherwise.
3562
3563 @param is_transactional if true, check the transaction cache.
3564 If false, check the statement cache.
3565 */
3566 bool is_binlog_cache_empty(bool is_transactional) const;
3567
3568 /**
3569 The GTID of the currently owned transaction.
3570
3571 ==== Modes of ownership ====
3572
3573 The following modes of ownership are possible:
3574
3575 - owned_gtid.sidno==0: the thread does not own any transaction.
3576
3577 - owned_gtid.sidno==THD::OWNED_SIDNO_ANONYMOUS(==-2): the thread
3578 owns an anonymous transaction
3579
3580 - owned_gtid.sidno>0 and owned_gtid.gno>0: the thread owns a GTID
3581 transaction.
3582
3583 - (owned_gtid.sidno==THD::OWNED_SIDNO_GTID_SET(==-1): this is
3584 currently not used. It was reserved for the case where multiple
3585 GTIDs are owned (using gtid_next_list). This was one idea to
3586 make GTIDs work with NDB: due to the epoch concept, multiple
3587 transactions can be combined into one in NDB, and therefore a
3588 single transaction on a slave can have multiple GTIDs.)
3589
3590 ==== Life cycle of ownership ====
3591
3592 Generally, transaction ownership starts when the transaction is
3593 assigned its GTID and ends when the transaction commits or rolls
3594 back. On a master (GTID_NEXT=AUTOMATIC), the GTID is assigned
3595 just before binlog flush; on a slave (GTID_NEXT=UUID:NUMBER or
3596 GTID_NEXT=ANONYMOUS) it is assigned before starting the
3597 transaction.
3598
3599 A new client always starts with owned_gtid.sidno=0.
3600
3601 Ownership can be acquired in the following ways:
3602
3603 A1. If GTID_NEXT = 'AUTOMATIC' and GTID_MODE = OFF/OFF_PERMISSIVE:
3604 The thread acquires anonymous ownership in
3605 gtid_state->generate_automatic_gtid called from
3606 MYSQL_BIN_LOG::write_transaction.
3607
3608 A2. If GTID_NEXT = 'AUTOMATIC' and GTID_MODE = ON/ON_PERMISSIVE:
3609 The thread generates the GTID and acquires ownership in
3610 gtid_state->generate_automatic_gtid called from
3611 MYSQL_BIN_LOG::write_transaction.
3612
3613 A3. If GTID_NEXT = 'UUID:NUMBER': The thread acquires ownership in
3614 the following ways:
3615
3616 - In a client, the SET GTID_NEXT statement acquires ownership.
3617
3618 - The slave's analogy to a clients SET GTID_NEXT statement is
3619 Gtid_log_event::do_apply_event. So the slave acquires
3620 ownership in this function.
3621
3622 Note: if the GTID UUID:NUMBER is already included in
3623 GTID_EXECUTED, then the transaction must be skipped (the GTID
3624 auto-skip feature). Thus, ownership is *not* acquired in this
3625 case and owned_gtid.sidno==0.
3626
3627 A4. If GTID_NEXT = 'ANONYMOUS':
3628
3629 - In a client, the SET GTID_NEXT statement acquires ownership.
3630
3631 - In a slave thread, Gtid_log_event::do_apply_event acquires
3632 ownership.
3633
3634 - Contrary to the case of GTID_NEXT='UUID:NUMBER', it is
3635 allowed to execute two transactions in sequence without
3636 changing GTID_NEXT (cf. R1 and R2 below). Both transactions
3637 should be executed as anonymous transactions. But ownership
3638 is released when the first transaction commits. Therefore,
3639 when GTID_NEXT='ANONYMOUS', we also acquire anonymous
3640 ownership when starting to execute a statement, in
3641 gtid_reacquire_ownership_if_anonymous called from
3642 gtid_pre_statement_checks (usually called from
3643 mysql_execute_command).
3644
3645 A5. Slave applier threads start in a special mode, having
3646 GTID_NEXT='NOT_YET_DETERMINED'. This mode cannot be set in a
3647 regular client. When GTID_NEXT=NOT_YET_DETERMINED, the slave
3648 thread is postponing the decision of the value of GTID_NEXT
3649 until it has more information. There are three cases:
3650
3651 - If the first transaction of the relay log has a
3652 Gtid_log_event, then it will set GTID_NEXT=GTID:NUMBER and
3653 acquire GTID ownership in Gtid_log_event::do_apply_event.
3654
3655 - If the first transaction of the relay log has a
3656 Anonymous_gtid_log_event, then it will set
3657 GTID_NEXT=ANONYMOUS and acquire anonymous ownership in
3658 Gtid_log_event::do_apply_event.
3659
3660 - If the relay log was received from a pre-5.7.6 master with
3661 GTID_MODE=OFF (or a pre-5.6 master), then there are neither
3662 Gtid_log_events nor Anonymous_log_events in the relay log.
3663 In this case, the slave sets GTID_NEXT=ANONYMOUS and
3664 acquires anonymous ownership when executing a
3665 Query_log_event (Query_log_event::do_apply_event calls
3666 dispatch_sql_command which calls gtid_pre_statement_checks which
3667 calls gtid_reacquire_ownership_if_anonymous).
3668
3669 Ownership is released in the following ways:
3670
3671 R1. A thread that holds GTID ownership releases ownership at
3672 transaction commit or rollback. If GTID_NEXT=AUTOMATIC, all
3673 is fine. If GTID_NEXT=UUID:NUMBER, the UUID:NUMBER cannot be
3674 used for another transaction, since only one transaction can
3675 have any given GTID. To avoid the user mistake of forgetting
3676 to set back GTID_NEXT, on commit we set
3677 thd->variables.gtid_next.type=UNDEFINED_GTID. Then, any
3678 statement that user tries to execute other than SET GTID_NEXT
3679 will generate an error.
3680
3681 R2. A thread that holds anonymous ownership releases ownership at
3682 transaction commit or rollback. In this case there is no harm
3683 in leaving GTID_NEXT='ANONYMOUS', so
3684 thd->variables.gtid_next.type will remain ANONYMOUS_GTID and
3685 not UNDEFINED_GTID.
3686
3687 There are statements that generate multiple transactions in the
3688 binary log. This includes the following:
3689
3690 M1. DROP TABLE that is used with multiple tables, and the tables
3691 belong to more than one of the following groups: non-temporary
3692 table, temporary transactional table, temporary
3693 non-transactional table. DROP TABLE is split into one
3694 transaction for each of these groups of tables.
3695
3696 M2. DROP DATABASE that fails e.g. because rmdir fails. Then a
3697 single DROP TABLE is generated, which lists all tables that
3698 were dropped before the failure happened. But if the list of
3699 tables is big, and grows over a limit, the statement will be
3700 split into multiple statements.
3701
3702 M3. CREATE TABLE ... SELECT that is logged in row format. Then
3703 the server generates a single CREATE statement, followed by a
3704 BEGIN ... row events ... COMMIT transaction.
3705
3706 M4. A statement that updates both transactional and
3707 non-transactional tables in the same statement, and is logged
3708 in row format. Then it generates one transaction for the
3709 non-transactional row updates, followed by one transaction for
3710 the transactional row updates.
3711
3712 M5. CALL is executed as multiple transactions and logged as
3713 multiple transactions.
3714
3715 The general rules for multi-transaction statements are:
3716
3717 - If GTID_NEXT=AUTOMATIC and GTID_MODE=ON or ON_PERMISSIVE, one
3718 GTID should be generated for each transaction within the
3719 statement. Therefore, ownership must be released after each
3720 commit so that a new GTID can be generated by the next
3721 transaction. Typically mysql_bin_log.commit() is called to
3722 achieve this. (Note that some of these statements are currently
3723 disallowed when GTID_MODE=ON.)
3724
3725 - If GTID_NEXT=AUTOMATIC and GTID_MODE=OFF or OFF_PERMISSIVE, one
3726 Anonymous_gtid_log_event should be generated for each
3727 transaction within the statement. Similar to the case above, we
3728 call mysql_bin_log.commit() and release ownership between
3729 transactions within the statement.
3730
3731 This works for all the special cases M1-M5 except M4. When a
3732 statement writes both non-transactional and transactional
3733 updates to the binary log, both the transaction cache and the
3734 statement cache are flushed within the same call to
3735 flush_thread_caches(THD) from within the binary log group commit
3736 code. At that point we cannot use mysql_bin_log.commit().
3737 Instead we release ownership using direct calls to
3738 gtid_state->release_anonymous_ownership() and
3739 thd->clear_owned_gtids() from binlog_cache_mngr::flush.
3740
3741 - If GTID_NEXT=ANONYMOUS, anonymous ownership must be *preserved*
3742 between transactions within the statement, to prevent that a
3743 concurrent SET GTID_MODE=ON makes it impossible to log the
3744 statement. To avoid that ownership is released if
3745 mysql_bin_log.commit() is called, we set
3746 thd->is_commit_in_middle_of_statement before calling
3747 mysql_bin_log.commit. Note that we must set this flag only if
3748 GTID_NEXT=ANONYMOUS, not if the transaction is anonymous when
3749 GTID_NEXT=AUTOMATIC and GTID_MODE=OFF.
3750
3751 This works for all the special cases M1-M5 except M4. When a
3752 statement writes non-transactional updates in the middle of a
3753 transaction, but keeps some transactional updates in the
3754 transaction cache, then it is not easy to know at the time of
3755 calling mysql_bin_log.commit() whether anonymous ownership needs
3756 to be preserved or not. Instead, we directly check if the
3757 transaction cache is nonempty before releasing anonymous
3758 ownership inside Gtid_state::update_gtids_impl.
3759
3760 - If GTID_NEXT='UUID:NUMBER', it is impossible to log a
3761 multi-transaction statement, since each GTID can only be used by
3762 one transaction. Therefore, an error must be generated in this
3763 case. Errors are generated in different ways for the different
3764 statement types:
3765
3766 - DROP TABLE: we can detect the situation before it happens,
3767 since the table type is known once the tables are opened. So
3768 we generate an error before even executing the statement.
3769
3770 - DROP DATABASE: we can't detect the situation until it is too
3771 late; the tables have already been dropped and we cannot log
3772 anything meaningful. So we don't log at all.
3773
3774 - CREATE TABLE ... SELECT: this is not allowed when
3775 enforce_gtid_consistency is ON; the statement will be
3776 forbidden in is_ddl_gtid_compatible.
3777
3778 - Statements that update both transactional and
3779 non-transactional tables are disallowed when GTID_MODE=ON, so
3780 this normally does not happen. However, it can happen if the
3781 slave uses a different engine type than the master, so that a
3782 statement that updates InnoDB+InnoDB on master updates
3783 InnoDB+MyISAM on slave. In this case the statement will be
3784 forbidden in is_dml_gtid_compatible and will not be allowed to
3785 execute.
3786
3787 - CALL: the second statement will generate an error because
3788 GTID_NEXT is 'undefined'. Note that this situation can only
3789 happen if user does it on purpose: A CALL on master is logged
3790 as multiple statements, so a slave never executes CALL with
3791 GTID_NEXT='UUID:NUMBER'.
3792
3793 Finally, ownership release is suppressed in one more corner case:
3794
3795 C1. Administration statements including OPTIMIZE TABLE, REPAIR
3796 TABLE, or ANALYZE TABLE are written to the binary log even if
3797 they fail. This means that the thread first calls
3798 trans_rollack, and then writes the statement to the binlog.
3799 Rollback normally releases ownership. But ownership must be
3800 kept until writing the binlog. The solution is that these
3801 statements set thd->skip_gtid_rollback=true before calling
3802 trans_rollback, and Gtid_state::update_on_rollback does not
3803 release ownership if the flag is set.
3804
3805 @todo It would probably be better to encapsulate this more, maybe
3806 use Gtid_specification instead of Gtid.
3807 */
3809 static const int OWNED_SIDNO_GTID_SET = -1;
3810 static const int OWNED_SIDNO_ANONYMOUS = -2;
3811
3812 /**
3813 For convenience, this contains the TSID component of the GTID
3814 stored in owned_gtid.
3815 */
3817
3818 /** SE GTID persistence flag types. */
3819 enum Se_GTID_flag : size_t {
3820 /** Pin owned GTID */
3822 /** Cleanup GTID during unpin. */
3824 /** SE would persist GTID for current transaction. */
3826 /** If RESET log in progress. */
3828 /** Explicit request for SE to persist GTID for current transaction. */
3830 /** Max element holding the biset size. */
3833
3834 using Se_GTID_flagset = std::bitset<SE_GTID_MAX>;
3835
3836 /** Flags for SE GTID persistence. */
3838
3839 /** Defer freeing owned GTID and TSID till unpinned. */
3841
3842 /** Unpin and free GTID and TSID. */
3843 void unpin_gtid() {
3845 /* Do any deferred cleanup */
3849 }
3850 }
3851
3852 /** @return true, if single phase XA commit operation. */
3853 bool is_one_phase_commit();
3854
3855 /** Set when binlog reset operation is started. */
3857
3858 /** Cleared after flushing SE logs during binlog reset. */
3860
3861 /** @return true, if binlog reset operation. */
3863
3864 /** Set by SE when it guarantees GTID persistence. */
3866
3867 /** Request SE to persist GTID explicitly. */
3871 }
3872
3873 /** Reset by SE at transaction end after persisting GTID. */
3877 }
3878
3879 /** @return true, if SE persists GTID for current transaction. */
3880 bool se_persists_gtid() const {
3881 DBUG_EXECUTE_IF("disable_se_persists_gtid", return (false););
3882 auto trx = get_transaction();
3883 auto xid_state = trx->xid_state();
3884 /* XA transactions are always persisted by Innodb. */
3885 return (!xid_state->has_state(XID_STATE::XA_NOTR) ||
3887 }
3888
3889 /** @return true, if SE is explicitly set to persists GTID. */
3891 DBUG_EXECUTE_IF("disable_se_persists_gtid", return (false););
3893 }
3894
3895 /** @return true, if external XA transaction is in progress. */
3896 bool is_extrenal_xa() const {
3897 auto trx = get_transaction();
3898 auto xid_state = trx->xid_state();
3899 return !xid_state->has_state(XID_STATE::XA_NOTR);
3900 }
3901
3902#ifdef HAVE_GTID_NEXT_LIST
3903 /**
3904 If this thread owns a set of GTIDs (i.e., GTID_NEXT_LIST != NULL),
3905 then this member variable contains the subset of those GTIDs that
3906 are owned by this thread.
3907 */
3908 Gtid_set owned_gtid_set;
3909#endif
3910
3911 /*
3912 Replication related context.
3913
3914 @todo: move more parts of replication related fields in THD to inside this
3915 class.
3916 */
3918
3920 /* Defer GTID cleanup if pinned. Used for XA transactions where
3921 SE(Innodb) needs to read GTID. */
3924 return;
3925 }
3927#ifdef HAVE_GTID_NEXT_LIST
3928 owned_gtid_set.clear();
3929#else
3930 assert(0);
3931#endif
3932 }
3933 owned_gtid.clear();
3934 owned_tsid.clear();
3935 owned_gtid.dbug_print(nullptr, "set owned_gtid in clear_owned_gtids");
3936 }
3937
3938 /** @return true, if owned GTID is empty or waiting for deferred cleanup. */
3941 return (true);
3942 }
3943 return (owned_gtid.is_empty());
3944 }
3945
3946 /*
3947 There are some statements (like OPTIMIZE TABLE, ANALYZE TABLE and
3948 REPAIR TABLE) that might call trans_rollback_stmt() and also will be
3949 successfully executed and will have to go to the binary log.
3950 For these statements, the skip_gtid_rollback flag must be set to avoid
3951 problems when the statement is executed with a GTID_NEXT set to
3952 ASSIGNED_GTID (like the SQL thread do when applying events from other
3953 server). When this flag is set, a call to gtid_rollback() will do nothing.
3954 */
3956
3957 private:
3958 /// Callback functions that determine if GTID rollback shall be skipped.
3959 std::list<std::function<bool(const THD &)>> m_skip_gtid_rollback_checkers;
3960
3961 public:
3962 /// Invoke the callback functions that determine if GTID rollback shall be
3963 /// skipped, and return true as soon as one of them returns true; otherwise
3964 /// return false.
3966 for (const auto &func : m_skip_gtid_rollback_checkers)
3967 if (func(*this)) return true;
3968 return false;
3969 }
3970
3971 /// Register a callback function that will determine if a subsequent GTID
3972 /// rollback shall be skipped. Returns a (moveable, but not copyable) object
3973 /// whose destructor will will unregister the callback.
3975 const std::invocable<const THD &> auto &shall_skip) {
3976 m_skip_gtid_rollback_checkers.emplace_back(shall_skip);
3977 auto it = std::prev(m_skip_gtid_rollback_checkers.end());
3978 return Scope_guard{
3979 [this, it] { this->m_skip_gtid_rollback_checkers.erase(it); }};
3980 }
3981
3982 /*
3983 There are some statements (like DROP DATABASE that fails on rmdir
3984 and gets rewritten to multiple DROP TABLE statements) that may
3985 call trans_commit_stmt() before it has written all statements to
3986 the binlog. When using GTID_NEXT = ANONYMOUS, such statements
3987 should not release ownership of the anonymous transaction until
3988 all statements have been written to the binlog. To prevent that
3989 update_gtid_impl releases ownership, such statements must set this
3990 flag.
3991 */
3993
3994 /*
3995 True while the transaction is executing, if one of
3996 is_ddl_gtid_consistent or is_dml_gtid_consistent returned false.
3997 */
3999
4000 const LEX_CSTRING &db() const { return m_db; }
4001
4002 /**
4003 Set the current database; use deep copy of C-string.
4004
4005 @param new_db the new database name.
4006
4007 Initialize the current database from a NULL-terminated string with
4008 length. If we run out of memory, we free the current database and
4009 return true. This way the user will notice the error as there will be
4010 no current database selected (in addition to the error message set by
4011 malloc).
4012
4013 @note This operation just sets {db, db_length}. Switching the current
4014 database usually involves other actions, like switching other database
4015 attributes including security context. In the future, this operation
4016 will be made private and more convenient interface will be provided.
4017
4018 @return Operation status
4019 @retval false Success
4020 @retval true Out-of-memory error
4021 */
4022 bool set_db(const LEX_CSTRING &new_db);
4023
4024 /**
4025 Set the current database; use shallow copy of C-string.
4026
4027 @param new_db the new database name.
4028
4029 @note This operation just sets {db, db_length}. Switching the current
4030 database usually involves other actions, like switching other database
4031 attributes including security context. In the future, this operation
4032 will be made private and more convenient interface will be provided.
4033 */
4034 void reset_db(const LEX_CSTRING &new_db) {
4035 m_db.str = new_db.str;
4036 m_db.length = new_db.length;
4037#ifdef HAVE_PSI_THREAD_INTERFACE
4038 PSI_THREAD_CALL(set_thread_db)(new_db.str, static_cast<int>(new_db.length));
4039#endif
4040 }
4041 /*
4042 Copy the current database to the argument. Use the current arena to
4043 allocate memory for a deep copy: current database may be freed after
4044 a statement is parsed but before it's executed.
4045 */
4046 bool copy_db_to(char const **p_db, size_t *p_db_length) const {
4047 if (m_db.str == nullptr) {
4048 my_error(ER_NO_DB_ERROR, MYF(0));
4049 return true;
4050 }
4051 *p_db = strmake(m_db.str, m_db.length);
4052 *p_db_length = m_db.length;
4053 return false;
4054 }
4055
4056 bool copy_db_to(char **p_db, size_t *p_db_length) const {
4057 return copy_db_to(const_cast<char const **>(p_db), p_db_length);
4058 }
4059
4061
4062 /**
4063 Get resource group context.
4064
4065 @returns pointer to resource group context.
4066 */
4067
4069 return &m_resource_group_ctx;
4070 }
4071
4072 public:
4073 /**
4074 Save the performance schema thread instrumentation
4075 associated with this user session.
4076 @param psi Performance schema thread instrumentation
4077 */
4078 void set_psi(PSI_thread *psi) { m_psi = psi; }
4079
4080 /**
4081 Read the performance schema thread instrumentation
4082 associated with this user session.
4083 This method is safe to use from a different thread.
4084 */
4085 PSI_thread *get_psi() const { return m_psi; }
4086
4087 private:
4088 /**
4089 Performance schema thread instrumentation for this session.
4090 This member is maintained using atomic operations,
4091 do not access it directly.
4092 @sa set_psi
4093 @sa get_psi
4094 */
4095 std::atomic<PSI_thread *> m_psi;
4096
4097 public:
4099 return m_internal_handler;
4100 }
4101
4102 /**
4103 Add an internal error handler to the thread execution context.
4104 @param handler the exception handler to add
4105 */
4107
4108 private:
4109 /**
4110 Handle a sql condition.
4111 @param sql_errno the condition error number
4112 @param sqlstate the condition sqlstate
4113 @param level the condition level
4114 @param msg the condition message text
4115 @return true if the condition is handled
4116 */
4117 bool handle_condition(uint sql_errno, const char *sqlstate,
4119 const char *msg);
4120
4121 public:
4122 /**
4123 Remove the error handler last pushed.
4124 */
4126
4127 Opt_trace_context opt_trace; ///< optimizer trace of current statement
4128 /**
4129 Raise an exception condition.
4130 @param code the MYSQL_ERRNO error code of the error
4131 */
4132 void raise_error(uint code);
4133
4134 /**
4135 Raise an exception condition, with a formatted message.
4136 @param code the MYSQL_ERRNO error code of the error
4137 */
4138 void raise_error_printf(uint code, ...);
4139
4140 /**
4141 Raise a completion condition (warning).
4142 @param code the MYSQL_ERRNO error code of the warning
4143 */
4144 void raise_warning(uint code);
4145
4146 /**
4147 Raise a completion condition (warning), with a formatted message.
4148 @param code the MYSQL_ERRNO error code of the warning
4149 */
4150 void raise_warning_printf(uint code, ...);
4151
4152 /**
4153 Raise a completion condition (note), with a fixed message.
4154 @param code the MYSQL_ERRNO error code of the note
4155 */
4156 void raise_note(uint code);
4157
4158 /**
4159 Raise an completion condition (note), with a formatted message.
4160 @param code the MYSQL_ERRNO error code of the note
4161 */
4162 void raise_note_printf(uint code, ...);
4163
4164 private:
4165 /*
4166 Only the implementation of the SIGNAL and RESIGNAL statements
4167 is permitted to raise SQL conditions in a generic way,
4168 or to raise them by bypassing handlers (RESIGNAL).
4169 To raise a SQL condition, the code should use the public
4170 raise_error() or raise_warning() methods provided by class THD.
4171 */
4173 friend class Sql_cmd_signal;
4174 friend class Sql_cmd_resignal;
4175 friend void push_warning(THD *thd,
4177 uint code, const char *message_text);
4178 friend void my_message_sql(uint, const char *, myf);
4179
4180 /**
4181 Raise a generic SQL condition. Also calls
4182 mysql_event_tracking_general_notify() unless the condition is handled by a
4183 SQL condition handler.
4184
4185 @param sql_errno the condition error number
4186 @param sqlstate the condition SQLSTATE
4187 @param level the condition level
4188 @param msg the condition message text
4189 @param fatal_error should the fatal_error flag be set?
4190 @return The condition raised, or NULL
4191 */
4192 Sql_condition *raise_condition(uint sql_errno, const char *sqlstate,
4194 const char *msg, bool fatal_error = false);
4195
4196 public:
4198
4199 inline enum enum_server_command get_command() const { return m_command; }
4200
4201 /**
4202 For safe and protected access to the query string, the following
4203 rules should be followed:
4204 1: Only the owner (current_thd) can set the query string.
4205 This will be protected by LOCK_thd_query.
4206 2: The owner (current_thd) can read the query string without
4207 locking LOCK_thd_query.
4208 3: Other threads must lock LOCK_thd_query before reading
4209 the query string.
4210
4211 This means that write-write conflicts are avoided by LOCK_thd_query.
4212 Read(by owner or other thread)-write(other thread) are disallowed.
4213 Read(other thread)-write(by owner) conflicts are avoided by LOCK_thd_query.
4214 Read(by owner)-write(by owner) won't happen as THD=thread.
4215
4216 We want to keep current_thd out of header files, so the debug assert,
4217 is moved to the .cc file. In optimized mode, we want this getter to
4218 be fast, so we inline it.
4219 */
4220 void debug_assert_query_locked() const;
4221 const LEX_CSTRING &query() const {
4222#ifndef NDEBUG
4224#endif
4225 return m_query_string;
4226 }
4227
4228 /**
4229 The current query in normalized form. The format is intended to be
4230 identical to the digest text of performance_schema, but not limited in
4231 size. In this case the parse tree is traversed as opposed to a (limited)
4232 token buffer. The string is allocated by this Statement and will be
4233 available until the next call to this function or this object is deleted.
4234
4235 @note We have no protection against out-of-memory errors as this function
4236 relies on the Item::print() interface which does not propagate errors.
4237
4238 @return The current query in normalized form.
4239 */
4240 const String normalized_query();
4241
4242 /**
4243 Set query to be displayed in performance schema (threads table etc.). Also
4244 mark the query safe to display for information_schema.process_list.
4245 */
4246 void set_query_for_display(const char *query_arg [[maybe_unused]],
4247 size_t query_length_arg [[maybe_unused]]) {
4248 // Set in pfs events statements table
4250 static_cast<uint>(query_length_arg));
4251#ifdef HAVE_PSI_THREAD_INTERFACE
4252 // Set in pfs threads table
4253 PSI_THREAD_CALL(set_thread_info)
4254 (query_arg, static_cast<uint>(query_length_arg));
4255#endif
4256 set_safe_display(true);
4257 }
4258
4259 /**
4260 Reset query string to be displayed in PFS. Also reset the safety flag
4261 for information_schema.process_list for next query.
4262 */
4264 set_query_for_display(nullptr, 0);
4265 m_safe_to_display.store(false);
4266 }
4267
4268 /** @return true, if safe to display the query string. */
4269 bool safe_to_display() const { return m_safe_to_display.load(); }
4270
4271 /** Set if the query string to be safe to display.
4272 @param[in] safe if it is safe to display query string */
4273 void set_safe_display(bool safe) { m_safe_to_display.store(safe); }
4274
4275 /**
4276 Assign a new value to thd->m_query_string.
4277 Protected with the LOCK_thd_query mutex.
4278 */
4279 void set_query(const char *query_arg, size_t query_length_arg) {
4280 const LEX_CSTRING tmp = {query_arg, query_length_arg};
4281 set_query(tmp);
4282 }
4283 void set_query(LEX_CSTRING query_arg);
4285
4286 /**
4287 Set the rewritten query (with passwords obfuscated etc.) on the THD.
4288 Wraps this in the LOCK_thd_query mutex to protect against race conditions
4289 with SHOW PROCESSLIST inspecting that string.
4290
4291 This uses swap() and therefore "steals" the argument from the caller;
4292 the caller MUST take care not to try to use its own string after calling
4293 this function! This is an optimization for mysql_rewrite_query() so we
4294 don't copy its temporary string (which may get very long, up to
4295 @@max_allowed_packet).
4296
4297 Using this outside of mysql_rewrite_query() is almost certainly wrong;
4298 please check with the runtime team!
4299
4300 @param query_arg The rewritten query to use for slow/bin/general logging.
4301 The value will be released in the caller and MUST NOT
4302 be used there after calling this function.
4303 */
4304 void swap_rewritten_query(String &query_arg);
4305
4306 /**
4307 Get the rewritten query (with passwords obfuscated etc.) from the THD.
4308 If done from a different thread (from the one that the rewritten_query
4309 is set on), the caller must hold LOCK_thd_query while calling this!
4310 */
4311 const String &rewritten_query() const {
4312#ifndef NDEBUG
4314#endif
4315 return m_rewritten_query;
4316 }
4317
4318 /**
4319 Reset thd->m_rewritten_query. Protected with the LOCK_thd_query mutex.
4320 */
4322 if (rewritten_query().length()) {
4323 String empty;
4325 }
4326 }
4327
4328 /**
4329 Assign a new value to thd->query_id.
4330 Protected with the LOCK_thd_data mutex.
4331 */
4332 void set_query_id(query_id_t new_query_id) {
4334 query_id = new_query_id;
4337 }
4338
4339 /**
4340 Assign a new value to open_tables.
4341 Protected with the LOCK_thd_data mutex.
4342 */
4343 void set_open_tables(TABLE *open_tables_arg) {
4345 open_tables = open_tables_arg;
4347 }
4348
4349 /**
4350 Assign a new value to is_killable
4351 Protected with the LOCK_thd_data mutex.
4352 */
4353 void set_is_killable(bool is_killable_arg) {
4355 is_killable = is_killable_arg;
4357 }
4358
4360 assert(locked_tables_mode == LTM_NONE);
4361
4362 if (mode_arg == LTM_LOCK_TABLES) {
4363 /*
4364 When entering LOCK TABLES mode we should set explicit duration
4365 for all metadata locks acquired so far in order to avoid releasing
4366 them till UNLOCK TABLES statement.
4367 We don't do this when entering prelocked mode since sub-statements
4368 don't release metadata locks and restoring status-quo after leaving
4369 prelocking mode gets complicated.
4370 */
4372 }
4373
4374 locked_tables_mode = mode_arg;
4375 }
4377 int decide_logging_format(Table_ref *tables);
4378 /**
4379 is_dml_gtid_compatible() and is_ddl_gtid_compatible() check if the
4380 statement that is about to be processed will safely get a
4381 GTID. Currently, the following cases may lead to errors
4382 (e.g. duplicated GTIDs) and as such are forbidden:
4383
4384 1. DML statements that mix non-transactional updates with
4385 transactional updates.
4386
4387 2. Transactions that use non-transactional tables after
4388 having used transactional tables.
4389
4390 3. CREATE...SELECT statement;
4391
4392 4. CREATE TEMPORARY TABLE or DROP TEMPORARY TABLE within a
4393 transaction
4394
4395 The first two conditions have to be checked in
4396 decide_logging_format, because that's where we know if the table
4397 is transactional or not. These are implemented in
4398 is_dml_gtid_compatible().
4399
4400 The third and fourth conditions have to be checked in
4401 mysql_execute_command because (1) that prevents implicit commit
4402 from being executed if the statement fails; (2) DROP TEMPORARY
4403 TABLE does not invoke decide_logging_format. These are
4404 implemented in is_ddl_gtid_compatible().
4405
4406 In the cases where GTID violations generate errors,
4407 is_ddl_gtid_compatible() needs to be called before the implicit
4408 pre-commit, so that there is no implicit commit if the statement
4409 fails.
4410
4411 In the cases where GTID violations do not generate errors,
4412 is_ddl_gtid_compatible() needs to be called after the implicit
4413 pre-commit, because in these cases the function will increase the
4414 global counter automatic_gtid_violating_transaction_count or
4415 anonymous_gtid_violating_transaction_count. If there is an
4416 ongoing transaction, the implicit commit will commit the
4417 transaction, which will call update_gtids_impl, which should
4418 decrease the counters depending on whether the *old* was violating
4419 GTID-consistency or not. Thus, we should increase the counters
4420 only after the old transaction is committed.
4421
4422 @param some_transactional_table true if the statement updates some
4423 transactional table; false otherwise.
4424
4425 @param some_non_transactional_table true if the statement updates
4426 some non-transactional table; false otherwise.
4427
4428 @param non_transactional_tables_are_tmp true if all updated
4429 non-transactional tables are temporary.
4430
4431 @retval true if the statement is compatible;
4432 @retval false if the statement is not compatible.
4433 */
4434 bool is_dml_gtid_compatible(bool some_transactional_table,
4435 bool some_non_transactional_table,
4436 bool non_transactional_tables_are_tmp);
4439 bool need_binlog_invoker() const { return m_binlog_invoker; }
4440 void get_definer(LEX_USER *definer);
4442 m_invoker_user.str = user->str;
4443 m_invoker_user.length = user->length;
4444 m_invoker_host.str = host->str;
4445 m_invoker_host.length = host->length;
4446 }
4449 bool has_invoker() const { return m_invoker_user.str != nullptr; }
4450
4452
4453 private:
4454 /** The current internal error handler for this thread, or NULL. */
4456
4457 /**
4458 This memory root is used for two purposes:
4459 - for conventional queries, to allocate structures stored in main_lex
4460 during parsing, and allocate runtime data (execution plan, etc.)
4461 during execution.
4462 - for prepared queries, only to allocate runtime data. The parsed
4463 tree itself is reused between executions and thus is stored elsewhere.
4464 */
4467 Diagnostics_area m_parser_da; /**< cf. get_parser_da() */
4470
4472
4473 /**
4474 It will be set TRUE if CURRENT_USER() is called in account management
4475 statements or default definer is set in CREATE/ALTER SP, SF, Event,
4476 TRIGGER or VIEW statements.
4477
4478 Current user will be binlogged into Query_log_event if current_user_used
4479 is true; It will be stored into m_invoker_host and m_invoker_user by SQL
4480 thread.
4481 */
4483
4484 /**
4485 It points to the invoker in the Query_log_event.
4486 SQL thread use it as the default definer in CREATE/ALTER SP, SF, Event,
4487 TRIGGER or VIEW statements or current user in account management
4488 statements if it is not NULL.
4489 */
4492
4493 friend class Protocol_classic;
4494
4495 private:
4496 /**
4497 Optimizer cost model for server operations.
4498 */
4501
4502 public:
4503 /**
4504 Initialize the optimizer cost model.
4505
4506 This function should be called each time a new query is started.
4507 */
4508 void init_cost_model();
4509
4510 /**
4511 Retrieve the optimizer cost model for this connection.
4512 */
4513 const Cost_model_server *cost_model() const;
4514
4517
4518 void syntax_error() { syntax_error(ER_SYNTAX_ERROR); }
4519 void syntax_error(const char *format, ...)
4520 MY_ATTRIBUTE((format(printf, 2, 3)));
4521 void syntax_error(int mysql_errno, ...);
4522
4523 void syntax_error_at(const POS &location) {
4524 syntax_error_at(location, ER_SYNTAX_ERROR);
4525 }
4526 void syntax_error_at(const POS &location, const char *format, ...)
4527 MY_ATTRIBUTE((format(printf, 3, 4)));
4528 void syntax_error_at(const POS &location, int mysql_errno, ...);
4529
4530 void vsyntax_error_at(const POS &location, const char *format, va_list args)
4531 MY_ATTRIBUTE((format(printf, 3, 0)));
4532 void vsyntax_error_at(const char *pos_in_lexer_raw_buffer, const char *format,
4533 va_list args) MY_ATTRIBUTE((format(printf, 3, 0)));
4534
4535 /**
4536 Send name and type of result to client.
4537
4538 Sum fields has table name empty and field_name.
4539
4540 @param list List of items to send to client
4541 @param flags Bit mask with the following functions:
4542 - 1 send number of rows
4543 - 2 send default values
4544 - 4 don't write eof packet
4545
4546 @retval
4547 false ok
4548 @retval
4549 true Error (Note that in this case the error is not sent to the client)
4550 */
4551
4552 bool send_result_metadata(const mem_root_deque<Item *> &list, uint flags);
4553
4554 /**
4555 Send one result set row.
4556
4557 @param row_items a collection of column values for that row
4558
4559 @return Error status.
4560 @retval true Error.
4561 @retval false Success.
4562 */
4563
4564 bool send_result_set_row(const mem_root_deque<Item *> &row_items);
4565
4566 /*
4567 Send the status of the current statement execution over network.
4568
4569 In MySQL, there are two types of SQL statements: those that return
4570 a result set and those that return status information only.
4571
4572 If a statement returns a result set, it consists of 3 parts:
4573 - result set meta-data
4574 - variable number of result set rows (can be 0)
4575 - followed and terminated by EOF or ERROR packet
4576
4577 Once the client has seen the meta-data information, it always
4578 expects an EOF or ERROR to terminate the result set. If ERROR is
4579 received, the result set rows are normally discarded (this is up
4580 to the client implementation, libmysql at least does discard them).
4581 EOF, on the contrary, means "successfully evaluated the entire
4582 result set". Since we don't know how many rows belong to a result
4583 set until it's evaluated, EOF/ERROR is the indicator of the end
4584 of the row stream. Note, that we can not buffer result set rows
4585 on the server -- there may be an arbitrary number of rows. But
4586 we do buffer the last packet (EOF/ERROR) in the Diagnostics_area and
4587 delay sending it till the very end of execution (here), to be able to
4588 change EOF to an ERROR if commit failed or some other error occurred
4589 during the last cleanup steps taken after execution.
4590
4591 A statement that does not return a result set doesn't send result
4592 set meta-data either. Instead it returns one of:
4593 - OK packet
4594 - ERROR packet.
4595 Similarly to the EOF/ERROR of the previous statement type, OK/ERROR
4596 packet is "buffered" in the Diagnostics Area and sent to the client
4597 in the end of statement.
4598
4599 @note This method defines a template, but delegates actual
4600 sending of data to virtual Protocol::send_{ok,eof,error}. This
4601 allows for implementation of protocols that "intercept" ok/eof/error
4602 messages, and store them in memory, etc, instead of sending to
4603 the client.
4604
4605 @pre The Diagnostics Area is assigned or disabled. It can not be empty
4606 -- we assume that every SQL statement or COM_* command
4607 generates OK, ERROR, or EOF status.
4608
4609 @post The status information is encoded to protocol format and sent to the
4610 client.
4611
4612 @return We conventionally return void, since the only type of error
4613 that can happen here is a NET (transport) error, and that one
4614 will become visible when we attempt to read from the NET the
4615 next command.
4616 Diagnostics_area::is_sent is set for debugging purposes only.
4617 */
4618
4619 void send_statement_status();
4620
4621 /**
4622 This is only used by master dump threads.
4623 When the master receives a new connection from a slave with a
4624 UUID (for slave versions >= 5.6)/server_id(for slave versions < 5.6)
4625 that is already connected, it will set this flag true
4626 before killing the old slave connection.
4627 */
4629
4630 /**
4631 Claim all the memory used by the THD object.
4632 This method is to keep memory instrumentation statistics
4633 updated, when an object is transferred across threads.
4634 */
4635 void claim_memory_ownership(bool claim);
4636
4639
4640 /**
4641 Returns the plugin, the thd belongs to.
4642 @return pointer to the plugin id
4643 */
4644 const st_plugin_int *get_plugin() const { return m_plugin; }
4645 /**
4646 Sets the plugin id to the value provided as parameter
4647 @param plugin the id of the plugin the thd belongs to
4648 */
4649 void set_plugin(const st_plugin_int *plugin) { m_plugin = plugin; }
4650#ifndef NDEBUG
4652 void set_tmp_table_seq_id(uint arg) { tmp_table_seq_id = arg; }
4653#endif
4654
4657
4658 private:
4659 /**
4660 Variable to mark if the object is part of a Srv_session object, which
4661 aggregates THD.
4662 */
4664
4665 /// Stores the plugin id it is attached to (if any).
4666 const st_plugin_int *m_plugin{nullptr};
4667
4668 /**
4669 Creating or dropping plugin native table through a plugin service.
4670 This variable enables the DDL command execution from
4671 dd::create_native_table() to be executed without committing the
4672 transaction.
4673 */
4675
4676#ifndef NDEBUG
4677 /**
4678 Sequential number of internal tmp table created in the statement. Useful for
4679 tracking tmp tables when number of them is involved in a query.
4680 */
4682
4683 public:
4684 /*
4685 The member serves to guard against duplicate use of the same xid
4686 at binary logging.
4687 */
4689#endif
4690 private:
4691 /*
4692 Flag set by my_write before waiting for disk space.
4693
4694 This is used by replication to decide if the I/O thread should be
4695 killed or not when stopping the replication threads.
4696
4697 In ordinary STOP REPLICA case, the I/O thread will wait for disk space
4698 or to be killed regardless of this flag value.
4699
4700 In server shutdown case, if this flag is true, the I/O thread will be
4701 signaled with KILL_CONNECTION to abort the waiting, letting the server
4702 to shutdown promptly.
4703 */
4705
4706 public:
4707 /**
4708 Set the waiting_for_disk_space flag.
4709
4710 @param waiting The value to set in the flag.
4711 */
4712 void set_waiting_for_disk_space(bool waiting) {
4713 waiting_for_disk_space = waiting;
4714 }
4715 /**
4716 Returns the current waiting_for_disk_space flag value.
4717 */
4719
4720 bool sql_parser();
4721
4722 /// Enables or disables use of secondary storage engines in this session.
4725 }
4726
4727 /**
4728 Can secondary storage engines be used for query execution in
4729 this session?
4730 */
4733 }
4734
4735 /**
4736 Checks if queries in this session can use a secondary storage engine for
4737 execution.
4738
4739 @return true if secondary storage engines can be used in this
4740 session, or false otherwise
4741 */
4743
4744 /// Indicate whether secondary storage engine is forced for this execution
4747 }
4748
4750
4751 private:
4752 /**
4753 This flag tells if a secondary storage engine can be used to
4754 execute a query in this session.
4755 */
4758
4759 /**
4760 Flag that tells whether secondary storage engine is forced for execution.
4761 Notice that use_secondary_engine is not reliable because it may be restored
4762 early.
4763 */
4765
4767
4768 /**
4769 Flag that indicates if the user of current session has SYSTEM_USER privilege
4770 */
4771 std::atomic<bool> m_is_system_user;
4772 /**
4773 Flag that indicates if the user of current session has CONNECTION_ADMIN
4774 privilege
4775 */
4776 std::atomic<bool> m_is_connection_admin;
4777
4778 public:
4779 bool is_system_user();
4780 void set_system_user(bool system_user_flag);
4781
4782 bool is_connection_admin();
4783 void set_connection_admin(bool connection_admin_flag);
4784
4785 public:
4787
4788 /**
4789 Flag to indicate this thread is executing
4790 @ref sys_var::update for a @ref OPT_GLOBAL variable.
4791
4792 This flag imply the thread already holds @ref LOCK_global_system_variables.
4793 Knowing this is required to resolve reentrancy issues
4794 in the system variable code, when callers
4795 read system variable Y while inside an update function
4796 for system variable X.
4797 Executing table io while inside a system variable update function
4798 will indirectly cause this.
4799 @todo Clean up callers and remove m_inside_system_variable_global_update.
4800 */
4802
4803 public:
4804 /** The parameter value bindings for the current query. Allocated on the THD
4805 * memroot. Can be empty */
4807 /** the number of elements in parameters */
4809
4810 public:
4811 /**
4812 Copy session properties that affect table access
4813 from the parent session to the current session.
4814
4815 The following properties:
4816 - the OPTION_BIN_LOG flag,
4817 - the skip_readonly_check flag,
4818 - the transaction isolation (tx_isolation)
4819 are copied from the parent to the current THD.
4820
4821 This is useful to execute an isolated, internal THD session
4822 to access tables, while leaving tables in the parent session
4823 unchanged.
4824
4825 @param thd parent session
4826 */
4830
4833
4834#ifndef NDEBUG
4835 const char *current_key_name;
4839 return (is_error() &&
4840 (get_stmt_da()->mysql_errno() == ER_DA_GLOBAL_CONN_LIMIT ||
4841 get_stmt_da()->mysql_errno() == ER_DA_CONN_LIMIT));
4842 }
4843#endif
4844
4845 public:
4846 bool add_external(unsigned int slot, void *data);
4847 void *fetch_external(unsigned int slot);
4849
4850 private:
4851 std::unordered_map<unsigned int, void *> external_store_;
4852
4853 public:
4854 /* Indicates if we are inside loadable function */
4856
4857 public:
4859 if (!event_tracking_data_.empty()) return event_tracking_data_.top();
4860 return std::make_pair(Event_tracking_class::LAST, nullptr);
4861 }
4862
4864 unsigned long subevent, bool check_audited);
4865 bool event_notify(struct st_mysql_event_generic *event_data);
4868 }
4869
4870 private:
4874
4876
4880
4881 public:
4882 /// Flag indicating whether this session incremented the number of sessions
4883 /// with GTID_NEXT set to AUTOMATIC:tag
4885
4886 /// Increment the owned temptable counter. This is used to find leaked
4887 /// temptable handles during close_connection calls
4889 /// Decrement the owned temptable counter.
4891 /// Return currently owned temptable count.
4893
4894 private:
4895 /** Each THD can open multiple temptables, we create these temptable objects
4896 in the temptable engine. These objects have their lifetime controlled with
4897 create and delete_table calls in the temptable handler. The sql layer is
4898 responsible for calling the create and delete_table functions. We increment
4899 this counter in create, and decrement it in delete_table. This allows us to
4900 detect any situation where we call close_connection which releases the
4901 underlying memory in the temptable engine, before all temptable objects
4902 have been deleted. This way we can react and clean up any temptable objects
4903 before we free the underlying memory. So we can think of the THD as owning
4904 multiple temptable objects in the temptable engine, and we tie the lifetime
4905 of these objects to the lifetime of the THD. In normal operation they
4906 should be deleted before the close_connection call but this enforces
4907 defined behaviour when they aren't.
4908 */
4910};
4911
4912/**
4913 Return lock_tables_mode for secondary engine.
4914 @param cthd thread context
4915 @retval true if lock_tables_mode is on
4916 @retval false, otherwise
4917 */
4918inline bool secondary_engine_lock_tables_mode(const THD &cthd) {
4919 return (cthd.locked_tables_mode == LTM_LOCK_TABLES ||
4921}
4922
4923/** A short cut for thd->get_stmt_da()->set_ok_status(). */
4924void my_ok(THD *thd, ulonglong affected_rows = 0, ulonglong id = 0,
4925 const char *message = nullptr);
4926
4927/** A short cut for thd->get_stmt_da()->set_eof_status(). */
4928void my_eof(THD *thd);
4929
4930bool add_item_to_list(THD *thd, Item *item);
4931
4932/*************************************************************************/
4933
4934/**
4935 Check if engine substitution is allowed in the current thread context.
4936
4937 @param thd thread context
4938 @retval true if engine substitution is allowed
4939 @retval false otherwise
4940*/
4941
4942inline bool is_engine_substitution_allowed(const THD *thd) {
4944}
4945
4946/**
4947 Returns if the user of the session has the SYSTEM_USER privilege or not.
4948
4949 @retval true User has SYSTEM_USER privilege
4950 @retval false Otherwise
4951*/
4952inline bool THD::is_system_user() {
4953 return m_is_system_user.load(std::memory_order_seq_cst);
4954}
4955
4956/**
4957 Sets the system_user flag atomically for the current session.
4958
4959 @param [in] system_user_flag boolean flag that indicates value to set.
4960*/
4961inline void THD::set_system_user(bool system_user_flag) {
4962 m_is_system_user.store(system_user_flag, std::memory_order_seq_cst);
4963}
4964
4965/**
4966 Returns if the user of the session has the CONNECTION_ADMIN privilege or not.
4967
4968 @retval true User has CONNECTION_ADMIN privilege
4969 @retval false Otherwise
4970*/
4972 return m_is_connection_admin.load(std::memory_order_seq_cst);
4973}
4974
4975/**
4976 Sets the connection_admin flag atomically for the current session.
4977
4978 @param [in] connection_admin_flag boolean flag that indicates value to set.
4979*/
4980inline void THD::set_connection_admin(bool connection_admin_flag) {
4981 m_is_connection_admin.store(connection_admin_flag, std::memory_order_seq_cst);
4982}
4983
4984/**
4985 Returns true if xa transactions are detached as part of executing XA PREPARE.
4986*/
4987inline bool is_xa_tran_detached_on_prepare(const THD *thd) {
4988 return thd->variables.xa_detach_on_prepare;
4989}
4990
4991#endif /* SQL_CLASS_INCLUDED */
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
uint32_t Access_bitmask
Definition: auth_acls.h:34
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
int64 query_id_t
Definition: binlog.h:72
API for getting cost estimates for server operations that are not directly related to a table object.
Definition: opt_costmodel.h:54
Stores status of the currently executed statement.
Definition: sql_error.h:269
bool is_error() const
Definition: sql_error.h:366
void reset_diagnostics_area()
Clear this Diagnostics Area.
Definition: sql_error.cc:361
Diagnostics_area * pop_diagnostics_area()
Pop "this" off the Diagnostics Area stack.
Definition: sql_error.cc:643
const Diagnostics_area * stacked_da() const
Returns the Diagnostics Area below the current diagnostics area on the stack.
Definition: sql_error.h:592
void push_diagnostics_area(THD *thd, Diagnostics_area *da, bool copy_conditions)
Push the given Diagnostics Area on top of the stack.
Definition: sql_error.cc:632
List of Discrete_interval objects.
Definition: discrete_interval.h:87
bool append(Discrete_interval *new_interval)
Definition: discrete_interval.h:117
void clear()
Definition: discrete_interval.h:144
Definition: reference_caching_setup.h:109
void refresh_all()
Definition: reference_caching_setup.cc:247
Definition: sql_audit.h:375
An instance of the global read lock in a connection.
Definition: sql_class.h:837
bool can_acquire_protection() const
Check if this connection can acquire protection against GRL and emit error if otherwise.
Definition: sql_class.h:857
MDL_ticket * m_mdl_blocks_commits_lock
Also in order to acquire the global read lock, the connection must acquire a shared metadata lock in ...
Definition: sql_class.h:881
MDL_ticket * m_mdl_global_shared_lock
In order to acquire the global read lock, the connection must acquire shared metadata lock in GLOBAL ...
Definition: sql_class.h:875
enum_grl_state m_state
Definition: sql_class.h:869
bool is_acquired() const
Definition: sql_class.h:865
Global_read_lock()
Definition: sql_class.h:845
enum_grl_state
Definition: sql_class.h:839
@ GRL_ACQUIRED_AND_BLOCKS_COMMIT
Definition: sql_class.h:842
@ GRL_ACQUIRED
Definition: sql_class.h:841
@ GRL_NONE
Definition: sql_class.h:840
Represents a set of GTIDs.
Definition: rpl_gtid.h:1556
void clear()
Removes all gtids from this Gtid_set.
Definition: rpl_gtid_set.cc:276
Either statement transaction or normal transaction - related thread-specific storage engine data.
Definition: transaction_info.h:403
This class represents the interface for internal error handlers.
Definition: error_handler.h:47
A registry for item tree transformations performed during query optimization.
Definition: sql_class.h:539
bool m_cancel
Definition: sql_class.h:550
Item * old_value
Definition: sql_class.h:548
Item_change_record(Item **place, Item *new_value)
Definition: sql_class.h:545
Item ** place
Definition: sql_class.h:547
Item * new_value
Definition: sql_class.h:549
Item_change_record()=default
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
Definition: sql_list.h:467
Tables that were locked with LOCK TABLES statement.
Definition: locked_tables_list.h:89
An interface to separate the MDL module from the THD, and the rest of the server code.
Definition: mdl.h:85
Context of the owner of metadata locks.
Definition: mdl.h:1412
void set_explicit_duration_for_all_locks()
Set explicit duration for all locks in the context.
Definition: mdl.cc:4634
Savepoint for MDL context.
Definition: mdl.h:1317
A granted metadata lock.
Definition: mdl.h:985
Table modification plan for JOIN-less statements (update/delete)
Definition: opt_explain.h:82
Storage for backup of Open_tables_state.
Definition: sql_class.h:697
MDL_savepoint mdl_system_tables_svp
When we backup the open tables state to open a system table or tables, we want to save state of metad...
Definition: sql_class.h:706
Class that holds information about tables which were opened and locked by the thread.
Definition: sql_class.h:561
MYSQL_LOCK * lock
Definition: sql_class.h:629
TABLE * open_tables
List of regular tables in use by this thread.
Definition: sql_class.h:608
MYSQL_LOCK * extra_lock
Definition: sql_class.h:636
Open_tables_state()
This constructor initializes Open_tables_state instance which can only be used as backup storage.
Definition: sql_class.h:683
uint state_flags
Definition: sql_class.h:676
void reset_open_tables_state()
Definition: sql_class.cc:620
Reprepare_observer * pop_reprepare_observer()
Definition: sql_class.h:595
void push_reprepare_observer(Reprepare_observer *o)
Definition: sql_class.h:591
enum_flags
Definition: sql_class.h:668
@ BACKUPS_AVAIL
Definition: sql_class.h:669
@ SYSTEM_TABLES
Definition: sql_class.h:670
enum enum_locked_tables_mode locked_tables_mode
Definition: sql_class.h:666
Reprepare_observer * get_reprepare_observer() const
Definition: sql_class.h:586
TABLE * temporary_tables
List of temporary tables used by this thread.
Definition: sql_class.h:614
void reset_reprepare_observers()
Definition: sql_class.h:601
void set_open_tables_state(Open_tables_state *state)
Definition: sql_class.cc:605
Prealloced_array< Reprepare_observer *, 4 > m_reprepare_observers
A stack of Reprepare_observer-instances.
Definition: sql_class.h:583
A per-session context which is always available at any point of execution, because in practice it's a...
Definition: opt_trace_context.h:93
Profiling state for a single THD; contains multiple QUERY_PROFILE objects.
Definition: sql_profile.h:226
Internal state of the parser.
Definition: sql_lexer_parser_state.h:44
Plugin array helper class.
Definition: sql_plugin_ref.h:110
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
Container for all prepared statements created/used in a connection.
Definition: sql_class.h:487
Prepared_statement_map()
Definition: sql_class.cc:2097
void claim_memory_ownership(bool claim)
Definition: sql_class.cc:2159
Prepared_statement * find_by_name(const LEX_CSTRING &name)
Find prepared statement by name.
Definition: sql_class.cc:2134
int insert(Prepared_statement *statement)
Insert a new statement to the thread-local prepared statement map.
Definition: sql_class.cc:2103
Prepared_statement * m_last_found_statement
Definition: sql_class.h:529
~Prepared_statement_map()
Definition: sql_class.cc:2183
void reset()
Definition: sql_class.cc:2165
void erase(Prepared_statement *statement)
Erase all prepared statements (calls Prepared_statement destructor).
Definition: sql_class.cc:2148
collation_unordered_map< std::string, Prepared_statement * > names_hash
Definition: sql_class.h:528
malloc_unordered_map< ulong, std::unique_ptr< Prepared_statement > > st_hash
Definition: sql_class.h:527
Prepared_statement * find(ulong id)
Find prepared statement by ID.
Definition: sql_class.cc:2139
Prepared_statement: a statement that can contain placeholders.
Definition: sql_prepare.h:152
Definition: protocol_classic.h:242
Definition: protocol_classic.h:54
Class used for the old (MySQL 4.0 protocol).
Definition: protocol_classic.h:220
Definition: protocol.h:33
Definition: sql_class.h:352
enum_state get_state() const
Definition: sql_class.h:415
bool is_stmt_prepare_or_first_stmt_execute() const
Definition: sql_class.h:420
T * memdup_typed(const T *mem)
Definition: sql_class.h:438
enum_state
Definition: sql_class.h:371
@ STMT_INITIALIZED
Definition: sql_class.h:372
@ STMT_ERROR
Definition: sql_class.h:377
@ STMT_REGULAR_EXECUTION
Definition: sql_class.h:375
@ STMT_PREPARED
Definition: sql_class.h:374
@ STMT_INITIALIZED_FOR_SP
Definition: sql_class.h:373
@ STMT_EXECUTED
Definition: sql_class.h:376
bool is_repreparing
To check whether a reprepare operation is active.
Definition: sql_class.h:363
bool is_stmt_prepare() const
Definition: sql_class.h:416
LEX_CSTRING strmake(LEX_CSTRING str)
Definition: sql_class.h:445
void reset_item_list()
Definition: sql_class.h:410
char * mem_strdup(const char *str)
Definition: sql_class.h:441
void free_items()
Definition: sql_class.cc:2061
Item * m_item_list
Definition: sql_class.h:358
void * alloc(size_t size)
Definition: sql_class.h:426
Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg)
Definition: sql_class.h:397
bool is_regular() const
Definition: sql_class.h:424
void set_query_arena(const Query_arena &set)
Copies memory-managing members from set.
Definition: sql_class.cc:2072
char * strmake(const char *str, size_t size) const
Definition: sql_class.h:442
enum_state state
Definition: sql_class.h:394
void set_item_list(Item *item)
Definition: sql_class.h:411
void add_item(Item *item)
Definition: sql_class.cc:2056
void * mem_calloc(size_t size)
Definition: sql_class.h:427
void swap_query_arena(const Query_arena &source, Query_arena *backup)
Copy the current arena to backup and set the current arena to match source
Definition: sql_class.cc:2078
void set_state(enum_state state_arg)
Definition: sql_class.h:414
T * alloc_typed()
Definition: sql_class.h:433
Query_arena()
Definition: sql_class.h:404
Item * item_list() const
Definition: sql_class.h:409
bool is_stmt_prepare_or_first_sp_execute() const
Definition: sql_class.h:417
void * memdup(const void *str, size_t size)
Definition: sql_class.h:451
MEM_ROOT * mem_root
Definition: sql_class.h:361
virtual ~Query_arena()=default
Definition: query_result.h:58
Definition: sql_lex.h:2615
Definition: rpl_rli.h:203
An interface that is used to take an action when the locking module notices that a table version has ...
Definition: sql_prepare.h:82
Common base class for all row-containing log events.
Definition: log_event.h:2764
Definition: rpl_context.h:413
A Lambda to be called at scope exit.
Definition: scope_guard.h:55
Base class for secondary engine statement context objects.
Definition: sql_class.h:933
virtual bool is_primary_engine_optimal() const
Definition: sql_class.h:943
virtual ~Secondary_engine_statement_context()=default
Destructs the secondary engine statement context object.
A set of THD members describing the current authenticated user.
Definition: sql_security_ctx.h:54
Definition: sys_vars_resource_mgr.h:70
Definition: session_tracker.h:129
Sql_cmd_common_signal represents the common properties of the SIGNAL and RESIGNAL statements.
Definition: sql_signal.h:88
Sql_cmd_resignal represents a RESIGNAL statement.
Definition: sql_signal.h:168
Sql_cmd_signal represents a SIGNAL statement.
Definition: sql_signal.h:148
Representation of a SQL condition.
Definition: sql_error.h:58
enum_severity_level
Enumeration value describing the severity of the condition.
Definition: sql_error.h:63
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
Used to save context when executing a function or trigger.
Definition: sql_class.h:747
ulonglong option_bits
Definition: sql_class.h:749
bool enable_slow_log
Definition: sql_class.h:758
ulong client_capabilities
Definition: sql_class.h:756
ulonglong first_successful_insert_id_in_cur_stmt
Definition: sql_class.h:751
ha_rows examined_row_count
Definition: sql_class.h:755
SAVEPOINT * savepoints
Definition: sql_class.h:759
ulonglong current_found_rows
Definition: sql_class.h:753
ha_rows sent_row_count
Definition: sql_class.h:755
ulonglong previous_found_rows
Definition: sql_class.h:754
enum enum_check_fields check_for_truncated_fields
Definition: sql_class.h:760
Discrete_intervals_list auto_inc_intervals_forced
Definition: sql_class.h:752
ha_rows num_truncated_fields
Definition: sql_class.h:755
uint in_sub_stmt
Definition: sql_class.h:757
ulonglong first_successful_insert_id_in_prev_stmt
Definition: sql_class.h:750
A derived from THD::Attachable_trx class allows updates in the attachable transaction.
Definition: sql_class.h:2138
bool is_read_only() const override
Definition: sql_class.h:2140
Attachable_trx_rw(const Attachable_trx_rw &)
Attachable_trx_rw & operator=(const Attachable_trx_rw &)
Attachable_trx_rw(THD *thd)
Definition: sql_class.cc:535
Class representing read-only attachable transaction, encapsulates knowledge how to backup state of cu...
Definition: sql_class.h:2095
THD * m_thd
THD instance.
Definition: sql_class.h:2106
Transaction_state m_trx_state
Transaction state data.
Definition: sql_class.h:2117
virtual ~Attachable_trx()
Definition: sql_class.cc:491
Attachable_trx * m_prev_attachable_trx
Attachable_trx which was active for the THD before when this transaction was started (NULL in most ca...
Definition: sql_class.h:2114
Attachable_trx(THD *thd, Attachable_trx *prev_trx)
Definition: sql_class.cc:396
virtual bool is_read_only() const
Definition: sql_class.h:2102
enum_reset_lex m_reset_lex
Definition: sql_class.h:2108
Attachable_trx * get_prev_attachable_trx() const
Definition: sql_class.h:2099
Attachable_trx(const Attachable_trx &)
Attachable_trx & operator=(const Attachable_trx &)
Query plan for EXPLAINable commands, should be locked with LOCK_query_plan before using.
Definition: sql_class.h:1420
void set_query_plan(enum_sql_command sql_cmd, LEX *lex_arg, bool ps)
Set query plan.
Definition: sql_class.cc:2723
void assert_plan_is_locked_if_other() const
Asserts that current_thd has locked this plan, if it does not own it.
Definition: sql_class.cc:2718
bool is_single_table_plan() const
Definition: sql_class.cc:3065
THD *const thd
Definition: sql_class.h:1422
Query_plan & operator=(const Query_plan &)
not defined
Query_plan(const Query_plan &)
not defined
bool is_ps_query() const
Definition: sql_class.h:1475
LEX * lex
LEX of topmost statement.
Definition: sql_class.h:1426
bool is_ps
True if query is run in prepared statement.
Definition: sql_class.h:1430
const Modification_plan * modification_plan
Query plan for UPDATE/DELETE/INSERT/REPLACE.
Definition: sql_class.h:1428
Modification_plan const * get_modification_plan() const
Definition: sql_class.h:1471
enum_sql_command get_command() const
Definition: sql_class.h:1463
LEX * get_lex() const
Definition: sql_class.h:1467
Query_plan(THD *thd_arg)
Definition: sql_class.h:1444
enum_sql_command sql_command
Original sql_command;.
Definition: sql_class.h:1424
void set_modification_plan(Modification_plan *plan_arg)
Definition: sql_class.cc:2739
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
bool is_being_disposed() const
Check if THD is being disposed (i.e.
Definition: sql_class.cc:1357
enum_vio_type get_vio_type() const
Definition: sql_class.cc:1974
std::atomic< mysql_cond_t * > current_cond
Pointer to the condition variable the thread owning this THD is currently waiting for.
Definition: sql_class.h:1579
bool has_gtid_consistency_violation
Definition: sql_class.h:3998
std::unique_ptr< Secondary_engine_statement_context > m_secondary_engine_statement_context
Current query's secondary engine statement context.
Definition: sql_class.h:1075
friend void my_message_sql(uint, const char *, myf)
All global error messages are sent here where the first one is stored for the client.
Definition: mysqld.cc:3893
Rpl_thd_context rpl_thd_ctx
Definition: sql_class.h:3917
struct THD_timer_info * timer
Holds active timer object.
Definition: sql_class.h:1890
void notify_hton_post_release_exclusive(const MDL_key *mdl_key) override
Notify interested storage engines that we have just released exclusive lock for the key.
Definition: sql_class.cc:3092
uint fill_variables_recursion_level
Definition: sql_class.h:1677
thd_scheduler scheduler
Definition: sql_class.h:4060
ulonglong first_successful_insert_id_in_prev_stmt_for_binlog
Definition: sql_class.h:2239
mysql_mutex_t LOCK_thd_query
Protects THD::m_query_string.
Definition: sql_class.h:1253
PSI_statement_locker * m_statement_psi
Current statement instrumentation.
Definition: sql_class.h:2513
std::unique_ptr< dd::cache::Dictionary_client > m_dd_client
Definition: sql_class.h:1012
void disconnect(bool server_shutdown=false)
Disconnect the associated communication endpoint.
Definition: sql_class.cc:1662
bool m_is_admin_conn
Definition: sql_class.h:1617
PSI_transaction_locker_state m_transaction_state
Current transaction instrumentation state.
Definition: sql_class.h:2523
PSI_stage_progress * m_stage_progress_psi
Current stage progress instrumentation.
Definition: sql_class.h:2504
std::atomic< bool > m_is_system_user
Flag that indicates if the user of current session has SYSTEM_USER privilege.
Definition: sql_class.h:4771
void cleanup_connection(void)
Definition: sql_class.cc:1193
Gtid owned_gtid
The GTID of the currently owned transaction.
Definition: sql_class.h:3808
sql_digest_state * m_digest
Current statement digest.
Definition: sql_class.h:2506
Diagnostics_area m_query_rewrite_plugin_da
Definition: sql_class.h:4468
void clear_binlog_local_stmt_filter()
Definition: sql_class.h:1875
struct System_status_var * initial_status_var
Definition: sql_class.h:1166
ulonglong first_successful_insert_id_in_cur_stmt
Definition: sql_class.h:2245
void store_globals()
Definition: sql_class.cc:1733
Secondary_engine_optimization m_secondary_engine_optimization
This flag tells if a secondary storage engine can be used to execute a query in this session.
Definition: sql_class.h:4756
void push_lock_usec(ulonglong &top)
Definition: sql_class.h:1645
rpl_event_coordinates binlog_next_event_pos
Definition: sql_class.h:1722
void reset_n_backup_open_tables_state(Open_tables_backup *backup, uint add_state_flags)
Definition: sql_class.cc:2227
void claim_memory_ownership(bool claim)
Claim all the memory used by the THD object.
Definition: sql_class.cc:2971
std::atomic< uint > m_cached_rw_status
Definition: sql_class.h:1309
void inc_status_select_range()
Definition: sql_class.cc:2460
void set_row_count_func(longlong row_count_func)
Definition: sql_class.h:2431
std::unordered_map< unsigned int, void * > external_store_
Definition: sql_class.h:4851
bool is_a_srv_session() const
Definition: sql_class.h:4637
void set_catalog(const LEX_CSTRING &catalog)
Definition: sql_class.h:1486
void clear_binlog_table_maps()
Definition: sql_class.h:2000
void enable_low_level_commit_ordering()
Enables ordering in ha_commit_low.
Definition: sql_class.cc:3050
void unlock_query_plan()
Definition: sql_class.h:1314
void get_trans_pos(const char **file_var, my_off_t *pos_var) const
Definition: sql_class.h:2702
void rpl_detach_engine_ha_data()
When the thread is a binlog or slave applier it detaches the engine ha_data associated with it and me...
Definition: sql_class.cc:3005
uint fill_status_recursion_level
Used by fill_status() to avoid acquiring LOCK_status mutex twice when this function is called recursi...
Definition: sql_class.h:1676
longlong m_row_count_func
Stores the result of ROW_COUNT() function.
Definition: sql_class.h:2426
unsigned long bind_parameter_values_count
the number of elements in parameters
Definition: sql_class.h:4808
bool is_current_stmt_binlog_disabled() const
Determine if binlogging is currently disabled for this session.
Definition: sql_class.cc:3031
PS_PARAM * bind_parameter_values
The parameter value bindings for the current query.
Definition: sql_class.h:4806
static const int OWNED_SIDNO_GTID_SET
Definition: sql_class.h:3809
Discrete_intervals_list auto_inc_intervals_forced
Definition: sql_class.h:2291
void set_psi(PSI_thread *psi)
Save the performance schema thread instrumentation associated with this user session.
Definition: sql_class.h:4078
bool add_external(unsigned int slot, void *data)
Definition: sql_class.cc:3290
void request_persist_gtid_by_se()
Request SE to persist GTID explicitly.
Definition: sql_class.h:3868
void set_query(const char *query_arg, size_t query_length_arg)
Assign a new value to thd->m_query_string.
Definition: sql_class.h:4279
const String normalized_query()
The current query in normalized form.
Definition: sql_class.cc:3070
void reset_query_for_display()
Reset query string to be displayed in PFS.
Definition: sql_class.h:4263
PSI_thread * get_psi() const
Read the performance schema thread instrumentation associated with this user session.
Definition: sql_class.h:4085
void init_cost_model()
Initialize the optimizer cost model.
Definition: sql_class.cc:3759
std::bitset< SE_GTID_MAX > Se_GTID_flagset
Definition: sql_class.h:3834
ulong statement_id_counter
Definition: sql_class.h:2546
void enter_cond(mysql_cond_t *cond, mysql_mutex_t *mutex, const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, int src_line) override
Enter a condition wait.
Definition: sql_class.h:3073
bool is_log_reset() const
Definition: sql_class.h:3862
bool slave_thread
Definition: sql_class.h:2778
bool m_is_fatal_error
Set to true if execution of the current compound statement can not continue.
Definition: sql_class.h:2790
void shutdown_active_vio()
Definition: sql_class.cc:1979
std::unique_ptr< Protocol_binary > protocol_binary
Definition: sql_class.h:1369
bool is_waiting_for_disk_space() const
Returns the current waiting_for_disk_space flag value.
Definition: sql_class.h:4718
uint dbug_sentry
Definition: sql_class.h:1558
ulonglong first_successful_insert_id_in_prev_stmt
Definition: sql_class.h:2232
Diagnostics_area main_da
Definition: sql_class.h:4466
dd::cache::Dictionary_client * dd_client() const
Definition: sql_class.h:1006
enum_binlog_query_type
Definition: sql_class.h:3057
@ ROW_QUERY_TYPE
Definition: sql_class.h:3059
@ QUERY_TYPE_COUNT
Definition: sql_class.h:3064
@ STMT_QUERY_TYPE
Definition: sql_class.h:3062
SSL_handle m_SSL
SSL data attached to this connection.
Definition: sql_class.h:1413
dd::DD_kill_immunizer * kill_immunizer
When operation on DD tables is in progress then THD is set to kill immune mode.
Definition: sql_class.h:2771
LEX_CSTRING m_invoker_host
Definition: sql_class.h:4491
Prealloced_array< unsigned long, 11 > audit_class_mask
Array of bits indicating which audit classes have already been added to the list of audit plugins whi...
Definition: sql_class.h:2900
bool is_applier_thread() const
Definition: sql_class.h:2012
void set_invoker(const LEX_STRING *user, const LEX_STRING *host)
Definition: sql_class.h:4441
void set_new_thread_id()
Assign a value to m_thread_id by calling Global_THD_manager::get_new_thread_id().
Definition: sql_class.cc:1177
XID debug_binlog_xid_last
Definition: sql_class.h:4688
PSI_statement_locker_state m_statement_state
Current statement instrumentation state.
Definition: sql_class.h:2516
bool notify_hton_pre_acquire_exclusive(const MDL_key *mdl_key, bool *victimized) override
Notify/get permission from interested storage engines before acquiring exclusive lock for the key.
Definition: sql_class.cc:3086
const st_plugin_int * m_plugin
Stores the plugin id it is attached to (if any).
Definition: sql_class.h:4666
void pop_diagnostics_area()
Pop the top DA off the Diagnostics Area stack.
Definition: sql_class.h:3373
bool m_binlog_invoker
It will be set TRUE if CURRENT_USER() is called in account management statements or default definer i...
Definition: sql_class.h:4482
MDL_context mdl_context
Definition: sql_class.h:970
void unpin_gtid()
Unpin and free GTID and TSID.
Definition: sql_class.h:3843
mysql_cond_t COND_thr_lock
Condition variable used for waiting by the THR_LOCK.c subsystem.
Definition: sql_class.h:1583
thr_lock_type insert_lock_default
Type of lock to be used for INSERT statement if lock is not specified explicitly.
Definition: sql_class.h:1663
bool running_explain_analyze
Whether we are currently in the execution phase of an EXPLAIN ANALYZE query.
Definition: sql_class.h:2762
void clear_current_query_costs()
Clear the query costs attributes for the current query.
Definition: sql_class.h:1190
bool has_invoker() const
Definition: sql_class.h:4449
std::unique_ptr< Protocol_text > protocol_text
Definition: sql_class.h:1368
void increment_updates_counter()
Definition: sql_class.cc:2680
const char * proc_info_session(THD *invoking_thd) const
Return the m_proc_info, possibly using the string of an older server release, according to @session....
Definition: sql_class.h:1532
collation_unordered_map< std::string, unique_ptr_my_free< Table_ref > > handler_tables_hash
Definition: sql_class.h:1548
enum_tx_isolation tx_isolation
Definition: sql_class.h:2631
bool is_error() const
true if there is an error in the error stack.
Definition: sql_class.h:3318
unsigned char * m_token_array
Current statement digest token array.
Definition: sql_class.h:2508
void set_ssl(Vio *vio)
Definition: sql_class.h:3010
void save_current_query_costs()
Save the current query costs attributes in the thread session status.
Definition: sql_class.h:1205
bool is_cleanup_done()
Definition: sql_class.cc:1245
my_off_t m_trans_end_pos
Definition: sql_class.h:1964
void restore_sub_statement_state(Sub_statement_state *backup)
Definition: sql_class.cc:2342
THD * get_thd() override
Within MDL subsystem this one is only used for DEBUG_SYNC.
Definition: sql_class.h:3119
void leave_locked_tables_mode()
Leave explicit LOCK TABLES or prelocked mode and restore value of transaction sentinel in MDL subsyst...
Definition: sql_class.cc:2554
bool skip_transaction_read_only_check
Definition: sql_class.h:1908
my_thread_id thread_id() const
Definition: sql_class.h:2568
resourcegroups::Resource_group_ctx * resource_group_ctx()
Get resource group context.
Definition: sql_class.h:4068
void set_trans_pos(const char *file, my_off_t pos)
Functions to set and get transaction position.
Definition: sql_class.h:2677
my_thread_t real_id
Definition: sql_class.h:2548
void push_protocol(const std::unique_ptr< ProtocolClass > &protocol)
Definition: sql_class.h:3386
void begin_attachable_rw_transaction()
Start a read-write attachable transaction.
Definition: sql_class.cc:2262
void lock_query_plan()
Locks the query plan of this THD.
Definition: sql_class.h:1313
void nocheck_register_item_tree_change(Item **place, Item *new_value)
Remember that place was updated with new_value so it can be restored by rollback_item_tree_changes().
Definition: sql_class.cc:2019
ha_rows get_examined_row_count() const
Definition: sql_class.h:2477
void get_trans_fixed_pos(const char **file_var, my_off_t *pos_var) const
Definition: sql_class.h:2712
bool copy_db_to(char **p_db, size_t *p_db_length) const
Definition: sql_class.h:4056
void set_security_context(Security_context *sctx)
Definition: sql_class.h:1341
void send_kill_message() const
Definition: sql_class.cc:2191
void inc_status_select_scan()
Definition: sql_class.cc:2476
Event_tracking_data_stack event_tracking_data_
Definition: sql_class.h:4878
void reset_gtid_persisted_by_se()
Reset by SE at transaction end after persisting GTID.
Definition: sql_class.h:3874
bool tx_commit_pending
Definition: sql_class.h:1095
void decrement_temptable_count()
Decrement the owned temptable counter.
Definition: sql_class.h:4890
USER_CONN * m_user_connect
Definition: sql_class.h:2457
void swap_rewritten_query(String &query_arg)
Set the rewritten query (with passwords obfuscated etc.) on the THD.
Definition: sql_class.cc:3165
Cost_model_server m_cost_model
Optimizer cost model for server operations.
Definition: sql_class.h:4499
char scramble[SCRAMBLE_LENGTH+1]
Definition: sql_class.h:2774
my_timeval query_start_timeval_trunc(uint decimals)
Definition: sql_class.cc:1011
void inc_status_sort_scan()
Definition: sql_class.cc:2509
PSI_stage_key m_current_stage_key
Definition: sql_class.h:1489
Relay_log_info * rli_slave
Definition: sql_class.h:1092
uint open_options
Definition: sql_class.h:2570
double double_value
Definition: sql_class.h:2850
List< Security_context > m_view_ctx_list
Definition: sql_class.h:1353
bool is_current_stmt_binlog_enabled_and_caches_empty() const
Checks whether binlog caches are disabled (binlog does not cache data) or empty in case binloggging i...
Definition: sql_class.cc:3041
Query_arena * stmt_arena
Definition: sql_class.h:2210
enum_binlog_format current_stmt_binlog_format
Indicates the format in which the current statement will be logged.
Definition: sql_class.h:1922
void reset_query()
Definition: sql_class.h:4284
void clear_clone_vio()
Clear clone network Vio for remote clone.
Definition: sql_class.h:3032
void inc_status_created_tmp_tables()
Definition: sql_class.cc:2436
uint get_rand_seed() const override
Provide thread specific random seed for MDL_context's PRNG.
Definition: sql_class.h:3157
ha_rows m_sent_row_count
Number of rows we actually sent to the client, including "synthetic" rows in ROLLUP etc.
Definition: sql_class.h:2442
std::atomic< PSI_thread * > m_psi
Performance schema thread instrumentation for this session.
Definition: sql_class.h:4095
void raise_error_printf(uint code,...)
Raise an exception condition, with a formatted message.
Definition: sql_class.cc:961
bool m_is_low_level_commit_ordering_enabled
Flag indicating whether additional ordering in the ha_commit_low function is enabled.
Definition: sql_class.h:1608
void set_status_no_index_used()
Definition: sql_class.cc:2517
size_t m_opened_temptable_count
Each THD can open multiple temptables, we create these temptable objects in the temptable engine.
Definition: sql_class.h:4909
static const int OWNED_SIDNO_ANONYMOUS
Definition: sql_class.h:3810
bool push_event_tracking_data(Event_tracking_class event, const Event_tracking_information *Event_tracking_information)
Definition: sql_class.cc:3327
Vio * clone_vio
Definition: sql_class.h:2171
bool is_server_upgrade_thread() const
Definition: sql_class.h:2603
void end_statement()
Definition: sql_class.cc:2084
LEX_CSTRING m_query_string
The query associated with this statement.
Definition: sql_class.h:1017
const CHARSET_INFO * collation()
Definition: sql_class.h:3165
bool charset_is_collation_connection
Definition: sql_class.h:2828
LEX_CSTRING m_invoker_user
It points to the invoker in the Query_log_event.
Definition: sql_class.h:4490
bool is_extrenal_xa() const
Definition: sql_class.h:3896
void reset_binlog_local_stmt_filter()
Definition: sql_class.h:1871
mysql_mutex_t LOCK_query_plan
Protects query plan (SELECT/UPDATE/DELETE's) from being freed/changed while another thread explains i...
Definition: sql_class.h:1300
void time_out_user_resource_limits()
Definition: sql_class.cc:2703
void clear_active_vio()
Definition: sql_class.h:3016
const Protocol * get_protocol() const
Definition: sql_class.h:1371
ulonglong m_lock_usec
Time spent waiting for TABLE locks and DATA locks.
Definition: sql_class.h:1640
bool need_binlog_invoker() const
Definition: sql_class.h:4439
bool is_dd_system_thread() const
Definition: sql_class.h:2577
ulong max_client_packet_length
Definition: sql_class.h:1545
int thd_tx_priority
Definition: sql_class.h:2647
LEX_CSTRING m_db
Name of the current (default) database.
Definition: sql_class.h:1038
std::atomic< bool > m_safe_to_display
Definition: sql_class.h:1019
binlog_filter_state get_binlog_local_stmt_filter() const
Definition: sql_class.h:1885
uchar * binlog_row_event_extra_data
Definition: sql_class.h:1731
THR_LOCK_INFO lock_info
Definition: sql_class.h:1239
bool derived_tables_processing
Definition: sql_class.h:2832
void pop_event_tracking_data()
Definition: sql_class.cc:3372
void record_first_successful_insert_id_in_cur_stmt(ulonglong id_arg)
Definition: sql_class.h:2328
long long_value
Definition: sql_class.h:2847
LEX_CSTRING m_catalog
Currently selected catalog.
Definition: sql_class.h:1025
Opt_trace_context opt_trace
optimizer trace of current statement
Definition: sql_class.h:4127
bool in_loadable_function
Definition: sql_class.h:4855
bool send_result_set_row(const mem_root_deque< Item * > &row_items)
Send one result set row.
Definition: sql_class.cc:2914
bool is_system_thread() const
Definition: sql_class.h:2574
void set_admin_connection(bool admin)
Definition: sql_class.h:1620
class THD::Query_plan query_plan
std::list< std::function< bool(const THD &)> > m_skip_gtid_rollback_checkers
Callback functions that determine if GTID rollback shall be skipped.
Definition: sql_class.h:3959
void reset_sub_statement_state(Sub_statement_state *backup, uint new_state)
Definition: sql_class.cc:2297
bool is_a_srv_session_thd
Variable to mark if the object is part of a Srv_session object, which aggregates THD.
Definition: sql_class.h:4663
Thd_mem_cnt m_mem_cnt
Controlled memory stats for this session.
Definition: sql_class.h:961
LEX * lex
Definition: sql_class.h:1005
bool status_var_aggregated
Definition: sql_class.h:1168
ulonglong current_found_rows
Dynamic, collected and set also in subqueries.
Definition: sql_class.h:2369
void increment_questions_counter()
Definition: sql_class.cc:2686
void increment_user_connections_counter()
Definition: sql_class.cc:2661
void set_clone_vio(Vio *vio)
Set active clone network Vio for remote clone.
Definition: sql_class.h:3025
Time_zone * time_zone()
Definition: sql_class.h:3169
void set_system_user(bool system_user_flag)
Sets the system_user flag atomically for the current session.
Definition: sql_class.h:4961
const Diagnostics_area * get_stmt_da() const
Returns first Diagnostics Area for the current statement.
Definition: sql_class.h:3324
query_id_t query_id
Definition: sql_class.h:2543
void set_safe_display(bool safe)
Set if the query string to be safe to display.
Definition: sql_class.h:4273
ulonglong get_lock_usec()
Definition: sql_class.h:1643
Session_sysvar_resource_manager session_sysvar_res_mgr
Definition: sql_class.h:4516
auto register_skip_gtid_rollback_checker(const std::invocable< const THD & > auto &shall_skip)
Register a callback function that will determine if a subsequent GTID rollback shall be skipped.
Definition: sql_class.h:3974
void send_statement_status()
Definition: sql_class.cc:2933
bool is_connected(bool use_cached_connection_alive=false) final
Return false if connection to client is broken.
Definition: sql_class.cc:3205
const char * thread_stack
Definition: sql_class.h:1322
LEX_CSTRING get_invoker_user() const
Definition: sql_class.h:4447
bool fill_information_schema_tables() const
Definition: sql_class.h:3266
void set_waiting_for_disk_space(bool waiting)
Set the waiting_for_disk_space flag.
Definition: sql_class.h:4712
std::atomic< mysql_mutex_t * > current_mutex
The mutex used with current_cond.
Definition: sql_class.h:1569
void decrement_user_connections_counter()
Definition: sql_class.cc:2667
~THD() override
Definition: sql_class.cc:1456
my_thread_id m_thread_id
This counter is 32 bit because of the client protocol.
Definition: sql_class.h:2560
void set_command(enum enum_server_command command)
Definition: sql_class.cc:2531
bool event_notify(struct st_mysql_event_generic *event_data)
Definition: sql_class.cc:3380
bool is_admin_connection() const
Definition: sql_class.h:1621
Protocol * m_protocol
Definition: sql_class.h:1402
void set_current_stmt_binlog_format_row_if_mixed()
Definition: sql_class.h:3493
String m_normalized_query
Definition: sql_class.h:1018
void init_query_mem_roots()
Initialize memory roots necessary for query processing and (!) pre-allocate memory for it.
Definition: sql_class.cc:1171
void fatal_error()
Mark the current error as fatal.
Definition: sql_class.h:3303
void set_connection_admin(bool connection_admin_flag)
Sets the connection_admin flag atomically for the current session.
Definition: sql_class.h:4980
const LEX_CSTRING & catalog() const
Definition: sql_class.h:1484
void clear_next_event_pos()
Definition: sql_class.cc:2620
void set_server_id(uint32 sid)
Definition: sql_class.h:1767
bool m_secondary_engine_forced
Flag that tells whether secondary storage engine is forced for execution.
Definition: sql_class.h:4764
bool set_db(const LEX_CSTRING &new_db)
Set the current database; use deep copy of C-string.
Definition: sql_class.cc:900
void exit_cond(const PSI_stage_info *stage, const char *src_function, const char *src_file, int src_line) override
End a wait on a condition.
Definition: sql_class.h:3090
bool is_engine_ha_data_detached() const
Definition: sql_class.cc:3025
bool is_attachable_ro_transaction_active() const
Definition: sql_class.h:3470
Sql_condition * raise_condition(uint sql_errno, const char *sqlstate, Sql_condition::enum_severity_level level, const char *msg, bool fatal_error=false)
Raise a generic SQL condition.
Definition: sql_class.cc:1024
PSI_transaction_locker * m_transaction_psi
Current transaction instrumentation.
Definition: sql_class.h:2520
void set_query_id(query_id_t new_query_id)
Assign a new value to thd->query_id.
Definition: sql_class.h:4332
Session_tracker session_tracker
Definition: sql_class.h:4515
const LEX_CSTRING & query() const
Definition: sql_class.h:4221
bool enable_slow_log
Definition: sql_class.h:2830
Internal_error_handler * pop_internal_handler()
Remove the error handler last pushed.
Definition: sql_class.cc:949
bool audit_plugins_present
Definition: sql_class.h:4879
Event_tracking_data get_event_tracking_data()
Definition: sql_class.h:4858
enum enum_mark_columns mark_used_columns
MARK_COLUMNS_NONE: Means mark_used_columns is not set and no indicator to handler of fields used is s...
Definition: sql_class.h:984
int is_killed() const final
Has the owner thread been killed?
Definition: sql_class.h:3107
struct timeval user_time
Definition: sql_class.h:1629
struct THD_timer_info * timer_cache
After resetting(cancelling) timer, current timer object is cached with timer_cache timer to reuse.
Definition: sql_class.h:1895
bool is_fatal_sub_stmt_error
true if we are in a sub-statement and the current error can not be safely recovered until we left the...
Definition: sql_class.h:2810
bool optimizer_switch_flag(ulonglong flag) const
Tells whether the given optimizer_switch flag is on.
Definition: sql_class.h:1861
Diagnostics_area * m_query_rewrite_plugin_da_ptr
Definition: sql_class.h:4469
void vsyntax_error_at(const POS &location, const char *format, va_list args)
Definition: sql_class.cc:2833
longlong get_row_count_func() const
Definition: sql_class.h:2429
ulong rand_saved_seed2
Definition: sql_class.h:2547
enum THD::Commit_error commit_error
ulonglong previous_found_rows
Stores the result of the FOUND_ROWS() function.
Definition: sql_class.h:2363
int binlog_flush_pending_rows_event(bool stmt_end)
Definition: sql_class.h:1777
void inc_status_sort_rows(ha_rows count)
Definition: sql_class.cc:2500
enum durability_properties durability_property
Definition: sql_class.h:2740
bool waiting_for_disk_space
Definition: sql_class.h:4704
SSL_handle get_ssl() const
Definition: sql_class.h:1375
bool m_audited
Definition: sql_class.h:2916
void clear_current_stmt_binlog_format_row()
Definition: sql_class.h:3522
void set_user_connect(USER_CONN *uc)
Definition: sql_class.cc:2655
enum enum_server_command get_command() const
Definition: sql_class.h:4199
bool is_regular() const =delete
double m_current_query_cost
Current query cost.
Definition: sql_class.h:1179
bool might_have_commit_order_waiters() const final
Indicates that owner thread might have some commit order (non-MDL) waits for it which are still taken...
Definition: sql_class.h:3108
Discrete_intervals_list auto_inc_intervals_in_cur_stmt_for_binlog
Definition: sql_class.h:2289
bool tx_read_only
Definition: sql_class.h:2636
void syntax_error_at(const POS &location)
Definition: sql_class.h:4523
Prealloced_array< Ha_data, PREALLOC_NUM_HA > ha_data
Definition: sql_class.h:1681
const CHARSET_INFO * db_charset
Definition: sql_class.h:2498
int is_current_stmt_binlog_format_row() const
Determine the binlog format of the current statement.
Definition: sql_class.h:1791
const Gtid_set * get_gtid_next_list_const() const
Return the value of @gtid_next_list: either a Gtid_set or NULL.
Definition: sql_class.h:3555
void set_next_event_pos(const char *_filename, ulonglong _pos)
Definition: sql_class.cc:2604
bool is_mem_cnt_error()
Definition: sql_class.h:4838
void set_plugin(const st_plugin_int *plugin)
Sets the plugin id to the value provided as parameter.
Definition: sql_class.h:4649
const Protocol_classic * get_protocol_classic() const
Asserts that the protocol is of type text or binary and then returns the m_protocol casted to Protoco...
Definition: sql_class.h:1394
String packet
Definition: sql_class.h:1969
void set_tmp_table_seq_id(uint arg)
Definition: sql_class.h:4652
bool stmt_depends_on_first_successful_insert_id_in_prev_stmt
Definition: sql_class.h:2274
void push_internal_handler(Internal_error_handler *handler)
Add an internal error handler to the thread execution context.
Definition: sql_class.cc:928
void copy_status_var(System_status_var *dst_var)
Copy status variables into a structure pointed by the specified pointer and keep track of the pointer...
Definition: sql_class.h:1223
bool is_operating_gtid_table_implicitly
Definition: sql_class.h:2377
void syntax_error()
Definition: sql_class.h:4518
bool handle_condition(uint sql_errno, const char *sqlstate, Sql_condition::enum_severity_level *level, const char *msg)
Handle a sql condition.
Definition: sql_class.cc:936
Event_reference_caching_cache * events_cache_
Definition: sql_class.h:4877
void set_current_stmt_binlog_format_row()
Definition: sql_class.h:3517
Prepared_statement_map stmt_map
All prepared statements of this connection.
Definition: sql_class.h:1317
uint server_status
Definition: sql_class.h:2570
friend void push_warning(THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *message_text)
Push the warning to error list if there is still room in the list.
Definition: sql_error.cc:659
void set_secondary_engine_statement_context(std::unique_ptr< Secondary_engine_statement_context > context)
Definition: sql_class.cc:895
bool bool_value
Definition: sql_class.h:2846
bool is_killable
Definition: sql_class.h:1560
void set_query_for_display(const char *query_arg, size_t query_length_arg)
Set query to be displayed in performance schema (threads table etc.).
Definition: sql_class.h:4246
bool is_system_user()
Returns if the user of the session has the SYSTEM_USER privilege or not.
Definition: sql_class.h:4952
bool is_current_stmt_binlog_log_replica_updates_disabled() const
Determine if binlogging is currently disabled for this session.
Definition: sql_class.cc:3036
void debug_assert_query_locked() const
For safe and protected access to the query string, the following rules should be followed: 1: Only th...
Definition: sql_class.cc:2538
void force_one_auto_inc_interval(ulonglong next_id)
Definition: sql_class.h:2354
uint64_t sql_mode_t
Definition: sql_lexer_thd.h:38
sp_rcontext * sp_runtime_ctx
Current SP-runtime context.
Definition: sql_class.h:2837
void inc_examined_row_count(ha_rows count)
Definition: sql_class.cc:2423
bool is_strict_mode() const
Definition: sql_class.h:3161
bool skip_gtid_rollback
Definition: sql_class.h:3955
Parser_state * m_parser_state
Internal parser state.
Definition: sql_lexer_thd.h:66
void update_charset()
Definition: sql_class.cc:1924
void inc_status_select_full_join()
Definition: sql_class.cc:2444
List< char > * get_binlog_accessed_db_names() const
Definition: sql_class.h:2005
void pop_protocol()
Pops the top protocol of the Protocol stack and sets the previous one as the current protocol.
Definition: sql_class.cc:3250
void enable_mem_cnt()
Definition: sql_class.h:4831
bool m_inside_system_variable_global_update
Flag to indicate this thread is executing sys_var::update for a OPT_GLOBAL variable.
Definition: sql_class.h:4801
bool is_current_stmt_binlog_row_enabled_with_write_set_extraction() const
Determine if binloging is enabled in row format and write set extraction is enabled for this session.
Definition: sql_class.cc:3045
void set_binlog_local_stmt_filter()
Definition: sql_class.h:1880
bool is_cmd_skip_readonly() const
Definition: sql_class.h:1982
thr_lock_type update_lock_default
Type of lock to be used for all DML statements, except INSERT, in cases when lock is not specified ex...
Definition: sql_class.h:1657
enum enum_thread_type system_thread
Definition: sql_class.h:2571
void clear_copy_status_var()
Clear copy of the status variables.
Definition: sql_class.h:1214
void raise_note_printf(uint code,...)
Raise an completion condition (note), with a formatted message.
Definition: sql_class.cc:998
bool is_mem_cnt_error_issued
Definition: sql_class.h:4837
void reset_skip_transaction_read_only_check()
Definition: sql_class.h:1992
const char * current_key_name
Definition: sql_class.h:4835
ha_rows num_truncated_fields
Definition: sql_class.h:2435
partition_info * work_part_info
Definition: sql_class.h:2888
bool has_incremented_gtid_automatic_count
Flag indicating whether this session incremented the number of sessions with GTID_NEXT set to AUTOMAT...
Definition: sql_class.h:4884
void * fetch_external(unsigned int slot)
Definition: sql_class.cc:3298
bool is_attachable_transaction_active() const
Definition: sql_class.h:3477
enum_thd_life_cycle_stages
Represents life cycle stages of THD instance.
Definition: sql_class.h:2960
@ ACTIVE_AND_CLEAN
Definition: sql_class.h:2962
@ SCHEDULED_FOR_DISPOSAL
Definition: sql_class.h:2963
@ RESOURCES_RELEASED
Definition: sql_class.h:2965
@ DISPOSED
Definition: sql_class.h:2966
@ ACTIVE
Definition: sql_class.h:2961
@ CLEANED_UP
Definition: sql_class.h:2964
System_variables variables
Definition: sql_lexer_thd.h:64
void set_log_reset()
Set when binlog reset operation is started.
Definition: sql_class.h:3856
struct rand_struct rand
Definition: sql_class.h:1160
bool is_slave_error
True if a slave error.
Definition: sql_class.h:2820
List< char > * binlog_accessed_db_names
Definition: sql_class.h:1946
void set_original_commit_timestamp_for_slave_thread()
Copies variables.original_commit_timestamp to ((Slave_worker *)rli_slave)->original_commit_timestamp,...
Definition: sql_class.cc:2628
bool is_stmt_prepare_or_first_stmt_execute() const =delete
binlog_filter_state
Definition: sql_class.h:1865
@ BINLOG_FILTER_CLEAR
Definition: sql_class.h:1867
@ BINLOG_FILTER_UNKNOWN
Definition: sql_class.h:1866
@ BINLOG_FILTER_SET
Definition: sql_class.h:1868
bool is_init_file_system_thread() const
Definition: sql_class.h:2590
void set_secondary_engine_forced(bool forced)
Indicate whether secondary storage engine is forced for this execution.
Definition: sql_class.h:4745
ha_rows m_examined_row_count
Number of rows read and/or evaluated for a statement.
Definition: sql_class.h:2454
bool query_start_usec_used
Definition: sql_class.h:2811
time_t query_start_in_secs() const
Definition: sql_class.h:3173
THD * next_to_commit
Used by MYSQL_BIN_LOG to maintain the commit queue for binary log group commit.
Definition: sql_class.h:2659
void set_transaction(Transaction_ctx *transaction_ctx)
Changes the Transaction_ctx instance within THD-object.
Definition: sql_class.cc:888
enum_thd_life_cycle_stages m_thd_life_cycle_stage
Definition: sql_class.h:2968
mysql_mutex_t LOCK_group_replication_connection_mutex
Definition: sql_class.h:4828
void raise_warning_printf(uint code,...)
Raise a completion condition (warning), with a formatted message.
Definition: sql_class.cc:978
bool is_classic_protocol() const
Definition: sql_class.cc:3200
Prealloced_array< Binlog_user_var_event *, 2 > user_var_events
Definition: sql_class.h:2652
PSI_stage_key get_current_stage_key() const
Definition: sql_class.h:1536
bool send_result_metadata(const mem_root_deque< Item * > &list, uint flags)
Send name and type of result to client.
Definition: sql_class.cc:2873
bool is_stmt_prepare_or_first_sp_execute() const =delete
mysql_mutex_t LOCK_thd_protocol
Protects THD::m_protocol when it gets removed in x plugin.
Definition: sql_class.h:1268
bool parsing_system_view
Definition: sql_class.h:2834
Diagnostics_area * m_stmt_da
Definition: sql_class.h:4471
bool is_binlog_applier() const
The function checks whether the thread is processing queries from binlog, as automatically generated ...
Definition: sql_class.h:1103
bool skip_readonly_check
Definition: sql_class.h:1902
const String & rewritten_query() const
Get the rewritten query (with passwords obfuscated etc.) from the THD.
Definition: sql_class.h:4311
void cleanup(void)
Definition: sql_class.cc:1255
cached_properties
Definition: sql_class.h:1079
void set_is_killable(bool is_killable_arg)
Assign a new value to is_killable Protected with the LOCK_thd_data mutex.
Definition: sql_class.h:4353
void inc_status_created_tmp_disk_tables()
Definition: sql_class.cc:2428
const Transaction_ctx * get_transaction() const
Definition: sql_class.h:2153
bool is_connection_admin()
Returns if the user of the session has the CONNECTION_ADMIN privilege or not.
Definition: sql_class.h:4971
void store_cached_properties(cached_properties prop_mask=cached_properties::ALL)
Definition: sql_class.cc:865
mysql::gtid::Tsid owned_tsid
For convenience, this contains the TSID component of the GTID stored in owned_gtid.
Definition: sql_class.h:3816
bool shall_skip_gtid_rollback() const
Invoke the callback functions that determine if GTID rollback shall be skipped, and return true as so...
Definition: sql_class.h:3965
struct timeval start_time
Definition: sql_class.h:1628
binlog_filter_state m_binlog_filter_state
Indicate if the current statement should be discarded instead of written to the binlog.
Definition: sql_class.h:1916
const CHARSET_INFO * charset() const
Definition: sql_class.h:3397
void init(void)
Definition: sql_class.cc:1089
void copy_table_access_properties(THD *thd)
Copy session properties that affect table access from the parent session to the current session.
Definition: sql_class.cc:881
bool is_secondary_storage_engine_eligible() const
Checks if queries in this session can use a secondary storage engine for execution.
Definition: sql_class.cc:3141
void set_status_no_good_index_used()
Definition: sql_class.cc:2524
std::unique_ptr< LEX > main_lex
The lex to hold the parsed tree of conventional (non-prepared) queries.
Definition: sql_class.h:1002
const char * where
Definition: sql_class.h:1543
LEX_CSTRING get_invoker_host() const
Definition: sql_class.h:4448
ha_rows get_sent_row_count() const
Definition: sql_class.h:2475
bool charset_is_character_set_filesystem
Definition: sql_class.h:2829
void reset_copy_status_var()
Copy status variables into a structure pointed by the specified pointer passed into copy_status_var m...
Definition: sql_class.h:1232
bool safe_to_display() const
Definition: sql_class.h:4269
void reset_first_successful_insert_id()
Definition: sql_class.h:2341
void set_time()
Definition: sql_class.cc:3257
bool is_fsp_truncate_mode() const
Definition: sql_class.h:3180
Access_bitmask want_privilege
Used by Item::check_column_privileges() to tell which privileges to check for.
Definition: sql_class.h:993
uint32 file_id
Definition: sql_class.h:1625
Internal_error_handler * m_internal_handler
The current internal error handler for this thread, or NULL.
Definition: sql_class.h:4455
void push_diagnostics_area(Diagnostics_area *da, bool copy_conditions=true)
Push the given Diagnostics Area on top of the stack, making it the new first Diagnostics Area.
Definition: sql_class.h:3366
void disable_low_level_commit_ordering()
Enables ordering in ha_commit_low.
Definition: sql_class.cc:3055
Plugin_array audit_class_plugins
Array of active audit plugins which have been used by this THD.
Definition: sql_class.h:2895
const NET * get_net() const
Definition: sql_class.h:1971
bool transaction_rollback_request
Set by a storage engine to request the entire transaction (that possibly spans multiple engines) to r...
Definition: sql_class.h:2798
void set_active_vio(Vio *vio)
Definition: sql_class.h:3004
void release_external_store()
Definition: sql_class.cc:3670
uint16 peer_port
Definition: sql_class.h:1627
Secondary_engine_optimization secondary_engine_optimization() const
Can secondary storage engines be used for query execution in this session?
Definition: sql_class.h:4731
bool binlog_need_explicit_defaults_ts
The member is served for marking a query that CREATEs or ALTERs a table declared with a TIMESTAMP col...
Definition: sql_class.h:2668
void set_skip_transaction_read_only_check()
Definition: sql_class.h:1979
uint in_sub_stmt
Definition: sql_class.h:1666
void inc_lock_usec(ulonglong usec)
Definition: sql_class.cc:3270
void disable_mem_cnt()
Definition: sql_class.h:4832
void rollback_item_tree_changes()
Restore locations set by calls to nocheck_register_item_tree_change().
Definition: sql_class.cc:2039
bool se_persists_gtid() const
Definition: sql_class.h:3880
char * m_trans_fixed_log_file
Definition: sql_class.h:1963
bool is_low_level_commit_ordering_enabled() const
Obtains flag indicating whether additional ordering in the ha_commit_low function is enabled.
Definition: sql_class.cc:3060
bool unioned_events_trans
Definition: sql_class.h:2870
char * strmake(const char *str, size_t size) const
Definition: sql_lexer_thd.h:52
Secondary_engine_statement_context * secondary_engine_statement_context()
Definition: sql_class.h:1121
bool copy_db_to(char const **p_db, size_t *p_db_length) const
Definition: sql_class.h:4046
union THD::@177 sys_var_tmp
void increment_con_per_hour_counter()
Definition: sql_class.cc:2674
std::atomic< bool > m_cached_is_connection_alive
Keep cached values of "connection alive" and "rw status".
Definition: sql_class.h:1308
uint get_tmp_table_seq_id()
Definition: sql_class.h:4651
const Diagnostics_area * get_stacked_da() const
Returns the second Diagnostics Area for the current statement.
Definition: sql_class.h:3327
void mark_transaction_to_rollback(bool all)
Mark transaction to rollback and mark error as fatal to a sub-statement.
Definition: sql_class.cc:2594
Attachable_trx * m_attachable_trx
Definition: sql_class.h:2148
void raise_warning(uint code)
Raise a completion condition (warning).
Definition: sql_class.cc:973
enum_check_fields check_for_truncated_fields
Definition: sql_class.h:2649
uint get_binlog_table_maps() const
Definition: sql_class.h:1999
PSI_idle_locker * m_idle_psi
Idle instrumentation.
Definition: sql_class.h:2527
Diagnostics_area * get_parser_da()
Returns thread-local Diagnostics Area for parsing.
Definition: sql_class.h:3340
void set_time(const struct timeval *t)
Definition: sql_class.h:3176
collation_unordered_map< std::string, unique_ptr_with_deleter< user_var_entry > > user_vars
Hash for user variables.
Definition: sql_class.h:1159
bool sql_parser()
Call parser to transform statement into a parse tree.
Definition: sql_class.cc:3101
bool rand_used
Definition: sql_class.h:2812
NET net
Definition: sql_class.h:1968
ulonglong m_current_query_partial_plans
Current query partial plans.
Definition: sql_class.h:1185
sp_cache * sp_func_cache
Definition: sql_class.h:2839
Cost_model_server m_cost_model_hypergraph
Definition: sql_class.h:4500
int tx_priority
Definition: sql_class.h:2642
std::unique_ptr< Transaction_ctx > m_transaction
Definition: sql_class.h:2018
table_map table_map_for_update
Definition: sql_class.h:2216
void cleanup_after_parse_error()
Restore session state in case of parse error.
Definition: sql_class.cc:3187
mysql_mutex_t LOCK_thd_sysvar
Protects THD::variables while being updated.
Definition: sql_class.h:1259
ulong ulong_value
Definition: sql_class.h:2848
void update_previous_found_rows()
Definition: sql_class.h:3198
void raise_note(uint code)
Raise a completion condition (note), with a fixed message.
Definition: sql_class.cc:990
void awake(THD::killed_state state_to_set)
Awake a thread.
Definition: sql_class.cc:1534
void change_item_tree(Item **place, Item *new_value)
Record a transient change to a pointer to an Item within another Item.
Definition: sql_class.h:3403
void mark_plugin_fake_ddl(bool flag)
Definition: sql_class.h:4656
mysql_mutex_t LOCK_thd_data
Protects THD data accessed from other threads.
Definition: sql_class.h:1247
bool convert_string(LEX_STRING *to, const CHARSET_INFO *to_cs, const char *from, size_t from_length, const CHARSET_INFO *from_cs, bool report_error=false)
void cleanup_after_query()
Definition: sql_class.cc:1794
void restore_globals()
Definition: sql_class.cc:1764
void inc_status_sort_range()
Definition: sql_class.cc:2492
query_id_t first_query_id
Definition: sql_class.h:2876
Ha_data * get_ha_data(int slot)
Retrieve Ha_data for a given slot.
Definition: sql_class.h:1687
Vio * active_vio
Definition: sql_class.h:2168
uint tmp_table_seq_id
Sequential number of internal tmp table created in the statement.
Definition: sql_class.h:4681
MEM_ROOT * user_var_events_alloc
Definition: sql_class.h:2653
THD(bool enable_plugins=true)
Definition: sql_class.cc:630
uint32 unmasked_server_id
Definition: sql_class.h:1623
const char * m_proc_info
Definition: sql_class.h:1503
void push_protocol(Protocol *protocol)
Inserts the new protocol at the top of the protocol stack, and make it the current protocol for this ...
Definition: sql_class.cc:3242
void end_attachable_transaction()
End an active attachable transaction.
Definition: sql_class.cc:2254
bool is_secondary_engine_forced() const
Definition: sql_class.h:4749
const char * proc_info() const
Definition: sql_class.h:1521
bool is_attachable_rw_transaction_active() const
Definition: sql_class.h:3484
void clear_log_reset()
Cleared after flushing SE logs during binlog reset.
Definition: sql_class.h:3859
const st_plugin_int * get_plugin() const
Returns the plugin, the thd belongs to.
Definition: sql_class.h:4644
enum enum_server_command m_command
Type of current query: COM_STMT_PREPARE, COM_QUERY, etc.
Definition: sql_class.h:1614
void reset_db(const LEX_CSTRING &new_db)
Set the current database; use shallow copy of C-string.
Definition: sql_class.h:4034
Se_GTID_flagset m_se_gtid_flags
Flags for SE GTID persistence.
Definition: sql_class.h:3837
Gtid_set * get_gtid_next_list()
Return the value of @gtid_next_list: either a Gtid_set or NULL.
Definition: sql_class.h:3548
mysql_mutex_t LOCK_current_cond
Mutex protecting access to current_mutex and current_cond.
Definition: sql_class.h:1564
void set_secondary_engine_optimization(Secondary_engine_optimization state)
Enables or disables use of secondary storage engines in this session.
Definition: sql_class.h:4723
Transaction_ctx * get_transaction()
Definition: sql_class.h:2151
bool is_initialize_system_thread() const
Definition: sql_class.h:2585
ulong rand_saved_seed1
Definition: sql_class.h:2547
sp_cache * sp_proc_cache
Definition: sql_class.h:2838
Item_change_list change_list
This is used to track transient changes to items during optimization of a prepared statement/stored p...
Definition: sql_class.h:2196
bool in_active_multi_stmt_transaction() const
true if the session is in a multi-statement transaction mode (
Definition: sql_class.h:3263
void refresh_reference_caches()
Definition: sql_class.h:4866
bool check_clone_vio()
Check if clone network Vio is active.
Definition: sql_class.h:3039
std::unique_ptr< PROFILING > profiling
Definition: sql_class.h:2500
void reset_current_stmt_binlog_format_row()
Definition: sql_class.h:3527
bool m_disable_password_validation
Definition: sql_class.h:1366
bool in_multi_stmt_transaction_mode() const
Returns true if session is in a multi-statement transaction mode.
Definition: sql_class.h:3225
void begin_attachable_ro_transaction()
Start a read-only attachable transaction.
Definition: sql_class.cc:2250
uint get_protocol_rw_status()
Return the cached protocol rw status.
Definition: sql_class.cc:3229
bool do_union
Definition: sql_class.h:2859
const LEX_CSTRING & db() const
Definition: sql_class.h:4000
const Internal_error_handler * get_internal_handler() const
Definition: sql_class.h:4098
ulonglong read_first_successful_insert_id_in_prev_stmt(void)
Definition: sql_class.h:2332
struct THD::@178 binlog_evt_union
uint32 binlog_unsafe_warning_flags
Bit field for the state of binlog warnings.
Definition: sql_class.h:1936
void raise_error(uint code)
Raise an exception condition.
Definition: sql_class.cc:956
std::atomic< killed_state > killed
Definition: sql_class.h:2755
ulonglong start_utime
Query start time, expressed in microseconds.
Definition: sql_class.h:1633
Security_context * m_security_ctx
Definition: sql_class.h:1338
bool is_stmt_prepare() const =delete
void restore_ha_data(const Prealloced_array< Ha_data, PREALLOC_NUM_HA > &backup)
Restore ha_data from the provided backup copy.
Definition: sql_class.h:1706
bool unioned_events
Definition: sql_class.h:2864
bool m_is_plugin_fake_ddl
Creating or dropping plugin native table through a plugin service.
Definition: sql_class.h:4674
void set_sent_row_count(ha_rows count)
Definition: sql_class.cc:2413
uint query_name_consts
number of name_const() substitutions, see sp_head.cc:subst_spvars()
Definition: sql_class.h:2842
NET_SERVER m_net_server_extension
Additional network instrumentation for the server only.
Definition: sql_class.h:1150
ulonglong conn_mem_alloc_number
Definition: sql_class.h:4836
String m_rewritten_query
In some cases, we may want to modify the query (i.e.
Definition: sql_class.h:1069
bool m_server_idle
True if the server code is IDLE for this connection.
Definition: sql_class.h:2533
Relay_log_info * rli_fake
Definition: sql_class.h:1090
mysql_mutex_t LOCK_thd_security_ctx
Protects THD::m_security_ctx from inspection (e.g.
Definition: sql_class.h:1274
void backup_ha_data(Prealloced_array< Ha_data, PREALLOC_NUM_HA > *backup)
Copy ha_data into the provided argument.
Definition: sql_class.h:1692
uint32 server_id
Definition: sql_class.h:1624
bool is_fatal_error() const
Definition: sql_class.h:3304
Transactional_ddl_context m_transactional_ddl
Definition: sql_class.h:4786
bool duplicate_slave_id
This is only used by master dump threads.
Definition: sql_class.h:4628
bool charset_is_system_charset
is set if a statement accesses a temporary table created through CREATE TEMPORARY TABLE.
Definition: sql_class.h:2828
void reset_rewritten_query()
Reset thd->m_rewritten_query.
Definition: sql_class.h:4321
void release_resources()
Release most resources, prior to THD destruction.
Definition: sql_class.cc:1378
Security_context * security_context() const
Definition: sql_class.h:1340
bool check_event_subscribers(Event_tracking_class event, unsigned long subevent, bool check_audited)
Definition: sql_class.cc:3302
size_t get_temptable_count() const
Return currently owned temptable count.
Definition: sql_class.h:4892
void restore_backup_open_tables_state(Open_tables_backup *backup)
Definition: sql_class.cc:2236
void pop_lock_usec(ulonglong top)
Definition: sql_class.h:1649
void enter_locked_tables_mode(enum_locked_tables_mode mode_arg)
Definition: sql_class.h:4359
bool time_zone_used
Definition: sql_class.h:2812
ulonglong ulonglong_value
Definition: sql_class.h:2849
void enter_stage(const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *calling_func, const char *calling_file, const unsigned int calling_line) SUPPRESS_TSAN
Definition: sql_class.cc:542
uint binlog_table_maps
Definition: sql_class.h:1942
void inc_status_select_range_check()
Definition: sql_class.cc:2468
int send_explain_fields(Query_result *result)
Definition: sql_class.cc:1936
void clear_error()
Clear the current error, if any.
Definition: sql_class.h:3283
bool is_bootstrap_system_thread() const
Definition: sql_class.h:2596
void binlog_invoker()
Definition: sql_class.h:4438
bool is_one_phase_commit()
Definition: sql_class.cc:3131
void set_gtid_persisted_by_se()
Set by SE when it guarantees GTID persistence.
Definition: sql_class.h:3865
void inc_status_sort_merge_passes()
Definition: sql_class.cc:2484
void mark_as_srv_session()
Definition: sql_class.h:4638
MEM_ROOT main_mem_root
This memory root is used for two purposes:
Definition: sql_class.h:4465
struct System_status_var status_var
Definition: sql_class.h:1162
bool m_enable_plugins
Definition: sql_class.h:2908
struct System_status_var * copy_status_var_ptr
Definition: sql_class.h:1163
void clear_owned_gtids()
Definition: sql_class.h:3919
killed_state
Definition: sql_class.h:2748
@ KILL_QUERY
Definition: sql_class.h:2751
@ KILL_CONNECTION
Definition: sql_class.h:2750
@ KILLED_NO_VALUE
Definition: sql_class.h:2753
@ KILL_TIMEOUT
Definition: sql_class.h:2752
@ NOT_KILLED
Definition: sql_class.h:2749
std::vector< char > m_connection_attributes
Session's connection attributes for the connected client.
Definition: sql_class.h:1173
Locked_tables_list locked_tables_list
Definition: sql_class.h:2886
void get_definer(LEX_USER *definer)
Definition: sql_class.cc:2577
const char * m_trans_log_file
The binary log position of the transaction.
Definition: sql_class.h:1962
bool is_commit_in_middle_of_statement
Definition: sql_class.h:3992
Diagnostics_area * get_stmt_da()
Returns first Diagnostics Area for the current statement.
Definition: sql_class.h:3321
mysql_cond_t COND_group_replication_connection_cond_var
Definition: sql_class.h:4829
std::atomic< bool > m_is_connection_admin
Flag that indicates if the user of current session has CONNECTION_ADMIN privilege.
Definition: sql_class.h:4776
void inc_status_select_full_range_join()
Definition: sql_class.cc:2452
Diagnostics_area m_parser_da
cf.
Definition: sql_class.h:4467
void notify_shared_lock(MDL_context_owner *ctx_in_use, bool needs_thr_lock_abort) override
A callback to the server internals that is used to address special cases of the locking protocol.
Definition: sql_class.cc:1706
const USER_CONN * get_user_connect() const
Definition: sql_class.h:2461
void shutdown_clone_vio()
Shutdown clone vio, if active.
Definition: sql_class.cc:1997
void pin_gtid()
Defer freeing owned GTID and TSID till unpinned.
Definition: sql_class.h:3840
PSI_idle_locker_state m_idle_state
Idle instrumentation state.
Definition: sql_class.h:2530
bool is_plugin_fake_ddl() const
Definition: sql_class.h:4655
bool arg_of_last_insert_id_function
Definition: sql_class.h:2219
void set_skip_readonly_check()
Definition: sql_class.h:1973
Se_GTID_flag
SE GTID persistence flag types.
Definition: sql_class.h:3819
@ SE_GTID_PERSIST_EXPLICIT
Explicit request for SE to persist GTID for current transaction.
Definition: sql_class.h:3829
@ SE_GTID_RESET_LOG
If RESET log in progress.
Definition: sql_class.h:3827
@ SE_GTID_CLEANUP
Cleanup GTID during unpin.
Definition: sql_class.h:3823
@ SE_GTID_PERSIST
SE would persist GTID for current transaction.
Definition: sql_class.h:3825
@ SE_GTID_MAX
Max element holding the biset size.
Definition: sql_class.h:3831
@ SE_GTID_PIN
Pin owned GTID.
Definition: sql_class.h:3821
bool se_persists_gtid_explicit() const
Definition: sql_class.h:3890
bool for_debug_only_is_set_persist_options
Definition: sql_class.h:1262
void rpl_reattach_engine_ha_data()
When the thread is a binlog or slave applier it reattaches the engine ha_data associated with it and ...
Definition: sql_class.cc:3015
bool release_resources_done() const
Definition: sql_class.cc:1352
bool is_operating_substatement_implicitly
Definition: sql_class.h:2394
void update_slow_query_status()
Evaluate the current time, and if it exceeds the long-query-time setting, mark the query as slow.
Definition: sql_class.cc:3285
uint tmp_table
Definition: sql_class.h:2569
Commit_error
Definition: sql_class.h:2727
@ CE_NONE
Definition: sql_class.h:2728
@ CE_COMMIT_ERROR
Definition: sql_class.h:2732
@ CE_ERROR_COUNT
Definition: sql_class.h:2733
@ CE_SYNC_ERROR
Definition: sql_class.h:2731
@ CE_FLUSH_ERROR
Definition: sql_class.h:2729
@ CE_FLUSH_GNO_EXHAUSTED_ERROR
Definition: sql_class.h:2730
Security_context m_main_security_ctx
Definition: sql_class.h:1337
malloc_unordered_map< std::string, User_level_lock * > ull_hash
Definition: sql_class.h:1555
static const char *const DEFAULT_WHERE
Definition: sql_class.h:1147
void reset_skip_readonly_check()
Definition: sql_class.h:1987
Global_read_lock global_read_lock
Definition: sql_class.h:2166
void inc_sent_row_count(ha_rows count)
Definition: sql_class.cc:2418
void increment_temptable_count()
Increment the owned temptable counter.
Definition: sql_class.h:4888
bool thread_specific_used
is set if some thread specific value(s) used in a statement.
Definition: sql_class.h:2823
void set_open_tables(TABLE *open_tables_arg)
Assign a new value to open_tables.
Definition: sql_class.h:4343
bool is_cmd_skip_transaction_read_only() const
Definition: sql_class.h:1984
bool owned_gtid_is_empty()
Definition: sql_class.h:3939
resourcegroups::Resource_group_ctx m_resource_group_ctx
Resource group context indicating the current resource group and the name of the resource group to sw...
Definition: sql_class.h:1045
enum_reset_lex
Definition: sql_class.h:2085
@ DO_NOT_RESET_LEX
Definition: sql_class.h:2085
@ RESET_LEX
Definition: sql_class.h:2085
uchar password
Definition: sql_class.h:2780
const Cost_model_server * cost_model() const
Retrieve the optimizer cost model for this connection.
Definition: sql_class.cc:3764
void set_proc_info(const char *proc_info)
Definition: sql_class.h:1535
void start_disposal()
Set THD in ACTIVE life stage to disposal stage.
Definition: sql_class.cc:1365
Diagnostics_area * get_query_rewrite_plugin_da()
Returns thread-local Diagnostics Area to be used by query rewrite plugins.
Definition: sql_class.h:3351
bool in_lock_tables
Definition: sql_class.h:2813
sql_digest_state m_digest_state
Top level statement digest.
Definition: sql_class.h:2510
ulonglong found_rows() const
Definition: sql_class.h:3190
Definition: table.h:2865
Definition: sql_class.h:256
void restore_mode()
Restore original memory counter mode.
Definition: sql_class.h:288
void no_error_mode()
Set NO ERROR memory counter mode.
Definition: sql_class.h:292
ulonglong glob_mem_counter
Definition: sql_class.h:263
void set_orig_mode(uint mode_arg)
Function sets original memory counter mode.
Definition: sql_class.h:306
void set_curr_mode(uint mode_arg)
Function sets current memory counter mode.
Definition: sql_class.h:300
void flush()
Function flushes memory counters before deleting the memory counter object.
Definition: sql_class.cc:289
void free_cnt(size_t size)
Decrease memory counter at 'free' operation.
Definition: sql_class.cc:236
bool is_error() const
Check if memory counter error is issued.
Definition: sql_class.h:312
ulonglong mem_counter
Definition: sql_class.h:261
void set_thd_error_status() const
Set THD error status using memory counter diagnostics area.
Definition: sql_class.cc:354
THD * m_thd
Definition: sql_class.h:259
int reset()
Function resets current memory counter mode and adjusts global memory counter according to thread mem...
Definition: sql_class.cc:251
Diagnostics_area m_da
Definition: sql_class.h:260
bool is_error_mode() const
Check if memory counter is in error mode.
Definition: sql_class.h:322
~Thd_mem_cnt()
Definition: sql_class.h:273
ulonglong max_conn_mem
Definition: sql_class.h:262
bool m_enabled
Definition: sql_class.h:258
void alloc_cnt(size_t size)
Increase memory counter at 'alloc' operation.
Definition: sql_class.cc:170
void set_thd(THD *thd)
Definition: sql_class.h:277
uint orig_mode
Definition: sql_class.h:266
int generate_error(int err_no, ulonglong mem_limit, ulonglong mem_size)
Generate OOM error and set therad to KILL_CONNECTION state.
Definition: sql_class.cc:310
void disable()
Definition: sql_class.cc:157
uint curr_mode
Definition: sql_class.h:265
bool is_error_log_mode() const
Check if memory counter is in error log mode.
Definition: sql_class.h:328
bool is_connection_stage
Definition: sql_class.h:268
void enable()
Definition: sql_class.h:278
Thd_mem_cnt()
Definition: sql_class.h:272
This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t co...
Definition: tztime.h:49
Definition: transaction_info.h:54
This class keeps the context of transactional DDL statements.
Definition: sql_class.h:890
void post_ddl()
End the transactional context created by calling post ddl hook for engine on which table is being cre...
Definition: sql_class.cc:3734
dd::String_type m_tablename
Definition: sql_class.h:919
void init(dd::String_type db, dd::String_type tablename, const handlerton *hton)
Initialize the transactional ddl context when executing CREATE TABLE ... SELECT command with engine w...
Definition: sql_class.cc:3684
~Transactional_ddl_context()
Definition: sql_class.h:896
THD * m_thd
Definition: sql_class.h:912
Transactional_ddl_context(THD *thd)
Definition: sql_class.h:892
dd::String_type m_db
Definition: sql_class.h:918
bool inited()
Definition: sql_class.h:904
const handlerton * m_hton
Definition: sql_class.h:915
void rollback()
Remove the table share used while creating the table, if the transaction is being rolledback.
Definition: sql_class.cc:3702
@ XA_NOTR
Definition: xa.h:298
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:219
RAII class for immunizing the THD from kill operations.
Definition: dd_kill_immunizer.h:46
Definition: dictionary_client.h:149
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4571
std::unordered_map, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:157
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:47
void clear()
Clears data - uuid and tag.
Definition: tsid.cpp:127
Definition: partition_info.h:209
Definition: sp_cache.cc:42
Definition: sp_rcontext.h:77
To be used for pool-of-threads (implemented differently on various OSs)
Definition: sql_class.h:213
void * data
Definition: sql_class.h:215
~thd_scheduler()=default
thd_scheduler()
Definition: sql_class.h:217
Definition: item_func.h:3021
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
#define PSI_THREAD_CALL(M)
Definition: psi_thread.h:36
static char buf[MAX_BUF]
Definition: conf_to_src.cc:73
#define U
Definition: ctype-tis620.cc:74
thread_local THD * current_thd
Definition: current_thd.cc:26
durability_properties
Definition: dur_prop.h:31
static bool report_error(THD *thd, int error_code, Sql_condition::enum_severity_level level, Args... args)
Definition: error_handler.cc:291
enum_check_fields
Definition: field.h:172
Rows_log_event * binlog_get_pending_rows_event(bool is_transactional) const
This function retrieves a pending row event from a cache which is specified through the parameter is_...
Definition: binlog.cc:9649
bool is_ddl_gtid_compatible()
Definition: binlog.cc:10718
bool is_binlog_cache_empty(bool is_transactional) const
Return true if the statement/transaction cache is currently empty, false otherwise.
Definition: binlog.cc:9376
int binlog_write_row(TABLE *table, bool is_transactional, const uchar *new_data, const unsigned char *extra_row_info)
Definition: binlog.cc:11174
int decide_logging_format(Table_ref *tables)
Decide on logging format to use for the statement and issue errors or warnings as needed.
Definition: binlog.cc:10026
bool binlog_configure_trx_cache_size(ulong new_size)
Configure size of binlog transaction cache.
Definition: binlog.cc:9440
int binlog_update_row(TABLE *table, bool is_transactional, const uchar *old_data, const uchar *new_data, const uchar *extra_row_info)
Definition: binlog.cc:11199
Rows_log_event * binlog_prepare_pending_rows_event(TABLE *table, uint32 serv_id, size_t needed, bool is_transactional, const unsigned char *extra_row_info, uint32 source_part_id=INT_MAX)
Definition: binlog.cc:10878
int binlog_delete_row(TABLE *table, bool is_transactional, const uchar *old_data, const unsigned char *extra_row_info)
Definition: binlog.cc:11272
bool is_dml_gtid_compatible(bool some_transactional_table, bool some_non_transactional_table, bool non_transactional_tables_are_tmp)
is_dml_gtid_compatible() and is_ddl_gtid_compatible() check if the statement that is about to be proc...
Definition: binlog.cc:10800
int binlog_query(enum_binlog_query_type qtype, const char *query, size_t query_len, bool is_trans, bool direct, bool suppress_use, int errcode)
Log the current query.
Definition: binlog.cc:11586
void add_to_binlog_accessed_dbs(const char *db)
Definition: binlog.cc:9677
void issue_unsafe_warnings()
Auxiliary method used by binlog_query() to raise warnings.
Definition: binlog.cc:11528
int binlog_write_table_map(TABLE *table, bool is_transactional, bool binlog_rows_query)
This function writes a table map to the binary log.
Definition: binlog.cc:9604
int binlog_setup_trx_data()
Definition: binlog.cc:9401
void unlock_global_read_lock(THD *thd)
Unlock global read lock.
Definition: lock.cc:1085
bool lock_global_read_lock(THD *thd)
Take global read lock, wait if there is protection against lock.
Definition: lock.cc:1045
bool make_global_read_lock_block_commit(THD *thd)
Make global read lock also block commits.
Definition: lock.cc:1114
void set_explicit_lock_duration(THD *thd)
Set explicit duration for metadata locks which are used to implement GRL.
Definition: lock.cc:1142
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
char * strmake_root(MEM_ROOT *root, const char *str, size_t len)
Definition: my_alloc.cc:287
char * strdup_root(MEM_ROOT *root, const char *str)
Definition: my_alloc.cc:279
void * memdup_root(MEM_ROOT *root, const void *str, size_t len)
Definition: my_alloc.cc:296
MYSQL_PLUGIN_IMPORT CHARSET_INFO * default_charset_info
Definition: charset.cc:181
size_t dirname_length(const char *name)
Get the string length of the directory part of name, including the last FN_LIBCHAR.
Definition: mf_dirname.cc:62
void reset_for_next_command()
Definition: sql_parse.cc:5171
struct PSI_idle_locker PSI_idle_locker
Definition: psi_idle_bits.h:41
unsigned int PSI_stage_key
Instrumented stage key.
Definition: psi_stage_bits.h:43
struct PSI_statement_locker PSI_statement_locker
Definition: psi_statement_bits.h:98
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:82
struct PSI_transaction_locker PSI_transaction_locker
Definition: psi_transaction_bits.h:41
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43
#define mysql_mutex_assert_not_owner(M)
Wrapper, to use safe_mutex_assert_not_owner with instrumented mutexes.
Definition: mysql_mutex.h:126
#define mysql_mutex_assert_owner(M)
Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
Definition: mysql_mutex.h:112
#define MYSQL_SET_STATEMENT_TEXT(LOCKER, P1, P2)
Definition: mysql_statement.h:107
#define MYSQL_SET_STATEMENT_QUERY_ID(LOCKER, P1)
Definition: mysql_statement.h:116
static int flags[50]
Definition: hp_test1.cc:40
static int flag
Definition: hp_test1.cc:40
Instrumentation helpers for mysys threads.
struct MYSQL_LEX_CSTRING LEX_CSTRING
Definition: lex_string.h:42
enum_locked_tables_mode
Type of locked tables mode.
Definition: locked_tables_list.h:47
@ LTM_LOCK_TABLES
Definition: locked_tables_list.h:49
@ LTM_PRELOCKED_UNDER_LOCK_TABLES
Definition: locked_tables_list.h:51
@ LTM_NONE
Definition: locked_tables_list.h:48
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_latin1
Definition: ctype-latin1.cc:366
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1544
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
enum_server_command
A list of all MySQL protocol commands.
Definition: my_command.h:48
Header for compiler-dependent features.
#define SUPPRESS_TSAN
Definition: my_compiler.h:138
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
#define DBUG_TRACE
Definition: my_dbug.h:146
Some integer typedefs for easier portability.
int myf
Definition: my_inttypes.h:94
unsigned long long int ulonglong
Definition: my_inttypes.h:56
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
#define MYF(v)
Definition: my_inttypes.h:97
uint16_t uint16
Definition: my_inttypes.h:65
uint32_t uint32
Definition: my_inttypes.h:67
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_END
Definition: my_sqlcommand.h:208
Common header for many mysys elements.
uint64_t table_map
Definition: my_table_map.h:30
Types to make different thread packages compatible.
pthread_t my_thread_t
Definition: my_thread_bits.h:48
uint32 my_thread_id
Definition: my_thread_local.h:34
static int count
Definition: myisam_ftdump.cc:45
static bool backup
Definition: myisampack.cc:198
unsigned int STDCALL mysql_errno(MYSQL *mysql)
Definition: client.cc:9174
@ SERVER_STATUS_IN_TRANS
Is raised when a multi-statement transaction has been started, either explicitly, by means of BEGIN o...
Definition: mysql_com.h:816
#define SCRAMBLE_LENGTH
Length of random string sent by server on handshake; this is also length of obfuscated password,...
Definition: mysql_com.h:128
Definitions private to the server, used in the networking layer to notify specific events.
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
Instrumentation helpers for statements.
char * user
Definition: mysqladmin.cc:66
const char * host
Definition: mysqladmin.cc:65
void error(const char *format,...)
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1087
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: os0file.h:89
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
bool empty(const Histogram &histogram)
Return true if 'histogram' was built on an empty table.
Definition: histogram.h:693
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
size_t size(const char *const c)
Definition: base64.h:46
bool is_active(space_id_t space_id, bool get_latch=true)
Definition: trx0purge.cc:1157
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2887
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2883
This contains the declaration of class Opt_trace_context, which is needed to declare THD.
Performance schema instrumentation (declarations).
Instrumentation helpers for mutexes.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
PSI_memory_key key_memory_THD_handler_tables_hash
Definition: psi_memory_key.cc:93
PSI_memory_key key_memory_user_var_entry
Definition: psi_memory_key.cc:148
PSI_memory_key key_memory_User_level_lock
Definition: psi_memory_key.cc:97
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
Performance schema instrumentation interface.
#define OPTION_NOT_AUTOCOMMIT
Definition: query_options.h:74
#define OPTION_BEGIN
Definition: query_options.h:75
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
required string event
Definition: replication_group_member_actions.proto:32
enum_tx_isolation
Definition: handler.h:3186
ha_notification_type
Definition: handler.h:940
char empty_c_string[1]
Definition: sql_class.cc:132
PSI_thread * thd_get_psi(THD *thd)
Get reference to Performance Schema object for THD object.
Definition: sql_thd_api.cc:110
void my_message_sql(uint error, const char *str, myf MyFlags)
All global error messages are sent here where the first one is stored for the client.
Definition: mysqld.cc:3893
void my_eof(THD *thd)
A short cut for thd->get_stmt_da()->set_eof_status().
Definition: sql_class.cc:3750
void thd_enter_stage(void *opaque_thd, const PSI_stage_info *new_stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, int src_line)
Definition: sql_thd_internal_api.cc:212
bool is_xa_tran_detached_on_prepare(const THD *thd)
Returns true if xa transactions are detached as part of executing XA PREPARE.
Definition: sql_class.h:4987
constexpr size_t PREALLOC_NUM_HA
Definition: sql_class.h:201
void thd_exit_cond(void *opaque_thd, const PSI_stage_info *stage, const char *src_function, const char *src_file, int src_line)
Set thread leaving a condition.
Definition: sql_thd_internal_api.cc:203
std::stack< Event_tracking_data > Event_tracking_data_stack
Definition: sql_class.h:926
bool add_item_to_list(THD *thd, Item *item)
Definition: sql_class.cc:3076
enum_mem_cnt_mode
Definition: sql_class.h:233
@ MEM_CNT_DEFAULT
Memory counter object doesn't update global memory counter and doesn't throw OOM error.
Definition: sql_class.h:238
@ MEM_CNT_GENERATE_ERROR
if MEM_CNT_GENERATE_ERROR is set, memory counter object generates OOM error if any.
Definition: sql_class.h:248
@ MEM_CNT_UPDATE_GLOBAL_COUNTER
if MEM_CNT_UPDATE_GLOBAL_COUNTER is set, memory counter object updates global memory counter.
Definition: sql_class.h:243
@ MEM_CNT_GENERATE_LOG_ERROR
if MEM_CNT_GENERATE_LOG_ERROR is set, memory counter object generates OOM error to error log if any.
Definition: sql_class.h:253
thread_local TDM expected_from_debug_flag
Definition: sql_class.h:207
Secondary_engine_optimization
Enum that represents which phase of secondary engine optimization the current statement is in.
Definition: sql_class.h:713
@ SECONDARY
The current statement should use tables from a secondary storage engine if possible.
@ PRIMARY_ONLY
The current statement should only use tables from primary storage engines.
@ PRIMARY_TENTATIVELY
The current statement should only use tables from the primary storage engine.
bool is_engine_substitution_allowed(const THD *thd)
Check if engine substitution is allowed in the current thread context.
Definition: sql_class.h:4942
void my_ok(THD *thd, ulonglong affected_rows=0, ulonglong id=0, const char *message=nullptr)
A short cut for thd->get_stmt_da()->set_ok_status().
Definition: sql_class.cc:3744
void thd_enter_cond(void *opaque_thd, mysql_cond_t *cond, mysql_mutex_t *mutex, const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, int src_line)
Set thread entering a condition.
Definition: sql_thd_internal_api.cc:190
char const * show_system_thread(enum_thread_type thread)
Definition: sql_class.h:763
#define RETURN_NAME_AS_STRING(NAME)
void thd_set_waiting_for_disk_space(void *opaque_thd, const bool waiting)
Definition: sql_thd_internal_api.cc:223
TDM
Definition: sql_class.h:206
@ ZERO
@ NOT_AVAILABLE
unsigned int thd_get_current_thd_terminology_use_previous()
Return @session.terminology_use_previous for the current THD.
Definition: sql_thd_api.cc:723
std::pair< Event_tracking_class, Event_tracking_information * > Event_tracking_data
Definition: sql_class.h:925
void thd_set_psi(THD *thd, PSI_thread *psi)
Set reference to Performance Schema object for THD object.
Definition: sql_thd_api.cc:131
bool secondary_engine_lock_tables_mode(const THD &cthd)
Return lock_tables_mode for secondary engine.
Definition: sql_class.h:4918
struct rpl_event_coordinates LOG_POS_COORD
the struct aggregates two parameters that identify an event uniquely in scope of communication of a p...
I_List< Item_change_record > Item_change_list
Definition: sql_class.h:553
File containing constants that can be used throughout the server.
enum_mark_columns
Definition: sql_const.h:230
Event_tracking_class
Event tracking classes If a new event tracking class is introduced, this class should be kept in sync...
Definition: sql_event_tracking_to_audit_event_mapping.h:41
static MEM_ROOT mem
Definition: sql_servers.cc:100
Our own string classes, used pervasively throughout the executor.
case opt name
Definition: sslopt-case.h:29
Definition: binlog.h:89
Definition: m_ctype.h:423
TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1100
bool is_empty() const
Return true if sidno is zero (and assert that gno is zero too in this case).
Definition: rpl_gtid.h:1125
void clear()
Set both components to 0.
Definition: rpl_gtid.h:1109
void dbug_print(const Tsid_map *tsid_map, const char *text="", bool need_lock=false) const
Print this Gtid to the trace file if debug is enabled; no-op otherwise.
Definition: rpl_gtid.h:1209
rpl_sidno sidno
SIDNO of this Gtid.
Definition: rpl_gtid.h:1104
Storage engine specific thread local data.
Definition: sql_class.h:794
void * ha_ptr_backup
A memorizer to engine specific "native" transaction object to provide storage engine detach-re-attach...
Definition: sql_class.h:810
void * ha_ptr
Storage engine specific thread local data.
Definition: sql_class.h:799
Ha_data()
Definition: sql_class.h:829
plugin_ref lock
NULL: engine is not bound to this thread non-NULL: engine is bound to this thread,...
Definition: sql_class.h:827
Ha_trx_info ha_info[2]
0: Life time: one statement within a transaction.
Definition: sql_class.h:821
Definition: table.h:2732
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3841
Definition: binlog.h:115
Metadata lock object key.
Definition: mdl.h:365
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:145
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42
Definition: mysql_lex_string.h:35
Definition: lock.h:39
Bison "location" class.
Definition: parse_location.h:43
Definition: mysql_com_server.h:59
Definition: mysql_com.h:914
State data storage for start_idle_wait_v1_t.
Definition: psi_idle_bits.h:52
Stage instrument information.
Definition: psi_stage_bits.h:74
Interface for an instrumented stage progress.
Definition: psi_stage_bits.h:63
State data storage for get_thread_statement_locker_v5_t.
Definition: psi_statement_bits.h:166
State data storage for get_thread_transaction_locker_v1_t, get_thread_transaction_locker_v1_t.
Definition: psi_transaction_bits.h:53
Definition: com_data.h:46
Definition: transaction_info.h:45
Per thread status variables.
Definition: system_variables.h:525
ulonglong last_query_partial_plans
Definition: system_variables.h:598
double last_query_cost
Definition: system_variables.h:597
Definition: table.h:1407
Definition: sql_lexer_thd.h:57
sql_mode_t sql_mode
Definition: sql_lexer_thd.h:58
const CHARSET_INFO * character_set_client
Definition: sql_lexer_thd.h:59
An utility struct for Attachable_trx.
Definition: sql_class.h:2021
bool m_in_lock_tables
THD::in_lock_tables value.
Definition: sql_class.h:2060
void backup(THD *thd)
Definition: sql_class.cc:361
ulonglong m_thd_option_bits
THD options.
Definition: sql_class.h:2051
~Transaction_state()
Definition: sql_class.cc:3084
void restore(THD *thd)
Definition: sql_class.cc:378
PSI_transaction_locker * m_transaction_psi
Current transaction instrumentation.
Definition: sql_class.h:2054
Prealloced_array< Ha_data, PREALLOC_NUM_HA > m_ha_data
Ha_data array.
Definition: sql_class.h:2042
uint m_server_status
Server status flags.
Definition: sql_class.h:2057
bool m_time_zone_used
Current time zone (i.e.
Definition: sql_class.h:2071
bool m_transaction_rollback_request
Transaction rollback request flag.
Definition: sql_class.h:2081
Transaction_ctx * m_trx
Transaction_ctx instance.
Definition: sql_class.h:2045
Open_tables_backup m_open_tables_state
Open-tables state.
Definition: sql_class.h:2033
bool m_tx_read_only
Transaction read-only state.
Definition: sql_class.h:2048
sql_mode_t m_sql_mode
SQL_MODE.
Definition: sql_class.h:2036
Transaction_state()
Definition: sql_class.cc:3080
enum_sql_command m_sql_command
SQL-command.
Definition: sql_class.h:2028
Query_tables_list * m_query_tables_list
Definition: sql_class.h:2030
enum_tx_isolation m_tx_isolation
Transaction isolation level.
Definition: sql_class.h:2039
Definition: sql_timer.cc:54
Definition: thr_lock.h:119
For locks with EXPLICIT duration, MDL returns a new ticket every time a lock is granted.
Definition: item_func.cc:5311
Definition: violite.h:320
void * ssl_arg
Definition: violite.h:416
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2734
Replacement of system's struct timeval to ensure we can carry 64 bit values even on a platform which ...
Definition: my_time_t.h:45
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Definition: mysql_com.h:1109
Definition: resource_group_basic_types.h:54
Definition: result.h:30
the struct aggregates two parameters that identify an event uniquely in scope of communication of a p...
Definition: sql_class.h:342
my_off_t pos
Definition: sql_class.h:344
char * file_name
Definition: sql_class.h:343
State data storage for digest_start, digest_add_token.
Definition: sql_digest_stream.h:36
Definition: sql_audit.h:56
Definition: sql_plugin_ref.h:45
Definition: mysqlslap.cc:219
Definition: sql_connect.h:70
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:83
constexpr sql_mode_t MODE_NO_ENGINE_SUBSTITUTION
Definition: system_variables.h:154
constexpr sql_mode_t MODE_TIME_TRUNCATE_FRACTIONAL
Definition: system_variables.h:161
constexpr sql_mode_t MODE_STRICT_TRANS_TABLES
Definition: system_variables.h:135
enum_binlog_format
Definition: system_variables.h:46
@ BINLOG_FORMAT_MIXED
statement if safe, otherwise row - autodetected
Definition: system_variables.h:47
@ BINLOG_FORMAT_ROW
row-based
Definition: system_variables.h:49
@ BINLOG_FORMAT_STMT
statement-based
Definition: system_variables.h:48
constexpr sql_mode_t MODE_STRICT_ALL_TABLES
Definition: system_variables.h:137
thr_lock_type
Definition: thr_lock.h:51
enum_thread_type
Definition: thread_type.h:34
@ NON_SYSTEM_THREAD
Definition: thread_type.h:35
@ SYSTEM_THREAD_BACKGROUND
Definition: thread_type.h:44
@ SYSTEM_THREAD_INIT_FILE
Definition: thread_type.h:48
@ SYSTEM_THREAD_SLAVE_IO
Definition: thread_type.h:36
@ SYSTEM_THREAD_EVENT_SCHEDULER
Definition: thread_type.h:39
@ SYSTEM_THREAD_COMPRESS_GTID_TABLE
Definition: thread_type.h:43
@ SYSTEM_THREAD_SLAVE_WORKER
Definition: thread_type.h:42
@ SYSTEM_THREAD_DD_RESTART
Definition: thread_type.h:46
@ SYSTEM_THREAD_SERVER_UPGRADE
Definition: thread_type.h:49
@ SYSTEM_THREAD_SERVER_INITIALIZE
Definition: thread_type.h:47
@ SYSTEM_THREAD_SLAVE_SQL
Definition: thread_type.h:37
@ SYSTEM_THREAD_DD_INITIALIZE
Definition: thread_type.h:45
@ SYSTEM_THREAD_INFO_REPOSITORY
Definition: thread_type.h:41
@ SYSTEM_THREAD_EVENT_WORKER
Definition: thread_type.h:40
@ SYSTEM_THREAD_NDBCLUSTER_BINLOG
Definition: thread_type.h:38
Include file for Sun RPC to compile out of the box.
Definition: dtoa.cc:588
command
Definition: version_token.cc:280
Vio Lite.
enum_vio_type
Definition: violite.h:79
#define SSL_handle
Definition: violite.h:454