16 #ifndef SQL_CLASS_INCLUDED
17 #define SQL_CLASS_INCLUDED
21 #include "my_global.h"
26 #include <mysql/plugin_audit.h>
28 #include "rpl_tblmap.h"
30 #include "sql_locale.h"
31 #include "sql_profile.h"
32 #include "scheduler.h"
43 #include <mysql_com_server.h>
46 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
53 const char *set_thd_proc_info(
void *thd_arg,
const char *info,
54 const char *calling_func,
55 const char *calling_file,
56 const unsigned int calling_line);
58 #define thd_proc_info(thd, msg) \
59 set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
62 void set_thd_stage_info(
void *thd,
65 const char *calling_func,
66 const char *calling_file,
67 const unsigned int calling_line);
69 #define THD_STAGE_INFO(thd, stage) \
70 (thd)->enter_stage(& stage, NULL, __func__, __FILE__, __LINE__)
85 enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
87 enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
88 DELAY_KEY_WRITE_ALL };
89 enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
90 SLAVE_EXEC_MODE_IDEMPOTENT,
91 SLAVE_EXEC_MODE_LAST_BIT };
92 enum enum_slave_type_conversions { SLAVE_TYPE_CONVERSIONS_ALL_LOSSY,
93 SLAVE_TYPE_CONVERSIONS_ALL_NON_LOSSY,
94 SLAVE_TYPE_CONVERSIONS_ALL_UNSIGNED,
95 SLAVE_TYPE_CONVERSIONS_ALL_SIGNED};
96 enum enum_slave_rows_search_algorithms { SLAVE_ROWS_TABLE_SCAN = (1
U << 0),
97 SLAVE_ROWS_INDEX_SCAN = (1
U << 1),
98 SLAVE_ROWS_HASH_SCAN = (1
U << 2)};
100 enum enum_mark_columns
101 { MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
102 enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
105 #define MODE_REAL_AS_FLOAT 1
106 #define MODE_PIPES_AS_CONCAT 2
107 #define MODE_ANSI_QUOTES 4
108 #define MODE_IGNORE_SPACE 8
109 #define MODE_NOT_USED 16
110 #define MODE_ONLY_FULL_GROUP_BY 32
111 #define MODE_NO_UNSIGNED_SUBTRACTION 64
112 #define MODE_NO_DIR_IN_CREATE 128
113 #define MODE_POSTGRESQL 256
114 #define MODE_ORACLE 512
115 #define MODE_MSSQL 1024
116 #define MODE_DB2 2048
117 #define MODE_MAXDB 4096
118 #define MODE_NO_KEY_OPTIONS 8192
119 #define MODE_NO_TABLE_OPTIONS 16384
120 #define MODE_NO_FIELD_OPTIONS 32768
121 #define MODE_MYSQL323 65536L
122 #define MODE_MYSQL40 (MODE_MYSQL323*2)
123 #define MODE_ANSI (MODE_MYSQL40*2)
124 #define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2)
125 #define MODE_NO_BACKSLASH_ESCAPES (MODE_NO_AUTO_VALUE_ON_ZERO*2)
126 #define MODE_STRICT_TRANS_TABLES (MODE_NO_BACKSLASH_ESCAPES*2)
127 #define MODE_STRICT_ALL_TABLES (MODE_STRICT_TRANS_TABLES*2)
128 #define MODE_NO_ZERO_IN_DATE (MODE_STRICT_ALL_TABLES*2)
129 #define MODE_NO_ZERO_DATE (MODE_NO_ZERO_IN_DATE*2)
130 #define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
131 #define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
132 #define MODE_TRADITIONAL (MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
133 #define MODE_NO_AUTO_CREATE_USER (MODE_TRADITIONAL*2)
134 #define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2)
135 #define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2)
136 #define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31)
138 extern char internal_table_name[2];
139 extern char empty_c_string[1];
142 extern MYSQL_PLUGIN_IMPORT
const char **errmesg;
144 extern bool volatile shutdown_in_progress;
146 extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd);
147 extern "C" char **thd_query(MYSQL_THD thd);
167 DBUG_ASSERT(cs_arg != NULL);
169 string.length= length_arg;
172 inline char *str()
const {
return string.str; }
173 inline size_t length()
const {
return string.length; }
176 friend LEX_STRING * thd_query_string (MYSQL_THD thd);
177 friend char **thd_query(MYSQL_THD thd);
181 #define TC_LOG_PAGE_SIZE 8192
182 #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
184 #define TC_HEURISTIC_RECOVER_COMMIT 1
185 #define TC_HEURISTIC_RECOVER_ROLLBACK 2
186 extern ulong tc_heuristic_recover;
190 user_var_entry *user_var_event;
204 : field_name(name), length(len)
206 Key_part_spec(
const char *name,
const size_t name_len, uint len)
208 { field_name.str= (
char *)name; field_name.length= name_len; }
226 enum drop_type {
KEY, COLUMN, FOREIGN_KEY };
229 Alter_drop(
enum drop_type par_type,
const char *par_name)
230 :name(par_name), type(par_type)
232 DBUG_ASSERT(par_name != NULL);
248 :name(par_name), def(literal) {}
260 enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY};
270 :type(type_par), key_create_info(*key_info_arg), columns(cols),
271 name(name_arg), generated(generated_arg)
273 Key(
enum Keytype type_par,
const char *name_arg,
size_t name_len_arg,
276 :type(type_par), key_create_info(*key_info_arg), columns(cols),
277 generated(generated_arg)
279 name.str= (
char *)name_arg;
280 name.length= name_len_arg;
285 friend bool foreign_key_prefix(
Key *a,
Key *b);
291 {
return new (mem_root)
Key(*
this, mem_root); }
298 enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL,
299 FK_MATCH_PARTIAL, FK_MATCH_SIMPLE};
300 enum fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
301 FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_DEFAULT};
306 uint delete_opt, update_opt, match_opt;
310 uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg)
311 :
Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
312 ref_db(ref_db_arg), ref_table(ref_table_arg), ref_columns(ref_cols),
313 delete_opt(delete_opt_arg), update_opt(update_opt_arg),
314 match_opt(match_opt_arg)
325 {
return new (mem_root)
Foreign_key(*
this, mem_root); }
331 uint table_count,lock_count;
361 first_query_block= first_query_block_arg;
373 typedef enum enum_diag_condition_item_name
380 DIAG_CLASS_ORIGIN= 0,
381 FIRST_DIAG_SET_PROPERTY= DIAG_CLASS_ORIGIN,
382 DIAG_SUBCLASS_ORIGIN= 1,
383 DIAG_CONSTRAINT_CATALOG= 2,
384 DIAG_CONSTRAINT_SCHEMA= 3,
385 DIAG_CONSTRAINT_NAME= 4,
386 DIAG_CATALOG_NAME= 5,
391 DIAG_MESSAGE_TEXT= 10,
392 DIAG_MYSQL_ERRNO= 11,
393 LAST_DIAG_SET_PROPERTY= DIAG_MYSQL_ERRNO
394 } Diag_condition_item_name;
400 extern const LEX_STRING Diag_condition_item_names[];
404 extern LEX_CSTRING sql_statement_names[(uint) SQLCOM_END + 1];
409 #define THD_SENTRY_MAGIC 0xfeedd1ff
410 #define THD_SENTRY_GONE 0xdeadbeef
412 #define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC)
414 typedef ulonglong sql_mode_t;
427 ulong dynamic_variables_version;
428 char* dynamic_variables_ptr;
429 uint dynamic_variables_head;
430 uint dynamic_variables_size;
431 LIST *dynamic_variables_allocs;
433 ulonglong max_heap_table_size;
434 ulonglong tmp_table_size;
435 ulonglong long_query_time;
436 my_bool end_markers_in_json;
438 ulonglong optimizer_switch;
441 long optimizer_trace_offset;
442 long optimizer_trace_limit;
443 ulong optimizer_trace_max_mem_size;
446 ha_rows select_limit;
447 ha_rows max_join_size;
448 ulong auto_increment_increment, auto_increment_offset;
449 ulong bulk_insert_buff_size;
450 uint eq_range_index_dive_limit;
451 ulong join_buff_size;
452 ulong lock_wait_timeout;
453 ulong max_allowed_packet;
454 ulong max_error_count;
455 ulong max_length_for_sort_data;
456 ulong max_sort_length;
457 ulong max_tmp_tables;
458 ulong max_insert_delayed_threads;
459 ulong min_examined_row_limit;
460 ulong multi_range_count;
461 ulong myisam_repair_threads;
462 ulong myisam_sort_buff_size;
463 ulong myisam_stats_method;
464 ulong net_buffer_length;
465 ulong net_interactive_timeout;
466 ulong net_read_timeout;
467 ulong net_retry_count;
468 ulong net_wait_timeout;
469 ulong net_write_timeout;
470 ulong optimizer_prune_level;
471 ulong optimizer_search_depth;
472 ulong preload_buff_size;
473 ulong profiling_history_size;
474 ulong read_buff_size;
475 ulong read_rnd_buff_size;
476 ulong div_precincrement;
478 ulong max_sp_recursion_depth;
479 ulong default_week_format;
480 ulong max_seeks_for_key;
481 ulong range_alloc_block_size;
482 ulong query_alloc_block_size;
483 ulong query_prealloc_size;
484 ulong trans_alloc_block_size;
485 ulong trans_prealloc_size;
486 ulong group_concat_max_len;
489 my_bool binlog_direct_non_trans_update;
490 ulong binlog_row_image;
492 ulong completion_type;
493 ulong query_cache_type;
495 ulong updatable_views_with_limit;
496 uint max_user_connections;
506 my_bool low_priority_updates;
508 my_bool query_cache_wlock_invalidate;
509 my_bool engine_condition_pushdown;
510 my_bool keep_files_on_create;
512 my_bool old_alter_table;
542 my_bool explicit_defaults_for_timestamp;
544 my_bool sysdate_is_now;
545 my_bool binlog_rows_query_log_events;
547 double long_query_time_double;
549 my_bool pseudo_slave_mode;
565 ulonglong created_tmp_disk_tables;
566 ulonglong created_tmp_tables;
567 ulonglong ha_commit_count;
568 ulonglong ha_delete_count;
569 ulonglong ha_read_first_count;
570 ulonglong ha_read_last_count;
571 ulonglong ha_read_key_count;
572 ulonglong ha_read_next_count;
573 ulonglong ha_read_prev_count;
574 ulonglong ha_read_rnd_count;
575 ulonglong ha_read_rnd_next_count;
581 ulonglong ha_multi_range_read_init_count;
582 ulonglong ha_rollback_count;
583 ulonglong ha_update_count;
584 ulonglong ha_write_count;
585 ulonglong ha_prepare_count;
586 ulonglong ha_discover_count;
587 ulonglong ha_savepoint_count;
588 ulonglong ha_savepoint_rollback_count;
589 ulonglong ha_external_lock_count;
590 ulonglong opened_tables;
591 ulonglong opened_shares;
592 ulonglong table_open_cache_hits;
593 ulonglong table_open_cache_misses;
594 ulonglong table_open_cache_overflows;
595 ulonglong select_full_join_count;
596 ulonglong select_full_range_join_count;
597 ulonglong select_range_count;
598 ulonglong select_range_check_count;
599 ulonglong select_scan_count;
600 ulonglong long_query_count;
601 ulonglong filesort_merge_passes;
602 ulonglong filesort_range_count;
603 ulonglong filesort_rows;
604 ulonglong filesort_scan_count;
606 ulonglong com_stmt_prepare;
607 ulonglong com_stmt_reprepare;
608 ulonglong com_stmt_execute;
609 ulonglong com_stmt_send_long_data;
610 ulonglong com_stmt_fetch;
611 ulonglong com_stmt_reset;
612 ulonglong com_stmt_close;
614 ulonglong bytes_received;
615 ulonglong bytes_sent;
622 ulong com_stat[(uint) SQLCOM_END];
630 double last_query_cost;
631 ulonglong last_query_partial_plans;
640 #define last_system_status_var questions
642 void mark_transaction_to_rollback(THD *thd,
bool all);
654 mysqld_collation_get_by_name(
const char *
name,
659 my_charset_loader_init_mysys(&loader);
660 if (!(cs= my_collation_get_by_name(&loader, name, MYF(0))))
663 my_error(ER_UNKNOWN_COLLATION, MYF(0), err.ptr());
665 push_warning_printf(current_thd,
666 Sql_condition::WARN_LEVEL_WARN,
667 ER_UNKNOWN_COLLATION,
"%s", loader.error);
680 #define INIT_ARENA_DBUG_INFO is_backup_arena= 0; is_reprepared= FALSE;
682 #define INIT_ARENA_DBUG_INFO
695 bool is_backup_arena;
707 STMT_INITIALIZED= 0, STMT_INITIALIZED_FOR_SP= 1, STMT_PREPARED= 2,
708 STMT_CONVENTIONAL_EXECUTION= 3, STMT_EXECUTED= 4, STMT_ERROR= -1
716 STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE
719 Query_arena(
MEM_ROOT *mem_root_arg,
enum enum_state state_arg) :
720 free_list(0), mem_root(mem_root_arg), state(state_arg)
721 { INIT_ARENA_DBUG_INFO; }
726 Query_arena() { INIT_ARENA_DBUG_INFO; }
728 virtual Type
type()
const;
729 virtual ~Query_arena() {};
731 inline bool is_stmt_prepare()
const {
return state == STMT_INITIALIZED; }
732 inline bool is_stmt_prepare_or_first_sp_execute()
const
733 {
return (
int)state < (int)STMT_PREPARED; }
734 inline bool is_stmt_prepare_or_first_stmt_execute()
const
735 {
return (
int)state <= (int)STMT_PREPARED; }
736 inline bool is_conventional()
const
737 {
return state == STMT_CONVENTIONAL_EXECUTION; }
739 inline void* alloc(
size_t size) {
return alloc_root(mem_root,size); }
740 inline void* calloc(
size_t size)
743 if ((ptr=alloc_root(mem_root,size)))
744 memset(ptr, 0, size);
747 inline char *strdup(
const char *str)
748 {
return strdup_root(mem_root,str); }
749 inline char *strmake(
const char *str,
size_t size)
750 {
return strmake_root(mem_root,str,size); }
751 inline void *memdup(
const void *str,
size_t size)
752 {
return memdup_root(mem_root,str,size); }
753 inline void *memdup_w_gap(
const void *str,
size_t size, uint gap)
756 if ((ptr= alloc_root(mem_root,size+gap)))
757 memcpy(ptr,str,size);
761 void set_query_arena(Query_arena *
set);
765 virtual void cleanup_stmt();
787 class Statement:
public Query_arena
789 Statement(
const Statement &rhs);
790 Statement &operator=(
const Statement &rhs);
809 enum enum_mark_columns mark_used_columns;
848 inline char *
query()
const {
return query_string.str(); }
849 inline uint32 query_length()
const {
return query_string.length(); }
850 const CHARSET_INFO *query_charset()
const {
return query_string.charset(); }
851 void set_query_inner(
const CSET_STRING &string_arg)
853 query_string= string_arg;
855 void set_query_inner(
char *query_arg, uint32 query_length_arg,
858 set_query_inner(
CSET_STRING(query_arg, query_length_arg, cs_arg));
860 void reset_query_inner()
885 Statement(LEX *lex_arg,
MEM_ROOT *mem_root_arg,
886 enum enum_state state_arg, ulong id_arg);
887 virtual ~Statement();
890 virtual void set_statement(Statement *stmt);
891 void set_n_backup_statement(Statement *stmt, Statement *backup);
892 void restore_backup_statement(Statement *stmt, Statement *backup);
894 virtual Type
type()
const;
914 int insert(THD *thd, Statement *
statement);
919 stmt= (Statement*)my_hash_search(&names_hash, (uchar*)name->str,
924 Statement *find(ulong
id)
926 if (last_found_statement == 0 ||
id != last_found_statement->id)
929 stmt= (Statement *) my_hash_search(&
st_hash, (uchar *) &
id,
sizeof(
id));
930 if (stmt && stmt->name.str)
932 last_found_statement= stmt;
934 return last_found_statement;
942 void close_transient_cursors();
950 Statement *last_found_statement;
961 Ha_trx_info *ha_list;
1002 unsigned int m_unsafe_rollback_flags;
1007 static unsigned int const MODIFIED_NON_TRANS_TABLE= 0x01;
1008 static unsigned int const CREATED_TEMP_TABLE= 0x02;
1009 static unsigned int const DROPPED_TEMP_TABLE= 0x04;
1013 void dbug_unsafe_rollback_flags(
const char*
msg)
const
1015 DBUG_PRINT(
"debug", (
"%s.unsafe_rollback_flags: %s%s%s",
1017 FLAGSTR(m_unsafe_rollback_flags, MODIFIED_NON_TRANS_TABLE),
1018 FLAGSTR(m_unsafe_rollback_flags, CREATED_TEMP_TABLE),
1019 FLAGSTR(m_unsafe_rollback_flags, DROPPED_TEMP_TABLE)));
1023 bool cannot_safely_rollback()
const
1025 return m_unsafe_rollback_flags > 0;
1027 unsigned int get_unsafe_rollback_flags()
const
1029 return m_unsafe_rollback_flags;
1031 void set_unsafe_rollback_flags(
unsigned int flags)
1033 DBUG_PRINT(
"debug", (
"set_unsafe_rollback_flags: %d", flags));
1034 m_unsafe_rollback_flags=
flags;
1036 void add_unsafe_rollback_flags(
unsigned int flags)
1038 DBUG_PRINT(
"debug", (
"add_unsafe_rollback_flags: %d", flags));
1039 m_unsafe_rollback_flags|=
flags;
1041 void reset_unsafe_rollback_flags()
1043 DBUG_PRINT(
"debug", (
"reset_unsafe_rollback_flags"));
1044 m_unsafe_rollback_flags= 0;
1046 void mark_modified_non_trans_table()
1048 DBUG_PRINT(
"debug", (
"mark_modified_non_trans_table"));
1049 m_unsafe_rollback_flags|= MODIFIED_NON_TRANS_TABLE;
1051 bool has_modified_non_trans_table()
const
1053 return m_unsafe_rollback_flags & MODIFIED_NON_TRANS_TABLE;
1055 void mark_created_temp_table()
1057 DBUG_PRINT(
"debug", (
"mark_created_temp_table"));
1058 m_unsafe_rollback_flags|= CREATED_TEMP_TABLE;
1060 bool has_created_temp_table()
const
1062 return m_unsafe_rollback_flags & CREATED_TEMP_TABLE;
1064 void mark_dropped_temp_table()
1066 DBUG_PRINT(
"debug", (
"mark_dropped_temp_table"));
1067 m_unsafe_rollback_flags|= DROPPED_TEMP_TABLE;
1069 bool has_dropped_temp_table()
const
1071 return m_unsafe_rollback_flags & DROPPED_TEMP_TABLE;
1078 reset_unsafe_rollback_flags();
1080 bool is_empty()
const {
return ha_list == NULL; }
1104 ha_list_names(Ha_trx_info *ha_list,
char *
const buf_arg)
1106 char *
buf = buf_arg;
1109 buf += sprintf(buf,
"%s", ha_legacy_type_name(ha_list->m_ht->db_type));
1110 ha_list = ha_list->m_next;
1112 buf += sprintf(buf,
", ");
1115 sprintf(buf,
"<NONE>");
1122 void register_ha(THD_TRANS *trans,
handlerton *ht_arg)
1124 DBUG_ENTER(
"Ha_trx_info::register_ha");
1125 DBUG_PRINT(
"enter", (
"trans: 0x%llx, ht: 0x%llx (%s)",
1126 (ulonglong) trans, (ulonglong) ht_arg,
1127 ha_legacy_type_name(ht_arg->db_type)));
1128 DBUG_ASSERT(m_flags == 0);
1129 DBUG_ASSERT(m_ht == NULL);
1130 DBUG_ASSERT(m_next == NULL);
1133 m_flags= (int) TRX_READ_ONLY;
1135 m_next= trans->ha_list;
1136 trans->ha_list=
this;
1143 DBUG_ENTER(
"Ha_trx_info::reset");
1150 Ha_trx_info() { reset(); }
1152 void set_trx_read_write()
1154 DBUG_ASSERT(is_started());
1155 m_flags|= (int) TRX_READ_WRITE;
1157 bool is_trx_read_write()
const
1159 DBUG_ASSERT(is_started());
1160 return m_flags & (int) TRX_READ_WRITE;
1162 bool is_started()
const {
return m_ht != NULL; }
1164 void coalesce_trx_with(
const Ha_trx_info *stmt_trx)
1171 DBUG_ASSERT(is_started());
1172 if (stmt_trx->is_trx_read_write())
1173 set_trx_read_write();
1175 Ha_trx_info *next()
const
1177 DBUG_ASSERT(is_started());
1182 DBUG_ASSERT(is_started());
1186 enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
1188 Ha_trx_info *m_next;
1203 struct st_savepoint {
1204 struct st_savepoint *prev;
1207 Ha_trx_info *ha_list;
1212 enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED, XA_ROLLBACK_ONLY};
1213 extern const char *xa_state_names[];
1215 typedef struct st_xid_state {
1218 enum xa_states xa_state;
1225 extern HASH xid_cache;
1226 bool xid_cache_init(
void);
1227 void xid_cache_free(
void);
1228 XID_STATE *xid_cache_search(
XID *xid);
1229 bool xid_cache_insert(
XID *xid,
enum xa_states xa_state);
1230 bool xid_cache_insert(XID_STATE *xid_state);
1231 void xid_cache_delete(XID_STATE *xid_state);
1238 class Security_context {
1245 Security_context() {}
1254 char priv_user[USERNAME_LENGTH];
1255 char proxy_user[USERNAME_LENGTH + MAX_HOSTNAME + 5];
1257 char priv_host[MAX_HOSTNAME];
1259 const char *host_or_ip;
1260 ulong master_access;
1262 bool password_expired;
1267 inline char *priv_host_name()
1269 return (*priv_host ? priv_host : (
char *)
"%");
1272 bool set_user(
char *user_arg);
1275 String *get_external_user();
1276 void set_host(
const char *p);
1277 void set_ip(
const char *p);
1278 void set_external_user(
const char *p);
1279 void set_host(
const char *str,
size_t len);
1280 #ifndef NO_EMBEDDED_ACCESS_CHECKS
1282 change_security_context(THD *thd,
1286 Security_context **backup);
1289 restore_security_context(THD *thd, Security_context *backup);
1291 bool user_matches(Security_context *);
1305 ulonglong window_end;
1311 const ulong window_size;
1326 const char *summary_template;
1331 void new_window(ulonglong now);
1341 bool inc_log_count(ulong rate) {
return (++count > rate); }
1348 bool in_window(ulonglong now)
const {
return (now < window_end); };
1360 ulong prepare_summary(ulong rate);
1366 Log_throttle(ulong window_usecs,
const char *msg)
1367 : window_end(0), window_size(window_usecs),
1368 count(0), summary_template(msg)
1376 static const ulong LOG_THROTTLE_WINDOW_SIZE= 60000000;
1385 class Slow_log_throttle :
public Log_throttle
1394 Security_context aggregate_sctx;
1400 ulonglong total_exec_time;
1406 ulonglong total_lock_time;
1418 bool (*log_summary)(THD *,
const char *, uint);
1428 void new_window(ulonglong now);
1433 void print_summary(THD *thd, ulong suppressed,
1434 ulonglong print_lock_time,
1435 ulonglong print_exec_time);
1445 Slow_log_throttle(ulong *threshold,
mysql_mutex_t *lock, ulong window_usecs,
1446 bool (*logger)(THD *,
const char *, uint),
1462 bool flush(THD *thd);
1471 bool log(THD *thd,
bool eligible);
1480 class Error_log_throttle :
public Log_throttle
1486 void (*log_summary)(
const char *, ...);
1491 void print_summary(ulong suppressed)
1493 (*log_summary)(summary_template, suppressed);
1502 Error_log_throttle(ulong window_usecs,
1503 void (*logger)(
const char*, ...),
1505 : Log_throttle(window_usecs, msg), log_summary(logger)
1518 bool flush(THD *thd);
1530 extern Slow_log_throttle log_throttle_qni;
1540 struct Item_change_record:
public ilink<Item_change_record>
1554 enum enum_locked_tables_mode
1559 LTM_PRELOCKED_UNDER_LOCK_TABLES
1569 class Open_tables_state
1598 m_reprepare_observers.elements() > 0 ?
1599 *m_reprepare_observers.back() :
1604 { m_reprepare_observers.append(o); }
1607 {
return m_reprepare_observers.pop(); }
1609 void reset_reprepare_observers()
1610 { m_reprepare_observers.clear(); }
1625 TABLE *temporary_tables;
1626 TABLE *derived_tables;
1678 enum enum_locked_tables_mode locked_tables_mode;
1679 uint current_tablenr;
1682 BACKUPS_AVAIL = (1
U << 0)
1695 Open_tables_state() : state_flags(0
U) { }
1697 void set_open_tables_state(Open_tables_state *state);
1699 void reset_open_tables_state();
1709 class Open_tables_backup:
public Open_tables_state
1729 #define SUB_STMT_TRIGGER 1
1730 #define SUB_STMT_FUNCTION 2
1733 class Sub_statement_state
1736 ulonglong option_bits;
1737 ulonglong first_successful_insert_id_in_prev_stmt;
1738 ulonglong first_successful_insert_id_in_cur_stmt, insert_id_for_cur_row;
1741 ulonglong limit_found_rows;
1742 ha_rows cuted_fields, sent_row_count, examined_row_count;
1743 ulong client_capabilities;
1745 bool enable_slow_log;
1746 bool last_insert_id_used;
1747 SAVEPOINT *savepoints;
1748 enum enum_check_fields count_cuted_fields;
1753 enum enum_thread_type
1755 NON_SYSTEM_THREAD= 0,
1756 SYSTEM_THREAD_DELAYED_INSERT= 1,
1757 SYSTEM_THREAD_SLAVE_IO= 2,
1758 SYSTEM_THREAD_SLAVE_SQL= 4,
1759 SYSTEM_THREAD_NDBCLUSTER_BINLOG= 8,
1760 SYSTEM_THREAD_EVENT_SCHEDULER= 16,
1761 SYSTEM_THREAD_EVENT_WORKER= 32,
1762 SYSTEM_THREAD_INFO_REPOSITORY= 64,
1763 SYSTEM_THREAD_SLAVE_WORKER= 128
1767 show_system_thread(enum_thread_type thread)
1769 #define RETURN_NAME_AS_STRING(NAME) case (NAME): return #NAME
1771 static char buf[64];
1772 RETURN_NAME_AS_STRING(NON_SYSTEM_THREAD);
1773 RETURN_NAME_AS_STRING(SYSTEM_THREAD_DELAYED_INSERT);
1774 RETURN_NAME_AS_STRING(SYSTEM_THREAD_SLAVE_IO);
1775 RETURN_NAME_AS_STRING(SYSTEM_THREAD_SLAVE_SQL);
1776 RETURN_NAME_AS_STRING(SYSTEM_THREAD_NDBCLUSTER_BINLOG);
1777 RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_SCHEDULER);
1778 RETURN_NAME_AS_STRING(SYSTEM_THREAD_EVENT_WORKER);
1779 RETURN_NAME_AS_STRING(SYSTEM_THREAD_INFO_REPOSITORY);
1780 RETURN_NAME_AS_STRING(SYSTEM_THREAD_SLAVE_WORKER);
1782 sprintf(buf,
"<UNKNOWN SYSTEM THREAD: %d>", thread);
1785 #undef RETURN_NAME_AS_STRING
1793 class Internal_error_handler
1796 Internal_error_handler() :
1797 m_prev_internal_handler(NULL)
1800 virtual ~Internal_error_handler() {}
1827 virtual bool handle_condition(THD *thd,
1829 const char* sqlstate,
1830 Sql_condition::enum_warning_level
level,
1835 Internal_error_handler *m_prev_internal_handler;
1845 class Dummy_error_handler :
public Internal_error_handler
1848 bool handle_condition(THD *thd,
1850 const char* sqlstate,
1851 Sql_condition::enum_warning_level
level,
1868 class Drop_table_error_handler :
public Internal_error_handler
1871 Drop_table_error_handler() {}
1874 bool handle_condition(THD *thd,
1876 const char* sqlstate,
1877 Sql_condition::enum_warning_level
level,
1910 class Locked_tables_list
1917 TABLE **m_reopen_array;
1924 size_t m_locked_tables_count;
1926 Locked_tables_list()
1927 :m_locked_tables(NULL),
1928 m_locked_tables_last(&m_locked_tables),
1929 m_reopen_array(NULL),
1930 m_locked_tables_count(0)
1932 init_sql_alloc(&m_locked_tables_root, MEM_ROOT_BLOCK_SIZE, 0);
1934 void unlock_locked_tables(THD *thd);
1935 ~Locked_tables_list()
1937 unlock_locked_tables(0);
1939 bool init_locked_tables(THD *thd);
1940 TABLE_LIST *locked_tables() {
return m_locked_tables; }
1941 void unlink_from_list(THD *thd,
TABLE_LIST *table_list,
1942 bool remove_from_locked_tables);
1943 void unlink_all_closed_tables(THD *thd,
1945 size_t reopen_count);
1946 bool reopen_tables(THD *thd);
1971 Ha_trx_info ha_info[2];
1977 Ha_data() :ha_ptr(NULL) {}
1985 class Global_read_lock
1992 GRL_ACQUIRED_AND_BLOCKS_COMMIT
1996 : m_state(GRL_NONE),
1997 m_mdl_global_shared_lock(NULL),
1998 m_mdl_blocks_commits_lock(NULL)
2001 bool lock_global_read_lock(THD *thd);
2002 void unlock_global_read_lock(THD *thd);
2007 bool can_acquire_protection()
const
2011 my_error(ER_CANT_UPDATE_WITH_READLOCK, MYF(0));
2016 bool make_global_read_lock_block_commit(THD *thd);
2017 bool is_acquired()
const {
return m_state != GRL_NONE; }
2018 void set_explicit_lock_duration(THD *thd);
2020 enum_grl_state m_state;
2035 extern "C" void my_message_sql(uint error,
const char *str, myf MyFlags);
2044 my_micro_time_to_timeval(ulonglong micro_time,
struct timeval *tm)
2046 tm->tv_sec= (long) (micro_time / 1000000);
2047 tm->tv_usec= (long) (micro_time % 1000000);
2058 public Open_tables_state
2061 inline bool is_stmt_prepare()
const
2062 { DBUG_ASSERT(0);
return Statement::is_stmt_prepare(); }
2064 inline bool is_stmt_prepare_or_first_sp_execute()
const
2065 { DBUG_ASSERT(0);
return Statement::is_stmt_prepare_or_first_sp_execute(); }
2067 inline bool is_stmt_prepare_or_first_stmt_execute()
const
2068 { DBUG_ASSERT(0);
return Statement::is_stmt_prepare_or_first_stmt_execute(); }
2070 inline bool is_conventional()
const
2071 { DBUG_ASSERT(0);
return Statement::is_conventional(); }
2081 void reset_for_next_command();
2088 static const char *
const DEFAULT_WHERE;
2090 #ifdef EMBEDDED_LIBRARY
2092 unsigned long client_stmt_id;
2093 unsigned long client_param_count;
2100 void clear_data_list();
2109 #ifdef HAVE_QUERY_CACHE
2136 Statement_map stmt_map;
2161 Security_context main_security_ctx;
2162 Security_context *security_ctx;
2176 const char *proc_info;
2179 unsigned int m_current_stage_key;
2184 const char *calling_func,
2185 const char *calling_file,
2186 const unsigned int calling_line);
2188 const char *get_proc_info()
const
2189 {
return proc_info; }
2198 ulong client_capabilities;
2199 ulong max_client_packet_length;
2201 HASH handler_tables_hash;
2218 enum enum_server_command m_command;
2221 uint32 unmasked_server_id;
2229 ulonglong prior_thr_create_utime, thr_create_utime;
2230 ulonglong start_utime, utime_after_lock;
2232 thr_lock_type update_lock_default;
2246 uint fill_status_recursion_level;
2249 Ha_data ha_data[MAX_HA];
2257 void set_next_event_pos(
const char* _filename, ulonglong _pos);
2258 void clear_next_event_pos();
2265 uchar* binlog_row_event_extra_data;
2266 static bool binlog_row_event_extra_data_eq(
const uchar* a,
2269 #ifndef MYSQL_CLIENT
2270 int binlog_setup_trx_data();
2275 int binlog_write_table_map(
TABLE *
table,
bool is_transactional,
2276 bool binlog_rows_query);
2277 int binlog_write_row(
TABLE*
table,
bool is_transactional,
2278 const uchar *new_data,
2279 const uchar* extra_row_info);
2280 int binlog_delete_row(
TABLE*
table,
bool is_transactional,
2281 const uchar *old_data,
2282 const uchar* extra_row_info);
2283 int binlog_update_row(
TABLE*
table,
bool is_transactional,
2284 const uchar *old_data,
const uchar *new_data,
2285 const uchar* extra_row_info);
2286 void binlog_prepare_row_images(
TABLE*
table);
2288 void set_server_id(uint32 sid) { server_id = sid; }
2294 binlog_prepare_pending_rows_event(
TABLE*
table, uint32 serv_id,
2296 bool is_transactional,
2298 const uchar* extra_row_info);
2299 Rows_log_event* binlog_get_pending_rows_event(
bool is_transactional)
const;
2300 inline int binlog_flush_pending_rows_event(
bool stmt_end)
2302 return (binlog_flush_pending_rows_event(stmt_end, FALSE) ||
2303 binlog_flush_pending_rows_event(stmt_end, TRUE));
2305 int binlog_flush_pending_rows_event(
bool stmt_end,
bool is_transactional);
2315 int is_current_stmt_binlog_format_row()
const {
2316 DBUG_ASSERT(current_stmt_binlog_format == BINLOG_FORMAT_STMT ||
2317 current_stmt_binlog_format == BINLOG_FORMAT_ROW);
2318 return current_stmt_binlog_format == BINLOG_FORMAT_ROW;
2321 inline bool optimizer_switch_flag(ulonglong flag)
const
2323 return (variables.optimizer_switch & flag);
2326 enum binlog_filter_state
2328 BINLOG_FILTER_UNKNOWN,
2329 BINLOG_FILTER_CLEAR,
2333 inline void reset_binlog_local_stmt_filter()
2335 m_binlog_filter_state= BINLOG_FILTER_UNKNOWN;
2338 inline void clear_binlog_local_stmt_filter()
2340 DBUG_ASSERT(m_binlog_filter_state == BINLOG_FILTER_UNKNOWN);
2341 m_binlog_filter_state= BINLOG_FILTER_CLEAR;
2344 inline void set_binlog_local_stmt_filter()
2346 DBUG_ASSERT(m_binlog_filter_state == BINLOG_FILTER_UNKNOWN);
2347 m_binlog_filter_state= BINLOG_FILTER_SET;
2350 inline binlog_filter_state get_binlog_local_stmt_filter()
2352 return m_binlog_filter_state;
2363 binlog_filter_state m_binlog_filter_state;
2369 enum_binlog_format current_stmt_binlog_format;
2383 uint32 binlog_unsafe_warning_flags;
2389 uint binlog_table_maps;
2409 const char *m_trans_log_file;
2410 const char *m_trans_fixed_log_file;
2411 my_off_t m_trans_end_pos;
2415 void issue_unsafe_warnings();
2417 uint get_binlog_table_maps()
const {
2418 return binlog_table_maps;
2420 void clear_binlog_table_maps() {
2421 binlog_table_maps= 0;
2429 return binlog_accessed_db_names;
2436 void clear_binlog_accessed_db_names() { binlog_accessed_db_names= NULL; }
2439 void add_to_binlog_accessed_dbs(
const char *db);
2445 struct st_transactions {
2446 SAVEPOINT *savepoints;
2449 XID_STATE xid_state;
2483 DBUG_ENTER(
"THD::st_transaction::cleanup");
2493 if (!xid_state.rm_error)
2494 xid_state.xid.null();
2495 free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
2500 return (all.ha_list != NULL);
2504 memset(
this, 0,
sizeof(*
this));
2505 xid_state.xid.null();
2506 init_sql_alloc(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
2508 void push_unsafe_rollback_warnings(THD *thd)
2510 if (all.has_modified_non_trans_table())
2511 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
2512 ER_WARNING_NOT_COMPLETE_ROLLBACK,
2513 ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
2515 if (all.has_created_temp_table())
2516 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
2517 ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_CREATED_TEMP_TABLE,
2518 ER(ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_CREATED_TEMP_TABLE));
2520 if (all.has_dropped_temp_table())
2521 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
2522 ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE,
2523 ER(ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE));
2525 void merge_unsafe_rollback_flags()
2532 all.add_unsafe_rollback_flags(stmt.get_unsafe_rollback_flags());
2535 Global_read_lock global_read_lock;
2540 #ifdef SIGNAL_WITH_VIO_SHUTDOWN
2550 Item_change_list change_list;
2564 Query_arena *stmt_arena;
2570 table_map table_map_for_update;
2573 bool arg_of_last_insert_id_function;
2586 ulonglong first_successful_insert_id_in_prev_stmt;
2593 ulonglong first_successful_insert_id_in_prev_stmt_for_binlog;
2599 ulonglong first_successful_insert_id_in_cur_stmt;
2628 bool stmt_depends_on_first_successful_insert_id_in_prev_stmt;
2682 inline void record_first_successful_insert_id_in_cur_stmt(ulonglong id_arg)
2684 if (first_successful_insert_id_in_cur_stmt == 0)
2685 first_successful_insert_id_in_cur_stmt= id_arg;
2687 inline ulonglong read_first_successful_insert_id_in_prev_stmt(
void)
2689 if (!stmt_depends_on_first_successful_insert_id_in_prev_stmt)
2692 first_successful_insert_id_in_prev_stmt_for_binlog=
2693 first_successful_insert_id_in_prev_stmt;
2694 stmt_depends_on_first_successful_insert_id_in_prev_stmt= 1;
2696 return first_successful_insert_id_in_prev_stmt;
2703 inline void force_one_auto_inc_interval(ulonglong next_id)
2705 auto_inc_intervals_forced.empty();
2706 auto_inc_intervals_forced.append(next_id, ULONGLONG_MAX, 0);
2709 ulonglong limit_found_rows;
2741 longlong m_row_count_func;
2744 inline longlong get_row_count_func()
const
2746 return m_row_count_func;
2749 inline void set_row_count_func(longlong row_count_func)
2751 m_row_count_func= row_count_func;
2754 ha_rows cuted_fields;
2761 ha_rows m_sent_row_count;
2773 ha_rows m_examined_row_count;
2781 {
return m_user_connect; }
2783 void increment_user_connections_counter();
2784 void decrement_user_connections_counter();
2786 void increment_con_per_hour_counter();
2788 void increment_updates_counter();
2790 void increment_questions_counter();
2792 void time_out_user_resource_limits();
2795 ha_rows get_sent_row_count()
const
2796 {
return m_sent_row_count; }
2798 ha_rows get_examined_row_count()
const
2799 {
return m_examined_row_count; }
2801 void set_sent_row_count(ha_rows count);
2802 void set_examined_row_count(ha_rows count);
2804 void inc_sent_row_count(ha_rows count);
2805 void inc_examined_row_count(ha_rows count);
2807 void inc_status_created_tmp_disk_tables();
2808 void inc_status_created_tmp_files();
2809 void inc_status_created_tmp_tables();
2810 void inc_status_select_full_join();
2811 void inc_status_select_full_range_join();
2812 void inc_status_select_range();
2813 void inc_status_select_range_check();
2814 void inc_status_select_scan();
2815 void inc_status_sort_merge_passes();
2816 void inc_status_sort_range();
2817 void inc_status_sort_rows(ha_rows count);
2818 void inc_status_sort_scan();
2819 void set_status_no_index_used();
2820 void set_status_no_good_index_used();
2823 #if defined(ENABLED_PROFILING)
2824 PROFILING profiling;
2828 PSI_statement_locker *m_statement_psi;
2829 #ifdef HAVE_PSI_STATEMENT_INTERFACE
2831 PSI_statement_locker_state m_statement_state;
2834 PSI_idle_locker *m_idle_psi;
2835 #ifdef HAVE_PSI_IDLE_INTERFACE
2837 PSI_idle_locker_state m_idle_state;
2850 query_id_t query_id;
2854 ulong statement_id_counter;
2855 ulong rand_saved_seed1, rand_saved_seed2;
2857 my_thread_id thread_id;
2859 uint server_status,open_options;
2860 enum enum_thread_type system_thread;
2886 enum_tx_isolation tx_isolation;
2892 enum_check_fields count_cuted_fields;
2901 THD *next_to_commit;
2910 void set_trans_pos(
const char *
file, my_off_t pos)
2912 DBUG_ENTER(
"THD::set_trans_pos");
2913 DBUG_ASSERT(((file == 0) && (pos == 0)) || ((file != 0) && (pos != 0)));
2916 DBUG_PRINT(
"enter", (
"file: %s, pos: %llu", file, pos));
2918 m_trans_log_file= file + dirname_length(file);
2919 MEM_ROOT *log_file_mem_root= &main_mem_root;
2920 if (!m_trans_fixed_log_file)
2921 m_trans_fixed_log_file=
new (log_file_mem_root)
char[FN_REFLEN + 1];
2922 m_trans_fixed_log_file= strdup_root(log_file_mem_root,
2923 file + dirname_length(file));
2927 m_trans_log_file= NULL;
2928 m_trans_fixed_log_file= NULL;
2931 m_trans_end_pos= pos;
2932 DBUG_PRINT(
"return", (
"m_trans_log_file: %s, m_trans_fixed_log_file: %s, "
2933 "m_trans_end_pos: %llu", m_trans_log_file,
2934 m_trans_fixed_log_file, m_trans_end_pos));
2938 void get_trans_pos(
const char **file_var, my_off_t *pos_var)
const
2940 DBUG_ENTER(
"THD::get_trans_pos");
2942 *file_var = m_trans_log_file;
2944 *pos_var= m_trans_end_pos;
2945 DBUG_PRINT(
"return", (
"file: %s, pos: %llu",
2946 file_var ? *file_var :
"<none>",
2947 pos_var ? *pos_var : 0));
2951 void get_trans_fixed_pos(
const char **file_var, my_off_t *pos_var)
const
2953 DBUG_ENTER(
"THD::get_trans_fixed_pos");
2955 *file_var = m_trans_fixed_log_file;
2957 *pos_var= m_trans_end_pos;
2958 DBUG_PRINT(
"return", (
"file: %s, pos: %llu",
2959 file_var ? *file_var :
"<none>",
2960 pos_var ? *pos_var : 0));
2981 enum durability_properties durability_property;
2993 KILL_CONNECTION=ER_SERVER_SHUTDOWN,
2994 KILL_QUERY=ER_QUERY_INTERRUPTED,
2997 killed_state
volatile killed;
3000 char scramble[SCRAMBLE_LENGTH+1];
3003 bool slave_thread, one_shot_set;
3013 bool is_fatal_error;
3019 bool transaction_rollback_request;
3031 bool is_fatal_sub_stmt_error;
3032 bool query_start_used, query_start_usec_used;
3033 bool rand_used, time_zone_used;
3035 bool substitute_null_with_insert_id;
3036 bool in_lock_tables;
3043 bool is_slave_error;
3047 bool thread_specific_used;
3052 bool charset_is_system_charset, charset_is_collation_connection;
3053 bool charset_is_character_set_filesystem;
3054 bool enable_slow_log;
3055 bool abort_on_warning;
3058 bool derived_tables_processing;
3059 my_bool tablespace_op;
3067 uint query_name_consts;
3079 my_bool my_bool_value;
3082 ulonglong ulonglong_value;
3083 double double_value;
3097 bool unioned_events;
3103 bool unioned_events_trans;
3109 query_id_t first_query_id;
3117 Parser_state *m_parser_state;
3119 Locked_tables_list locked_tables_list;
3121 #ifdef WITH_PARTITION_STORAGE_ENGINE
3125 #ifndef EMBEDDED_LIBRARY
3136 unsigned long audit_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
3139 #if defined(ENABLED_DEBUG_SYNC)
3141 struct st_debug_sync_control *debug_sync_control;
3145 bool m_enable_plugins;
3147 THD(
bool enable_plugins=
true);
3164 void release_resources();
3165 bool release_resources_done()
const {
return m_release_resources_done; }
3168 bool m_release_resources_done;
3184 void change_user(
void);
3185 void cleanup_after_query();
3186 bool store_globals();
3187 bool restore_globals();
3188 #ifdef SIGNAL_WITH_VIO_SHUTDOWN
3189 inline void set_active_vio(
Vio* vio)
3195 inline void clear_active_vio()
3201 void shutdown_active_vio();
3203 void awake(THD::killed_state state_to_set);
3208 #ifndef MYSQL_CLIENT
3209 enum enum_binlog_query_type {
3219 int binlog_query(enum_binlog_query_type qtype,
3220 char const *
query, ulong query_len,
bool is_trans,
3221 bool direct,
bool suppress_use,
3230 const char *src_function,
const char *src_file,
3233 DBUG_ENTER(
"THD::enter_cond");
3235 DBUG_PRINT(
"debug", (
"thd: 0x%llx, mysys_var: 0x%llx, current_mutex: 0x%llx -> 0x%llx",
3237 (ulonglong) mysys_var,
3238 (ulonglong) mysys_var->current_mutex,
3239 (ulonglong) mutex));
3240 mysys_var->current_mutex = mutex;
3241 mysys_var->current_cond = cond;
3242 enter_stage(stage, old_stage, src_function, src_file, src_line);
3246 const char *src_function,
const char *src_file,
3249 DBUG_ENTER(
"THD::exit_cond");
3256 DBUG_PRINT(
"debug", (
"thd: 0x%llx, mysys_var: 0x%llx, current_mutex: 0x%llx -> 0x%llx",
3258 (ulonglong) mysys_var,
3259 (ulonglong) mysys_var->current_mutex,
3263 mysys_var->current_mutex = 0;
3264 mysys_var->current_cond = 0;
3265 enter_stage(stage, NULL, src_function, src_file, src_line);
3270 virtual int is_killed() {
return killed; }
3271 virtual THD* get_thd() {
return this; }
3297 bool needs_thr_lock_abort);
3301 inline sql_mode_t datetime_flags()
const
3303 return variables.sql_mode &
3304 (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES);
3306 inline bool is_strict_mode()
const
3308 return test(variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
3309 MODE_STRICT_ALL_TABLES));
3314 return variables.time_zone;
3316 inline time_t query_start()
3318 query_start_used= 1;
3319 return start_time.tv_sec;
3321 inline long query_start_usec()
3323 query_start_usec_used= 1;
3324 return start_time.tv_usec;
3326 inline timeval query_start_timeval()
3328 query_start_used= query_start_usec_used=
true;
3331 timeval query_start_timeval_trunc(uint decimals);
3332 inline void set_time()
3334 start_utime= utime_after_lock= my_micro_time();
3335 if (user_time.tv_sec || user_time.tv_usec)
3337 start_time= user_time;
3340 my_micro_time_to_timeval(start_utime, &start_time);
3342 #ifdef HAVE_PSI_THREAD_INTERFACE
3343 PSI_THREAD_CALL(set_thread_start_time)(start_time.tv_sec);
3346 inline void set_current_time()
3348 my_micro_time_to_timeval(my_micro_time(), &start_time);
3349 #ifdef HAVE_PSI_THREAD_INTERFACE
3350 PSI_THREAD_CALL(set_thread_start_time)(start_time.tv_sec);
3353 inline void set_time(
const struct timeval *t)
3355 start_time= user_time= *t;
3356 start_utime= utime_after_lock= my_micro_time();
3357 #ifdef HAVE_PSI_THREAD_INTERFACE
3358 PSI_THREAD_CALL(set_thread_start_time)(start_time.tv_sec);
3362 inline bool is_valid_time()
3364 return (IS_TIME_T_VALID_FOR_TIMESTAMP(start_time.tv_sec));
3366 void set_time_after_lock()
3368 utime_after_lock= my_micro_time();
3369 MYSQL_SET_STATEMENT_LOCK_TIME(m_statement_psi, (utime_after_lock - start_utime));
3371 ulonglong current_utime() {
return my_micro_time(); }
3380 void update_server_status()
3382 ulonglong end_utime_of_query= current_utime();
3383 if (end_utime_of_query > utime_after_lock + variables.long_query_time)
3384 server_status|= SERVER_QUERY_WAS_SLOW;
3386 inline ulonglong found_rows(
void)
3388 return limit_found_rows;
3413 inline bool in_multi_stmt_transaction_mode()
const
3415 return variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
3450 inline bool in_active_multi_stmt_transaction()
const
3452 return server_status & SERVER_STATUS_IN_TRANS;
3454 inline bool fill_derived_tables()
3456 return !stmt_arena->is_stmt_prepare() && !lex->only_view_structure();
3458 inline bool fill_information_schema_tables()
3460 return !stmt_arena->is_stmt_prepare();
3462 inline void* trans_alloc(
unsigned int size)
3464 return alloc_root(&transaction.mem_root,size);
3468 const char* str, uint length,
3469 bool allocate_lex_string);
3472 const char *from, uint from_length,
3479 void add_changed_table(
const char *key,
long key_length);
3481 int send_explain_fields(select_result *result);
3490 inline void clear_error()
3492 DBUG_ENTER(
"clear_error");
3493 if (get_stmt_da()->is_error())
3494 get_stmt_da()->reset_diagnostics_area();
3498 #ifndef EMBEDDED_LIBRARY
3499 inline bool vio_ok()
const {
return net.vio != 0; }
3508 return system_thread || (vio_ok() ? vio_is_connected(net.vio) : FALSE);
3511 inline bool vio_ok()
const {
return TRUE; }
3512 inline bool is_connected() {
return TRUE; }
3519 inline void fatal_error()
3521 DBUG_ASSERT(get_stmt_da()->is_error() || killed);
3523 DBUG_PRINT(
"error",(
"Fatal error set"));
3538 inline bool is_error()
const {
return get_stmt_da()->is_error(); }
3542 {
return m_stmt_da; }
3546 {
return m_stmt_da; }
3554 {
return variables.character_set_client; }
3555 void update_charset();
3557 void change_item_tree(
Item **place,
Item *new_value)
3560 if (!stmt_arena->is_conventional())
3563 (
"change_item_tree place %p old_value %p new_value %p",
3564 place, *place, new_value));
3565 nocheck_register_item_tree_change(place, *place, mem_root);
3583 void change_item_tree_place(
Item **old_ref,
Item **new_ref);
3584 void nocheck_register_item_tree_change(
Item **place,
Item *old_value,
3586 void rollback_item_tree_changes();
3592 void end_statement();
3593 inline int killed_errno()
const
3595 killed_state killed_val;
3596 return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;
3598 inline void send_kill_message()
const
3600 int err= killed_errno();
3601 if (err && !get_stmt_da()->is_set())
3603 if ((err == KILL_CONNECTION) && !shutdown_in_progress)
3613 my_message(err, ER(err), MYF(ME_FATALERROR));
3617 inline bool really_abort_on_warning()
3619 return (abort_on_warning &&
3620 (!transaction.stmt.cannot_safely_rollback() ||
3621 (variables.sql_mode & MODE_STRICT_ALL_TABLES)));
3623 void set_status_var_init();
3624 void reset_n_backup_open_tables_state(Open_tables_backup *backup);
3625 void restore_backup_open_tables_state(Open_tables_backup *backup);
3626 void reset_sub_statement_state(Sub_statement_state *backup, uint new_state);
3627 void restore_sub_statement_state(Sub_statement_state *backup);
3628 void set_n_backup_active_arena(Query_arena *
set, Query_arena *backup);
3629 void restore_active_arena(Query_arena *
set, Query_arena *backup);
3635 inline void set_current_stmt_binlog_format_row_if_mixed()
3637 DBUG_ENTER(
"set_current_stmt_binlog_format_row_if_mixed");
3655 if ((variables.binlog_format == BINLOG_FORMAT_MIXED) &&
3657 set_current_stmt_binlog_format_row();
3661 inline void set_current_stmt_binlog_format_row()
3663 DBUG_ENTER(
"set_current_stmt_binlog_format_row");
3664 current_stmt_binlog_format= BINLOG_FORMAT_ROW;
3667 inline void clear_current_stmt_binlog_format_row()
3669 DBUG_ENTER(
"clear_current_stmt_binlog_format_row");
3670 current_stmt_binlog_format= BINLOG_FORMAT_STMT;
3673 inline void reset_current_stmt_binlog_format_row()
3675 DBUG_ENTER(
"reset_current_stmt_binlog_format_row");
3692 (
"temporary_tables: %s, in_sub_stmt: %s, system_thread: %s",
3693 YESNO(temporary_tables), YESNO(in_sub_stmt),
3694 show_system_thread(system_thread)));
3695 if (in_sub_stmt == 0)
3697 if (variables.binlog_format == BINLOG_FORMAT_ROW)
3698 set_current_stmt_binlog_format_row();
3699 else if (temporary_tables == NULL)
3700 clear_current_stmt_binlog_format_row();
3708 return variables.gtid_next_list.is_non_null ?
3709 variables.gtid_next_list.gtid_set : NULL;
3713 const Gtid_set *get_gtid_next_list_const()
const
3715 return const_cast<THD *
>(
this)->get_gtid_next_list();
3723 Group_cache *get_group_cache(
bool is_transactional);
3739 void clear_owned_gtids()
3741 if (owned_gtid.sidno == -1)
3743 #ifdef HAVE_GTID_NEXT_LIST
3744 owned_gtid_set.
clear();
3749 owned_gtid.sidno= 0;
3773 bool set_db(
const char *new_db,
size_t new_db_len)
3783 if (db && new_db && db_length >= new_db_len)
3784 memcpy(db, new_db, new_db_len+1);
3789 db= my_strndup(new_db, new_db_len, MYF(MY_WME | ME_FATALERROR));
3793 db_length= db ? new_db_len : 0;
3795 result= new_db && !db;
3796 #ifdef HAVE_PSI_THREAD_INTERFACE
3798 PSI_THREAD_CALL(set_thread_db)(new_db,
static_cast<int>(new_db_len));
3814 void reset_db(
char *new_db,
size_t new_db_len)
3817 db_length= new_db_len;
3818 #ifdef HAVE_PSI_THREAD_INTERFACE
3819 PSI_THREAD_CALL(set_thread_db)(new_db,
static_cast<int>(new_db_len));
3827 bool copy_db_to(
char **p_db,
size_t *p_db_length)
3831 my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
3834 *p_db= strmake(db, db_length);
3835 *p_db_length= db_length;
3841 inline Internal_error_handler *get_internal_handler()
3842 {
return m_internal_handler; }
3848 void push_internal_handler(Internal_error_handler *
handler);
3860 bool handle_condition(uint sql_errno,
3861 const char* sqlstate,
3862 Sql_condition::enum_warning_level
level,
3870 Internal_error_handler *pop_internal_handler();
3877 void raise_error(uint
code);
3883 void raise_error_printf(uint
code, ...);
3889 void raise_warning(uint
code);
3895 void raise_warning_printf(uint
code, ...);
3901 void raise_note(uint
code);
3907 void raise_note_printf(uint
code, ...);
3920 friend void push_warning(THD*, Sql_condition::enum_warning_level, uint,
const char*);
3921 friend void my_message_sql(uint,
const char *, myf);
3933 const char* sqlstate,
3934 Sql_condition::enum_warning_level
level,
3939 virtual void set_statement(Statement *stmt);
3941 void set_command(
enum enum_server_command command);
3943 inline enum enum_server_command get_command()
const
3944 {
return m_command; }
3950 void set_query(
char *query_arg, uint32 query_length_arg,
3953 set_query(
CSET_STRING(query_arg, query_length_arg, cs_arg));
3955 void set_query(
char *query_arg, uint32 query_length_arg)
3957 set_query(
CSET_STRING(query_arg, query_length_arg, charset()));
3962 void set_query_and_id(
char *query_arg, uint32 query_length_arg,
3964 void set_query_id(query_id_t new_query_id);
3965 void set_open_tables(
TABLE *open_tables_arg)
3972 void enter_locked_tables_mode(enum_locked_tables_mode mode_arg)
3974 DBUG_ASSERT(locked_tables_mode == LTM_NONE);
3976 if (mode_arg == LTM_LOCK_TABLES)
3986 mdl_context.set_explicit_duration_for_all_locks();
3989 locked_tables_mode= mode_arg;
3991 void leave_locked_tables_mode();
3992 int decide_logging_format(
TABLE_LIST *tables);
4034 is_dml_gtid_compatible(
bool transactional_table,
4035 bool non_transactional_table,
4036 bool non_transactional_tmp_tables)
const;
4037 bool is_ddl_gtid_compatible()
const;
4038 void binlog_invoker() { m_binlog_invoker= TRUE; }
4039 bool need_binlog_invoker() {
return m_binlog_invoker; }
4040 void get_definer(
LEX_USER *definer);
4043 invoker_user= *user;
4044 invoker_host= *host;
4046 LEX_STRING get_invoker_user() {
return invoker_user; }
4047 LEX_STRING get_invoker_host() {
return invoker_host; }
4048 bool has_invoker() {
return invoker_user.length > 0; }
4054 int get_gis_debug() {
return gis_debug; }
4055 void set_gis_debug(
int arg) { gis_debug= arg; }
4061 Internal_error_handler *m_internal_handler;
4090 bool m_binlog_invoker;
4107 class Prepared_stmt_arena_holder
4118 Prepared_stmt_arena_holder(THD *thd,
bool activate_now_if_needed=
true)
4122 if (activate_now_if_needed &&
4123 !m_thd->stmt_arena->is_conventional() &&
4124 m_thd->mem_root != m_thd->stmt_arena->mem_root)
4126 m_thd->set_n_backup_active_arena(m_thd->stmt_arena, &m_backup);
4127 m_arena= m_thd->stmt_arena;
4135 ~Prepared_stmt_arena_holder()
4138 m_thd->restore_active_arena(m_arena, &m_backup);
4141 bool is_activated()
const
4142 {
return m_arena != NULL; }
4149 Query_arena *m_arena;
4152 Query_arena m_backup;
4159 my_ok(THD *thd, ulonglong affected_rows= 0, ulonglong
id= 0,
4162 thd->set_row_count_func(affected_rows);
4163 thd->get_stmt_da()->set_ok_status(affected_rows,
id,
message);
4172 thd->set_row_count_func(-1);
4173 thd->get_stmt_da()->set_eof_status(thd);
4176 #define tmp_disable_binlog(A) \
4177 {ulonglong tmp_disable_binlog__save_options= (A)->variables.option_bits; \
4178 (A)->variables.option_bits&= ~OPTION_BIN_LOG
4180 #define reenable_binlog(A) (A)->variables.option_bits= tmp_disable_binlog__save_options;}
4184 make_lex_string_root(
MEM_ROOT *mem_root,
4185 LEX_STRING *lex_str,
const char* str, uint length,
4186 bool allocate_lex_string);
4197 enum enum_filetype filetype;
4199 const String *field_term, *enclosed, *line_term, *line_start, *escaped;
4204 sql_exchange(
char *name,
bool dumpfile_flag,
4205 enum_filetype filetype_arg= FILETYPE_CSV);
4206 bool escaped_given(
void);
4218 SELECT_LEX_UNIT *unit;
4224 ha_rows estimated_rowcount;
4226 virtual ~select_result() {};
4227 virtual int prepare(
List<Item> &list, SELECT_LEX_UNIT *u)
4232 virtual int prepare2(
void) {
return 0; }
4238 virtual uint field_count(
List<Item> &fields)
const
4239 {
return fields.elements; }
4240 virtual bool send_result_set_metadata(
List<Item> &list, uint flags)=0;
4242 virtual bool initialize_tables (
JOIN *join=0) {
return 0; }
4243 virtual void send_error(uint errcode,
const char *err);
4244 virtual bool send_eof()=0;
4253 virtual void abort_result_set() {}
4258 virtual void cleanup();
4259 void set_thd(THD *thd_arg) { thd= thd_arg; }
4266 void reset_offset_limit_cnt() { unit->offset_limit_cnt= 0; }
4268 #ifdef EMBEDDED_LIBRARY
4269 virtual void begin_dataset() {}
4271 void begin_dataset() {}
4282 class select_result_interceptor:
public select_result
4285 select_result_interceptor() {}
4286 uint field_count(
List<Item> &fields)
const {
return 0; }
4287 bool send_result_set_metadata(
List<Item> &fields, uint flag) {
return FALSE; }
4291 class select_send :
public select_result {
4297 bool is_result_set_started;
4299 select_send() :is_result_set_started(FALSE) {}
4300 bool send_result_set_metadata(
List<Item> &list, uint flags);
4304 void abort_result_set();
4305 virtual void cleanup();
4309 class select_to_file :
public select_result_interceptor {
4311 sql_exchange *exchange;
4315 char path[FN_REFLEN];
4318 select_to_file(sql_exchange *ex) :exchange(ex), file(-1),row_count(0L)
4321 void send_error(uint errcode,
const char *err);
4327 #define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
4333 #define NUMERIC_CHARS ".0123456789e+-"
4336 class select_export :
public select_to_file {
4337 uint field_term_length;
4338 int field_sep_char,escape_char,line_sep_char;
4339 int field_term_char;
4345 bool is_ambiguous_field_sep;
4351 bool is_ambiguous_field_term;
4357 bool is_unsafe_field_sep;
4358 bool fixed_row_size;
4361 select_export(sql_exchange *ex) :select_to_file(ex) {}
4363 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
4368 class select_dump :
public select_to_file {
4370 select_dump(sql_exchange *ex) :select_to_file(ex) {}
4371 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
4380 class select_insert :
public select_result_interceptor {
4393 bool bulk_insert_started;
4395 ulonglong autoinc_value_of_last_inserted_row;
4398 bool insert_into_view;
4454 enum_duplicates duplic,
4456 :table_list(table_list_par),
4458 fields(target_or_source_columns),
4459 bulk_insert_started(false),
4460 autoinc_value_of_last_inserted_row(0),
4464 (target_columns == NULL || target_columns->elements != 0),
4470 insert_into_view(table_list_par && table_list_par->
view != 0)
4472 DBUG_ASSERT(target_or_source_columns != NULL);
4473 DBUG_ASSERT(target_columns == target_or_source_columns ||
4474 target_columns == NULL);
4480 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
4481 virtual int prepare2(
void);
4483 virtual void store_values(
List<Item> &values);
4484 void send_error(uint errcode,
const char *err);
4486 virtual void abort_result_set();
4498 class select_create:
public select_insert {
4513 List<Item> &select_fields,enum_duplicates duplic,
bool ignore,
4515 :select_insert (NULL,
4524 create_info(create_info_par),
4525 select_tables(select_tables_arg),
4526 alter_info(alter_info_arg),
4529 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
4531 int binlog_show_create_table(
TABLE **tables, uint count);
4533 void send_error(uint errcode,
const char *err);
4535 virtual void abort_result_set();
4538 const THD *get_thd(
void) {
return thd; }
4557 Item **items_to_copy;
4560 ha_rows end_write_records;
4586 uint sum_func_count;
4587 uint hidden_field_count;
4588 uint group_parts,group_length,group_null_parts;
4596 uint outer_sum_func_count;
4603 bool using_outer_summary_function;
4612 bool precomputed_group_by;
4613 bool force_copy_fields;
4620 bool skip_create_table;
4626 bool bit_fields_as_long;
4629 :copy_field(0), copy_field_end(0), group_parts(0),
4630 group_length(0), group_null_parts(0), outer_sum_func_count(0),
4631 using_outer_summary_function(0),
4632 schema_table(0), precomputed_group_by(0), force_copy_fields(0),
4633 skip_create_table(FALSE), bit_fields_as_long(0)
4640 inline void cleanup(
void)
4644 delete [] copy_field;
4646 copy_field_end= NULL;
4651 class select_union :
public select_result_interceptor
4653 TMP_TABLE_PARAM tmp_table_param;
4657 select_union() :
table(0) {}
4658 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
4663 bool create_result_table(THD *thd,
List<Item> *column_types,
4664 bool is_distinct, ulonglong options,
4665 const char *alias,
bool bit_fields_as_long,
4667 friend bool mysql_derived_create(THD *thd, LEX *lex,
TABLE_LIST *derived);
4671 class select_subselect :
public select_result_interceptor
4678 bool send_eof() {
return 0; };
4682 class select_singlerow_subselect :
public select_subselect
4686 :select_subselect(item_arg)
4692 class select_max_min_finder_subselect :
public select_subselect
4695 bool (select_max_min_finder_subselect::*op)();
4704 select_max_min_finder_subselect(
Item_subselect *item_arg,
bool mx,
4706 :select_subselect(item_arg), cache(0), fmax(mx), ignore_nulls(ignore_nulls)
4718 class select_exists_subselect :
public select_subselect
4722 :select_subselect(item_arg){}
4729 typedef struct st_sort_field {
4734 Item_result result_type;
4740 typedef struct st_sort_buffer {
4745 SORT_FIELD *sortorder;
4755 SELECT_LEX_UNIT *sel;
4758 :
table(table_arg), sel((SELECT_LEX_UNIT *)0)
4760 if (!force && (thd->client_capabilities & CLIENT_NO_SCHEMA))
4766 :
table(table_arg), sel((SELECT_LEX_UNIT *)0)
4776 inline Table_ident(SELECT_LEX_UNIT *s) : sel(s)
4779 db.str= empty_c_string;
4781 table.str= internal_table_name;
4784 bool is_derived_table()
const {
return test(sel); }
4785 inline void change_db(
char *db_name)
4787 db.str= db_name; db.length= (uint) strlen(db_name);
4792 class user_var_entry
4794 static const size_t extra_size=
sizeof(double);
4800 { m_ptr= NULL; m_length= 0; }
4801 void set_value(
char *value, ulong length)
4802 { m_ptr= value; m_length= length; }
4811 char *internal_buffer_ptr()
const
4812 {
return (
char *)
this + ALIGN_SIZE(
sizeof(user_var_entry)); }
4818 char *name_ptr()
const
4819 {
return internal_buffer_ptr() + extra_size; }
4826 bool realloc(uint length);
4834 {
return m_ptr && m_ptr != internal_buffer_ptr(); }
4864 collation.set(NULL, DERIVATION_IMPLICIT, 0);
4876 used_query_id= current_thd->query_id;
4877 set_type(STRING_RESULT);
4889 bool store(
void *from, uint length, Item_result
type);
4896 query_id_t update_query_id, used_query_id;
4912 bool store(
void *from, uint length, Item_result
type,
4913 const CHARSET_INFO *cs, Derivation dv,
bool unsigned_arg);
4918 void set_type(Item_result
type) { m_type=
type; }
4924 void set_null_value(Item_result
type)
4938 static user_var_entry *create(
const Name_string &name)
4940 user_var_entry *
entry;
4941 uint size= ALIGN_SIZE(
sizeof(user_var_entry)) +
4942 (name.
length() + 1) + extra_size;
4943 if (!(entry= (user_var_entry*) my_malloc(size, MYF(MY_WME |
4961 const char *ptr()
const {
return m_ptr; }
4962 ulong length()
const {
return m_length; }
4963 Item_result
type()
const {
return m_type; }
4965 double val_real(my_bool *null_value);
4966 longlong val_int(my_bool *null_value)
const;
4967 String *val_str(my_bool *null_value,
String *str, uint decimals);
4983 ulonglong max_in_memory_size;
4986 uchar *record_pointers;
4992 Unique(qsort_cmp2 comp_func,
void *comp_func_fixed_arg,
4993 uint size_arg, ulonglong max_in_memory_size_arg);
4995 ulong elements_in_tree() {
return tree.elements_in_tree; }
4996 inline bool unique_add(
void *ptr)
4998 DBUG_ENTER(
"unique_add");
4999 DBUG_PRINT(
"info", (
"tree %u - %lu", tree.elements_in_tree, max_elements));
5000 if (tree.elements_in_tree > max_elements && flush())
5002 DBUG_RETURN(!tree_insert(&tree, ptr, 0, tree.custom_arg));
5006 static double get_use_cost(uint *buffer, uint nkeys, uint key_size,
5007 ulonglong max_in_memory_size);
5008 inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size,
5009 ulonglong max_in_memory_size)
5011 register ulonglong max_elems_in_tree=
5012 (1 + max_in_memory_size / ALIGN_SIZE(
sizeof(
TREE_ELEMENT)+key_size));
5013 return (
int) (
sizeof(uint)*(1 + nkeys/max_elems_in_tree));
5017 bool walk(tree_walk_action action,
void *walk_action_arg);
5019 uint get_size()
const {
return size; }
5020 ulonglong get_max_in_memory_size()
const {
return max_in_memory_size; }
5022 friend int unique_write_to_file(uchar* key, element_count count, Unique *unique);
5023 friend int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique);
5027 class multi_delete :
public select_result_interceptor
5029 TABLE_LIST *delete_tables, *table_being_deleted;
5031 ha_rows deleted, found;
5036 bool transactional_tables;
5039 bool delete_while_scanning;
5047 multi_delete(
TABLE_LIST *dt, uint num_of_tables);
5049 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
5051 bool initialize_tables (
JOIN *join);
5052 void send_error(uint errcode,
const char *err);
5054 int do_table_deletes(
TABLE *
table,
bool ignore);
5056 inline ha_rows num_deleted()
5060 virtual void abort_result_set();
5068 class multi_update :
public select_result_interceptor
5072 TABLE_LIST *update_tables, *table_being_updated;
5073 TABLE **tmp_tables, *main_table, *table_to_update;
5074 TMP_TABLE_PARAM *tmp_table_param;
5075 ha_rows updated, found;
5077 List <Item> **fields_for_table, **values_for_table;
5085 enum enum_duplicates handle_duplicates;
5086 bool do_update, trans_safe;
5088 bool transactional_tables;
5115 enum_duplicates handle_duplicates,
bool ignore);
5117 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
5119 bool initialize_tables (
JOIN *join);
5120 void send_error(uint errcode,
const char *err);
5123 inline ha_rows num_found()
5127 inline ha_rows num_updated()
5131 virtual void abort_result_set();
5146 enum_field_types
type;
5147 my_var (
LEX_STRING& j,
bool i, uint o, enum_field_types t)
5153 class select_dumpvar :
public select_result_interceptor {
5157 select_dumpvar() { var_list.empty(); row_count= 0;}
5158 ~select_dumpvar() {}
5159 int prepare(
List<Item> &list, SELECT_LEX_UNIT *u);
5168 #define CF_CHANGES_DATA (1U << 0)
5170 #define CF_STATUS_COMMAND (1U << 2)
5171 #define CF_SHOW_TABLE_COMMAND (1U << 3)
5172 #define CF_WRITE_LOGS_COMMAND (1U << 4)
5186 #define CF_REEXECUTION_FRAGILE (1U << 5)
5198 #define CF_IMPLICIT_COMMIT_BEGIN (1U << 6)
5209 #define CF_IMPLICIT_COMMIT_END (1U << 7)
5216 #define CF_AUTO_COMMIT_TRANS (CF_IMPLICIT_COMMIT_BEGIN | CF_IMPLICIT_COMMIT_END)
5226 #define CF_DIAGNOSTIC_STMT (1U << 8)
5232 #define CF_CAN_GENERATE_ROW_EVENTS (1U << 9)
5238 #define CF_PREOPEN_TMP_TABLES (1U << 10)
5244 #define CF_HA_CLOSE (1U << 11)
5249 #define CF_CAN_BE_EXPLAINED (1U << 12)
5252 #define CF_OPTIMIZER_TRACE (1U << 14)
5258 #define CF_DISALLOW_IN_RO_TRANS (1U << 15)
5269 #define CF_SKIP_QUERY_ID (1U << 0)
5277 #define CF_SKIP_QUESTIONS (1U << 1)
5283 void mark_transaction_to_rollback(THD *thd,
bool all);
5287 inline bool add_item_to_list(THD *thd,
Item *item)
5289 return thd->lex->current_select->add_item_to_list(thd, item);
5292 inline bool add_value_to_list(THD *thd,
Item *value)
5294 return thd->lex->value_list.push_back(value);
5297 inline bool add_order_to_list(THD *thd,
Item *item,
bool asc)
5299 return thd->lex->current_select->add_order_to_list(thd, item, asc);
5302 inline bool add_gorder_to_list(THD *thd,
Item *item,
bool asc)
5304 return thd->lex->current_select->add_gorder_to_list(thd, item, asc);
5307 inline bool add_group_to_list(THD *thd,
Item *item,
bool asc)
5309 return thd->lex->current_select->add_group_to_list(thd, item, asc);