2012-02-16 10:48:16 +01:00
|
|
|
/* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
|
|
|
|
|
|
|
#ifndef MYSQLD_INCLUDED
|
|
|
|
#define MYSQLD_INCLUDED
|
|
|
|
|
|
|
|
#include "my_global.h" /* MYSQL_PLUGIN_IMPORT, FN_REFLEN, FN_EXTLEN */
|
|
|
|
#include "sql_bitmap.h" /* Bitmap */
|
|
|
|
#include "my_decimal.h" /* my_decimal */
|
|
|
|
#include "mysql_com.h" /* SERVER_VERSION_LENGTH */
|
|
|
|
#include "my_atomic.h" /* my_atomic_rwlock_t */
|
|
|
|
#include "mysql/psi/mysql_file.h" /* MYSQL_FILE */
|
|
|
|
#include "sql_list.h" /* I_List */
|
|
|
|
|
|
|
|
class THD;
|
2010-04-12 15:17:37 +02:00
|
|
|
struct handlerton;
|
2010-03-31 16:05:33 +02:00
|
|
|
class Time_zone;
|
|
|
|
|
2010-08-17 07:46:53 +02:00
|
|
|
struct scheduler_functions;
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
typedef struct st_mysql_const_lex_string LEX_CSTRING;
|
|
|
|
typedef struct st_mysql_show_var SHOW_VAR;
|
|
|
|
|
|
|
|
#if MAX_INDEXES <= 64
|
|
|
|
typedef Bitmap<64> key_map; /* Used for finding keys */
|
|
|
|
#else
|
|
|
|
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Bits from testflag */
|
|
|
|
#define TEST_PRINT_CACHED_TABLES 1
|
|
|
|
#define TEST_NO_KEY_GROUP 2
|
|
|
|
#define TEST_MIT_THREAD 4
|
|
|
|
#define TEST_BLOCKING 8
|
|
|
|
#define TEST_KEEP_TMP_TABLES 16
|
|
|
|
#define TEST_READCHECK 64 /**< Force use of readcheck */
|
|
|
|
#define TEST_NO_EXTRA 128
|
|
|
|
#define TEST_CORE_ON_SIGNAL 256 /**< Give core if signal */
|
|
|
|
#define TEST_SIGINT 1024 /**< Allow sigint on threads */
|
|
|
|
#define TEST_SYNCHRONIZATION 2048 /**< get server to do sleep in
|
|
|
|
some places */
|
|
|
|
/* Function prototypes */
|
|
|
|
void kill_mysql(void);
|
2010-12-15 23:59:21 +01:00
|
|
|
void close_connection(THD *thd, uint sql_errno= 0);
|
2010-03-31 16:05:33 +02:00
|
|
|
void handle_connection_in_main_thread(THD *thd);
|
|
|
|
void create_thread_to_handle_connection(THD *thd);
|
|
|
|
void unlink_thd(THD *thd);
|
|
|
|
bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
|
|
|
|
void flush_thread_cache();
|
|
|
|
void refresh_status(THD *thd);
|
2010-05-07 18:17:55 +02:00
|
|
|
bool is_secure_file_path(char *path);
|
2010-03-31 16:05:33 +02:00
|
|
|
|
2011-03-18 07:37:08 +01:00
|
|
|
extern "C" MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Character set of the buildin error messages loaded from errmsg.sys.
|
|
|
|
*/
|
|
|
|
extern CHARSET_INFO *error_message_charset_info;
|
|
|
|
|
|
|
|
extern CHARSET_INFO *character_set_filesystem;
|
|
|
|
|
|
|
|
extern MY_BITMAP temp_pool;
|
|
|
|
extern bool opt_large_files, server_id_supplied;
|
|
|
|
extern bool opt_update_log, opt_bin_log, opt_error_log;
|
2013-01-11 01:03:43 +01:00
|
|
|
extern my_bool opt_log, opt_slow_log, opt_bootstrap;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern my_bool opt_backup_history_log;
|
|
|
|
extern my_bool opt_backup_progress_log;
|
|
|
|
extern ulonglong log_output_options;
|
|
|
|
extern ulong log_backup_output_options;
|
|
|
|
extern my_bool opt_log_queries_not_using_indexes;
|
|
|
|
extern bool opt_disable_networking, opt_skip_show_db;
|
2010-04-19 14:09:44 +02:00
|
|
|
extern bool opt_skip_name_resolve;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern bool opt_ignore_builtin_innodb;
|
|
|
|
extern my_bool opt_character_set_client_handshake;
|
|
|
|
extern bool volatile abort_loop;
|
|
|
|
extern bool in_bootstrap;
|
2010-11-11 18:11:05 +01:00
|
|
|
extern uint volatile thread_count;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern uint connection_count;
|
2010-07-23 22:13:36 +02:00
|
|
|
extern my_bool opt_safe_user_create;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
|
|
|
|
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
|
2010-08-05 14:34:19 +02:00
|
|
|
extern ulong slave_exec_mode_options;
|
2012-10-03 00:44:54 +02:00
|
|
|
extern ulong slave_retried_transactions;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulonglong slave_type_conversions_options;
|
2010-12-07 18:08:54 +01:00
|
|
|
extern my_bool read_only, opt_readonly;
|
|
|
|
extern my_bool lower_case_file_system;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
|
|
|
|
extern my_bool opt_secure_auth;
|
|
|
|
extern char* opt_secure_file_priv;
|
|
|
|
extern char* opt_secure_backup_file_priv;
|
|
|
|
extern size_t opt_secure_backup_file_priv_len;
|
|
|
|
extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
|
|
|
|
extern my_bool sp_automatic_privileges, opt_noacl;
|
2012-06-03 02:19:01 +02:00
|
|
|
extern ulong use_stat_tables;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern my_bool opt_old_style_user_limits, trust_function_creators;
|
|
|
|
extern uint opt_crash_binlog_innodb;
|
|
|
|
extern char *shared_memory_base_name, *mysqld_unix_port;
|
|
|
|
extern my_bool opt_enable_shared_memory;
|
2012-03-01 12:41:49 +01:00
|
|
|
extern ulong opt_replicate_events_marked_for_skip;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern char *default_tz_name;
|
|
|
|
extern Time_zone *default_tz;
|
|
|
|
extern char *default_storage_engine;
|
|
|
|
extern bool opt_endinfo, using_udf_functions;
|
|
|
|
extern my_bool locked_in_memory;
|
|
|
|
extern bool opt_using_transactions;
|
2011-03-15 13:57:36 +01:00
|
|
|
extern ulong max_long_data_size;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulong current_pid;
|
|
|
|
extern ulong expire_logs_days;
|
|
|
|
extern my_bool relay_log_recovery;
|
|
|
|
extern uint sync_binlog_period, sync_relaylog_period,
|
|
|
|
sync_relayloginfo_period, sync_masterinfo_period;
|
|
|
|
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
|
|
|
|
extern ulong tc_log_page_waits;
|
|
|
|
extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
|
|
|
|
extern my_bool relay_log_recovery;
|
|
|
|
extern uint test_flags,select_errors,ha_open_options;
|
|
|
|
extern uint protocol_version, mysqld_port, dropping_tables;
|
2010-08-05 14:34:19 +02:00
|
|
|
extern ulong delay_key_write_options;
|
BUG#11745230: 12133: MASTER.INDEX FILE KEEPS MYSQLD FROM STARTING IF
BIN LOG HAS BEEN MOVED
When moving the binary/relay log files from one location to
another and restarting the server with a different log-bin or
relay-log paths, would cause the startup process to abort. The
root cause was that the server would not be able to find the log
files because it would consider old paths for entries in the
index file instead of the new location. What's even worse, the
relative paths would not be considered relative to the path
provided in log-bin and relay-log, but to mysql_data_dir.
We fix the cases where the server contains relative paths. When
the server is reading from the index file, it checks whether the
entry contains relative paths. If it does, we replace it with the
absolute path set in log-bin/relay-log option. Absolute paths
remain unchanged and the index must be manually edited to
consider the new log-bin and/or relay-log path (this should be
documented). This is a fix for a GA version, that does not break
behavior (that much).
For development versions, we should go with Zhenxing's approach
that removes paths altogether from index files.
mysql-test/include/begin_include_file.inc:
Added parameter to keep the begin_include_file.inc silent. Useful when
including scripts that contain platform dependent parameters, for example:
--let $rpl_server_parameters=--log-bin=$tmpdir/slave-bin --relay-log=$tmpdir/slave-relay-bin
--let $keep_include_silent=1
source include/rpl_start_server.inc;
--let $keep_include_silent=0
We want the paths ($tmpdir/slave-bin and $tmpdir/slave-relay-bin) not to be in the
result file.
mysql-test/suite/rpl/t/rpl_binlog_index.test:
Test case.
sql/log.cc:
When finding the corresponding log entry in the index file, we first
normalize the paths before doing the comparison. This will make relative
paths to be turned into absolute paths (based on the opt_bin_logname or
opt_relay_logname) and then compared against also, expanded paths entered,
through CHANGE MASTER for instance.
sql/log.h:
Added normalize_binlog_name, which turns relative paths, into absolute paths
given the parameter: is_relay_log ? opt_relay_logname : opt_bin_logname .
sql/mysqld.cc:
Exposing opt_bin_logname.
sql/mysqld.h:
Exposing opt_bin_logname.
2011-11-24 18:15:58 +01:00
|
|
|
extern char *opt_logname, *opt_slow_logname, *opt_bin_logname,
|
|
|
|
*opt_relay_logname;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern char *opt_backup_history_logname, *opt_backup_progress_logname,
|
|
|
|
*opt_backup_settings_name;
|
|
|
|
extern const char *log_output_str;
|
|
|
|
extern const char *log_backup_output_str;
|
|
|
|
extern char *mysql_home_ptr, *pidfile_name_ptr;
|
|
|
|
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
|
|
|
|
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
|
|
|
|
extern char default_logfile_name[FN_REFLEN];
|
|
|
|
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
|
|
|
|
extern const double log_10[309];
|
|
|
|
extern ulonglong keybuff_size;
|
|
|
|
extern ulonglong thd_startup_options;
|
|
|
|
extern ulong thread_id;
|
|
|
|
extern ulong binlog_cache_use, binlog_cache_disk_use;
|
2010-11-05 18:42:37 +01:00
|
|
|
extern ulong binlog_stmt_cache_use, binlog_stmt_cache_disk_use;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulong aborted_threads,aborted_connects;
|
|
|
|
extern ulong delayed_insert_timeout;
|
|
|
|
extern ulong delayed_insert_limit, delayed_queue_size;
|
|
|
|
extern ulong delayed_insert_threads, delayed_insert_writes;
|
|
|
|
extern ulong delayed_rows_in_use,delayed_insert_errors;
|
|
|
|
extern ulong slave_open_temp_tables;
|
2011-12-02 19:49:05 +01:00
|
|
|
extern ulonglong query_cache_size;
|
|
|
|
extern ulong query_cache_min_res_unit;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulong slow_launch_threads, slow_launch_time;
|
|
|
|
extern ulong table_cache_size, table_def_size;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT ulong max_connections;
|
|
|
|
extern ulong max_connect_errors, connect_timeout;
|
|
|
|
extern my_bool slave_allow_batching;
|
|
|
|
extern my_bool allow_slave_start;
|
|
|
|
extern LEX_CSTRING reason_slave_blocked;
|
|
|
|
extern ulong slave_trans_retries;
|
|
|
|
extern uint slave_net_timeout;
|
2011-11-22 18:04:38 +01:00
|
|
|
extern int max_user_connections;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulong what_to_log,flush_time;
|
|
|
|
extern ulong max_prepared_stmt_count, prepared_stmt_count;
|
2010-11-05 18:42:37 +01:00
|
|
|
extern ulong open_files_limit;
|
2011-12-02 19:49:05 +01:00
|
|
|
extern ulonglong binlog_cache_size, binlog_stmt_cache_size;
|
|
|
|
extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size;
|
2012-10-01 01:30:44 +02:00
|
|
|
extern ulong max_binlog_size;
|
2012-06-12 09:29:56 +02:00
|
|
|
extern ulong slave_max_allowed_packet;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulong opt_binlog_rows_event_max_size;
|
2010-06-07 16:01:39 +02:00
|
|
|
extern ulong rpl_recovery_rank, thread_cache_size;
|
2012-01-25 10:59:30 +01:00
|
|
|
extern ulong stored_program_cache_size;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern ulong back_log;
|
2012-09-09 00:22:06 +02:00
|
|
|
extern ulong executed_events;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern char language[FN_REFLEN];
|
2011-03-18 07:37:08 +01:00
|
|
|
extern "C" MYSQL_PLUGIN_IMPORT ulong server_id;
|
|
|
|
extern ulong concurrency;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern time_t server_start_time, flush_status_time;
|
|
|
|
extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
|
|
|
|
extern int mysql_unpacked_real_data_home_len;
|
2010-04-12 15:35:06 +02:00
|
|
|
extern MYSQL_PLUGIN_IMPORT MY_TMPDIR mysql_tmpdir_list;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern const char *first_keyword, *delayed_user, *binary_keyword;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT const char *my_localhost;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT const char **errmesg; /* Error messages */
|
|
|
|
extern const char *myisam_recover_options_str;
|
|
|
|
extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
|
|
|
|
extern SHOW_VAR status_vars[];
|
|
|
|
extern struct system_variables max_system_variables;
|
|
|
|
extern struct system_status_var global_status_var;
|
2010-11-25 18:17:28 +01:00
|
|
|
extern struct my_rnd_struct sql_rand;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern const char *opt_date_time_formats[];
|
|
|
|
extern handlerton *partition_hton;
|
|
|
|
extern handlerton *myisam_hton;
|
|
|
|
extern handlerton *heap_hton;
|
|
|
|
extern const char *load_default_groups[];
|
|
|
|
extern struct my_option my_long_options[];
|
2012-09-28 01:06:56 +02:00
|
|
|
extern int mysqld_server_started, mysqld_server_initialized;
|
2011-03-18 07:37:08 +01:00
|
|
|
extern "C" MYSQL_PLUGIN_IMPORT int orig_argc;
|
|
|
|
extern "C" MYSQL_PLUGIN_IMPORT char **orig_argv;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern pthread_attr_t connection_attrib;
|
|
|
|
extern MYSQL_FILE *bootstrap_file;
|
|
|
|
extern my_bool old_mode;
|
|
|
|
extern LEX_STRING opt_init_connect, opt_init_slave;
|
|
|
|
extern int bootstrap_error;
|
|
|
|
extern I_List<THD> threads;
|
|
|
|
extern char err_shared_dir[];
|
|
|
|
extern TYPELIB thread_handling_typelib;
|
|
|
|
|
2011-05-18 16:17:29 +02:00
|
|
|
/*
|
|
|
|
THR_MALLOC is a key which will be used to set/get MEM_ROOT** for a thread,
|
|
|
|
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
|
|
|
|
*/
|
2010-03-31 16:05:33 +02:00
|
|
|
extern pthread_key(MEM_ROOT**,THR_MALLOC);
|
|
|
|
|
|
|
|
#ifdef HAVE_PSI_INTERFACE
|
|
|
|
#ifdef HAVE_MMAP
|
|
|
|
extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active,
|
2012-09-13 14:31:29 +02:00
|
|
|
key_LOCK_pool, key_LOCK_pending_checkpoint;
|
2010-03-31 16:05:33 +02:00
|
|
|
#endif /* HAVE_MMAP */
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENSSL
|
|
|
|
extern PSI_mutex_key key_LOCK_des_key_file;
|
|
|
|
#endif
|
|
|
|
|
2012-06-22 11:46:28 +02:00
|
|
|
extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
|
2012-12-14 15:38:07 +01:00
|
|
|
key_BINLOG_LOCK_binlog_background_thread,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
|
|
|
|
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
|
|
|
|
key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
|
2010-11-11 18:11:05 +01:00
|
|
|
key_LOCK_gdl, key_LOCK_global_system_variables,
|
2010-07-27 16:32:42 +02:00
|
|
|
key_LOCK_logger, key_LOCK_manager,
|
2010-08-12 15:50:23 +02:00
|
|
|
key_LOCK_prepared_stmt_count,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
|
|
|
|
key_LOCK_table_share, key_LOCK_thd_data,
|
2011-07-13 21:10:18 +02:00
|
|
|
key_LOCK_user_conn, key_LOG_LOCK_log,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_master_info_data_lock, key_master_info_run_lock,
|
2012-01-23 13:09:37 +01:00
|
|
|
key_master_info_sleep_lock,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
|
|
|
|
key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
|
2012-01-23 13:09:37 +01:00
|
|
|
key_relay_log_info_sleep_lock,
|
2010-05-24 14:51:59 +02:00
|
|
|
key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data,
|
|
|
|
key_LOCK_error_messages, key_LOCK_thread_count, key_PARTITION_LOCK_auto_inc;
|
2011-03-01 17:39:28 +01:00
|
|
|
extern PSI_mutex_key key_RELAYLOG_LOCK_index;
|
2012-11-05 15:01:49 +01:00
|
|
|
extern PSI_mutex_key key_LOCK_slave_state, key_LOCK_binlog_state;
|
2010-03-31 16:05:33 +02:00
|
|
|
|
2011-04-25 17:22:25 +02:00
|
|
|
extern PSI_mutex_key key_LOCK_stats,
|
|
|
|
key_LOCK_global_user_client_stats, key_LOCK_global_table_stats,
|
2011-10-19 21:45:18 +02:00
|
|
|
key_LOCK_global_index_stats, key_LOCK_wakeup_ready;
|
2011-04-25 17:22:25 +02:00
|
|
|
|
2012-10-23 11:19:42 +02:00
|
|
|
extern PSI_mutex_key key_LOCK_gtid_counter, key_LOCK_rpl_gtid_state;
|
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
|
|
|
|
key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
|
|
|
|
key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
|
|
|
|
|
|
|
|
#ifdef HAVE_MMAP
|
2011-10-25 12:53:40 +02:00
|
|
|
extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
|
2010-03-31 16:05:33 +02:00
|
|
|
#endif /* HAVE_MMAP */
|
|
|
|
|
2012-06-22 11:46:28 +02:00
|
|
|
extern PSI_cond_key key_BINLOG_COND_xid_list, key_BINLOG_update_cond,
|
2012-12-14 15:38:07 +01:00
|
|
|
key_BINLOG_COND_binlog_background_thread,
|
|
|
|
key_BINLOG_COND_binlog_background_thread_end,
|
2010-11-11 18:11:05 +01:00
|
|
|
key_COND_cache_status_changed, key_COND_manager,
|
2010-07-27 15:34:58 +02:00
|
|
|
key_COND_rpl_status, key_COND_server_started,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_delayed_insert_cond, key_delayed_insert_cond_client,
|
|
|
|
key_item_func_sleep_cond, key_master_info_data_cond,
|
|
|
|
key_master_info_start_cond, key_master_info_stop_cond,
|
2012-01-23 13:09:37 +01:00
|
|
|
key_master_info_sleep_cond,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
|
|
|
|
key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
|
2012-01-23 13:09:37 +01:00
|
|
|
key_relay_log_info_sleep_cond,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_TABLE_SHARE_cond, key_user_level_lock_cond,
|
|
|
|
key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache;
|
2011-10-19 21:45:18 +02:00
|
|
|
extern PSI_cond_key key_RELAYLOG_update_cond, key_COND_wakeup_ready;
|
2011-10-25 12:53:40 +02:00
|
|
|
extern PSI_cond_key key_RELAYLOG_COND_queue_busy;
|
|
|
|
extern PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy;
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
|
|
|
|
key_thread_handle_manager, key_thread_kill_server, key_thread_main,
|
|
|
|
key_thread_one_connection, key_thread_signal_hand;
|
|
|
|
|
|
|
|
extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
|
|
|
|
key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
|
|
|
|
key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
|
|
|
|
key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
|
2010-11-12 07:23:26 +01:00
|
|
|
key_file_master_info, key_file_misc, key_file_partition,
|
2010-03-31 16:05:33 +02:00
|
|
|
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
|
|
|
|
key_file_trg, key_file_trn, key_file_init;
|
2010-11-12 07:23:26 +01:00
|
|
|
extern PSI_file_key key_file_query_log, key_file_slow_log;
|
2011-03-01 17:39:28 +01:00
|
|
|
extern PSI_file_key key_file_relaylog, key_file_relaylog_index;
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
void init_server_psi_keys();
|
|
|
|
#endif /* HAVE_PSI_INTERFACE */
|
|
|
|
|
|
|
|
#ifndef __WIN__
|
|
|
|
extern pthread_t signal_thread;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENSSL
|
|
|
|
extern struct st_VioSSLFd * ssl_acceptor_fd;
|
|
|
|
#endif /* HAVE_OPENSSL */
|
|
|
|
|
|
|
|
/*
|
|
|
|
The following variables were under INNODB_COMPABILITY_HOOKS
|
|
|
|
*/
|
|
|
|
extern my_bool opt_large_pages;
|
|
|
|
extern uint opt_large_page_size;
|
|
|
|
extern char lc_messages_dir[FN_REFLEN];
|
|
|
|
extern char *lc_messages_dir_ptr, *log_error_file_ptr;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT char reg_ext[FN_EXTLEN];
|
|
|
|
extern MYSQL_PLUGIN_IMPORT uint reg_ext_length;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT bool mysqld_embedded;
|
|
|
|
extern ulong specialflag;
|
|
|
|
extern uint mysql_data_home_len;
|
|
|
|
extern uint mysql_real_data_home_len;
|
|
|
|
extern const char *mysql_real_data_home_ptr;
|
2010-08-05 14:34:19 +02:00
|
|
|
extern ulong thread_handling;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern MYSQL_PLUGIN_IMPORT char *mysql_data_home;
|
2011-03-18 07:37:08 +01:00
|
|
|
extern "C" MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH];
|
2010-03-31 16:05:33 +02:00
|
|
|
extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
|
|
|
|
extern char mysql_unpacked_real_data_home[];
|
|
|
|
extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
|
|
|
|
extern char default_logfile_name[FN_REFLEN];
|
|
|
|
|
|
|
|
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
|
|
|
|
|
|
|
|
extern MYSQL_PLUGIN_IMPORT const key_map key_map_empty;
|
|
|
|
extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded as const */
|
|
|
|
|
|
|
|
/*
|
|
|
|
Server mutex locks and condition variables.
|
|
|
|
*/
|
2010-08-12 15:50:23 +02:00
|
|
|
extern mysql_mutex_t
|
2010-07-23 22:14:35 +02:00
|
|
|
LOCK_user_locks, LOCK_status,
|
2011-10-19 21:45:18 +02:00
|
|
|
LOCK_error_log, LOCK_delayed_insert, LOCK_short_uuid_generator,
|
2010-03-31 16:05:33 +02:00
|
|
|
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
|
2010-11-11 18:11:05 +01:00
|
|
|
LOCK_slave_list, LOCK_active_mi, LOCK_manager,
|
2010-03-31 16:05:33 +02:00
|
|
|
LOCK_global_system_variables, LOCK_user_conn,
|
|
|
|
LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
|
2012-10-23 11:19:42 +02:00
|
|
|
extern mysql_mutex_t LOCK_gtid_counter, LOCK_rpl_gtid_state;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count;
|
|
|
|
#ifdef HAVE_OPENSSL
|
|
|
|
extern mysql_mutex_t LOCK_des_key_file;
|
|
|
|
#endif
|
|
|
|
extern mysql_mutex_t LOCK_server_started;
|
|
|
|
extern mysql_cond_t COND_server_started;
|
|
|
|
extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
|
|
|
|
extern mysql_rwlock_t LOCK_system_variables_hash;
|
|
|
|
extern mysql_cond_t COND_thread_count;
|
2010-07-27 15:34:58 +02:00
|
|
|
extern mysql_cond_t COND_manager;
|
2010-03-31 16:05:33 +02:00
|
|
|
extern int32 thread_running;
|
|
|
|
extern my_atomic_rwlock_t thread_running_lock;
|
|
|
|
|
|
|
|
extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
|
|
|
|
*opt_ssl_key;
|
|
|
|
|
|
|
|
extern MYSQL_PLUGIN_IMPORT pthread_key(THD*, THR_THD);
|
|
|
|
|
2011-04-25 17:22:25 +02:00
|
|
|
#ifdef MYSQL_SERVER
|
2011-07-02 22:12:12 +02:00
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
/**
|
|
|
|
only options that need special treatment in get_one_option() deserve
|
|
|
|
to be listed below
|
|
|
|
*/
|
|
|
|
enum options_mysqld
|
|
|
|
{
|
|
|
|
OPT_to_set_the_start_number=256,
|
|
|
|
OPT_BIND_ADDRESS,
|
|
|
|
OPT_BINLOG_DO_DB,
|
|
|
|
OPT_BINLOG_FORMAT,
|
|
|
|
OPT_BINLOG_IGNORE_DB,
|
|
|
|
OPT_BIN_LOG,
|
|
|
|
OPT_BOOTSTRAP,
|
|
|
|
OPT_CONSOLE,
|
|
|
|
OPT_DEBUG_SYNC_TIMEOUT,
|
|
|
|
OPT_DELAY_KEY_WRITE_ALL,
|
2010-11-25 18:17:28 +01:00
|
|
|
OPT_DEPRECATED_OPTION,
|
2012-10-18 23:33:06 +02:00
|
|
|
OPT_ENGINE_CONDITION_PUSHDOWN,
|
|
|
|
OPT_IGNORE_DB_DIRECTORY,
|
2010-03-31 16:05:33 +02:00
|
|
|
OPT_ISAM_LOG,
|
|
|
|
OPT_KEY_BUFFER_SIZE,
|
|
|
|
OPT_KEY_CACHE_AGE_THRESHOLD,
|
|
|
|
OPT_KEY_CACHE_BLOCK_SIZE,
|
|
|
|
OPT_KEY_CACHE_DIVISION_LIMIT,
|
2010-11-25 18:17:28 +01:00
|
|
|
OPT_KEY_CACHE_PARTITIONS,
|
2012-10-18 23:33:06 +02:00
|
|
|
OPT_LOG_BASENAME,
|
|
|
|
OPT_LOG_ERROR,
|
2010-03-31 16:05:33 +02:00
|
|
|
OPT_LOWER_CASE_TABLE_NAMES,
|
2012-10-18 23:33:06 +02:00
|
|
|
OPT_MAX_LONG_DATA_SIZE,
|
2010-03-31 16:05:33 +02:00
|
|
|
OPT_ONE_THREAD,
|
|
|
|
OPT_POOL_OF_THREADS,
|
|
|
|
OPT_REPLICATE_DO_DB,
|
|
|
|
OPT_REPLICATE_DO_TABLE,
|
|
|
|
OPT_REPLICATE_IGNORE_DB,
|
|
|
|
OPT_REPLICATE_IGNORE_TABLE,
|
|
|
|
OPT_REPLICATE_REWRITE_DB,
|
|
|
|
OPT_REPLICATE_WILD_DO_TABLE,
|
|
|
|
OPT_REPLICATE_WILD_IGNORE_TABLE,
|
|
|
|
OPT_SAFE,
|
|
|
|
OPT_SERVER_ID,
|
|
|
|
OPT_SKIP_HOST_CACHE,
|
|
|
|
OPT_SKIP_LOCK,
|
|
|
|
OPT_SKIP_PRIOR,
|
|
|
|
OPT_SKIP_RESOLVE,
|
|
|
|
OPT_SKIP_STACK_TRACE,
|
|
|
|
OPT_SKIP_SYMLINKS,
|
|
|
|
OPT_SLOW_QUERY_LOG,
|
|
|
|
OPT_SSL_CA,
|
|
|
|
OPT_SSL_CAPATH,
|
|
|
|
OPT_SSL_CERT,
|
|
|
|
OPT_SSL_CIPHER,
|
|
|
|
OPT_SSL_KEY,
|
|
|
|
OPT_UPDATE_LOG,
|
|
|
|
OPT_WANT_CORE,
|
2012-10-18 23:33:06 +02:00
|
|
|
OPT_which_is_always_the_last
|
2010-03-31 16:05:33 +02:00
|
|
|
};
|
2011-04-25 17:22:25 +02:00
|
|
|
#endif
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
/**
|
2011-03-04 16:43:28 +01:00
|
|
|
Query type constants (usable as bitmap flags).
|
2010-03-31 16:05:33 +02:00
|
|
|
*/
|
|
|
|
enum enum_query_type
|
|
|
|
{
|
2011-03-04 16:43:28 +01:00
|
|
|
/// Nothing specific, ordinary SQL query.
|
|
|
|
QT_ORDINARY= 0,
|
|
|
|
/// In utf8.
|
|
|
|
QT_TO_SYSTEM_CHARSET= (1 << 0),
|
|
|
|
/// Without character set introducers.
|
2011-10-19 21:45:18 +02:00
|
|
|
QT_WITHOUT_INTRODUCERS= (1 << 1),
|
|
|
|
/// view internal representation (like QT_ORDINARY except ORDER BY clause)
|
|
|
|
QT_VIEW_INTERNAL= (1 << 2)
|
2010-03-31 16:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* query_id */
|
|
|
|
typedef int64 query_id_t;
|
|
|
|
extern query_id_t global_query_id;
|
|
|
|
extern my_atomic_rwlock_t global_query_id_lock;
|
2012-07-27 21:05:23 +02:00
|
|
|
extern my_atomic_rwlock_t statistics_lock;
|
2010-03-31 16:05:33 +02:00
|
|
|
|
|
|
|
void unireg_end(void) __attribute__((noreturn));
|
|
|
|
|
|
|
|
/* increment query_id and return it. */
|
|
|
|
inline query_id_t next_query_id()
|
|
|
|
{
|
|
|
|
query_id_t id;
|
|
|
|
my_atomic_rwlock_wrlock(&global_query_id_lock);
|
|
|
|
id= my_atomic_add64(&global_query_id, 1);
|
|
|
|
my_atomic_rwlock_wrunlock(&global_query_id_lock);
|
|
|
|
return (id+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline query_id_t get_query_id()
|
|
|
|
{
|
|
|
|
query_id_t id;
|
|
|
|
my_atomic_rwlock_wrlock(&global_query_id_lock);
|
|
|
|
id= my_atomic_load64(&global_query_id);
|
|
|
|
my_atomic_rwlock_wrunlock(&global_query_id_lock);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
TODO: Replace this with an inline function.
|
|
|
|
*/
|
|
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
|
extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
|
|
|
|
#else
|
|
|
|
extern "C" void unireg_clear(int exit_code);
|
|
|
|
#define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
inline void table_case_convert(char * name, uint length)
|
|
|
|
{
|
|
|
|
if (lower_case_table_names)
|
|
|
|
files_charset_info->cset->casedn(files_charset_info,
|
|
|
|
name, length, name, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ulong sql_rnd_with_mutex()
|
|
|
|
{
|
|
|
|
mysql_mutex_lock(&LOCK_thread_count);
|
|
|
|
ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
|
|
|
|
mysql_mutex_unlock(&LOCK_thread_count);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int32
|
|
|
|
inc_thread_running()
|
|
|
|
{
|
|
|
|
int32 num_thread_running;
|
|
|
|
my_atomic_rwlock_wrlock(&thread_running_lock);
|
|
|
|
num_thread_running= my_atomic_add32(&thread_running, 1);
|
|
|
|
my_atomic_rwlock_wrunlock(&thread_running_lock);
|
|
|
|
return (num_thread_running+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int32
|
|
|
|
dec_thread_running()
|
|
|
|
{
|
|
|
|
int32 num_thread_running;
|
|
|
|
my_atomic_rwlock_wrlock(&thread_running_lock);
|
|
|
|
num_thread_running= my_atomic_add32(&thread_running, -1);
|
|
|
|
my_atomic_rwlock_wrunlock(&thread_running_lock);
|
|
|
|
return (num_thread_running-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int32
|
|
|
|
get_thread_running()
|
|
|
|
{
|
|
|
|
int32 num_thread_running;
|
|
|
|
my_atomic_rwlock_wrlock(&thread_running_lock);
|
|
|
|
num_thread_running= my_atomic_load32(&thread_running);
|
|
|
|
my_atomic_rwlock_wrunlock(&thread_running_lock);
|
|
|
|
return num_thread_running;
|
|
|
|
}
|
|
|
|
|
2012-02-21 20:51:56 +01:00
|
|
|
void set_server_version(void);
|
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
#if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32)
|
|
|
|
extern "C" THD *_current_thd_noinline();
|
|
|
|
#define _current_thd() _current_thd_noinline()
|
|
|
|
#else
|
2011-05-18 16:17:29 +02:00
|
|
|
/*
|
|
|
|
THR_THD is a key which will be used to set/get THD* for a thread,
|
|
|
|
using my_pthread_setspecific_ptr()/my_thread_getspecific_ptr().
|
|
|
|
*/
|
2010-03-31 16:05:33 +02:00
|
|
|
extern pthread_key(THD*, THR_THD);
|
|
|
|
inline THD *_current_thd(void)
|
|
|
|
{
|
|
|
|
return my_pthread_getspecific_ptr(THD*,THR_THD);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#define current_thd _current_thd()
|
2013-01-23 16:20:39 +01:00
|
|
|
inline int set_current_thd(THD *thd)
|
|
|
|
{
|
|
|
|
return my_pthread_setspecific_ptr(THR_THD, thd);
|
|
|
|
}
|
2010-03-31 16:05:33 +02:00
|
|
|
|
2010-11-25 18:17:28 +01:00
|
|
|
/*
|
|
|
|
@todo remove, make it static in ha_maria.cc
|
|
|
|
currently it's needed for sql_select.cc
|
|
|
|
*/
|
|
|
|
extern handlerton *maria_hton;
|
|
|
|
|
|
|
|
extern uint extra_connection_count;
|
2012-10-23 11:19:42 +02:00
|
|
|
extern uint64 global_gtid_counter;
|
2011-10-19 21:45:18 +02:00
|
|
|
extern my_bool opt_userstat_running, debug_assert_if_crashed_table;
|
2010-11-25 18:17:28 +01:00
|
|
|
extern uint mysqld_extra_port;
|
2011-10-19 21:45:18 +02:00
|
|
|
extern ulong opt_progress_report_time;
|
2010-11-25 18:17:28 +01:00
|
|
|
extern ulong extra_max_connections;
|
|
|
|
extern ulonglong denied_connections;
|
|
|
|
extern ulong thread_created;
|
2011-07-02 22:12:12 +02:00
|
|
|
extern scheduler_functions *thread_scheduler, *extra_thread_scheduler;
|
2011-10-19 21:45:18 +02:00
|
|
|
extern char *opt_log_basename;
|
|
|
|
extern my_bool opt_master_verify_checksum;
|
2012-01-16 20:16:35 +01:00
|
|
|
extern my_bool opt_stack_trace;
|
2012-02-21 20:51:56 +01:00
|
|
|
extern my_bool opt_expect_abort;
|
2011-10-19 21:45:18 +02:00
|
|
|
extern my_bool opt_slave_sql_verify_checksum;
|
|
|
|
extern ulong binlog_checksum_options;
|
2011-11-22 18:04:38 +01:00
|
|
|
extern bool max_user_connections_checking;
|
|
|
|
extern ulong opt_binlog_dbug_fsync_sleep;
|
|
|
|
|
|
|
|
extern uint internal_tmp_table_max_key_length;
|
|
|
|
extern uint internal_tmp_table_max_key_segments;
|
2011-10-19 21:45:18 +02:00
|
|
|
|
|
|
|
extern uint volatile global_disable_checkpoint;
|
2011-12-12 23:58:40 +01:00
|
|
|
extern my_bool opt_help;
|
2011-10-19 21:45:18 +02:00
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
#endif /* MYSQLD_INCLUDED */
|