My Project
mysqld.h
00001 /* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 #ifndef MYSQLD_INCLUDED
00017 #define MYSQLD_INCLUDED
00018 
00019 #include "my_global.h" /* MYSQL_PLUGIN_IMPORT, FN_REFLEN, FN_EXTLEN */
00020 #include "sql_bitmap.h"                         /* Bitmap */
00021 #include "my_decimal.h"                         /* my_decimal */
00022 #include "mysql_com.h"                     /* SERVER_VERSION_LENGTH */
00023 #include "my_atomic.h"                     /* my_atomic_rwlock_t */
00024 #include "mysql/psi/mysql_file.h"          /* MYSQL_FILE */
00025 #include "sql_list.h"                      /* I_List */
00026 #include "sql_cmd.h"                       /* SQLCOM_END */
00027 
00028 class THD;
00029 struct handlerton;
00030 class Time_zone;
00031 
00032 struct scheduler_functions;
00033 
00034 typedef struct st_mysql_const_lex_string LEX_CSTRING;
00035 typedef struct st_mysql_show_var SHOW_VAR;
00036 
00037 /*
00038   This forward declaration is used from C files where the real
00039   definition is included before.  Since C does not allow repeated
00040   typedef declarations, even when identical, the definition may not be
00041   repeated.
00042 */
00043 #ifndef CHARSET_INFO_DEFINED
00044 typedef struct charset_info_st CHARSET_INFO;
00045 #endif  /* CHARSET_INFO_DEFINED */
00046 
00047 #if MAX_INDEXES <= 64
00048 typedef Bitmap<64>  key_map;          /* Used for finding keys */
00049 #else
00050 typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
00051 #endif
00052 
00053         /* Bits from testflag */
00054 #define TEST_PRINT_CACHED_TABLES 1
00055 #define TEST_NO_KEY_GROUP        2
00056 #define TEST_MIT_THREAD         4
00057 #define TEST_BLOCKING           8
00058 #define TEST_KEEP_TMP_TABLES    16
00059 #define TEST_READCHECK          64      
00060 #define TEST_NO_EXTRA           128
00061 #define TEST_CORE_ON_SIGNAL     256     
00062 #define TEST_NO_STACKTRACE      512
00063 #define TEST_SIGINT             1024    
00064 #define TEST_SYNCHRONIZATION    2048    
00066 /* Function prototypes */
00067 void kill_mysql(void);
00068 void close_connection(THD *thd, uint sql_errno= 0);
00069 void handle_connection_in_main_thread(THD *thd);
00070 void create_thread_to_handle_connection(THD *thd);
00071 void destroy_thd(THD *thd);
00072 bool one_thread_per_connection_end(THD *thd, bool block_pthread);
00073 void kill_blocked_pthreads();
00074 void refresh_status(THD *thd);
00075 bool is_secure_file_path(char *path);
00076 void dec_connection_count();
00077 
00078 // These are needed for unit testing.
00079 void set_remaining_args(int argc, char **argv);
00080 int init_common_variables();
00081 void my_init_signals();
00082 bool gtid_server_init();
00083 void gtid_server_cleanup();
00084 
00085 extern "C" MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
00086 extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ;
00087 extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info;
00088 extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset;
00089 
00093 extern CHARSET_INFO *error_message_charset_info;
00094 
00095 extern CHARSET_INFO *character_set_filesystem;
00096 
00097 extern MY_BITMAP temp_pool;
00098 extern bool opt_large_files, server_id_supplied;
00099 extern bool opt_update_log, opt_bin_log, opt_error_log;
00100 extern my_bool opt_log, opt_slow_log, opt_log_raw;
00101 extern my_bool opt_backup_history_log;
00102 extern my_bool opt_backup_progress_log;
00103 extern ulonglong log_output_options;
00104 extern ulong log_backup_output_options;
00105 extern my_bool opt_log_queries_not_using_indexes;
00106 extern ulong opt_log_throttle_queries_not_using_indexes;
00107 extern bool opt_disable_networking, opt_skip_show_db;
00108 extern bool opt_skip_name_resolve;
00109 extern bool opt_ignore_builtin_innodb;
00110 extern my_bool opt_character_set_client_handshake;
00111 extern MYSQL_PLUGIN_IMPORT bool volatile abort_loop;
00112 extern bool in_bootstrap;
00113 extern my_bool opt_bootstrap;
00114 extern uint connection_count;
00115 extern my_bool opt_safe_user_create;
00116 extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
00117 extern my_bool opt_slave_compressed_protocol, use_temp_pool;
00118 extern ulong slave_exec_mode_options;
00119 extern ulonglong slave_type_conversions_options;
00120 extern my_bool read_only, opt_readonly;
00121 extern my_bool lower_case_file_system;
00122 extern ulonglong slave_rows_search_algorithms_options;
00123 #ifndef DBUG_OFF
00124 extern uint slave_rows_last_search_algorithm_used;
00125 #endif
00126 #ifndef EMBEDDED_LIBRARY
00127 extern "C" int check_enough_stack_size(int);
00128 #endif
00129 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
00130 extern my_bool opt_secure_auth;
00131 extern char* opt_secure_file_priv;
00132 extern char* opt_secure_backup_file_priv;
00133 extern size_t opt_secure_backup_file_priv_len;
00134 extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
00135 extern my_bool sp_automatic_privileges, opt_noacl;
00136 extern my_bool opt_old_style_user_limits, trust_function_creators;
00137 extern uint opt_crash_binlog_innodb;
00138 extern char *shared_memory_base_name, *mysqld_unix_port;
00139 extern my_bool opt_enable_shared_memory;
00140 extern char *default_tz_name;
00141 extern Time_zone *default_tz;
00142 extern char *default_storage_engine;
00143 extern char *default_tmp_storage_engine;
00144 extern bool opt_endinfo, using_udf_functions;
00145 extern my_bool locked_in_memory;
00146 extern bool opt_using_transactions;
00147 extern ulong max_long_data_size;
00148 extern ulong current_pid;
00149 extern ulong expire_logs_days;
00150 extern my_bool relay_log_recovery;
00151 extern uint sync_binlog_period, sync_relaylog_period, 
00152             sync_relayloginfo_period, sync_masterinfo_period,
00153             opt_mts_checkpoint_period, opt_mts_checkpoint_group;
00154 extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
00155 extern ulong tc_log_page_waits;
00156 extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
00157 extern my_bool relay_log_recovery;
00158 extern uint test_flags,select_errors,ha_open_options;
00159 extern uint protocol_version, mysqld_port, dropping_tables;
00160 extern ulong delay_key_write_options;
00161 extern char *opt_logname, *opt_slow_logname, *opt_bin_logname, 
00162             *opt_relay_logname;
00163 extern char *opt_backup_history_logname, *opt_backup_progress_logname,
00164             *opt_backup_settings_name;
00165 extern const char *log_output_str;
00166 extern const char *log_backup_output_str;
00167 extern char *mysql_home_ptr, *pidfile_name_ptr;
00168 extern char *my_bind_addr_str;
00169 extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
00170 extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
00171 extern char default_logfile_name[FN_REFLEN];
00172 extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
00173 /*Move UUID_LENGTH from item_strfunc.h*/
00174 #define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
00175 extern char server_uuid[UUID_LENGTH+1];
00176 extern const char *server_uuid_ptr;
00177 extern const double log_10[309];
00178 extern ulonglong keybuff_size;
00179 extern ulonglong thd_startup_options;
00180 extern ulong thread_id;
00181 extern ulong binlog_cache_use, binlog_cache_disk_use;
00182 extern ulong binlog_stmt_cache_use, binlog_stmt_cache_disk_use;
00183 extern ulong aborted_threads,aborted_connects;
00184 extern ulong delayed_insert_timeout;
00185 extern ulong delayed_insert_limit, delayed_queue_size;
00186 extern ulong delayed_insert_threads, delayed_insert_writes;
00187 extern ulong delayed_rows_in_use,delayed_insert_errors;
00188 extern int32 slave_open_temp_tables;
00189 extern ulong query_cache_size, query_cache_min_res_unit;
00190 extern ulong slow_launch_threads, slow_launch_time;
00191 extern ulong table_cache_size, table_def_size;
00192 extern ulong table_cache_size_per_instance, table_cache_instances;
00193 extern MYSQL_PLUGIN_IMPORT ulong max_connections;
00194 extern ulong max_digest_length;
00195 extern ulong max_connect_errors, connect_timeout;
00196 extern my_bool opt_slave_allow_batching;
00197 extern my_bool allow_slave_start;
00198 extern LEX_CSTRING reason_slave_blocked;
00199 extern ulong slave_trans_retries;
00200 extern uint  slave_net_timeout;
00201 extern ulong opt_mts_slave_parallel_workers;
00202 extern ulonglong opt_mts_pending_jobs_size_max;
00203 extern uint max_user_connections;
00204 extern ulong rpl_stop_slave_timeout;
00205 extern my_bool log_bin_use_v1_row_events;
00206 extern ulong what_to_log,flush_time;
00207 extern ulong max_prepared_stmt_count, prepared_stmt_count;
00208 extern ulong open_files_limit;
00209 extern ulong binlog_cache_size, binlog_stmt_cache_size;
00210 extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size;
00211 extern int32 opt_binlog_max_flush_queue_time;
00212 extern ulong max_binlog_size, max_relay_log_size;
00213 extern ulong slave_max_allowed_packet;
00214 extern ulong opt_binlog_rows_event_max_size;
00215 extern ulong binlog_checksum_options;
00216 extern const char *binlog_checksum_type_names[];
00217 extern my_bool opt_master_verify_checksum;
00218 extern my_bool opt_slave_sql_verify_checksum;
00219 extern my_bool enforce_gtid_consistency;
00220 extern my_bool binlog_gtid_simple_recovery;
00221 extern ulong binlog_error_action;
00222 enum enum_binlog_error_action
00223 {
00225   IGNORE_ERROR= 0,
00227   ABORT_SERVER= 1
00228 };
00229 extern const char *binlog_error_action_list[];
00230 enum enum_gtid_mode
00231 {
00233   GTID_MODE_OFF= 0,
00235   GTID_MODE_UPGRADE_STEP_1= 1,
00237   GTID_MODE_UPGRADE_STEP_2= 2,
00239   GTID_MODE_ON= 3
00240 };
00241 extern ulong gtid_mode;
00242 extern const char *gtid_mode_names[];
00243 extern TYPELIB gtid_mode_typelib;
00244 
00245 extern ulong max_blocked_pthreads;
00246 extern ulong stored_program_cache_size;
00247 extern ulong back_log;
00248 extern char language[FN_REFLEN];
00249 extern "C" MYSQL_PLUGIN_IMPORT ulong server_id;
00250 extern ulong concurrency;
00251 extern time_t server_start_time, flush_status_time;
00252 extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
00253 extern int mysql_unpacked_real_data_home_len;
00254 extern MYSQL_PLUGIN_IMPORT MY_TMPDIR mysql_tmpdir_list;
00255 extern const char *first_keyword, *delayed_user, *binary_keyword;
00256 extern MYSQL_PLUGIN_IMPORT const char  *my_localhost;
00257 extern MYSQL_PLUGIN_IMPORT const char **errmesg;                        /* Error messages */
00258 extern const char *myisam_recover_options_str;
00259 extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
00260 extern SHOW_VAR status_vars[];
00261 extern struct system_variables max_system_variables;
00262 extern struct system_status_var global_status_var;
00263 extern struct rand_struct sql_rand;
00264 extern const char *opt_date_time_formats[];
00265 extern handlerton *partition_hton;
00266 extern handlerton *myisam_hton;
00267 extern handlerton *heap_hton;
00268 extern uint opt_server_id_bits;
00269 extern ulong opt_server_id_mask;
00270 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
00271 /* engine specific hook, to be made generic */
00272 extern int(*ndb_wait_setup_func)(ulong);
00273 extern ulong opt_ndb_wait_setup;
00274 #endif
00275 extern const char *load_default_groups[];
00276 extern struct my_option my_long_options[];
00277 extern struct my_option my_long_early_options[];
00278 int handle_early_options();
00279 void adjust_related_options(ulong *requested_open_files);
00280 extern int mysqld_server_started;
00281 extern "C" MYSQL_PLUGIN_IMPORT int orig_argc;
00282 extern "C" MYSQL_PLUGIN_IMPORT char **orig_argv;
00283 extern pthread_attr_t connection_attrib;
00284 extern MYSQL_FILE *bootstrap_file;
00285 extern my_bool old_mode;
00286 extern my_bool avoid_temporal_upgrade;
00287 extern LEX_STRING opt_init_connect, opt_init_slave;
00288 extern int bootstrap_error;
00289 extern char err_shared_dir[];
00290 extern TYPELIB thread_handling_typelib;
00291 extern my_decimal decimal_zero;
00292 extern ulong connection_errors_select;
00293 extern ulong connection_errors_accept;
00294 extern ulong connection_errors_tcpwrap;
00295 extern ulong connection_errors_internal;
00296 extern ulong connection_errors_max_connection;
00297 extern ulong connection_errors_peer_addr;
00298 extern ulong log_warnings;
00300 extern uint host_cache_size;
00301 void init_sql_statement_names();
00302 
00303 /*
00304   THR_MALLOC is a key which will be used to set/get MEM_ROOT** for a thread,
00305   using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
00306 */
00307 extern pthread_key(MEM_ROOT**,THR_MALLOC);
00308 
00309 #ifdef HAVE_PSI_INTERFACE
00310 #ifdef HAVE_MMAP
00311 extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active,
00312        key_LOCK_pool;
00313 #endif /* HAVE_MMAP */
00314 
00315 #ifdef HAVE_OPENSSL
00316 extern PSI_mutex_key key_LOCK_des_key_file;
00317 #endif
00318 
00319 extern PSI_mutex_key key_BINLOG_LOCK_commit;
00320 extern PSI_mutex_key key_BINLOG_LOCK_commit_queue;
00321 extern PSI_mutex_key key_BINLOG_LOCK_done;
00322 extern PSI_mutex_key key_BINLOG_LOCK_flush_queue;
00323 extern PSI_mutex_key key_BINLOG_LOCK_index;
00324 extern PSI_mutex_key key_BINLOG_LOCK_log;
00325 extern PSI_mutex_key key_BINLOG_LOCK_sync;
00326 extern PSI_mutex_key key_BINLOG_LOCK_sync_queue;
00327 extern PSI_mutex_key key_BINLOG_LOCK_xids;
00328 extern PSI_mutex_key
00329   key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
00330   key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
00331   key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
00332   key_LOCK_gdl, key_LOCK_global_system_variables,
00333   key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager,
00334   key_LOCK_prepared_stmt_count,
00335   key_LOCK_sql_slave_skip_counter,
00336   key_LOCK_slave_net_timeout,
00337   key_LOCK_server_started, key_LOCK_status,
00338   key_LOCK_table_share, key_LOCK_thd_data,
00339   key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
00340   key_master_info_data_lock, key_master_info_run_lock,
00341   key_master_info_sleep_lock,
00342   key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
00343   key_relay_log_info_sleep_lock,
00344   key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
00345   key_mutex_slave_parallel_pend_jobs, key_mutex_mts_temp_tables_lock,
00346   key_mutex_slave_parallel_worker,
00347   key_mutex_slave_parallel_worker_count,
00348   key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data,
00349   key_LOCK_error_messages, key_LOCK_thread_count, key_LOCK_thd_remove,
00350   key_LOCK_log_throttle_qni;
00351 extern PSI_mutex_key key_RELAYLOG_LOCK_commit;
00352 extern PSI_mutex_key key_RELAYLOG_LOCK_commit_queue;
00353 extern PSI_mutex_key key_RELAYLOG_LOCK_done;
00354 extern PSI_mutex_key key_RELAYLOG_LOCK_flush_queue;
00355 extern PSI_mutex_key key_RELAYLOG_LOCK_index;
00356 extern PSI_mutex_key key_RELAYLOG_LOCK_log;
00357 extern PSI_mutex_key key_RELAYLOG_LOCK_sync;
00358 extern PSI_mutex_key key_RELAYLOG_LOCK_sync_queue;
00359 extern PSI_mutex_key key_RELAYLOG_LOCK_xids;
00360 extern PSI_mutex_key key_LOCK_sql_rand;
00361 extern PSI_mutex_key key_gtid_ensure_index_mutex;
00362 extern PSI_mutex_key key_LOCK_thread_created;
00363 
00364 extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
00365   key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
00366   key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock,
00367   key_rwlock_global_sid_lock;
00368 
00369 #ifdef HAVE_MMAP
00370 extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
00371 #endif /* HAVE_MMAP */
00372 
00373 extern PSI_cond_key key_BINLOG_update_cond,
00374   key_COND_cache_status_changed, key_COND_manager,
00375   key_COND_server_started,
00376   key_delayed_insert_cond, key_delayed_insert_cond_client,
00377   key_item_func_sleep_cond, key_master_info_data_cond,
00378   key_master_info_start_cond, key_master_info_stop_cond,
00379   key_master_info_sleep_cond,
00380   key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
00381   key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
00382   key_relay_log_info_sleep_cond, key_cond_slave_parallel_pend_jobs,
00383   key_cond_slave_parallel_worker,
00384   key_TABLE_SHARE_cond, key_user_level_lock_cond,
00385   key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache;
00386 extern PSI_cond_key key_BINLOG_COND_done;
00387 extern PSI_cond_key key_RELAYLOG_COND_done;
00388 extern PSI_cond_key key_RELAYLOG_update_cond;
00389 extern PSI_cond_key key_BINLOG_prep_xids_cond;
00390 extern PSI_cond_key key_RELAYLOG_prep_xids_cond;
00391 extern PSI_cond_key key_gtid_ensure_index_cond;
00392 
00393 extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
00394   key_thread_handle_manager, key_thread_kill_server, key_thread_main,
00395   key_thread_one_connection, key_thread_signal_hand;
00396 
00397 #ifdef HAVE_MMAP
00398 extern PSI_file_key key_file_map;
00399 #endif /* HAVE_MMAP */
00400 
00401 extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
00402   key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
00403   key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
00404   key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
00405   key_file_master_info, key_file_misc, key_file_partition,
00406   key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
00407   key_file_trg, key_file_trn, key_file_init;
00408 extern PSI_file_key key_file_query_log, key_file_slow_log;
00409 extern PSI_file_key key_file_relaylog, key_file_relaylog_index;
00410 extern PSI_socket_key key_socket_tcpip, key_socket_unix, key_socket_client_connection;
00411 
00412 void init_server_psi_keys();
00413 #endif /* HAVE_PSI_INTERFACE */
00414 
00415 /*
00416   MAINTAINER: Please keep this list in order, to limit merge collisions.
00417   Hint: grep PSI_stage_info | sort -u
00418 */
00419 extern PSI_stage_info stage_after_create;
00420 extern PSI_stage_info stage_allocating_local_table;
00421 extern PSI_stage_info stage_alter_inplace_prepare;
00422 extern PSI_stage_info stage_alter_inplace;
00423 extern PSI_stage_info stage_alter_inplace_commit;
00424 extern PSI_stage_info stage_changing_master;
00425 extern PSI_stage_info stage_checking_master_version;
00426 extern PSI_stage_info stage_checking_permissions;
00427 extern PSI_stage_info stage_checking_privileges_on_cached_query;
00428 extern PSI_stage_info stage_checking_query_cache_for_query;
00429 extern PSI_stage_info stage_cleaning_up;
00430 extern PSI_stage_info stage_closing_tables;
00431 extern PSI_stage_info stage_connecting_to_master;
00432 extern PSI_stage_info stage_converting_heap_to_myisam;
00433 extern PSI_stage_info stage_copying_to_group_table;
00434 extern PSI_stage_info stage_copying_to_tmp_table;
00435 extern PSI_stage_info stage_copy_to_tmp_table;
00436 extern PSI_stage_info stage_creating_delayed_handler;
00437 extern PSI_stage_info stage_creating_sort_index;
00438 extern PSI_stage_info stage_creating_table;
00439 extern PSI_stage_info stage_creating_tmp_table;
00440 extern PSI_stage_info stage_deleting_from_main_table;
00441 extern PSI_stage_info stage_deleting_from_reference_tables;
00442 extern PSI_stage_info stage_discard_or_import_tablespace;
00443 extern PSI_stage_info stage_end;
00444 extern PSI_stage_info stage_executing;
00445 extern PSI_stage_info stage_execution_of_init_command;
00446 extern PSI_stage_info stage_explaining;
00447 extern PSI_stage_info stage_finished_reading_one_binlog_switching_to_next_binlog;
00448 extern PSI_stage_info stage_flushing_relay_log_and_master_info_repository;
00449 extern PSI_stage_info stage_flushing_relay_log_info_file;
00450 extern PSI_stage_info stage_freeing_items;
00451 extern PSI_stage_info stage_fulltext_initialization;
00452 extern PSI_stage_info stage_got_handler_lock;
00453 extern PSI_stage_info stage_got_old_table;
00454 extern PSI_stage_info stage_init;
00455 extern PSI_stage_info stage_insert;
00456 extern PSI_stage_info stage_invalidating_query_cache_entries_table;
00457 extern PSI_stage_info stage_invalidating_query_cache_entries_table_list;
00458 extern PSI_stage_info stage_killing_slave;
00459 extern PSI_stage_info stage_logging_slow_query;
00460 extern PSI_stage_info stage_making_temp_file_append_before_load_data;
00461 extern PSI_stage_info stage_making_temp_file_create_before_load_data;
00462 extern PSI_stage_info stage_manage_keys;
00463 extern PSI_stage_info stage_master_has_sent_all_binlog_to_slave;
00464 extern PSI_stage_info stage_opening_tables;
00465 extern PSI_stage_info stage_optimizing;
00466 extern PSI_stage_info stage_preparing;
00467 extern PSI_stage_info stage_purging_old_relay_logs;
00468 extern PSI_stage_info stage_query_end;
00469 extern PSI_stage_info stage_queueing_master_event_to_the_relay_log;
00470 extern PSI_stage_info stage_reading_event_from_the_relay_log;
00471 extern PSI_stage_info stage_registering_slave_on_master;
00472 extern PSI_stage_info stage_removing_duplicates;
00473 extern PSI_stage_info stage_removing_tmp_table;
00474 extern PSI_stage_info stage_rename;
00475 extern PSI_stage_info stage_rename_result_table;
00476 extern PSI_stage_info stage_requesting_binlog_dump;
00477 extern PSI_stage_info stage_reschedule;
00478 extern PSI_stage_info stage_searching_rows_for_update;
00479 extern PSI_stage_info stage_sending_binlog_event_to_slave;
00480 extern PSI_stage_info stage_sending_cached_result_to_client;
00481 extern PSI_stage_info stage_sending_data;
00482 extern PSI_stage_info stage_setup;
00483 extern PSI_stage_info stage_slave_has_read_all_relay_log;
00484 extern PSI_stage_info stage_sorting_for_group;
00485 extern PSI_stage_info stage_sorting_for_order;
00486 extern PSI_stage_info stage_sorting_result;
00487 extern PSI_stage_info stage_sql_thd_waiting_until_delay;
00488 extern PSI_stage_info stage_statistics;
00489 extern PSI_stage_info stage_storing_result_in_query_cache;
00490 extern PSI_stage_info stage_storing_row_into_queue;
00491 extern PSI_stage_info stage_system_lock;
00492 extern PSI_stage_info stage_update;
00493 extern PSI_stage_info stage_updating;
00494 extern PSI_stage_info stage_updating_main_table;
00495 extern PSI_stage_info stage_updating_reference_tables;
00496 extern PSI_stage_info stage_upgrading_lock;
00497 extern PSI_stage_info stage_user_lock;
00498 extern PSI_stage_info stage_user_sleep;
00499 extern PSI_stage_info stage_verifying_table;
00500 extern PSI_stage_info stage_waiting_for_delay_list;
00501 extern PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log;
00502 extern PSI_stage_info stage_waiting_for_handler_insert;
00503 extern PSI_stage_info stage_waiting_for_handler_lock;
00504 extern PSI_stage_info stage_waiting_for_handler_open;
00505 extern PSI_stage_info stage_waiting_for_insert;
00506 extern PSI_stage_info stage_waiting_for_master_to_send_event;
00507 extern PSI_stage_info stage_waiting_for_master_update;
00508 extern PSI_stage_info stage_waiting_for_relay_log_space;
00509 extern PSI_stage_info stage_waiting_for_slave_mutex_on_exit;
00510 extern PSI_stage_info stage_waiting_for_slave_thread_to_start;
00511 extern PSI_stage_info stage_waiting_for_query_cache_lock;
00512 extern PSI_stage_info stage_waiting_for_table_flush;
00513 extern PSI_stage_info stage_waiting_for_the_next_event_in_relay_log;
00514 extern PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position;
00515 extern PSI_stage_info stage_waiting_to_finalize_termination;
00516 extern PSI_stage_info stage_waiting_to_get_readlock;
00517 extern PSI_stage_info stage_slave_waiting_worker_to_release_partition;
00518 extern PSI_stage_info stage_slave_waiting_worker_to_free_events;
00519 extern PSI_stage_info stage_slave_waiting_worker_queue;
00520 extern PSI_stage_info stage_slave_waiting_event_from_coordinator;
00521 extern PSI_stage_info stage_slave_waiting_workers_to_exit;
00522 #ifdef HAVE_PSI_STATEMENT_INTERFACE
00523 
00527 extern PSI_statement_info sql_statement_info[(uint) SQLCOM_END + 1];
00528 
00533 extern PSI_statement_info com_statement_info[(uint) COM_END + 1];
00534 
00538 extern PSI_statement_info stmt_info_rpl;
00539 
00540 void init_sql_statement_info();
00541 void init_com_statement_info();
00542 #endif /* HAVE_PSI_STATEMENT_INTERFACE */
00543 
00544 #ifndef __WIN__
00545 extern pthread_t signal_thread;
00546 #endif
00547 
00548 #ifdef HAVE_OPENSSL
00549 extern struct st_VioSSLFd * ssl_acceptor_fd;
00550 #endif /* HAVE_OPENSSL */
00551 
00552 /*
00553   The following variables were under INNODB_COMPABILITY_HOOKS
00554  */
00555 extern my_bool opt_large_pages;
00556 extern uint opt_large_page_size;
00557 extern char lc_messages_dir[FN_REFLEN];
00558 extern char *lc_messages_dir_ptr, *log_error_file_ptr;
00559 extern MYSQL_PLUGIN_IMPORT char reg_ext[FN_EXTLEN];
00560 extern MYSQL_PLUGIN_IMPORT uint reg_ext_length;
00561 extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names;
00562 extern MYSQL_PLUGIN_IMPORT bool mysqld_embedded;
00563 extern ulong specialflag;
00564 extern uint mysql_data_home_len;
00565 extern uint mysql_real_data_home_len;
00566 extern const char *mysql_real_data_home_ptr;
00567 extern ulong thread_handling;
00568 extern MYSQL_PLUGIN_IMPORT char  *mysql_data_home;
00569 extern "C" MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH];
00570 extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
00571 extern char mysql_unpacked_real_data_home[];
00572 extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
00573 extern char default_logfile_name[FN_REFLEN];
00574 
00575 #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
00576 
00577 extern MYSQL_PLUGIN_IMPORT const key_map key_map_empty;
00578 extern MYSQL_PLUGIN_IMPORT key_map key_map_full;          /* Should be threaded as const */
00579 
00580 /*
00581   Server mutex locks and condition variables.
00582  */
00583 extern mysql_mutex_t
00584        LOCK_user_locks, LOCK_status,
00585        LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
00586        LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
00587        LOCK_slave_list, LOCK_active_mi, LOCK_manager,
00588        LOCK_global_system_variables, LOCK_user_conn, LOCK_log_throttle_qni,
00589        LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count,
00590        LOCK_sql_slave_skip_counter, LOCK_slave_net_timeout;
00591 #ifdef HAVE_OPENSSL
00592 extern mysql_mutex_t LOCK_des_key_file;
00593 #endif
00594 extern mysql_mutex_t LOCK_server_started;
00595 extern mysql_cond_t COND_server_started;
00596 extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
00597 extern mysql_rwlock_t LOCK_system_variables_hash;
00598 extern mysql_cond_t COND_manager;
00599 extern int32 thread_running;
00600 extern my_atomic_rwlock_t thread_running_lock;
00601 extern my_atomic_rwlock_t slave_open_temp_tables_lock;
00602 extern my_atomic_rwlock_t opt_binlog_max_flush_queue_time_lock;
00603 
00604 extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
00605             *opt_ssl_key, *opt_ssl_crl, *opt_ssl_crlpath;
00606 
00607 extern MYSQL_PLUGIN_IMPORT pthread_key(THD*, THR_THD);
00608 
00613 enum options_mysqld
00614 {
00615   OPT_to_set_the_start_number=256,
00616   OPT_BIND_ADDRESS,
00617   OPT_BINLOG_CHECKSUM,
00618   OPT_BINLOG_DO_DB,
00619   OPT_BINLOG_FORMAT,
00620   OPT_BINLOG_IGNORE_DB,
00621   OPT_BIN_LOG,
00622   OPT_BINLOGGING_IMPOSSIBLE_MODE,
00623   OPT_SIMPLIFIED_BINLOG_GTID_RECOVERY,
00624   OPT_BOOTSTRAP,
00625   OPT_CONSOLE,
00626   OPT_DEBUG_SYNC_TIMEOUT,
00627   OPT_DELAY_KEY_WRITE_ALL,
00628   OPT_ISAM_LOG,
00629   OPT_IGNORE_DB_DIRECTORY,
00630   OPT_KEY_BUFFER_SIZE,
00631   OPT_KEY_CACHE_AGE_THRESHOLD,
00632   OPT_KEY_CACHE_BLOCK_SIZE,
00633   OPT_KEY_CACHE_DIVISION_LIMIT,
00634   OPT_LC_MESSAGES_DIRECTORY,
00635   OPT_LOWER_CASE_TABLE_NAMES,
00636   OPT_MASTER_RETRY_COUNT,
00637   OPT_MASTER_VERIFY_CHECKSUM,
00638   OPT_POOL_OF_THREADS,
00639   OPT_REPLICATE_DO_DB,
00640   OPT_REPLICATE_DO_TABLE,
00641   OPT_REPLICATE_IGNORE_DB,
00642   OPT_REPLICATE_IGNORE_TABLE,
00643   OPT_REPLICATE_REWRITE_DB,
00644   OPT_REPLICATE_WILD_DO_TABLE,
00645   OPT_REPLICATE_WILD_IGNORE_TABLE,
00646   OPT_SERVER_ID,
00647   OPT_SKIP_HOST_CACHE,
00648   OPT_SKIP_LOCK,
00649   OPT_SKIP_NEW,
00650   OPT_SKIP_RESOLVE,
00651   OPT_SKIP_STACK_TRACE,
00652   OPT_SKIP_SYMLINKS,
00653   OPT_SLAVE_SQL_VERIFY_CHECKSUM,
00654   OPT_SSL_CA,
00655   OPT_SSL_CAPATH,
00656   OPT_SSL_CERT,
00657   OPT_SSL_CIPHER,
00658   OPT_SSL_KEY,
00659   OPT_THREAD_CONCURRENCY,
00660   OPT_UPDATE_LOG,
00661   OPT_WANT_CORE,
00662   OPT_ENGINE_CONDITION_PUSHDOWN,
00663   OPT_LOG_ERROR,
00664   OPT_MAX_LONG_DATA_SIZE,
00665   OPT_PLUGIN_LOAD,
00666   OPT_PLUGIN_LOAD_ADD,
00667   OPT_SSL_CRL,
00668   OPT_SSL_CRLPATH,
00669   OPT_PFS_INSTRUMENT,
00670   OPT_DEFAULT_AUTH,
00671   OPT_SECURE_AUTH,
00672   OPT_THREAD_CACHE_SIZE,
00673   OPT_HOST_CACHE_SIZE,
00674   OPT_TABLE_DEFINITION_CACHE,
00675   OPT_AVOID_TEMPORAL_UPGRADE,
00676   OPT_SHOW_OLD_TEMPORALS
00677 };
00678 
00679 
00683 enum enum_query_type
00684 {
00686   QT_ORDINARY= 0,
00688   QT_TO_SYSTEM_CHARSET= (1 << 0),
00690   QT_WITHOUT_INTRODUCERS= (1 << 1),
00692   QT_SHOW_SELECT_NUMBER= (1 << 2),
00694   QT_NO_DEFAULT_DB= (1 << 3),
00696   QT_DERIVED_TABLE_ONLY_ALIAS= (1 << 4)
00697 };
00698 
00699 /* query_id */
00700 typedef int64 query_id_t;
00701 extern query_id_t global_query_id;
00702 extern my_atomic_rwlock_t global_query_id_lock;
00703 
00704 void unireg_end(void) __attribute__((noreturn));
00705 
00706 /* increment query_id and return it.  */
00707 inline __attribute__((warn_unused_result)) query_id_t next_query_id()
00708 {
00709   query_id_t id;
00710   my_atomic_rwlock_wrlock(&global_query_id_lock);
00711   id= my_atomic_add64(&global_query_id, 1);
00712   my_atomic_rwlock_wrunlock(&global_query_id_lock);
00713   return (id+1);
00714 }
00715 
00716 /*
00717   TODO: Replace this with an inline function.
00718  */
00719 #ifndef EMBEDDED_LIBRARY
00720 extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
00721 #else
00722 extern "C" void unireg_clear(int exit_code);
00723 #define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0)
00724 #endif
00725 
00726 inline void table_case_convert(char * name, uint length)
00727 {
00728   if (lower_case_table_names)
00729     files_charset_info->cset->casedn(files_charset_info,
00730                                      name, length, name, length);
00731 }
00732 
00733 ulong sql_rnd_with_mutex();
00734 
00735 extern int32 num_thread_running;
00736 inline int32
00737 inc_thread_running()
00738 {
00739   int32 num_threads;
00740   my_atomic_rwlock_wrlock(&thread_running_lock);
00741   num_threads= my_atomic_add32(&num_thread_running, 1);
00742   my_atomic_rwlock_wrunlock(&thread_running_lock);
00743   return (num_threads+1);
00744 }
00745 
00746 inline int32
00747 dec_thread_running()
00748 {
00749   int32 num_threads;
00750   my_atomic_rwlock_wrlock(&thread_running_lock);
00751   num_threads= my_atomic_add32(&num_thread_running, -1);
00752   my_atomic_rwlock_wrunlock(&thread_running_lock);
00753   return (num_threads-1);
00754 }
00755 
00756 #if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32)
00757 extern "C" THD *_current_thd_noinline();
00758 #define _current_thd() _current_thd_noinline()
00759 #else
00760 /*
00761   THR_THD is a key which will be used to set/get THD* for a thread,
00762   using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
00763 */
00764 extern pthread_key(THD*, THR_THD);
00765 inline THD *_current_thd(void)
00766 {
00767   return my_pthread_getspecific_ptr(THD*,THR_THD);
00768 }
00769 #endif
00770 #define current_thd _current_thd()
00771 
00772 extern const char *MY_BIND_ALL_ADDRESSES;
00773 
00774 #endif /* MYSQLD_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines