1 | /* Copyright (c) 2006, 2016, Oracle and/or its affiliates. |
2 | Copyright (c) 2010, 2017, MariaDB Corporation. |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; version 2 of the License. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software |
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
16 | |
17 | #ifndef MYSQLD_INCLUDED |
18 | #define MYSQLD_INCLUDED |
19 | |
20 | #include "sql_basic_types.h" /* query_id_t */ |
21 | #include "sql_plugin.h" |
22 | #include "sql_bitmap.h" /* Bitmap */ |
23 | #include "my_decimal.h" /* my_decimal */ |
24 | #include "mysql_com.h" /* SERVER_VERSION_LENGTH */ |
25 | #include "my_atomic.h" |
26 | #include "mysql/psi/mysql_file.h" /* MYSQL_FILE */ |
27 | #include "sql_list.h" /* I_List */ |
28 | #include "sql_cmd.h" |
29 | #include <my_rnd.h> |
30 | #include "my_pthread.h" |
31 | #include "my_rdtsc.h" |
32 | |
33 | class THD; |
34 | class CONNECT; |
35 | struct handlerton; |
36 | class Time_zone; |
37 | |
38 | struct scheduler_functions; |
39 | |
40 | typedef struct st_mysql_show_var SHOW_VAR; |
41 | |
42 | #if MAX_INDEXES <= 64 |
43 | typedef Bitmap<64> key_map; /* Used for finding keys */ |
44 | #elif MAX_INDEXES > 128 |
45 | #error "MAX_INDEXES values greater than 128 is not supported." |
46 | #else |
47 | typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */ |
48 | #endif |
49 | |
50 | /* Bits from testflag */ |
51 | #define TEST_PRINT_CACHED_TABLES 1U |
52 | #define TEST_NO_KEY_GROUP 2U |
53 | #define TEST_MIT_THREAD 4U |
54 | #define TEST_BLOCKING 8U |
55 | #define TEST_KEEP_TMP_TABLES 16U |
56 | #define TEST_READCHECK 64U /**< Force use of readcheck */ |
57 | #define 128U |
58 | #define TEST_CORE_ON_SIGNAL 256U /**< Give core if signal */ |
59 | #define TEST_SIGINT 1024U /**< Allow sigint on threads */ |
60 | #define TEST_SYNCHRONIZATION 2048U /**< get server to do sleep in |
61 | some places */ |
62 | |
63 | /* Keep things compatible */ |
64 | #define OPT_DEFAULT SHOW_OPT_DEFAULT |
65 | #define OPT_SESSION SHOW_OPT_SESSION |
66 | #define OPT_GLOBAL SHOW_OPT_GLOBAL |
67 | |
68 | extern MY_TIMER_INFO sys_timer_info; |
69 | |
70 | /* |
71 | Values for --slave-parallel-mode |
72 | Must match order in slave_parallel_mode_typelib in sys_vars.cc. |
73 | */ |
74 | enum enum_slave_parallel_mode { |
75 | SLAVE_PARALLEL_NONE, |
76 | SLAVE_PARALLEL_MINIMAL, |
77 | SLAVE_PARALLEL_CONSERVATIVE, |
78 | SLAVE_PARALLEL_OPTIMISTIC, |
79 | SLAVE_PARALLEL_AGGRESSIVE |
80 | }; |
81 | |
82 | /* Function prototypes */ |
83 | void kill_mysql(THD *thd= 0); |
84 | void close_connection(THD *thd, uint sql_errno= 0); |
85 | void handle_connection_in_main_thread(CONNECT *thd); |
86 | void create_thread_to_handle_connection(CONNECT *connect); |
87 | void signal_thd_deleted(); |
88 | void unlink_thd(THD *thd); |
89 | bool one_thread_per_connection_end(THD *thd, bool put_in_cache); |
90 | void flush_thread_cache(); |
91 | void refresh_status(THD *thd); |
92 | bool is_secure_file_path(char *path); |
93 | void dec_connection_count(scheduler_functions *scheduler); |
94 | extern void init_net_server_extension(THD *thd); |
95 | |
96 | extern "C" MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info; |
97 | extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ; |
98 | extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info; |
99 | extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset; |
100 | |
101 | /** |
102 | Character set of the buildin error messages loaded from errmsg.sys. |
103 | */ |
104 | extern CHARSET_INFO *error_message_charset_info; |
105 | |
106 | extern CHARSET_INFO *character_set_filesystem; |
107 | |
108 | extern MY_BITMAP temp_pool; |
109 | extern bool opt_large_files; |
110 | extern bool opt_update_log, opt_bin_log, opt_error_log, opt_bin_log_compress; |
111 | extern uint opt_bin_log_compress_min_len; |
112 | extern my_bool opt_log, opt_bootstrap; |
113 | extern my_bool opt_backup_history_log; |
114 | extern my_bool opt_backup_progress_log; |
115 | extern my_bool opt_support_flashback; |
116 | extern ulonglong log_output_options; |
117 | extern ulong log_backup_output_options; |
118 | extern bool opt_disable_networking, opt_skip_show_db; |
119 | extern bool opt_skip_name_resolve; |
120 | extern bool opt_ignore_builtin_innodb; |
121 | extern my_bool opt_character_set_client_handshake; |
122 | extern my_bool debug_assert_on_not_freed_memory; |
123 | extern bool volatile abort_loop; |
124 | extern bool volatile in_bootstrap; |
125 | extern uint connection_count; |
126 | extern my_bool opt_safe_user_create; |
127 | extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; |
128 | extern my_bool opt_slave_compressed_protocol, use_temp_pool; |
129 | extern ulong slave_exec_mode_options, slave_ddl_exec_mode_options; |
130 | extern ulong slave_retried_transactions; |
131 | extern ulong transactions_multi_engine; |
132 | extern ulong rpl_transactions_multi_engine; |
133 | extern ulong transactions_gtid_foreign_engine; |
134 | extern ulong slave_run_triggers_for_rbr; |
135 | extern ulonglong slave_type_conversions_options; |
136 | extern my_bool read_only, opt_readonly; |
137 | extern MYSQL_PLUGIN_IMPORT my_bool lower_case_file_system; |
138 | extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs; |
139 | extern my_bool opt_secure_auth; |
140 | extern const char *current_dbug_option; |
141 | extern char* opt_secure_file_priv; |
142 | extern char* opt_secure_backup_file_priv; |
143 | extern size_t opt_secure_backup_file_priv_len; |
144 | extern my_bool sp_automatic_privileges, opt_noacl; |
145 | extern ulong use_stat_tables; |
146 | extern my_bool opt_old_style_user_limits, trust_function_creators; |
147 | extern uint opt_crash_binlog_innodb; |
148 | extern const char *shared_memory_base_name; |
149 | extern char *mysqld_unix_port; |
150 | extern my_bool opt_enable_shared_memory; |
151 | extern ulong opt_replicate_events_marked_for_skip; |
152 | extern char *default_tz_name; |
153 | extern Time_zone *default_tz; |
154 | extern char *my_bind_addr_str; |
155 | extern char *default_storage_engine, *default_tmp_storage_engine; |
156 | extern char *enforced_storage_engine; |
157 | extern char *gtid_pos_auto_engines; |
158 | extern plugin_ref *opt_gtid_pos_auto_plugins; |
159 | extern bool opt_endinfo, using_udf_functions; |
160 | extern my_bool locked_in_memory; |
161 | extern bool opt_using_transactions; |
162 | extern ulong max_long_data_size; |
163 | extern ulong current_pid; |
164 | extern ulong expire_logs_days; |
165 | extern my_bool relay_log_recovery; |
166 | extern uint sync_binlog_period, sync_relaylog_period, |
167 | sync_relayloginfo_period, sync_masterinfo_period; |
168 | extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size; |
169 | extern ulong tc_log_page_waits; |
170 | extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb; |
171 | extern my_bool relay_log_recovery; |
172 | extern uint test_flags,select_errors,ha_open_options; |
173 | extern uint protocol_version, mysqld_port, dropping_tables; |
174 | extern ulong delay_key_write_options; |
175 | extern char *opt_logname, *opt_slow_logname, *opt_bin_logname, |
176 | *opt_relay_logname; |
177 | extern char *opt_backup_history_logname, *opt_backup_progress_logname, |
178 | *opt_backup_settings_name; |
179 | extern const char *log_output_str; |
180 | extern const char *log_backup_output_str; |
181 | |
182 | /* System Versioning begin */ |
183 | enum vers_system_time_t |
184 | { |
185 | SYSTEM_TIME_UNSPECIFIED = 0, |
186 | SYSTEM_TIME_AS_OF, |
187 | SYSTEM_TIME_FROM_TO, |
188 | SYSTEM_TIME_BETWEEN, |
189 | SYSTEM_TIME_BEFORE, |
190 | SYSTEM_TIME_ALL |
191 | }; |
192 | |
193 | struct vers_asof_timestamp_t |
194 | { |
195 | ulong type; |
196 | MYSQL_TIME ltime; |
197 | vers_asof_timestamp_t() : |
198 | type(SYSTEM_TIME_UNSPECIFIED) |
199 | {} |
200 | }; |
201 | |
202 | enum vers_alter_history_enum |
203 | { |
204 | VERS_ALTER_HISTORY_ERROR= 0, |
205 | VERS_ALTER_HISTORY_KEEP |
206 | }; |
207 | /* System Versioning end */ |
208 | |
209 | extern char *mysql_home_ptr, *pidfile_name_ptr; |
210 | extern MYSQL_PLUGIN_IMPORT char glob_hostname[FN_REFLEN]; |
211 | extern char mysql_home[FN_REFLEN]; |
212 | extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; |
213 | extern char default_logfile_name[FN_REFLEN]; |
214 | extern char log_error_file[FN_REFLEN], *opt_tc_log_file; |
215 | extern const double log_10[309]; |
216 | extern ulonglong keybuff_size; |
217 | extern ulonglong thd_startup_options; |
218 | extern my_thread_id global_thread_id; |
219 | extern ulong binlog_cache_use, binlog_cache_disk_use; |
220 | extern ulong binlog_stmt_cache_use, binlog_stmt_cache_disk_use; |
221 | extern ulong aborted_threads,aborted_connects; |
222 | extern ulong delayed_insert_timeout; |
223 | extern ulong delayed_insert_limit, delayed_queue_size; |
224 | extern ulong delayed_insert_threads, delayed_insert_writes; |
225 | extern ulong delayed_rows_in_use,delayed_insert_errors; |
226 | extern int32 slave_open_temp_tables; |
227 | extern ulonglong query_cache_size; |
228 | extern ulong query_cache_limit; |
229 | extern ulong query_cache_min_res_unit; |
230 | extern ulong slow_launch_threads, slow_launch_time; |
231 | extern MYSQL_PLUGIN_IMPORT ulong max_connections; |
232 | extern uint max_digest_length; |
233 | extern ulong max_connect_errors, connect_timeout; |
234 | extern my_bool slave_allow_batching; |
235 | extern my_bool allow_slave_start; |
236 | extern LEX_CSTRING reason_slave_blocked; |
237 | extern ulong slave_trans_retries; |
238 | extern ulong slave_trans_retry_interval; |
239 | extern uint slave_net_timeout; |
240 | extern int max_user_connections; |
241 | extern volatile ulong cached_thread_count; |
242 | extern ulong what_to_log,flush_time; |
243 | extern uint max_prepared_stmt_count, prepared_stmt_count; |
244 | extern MYSQL_PLUGIN_IMPORT ulong open_files_limit; |
245 | extern ulonglong binlog_cache_size, binlog_stmt_cache_size, binlog_file_cache_size; |
246 | extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size; |
247 | extern ulong max_binlog_size; |
248 | extern ulong slave_max_allowed_packet; |
249 | extern ulong opt_binlog_rows_event_max_size; |
250 | extern ulong rpl_recovery_rank, thread_cache_size; |
251 | extern ulong stored_program_cache_size; |
252 | extern ulong opt_slave_parallel_threads; |
253 | extern ulong opt_slave_domain_parallel_threads; |
254 | extern ulong opt_slave_parallel_max_queued; |
255 | extern ulong opt_slave_parallel_mode; |
256 | extern ulong opt_binlog_commit_wait_count; |
257 | extern ulong opt_binlog_commit_wait_usec; |
258 | extern my_bool opt_gtid_ignore_duplicates; |
259 | extern ulong back_log; |
260 | extern ulong executed_events; |
261 | extern char language[FN_REFLEN]; |
262 | extern "C" MYSQL_PLUGIN_IMPORT ulong server_id; |
263 | extern ulong concurrency; |
264 | extern time_t server_start_time, flush_status_time; |
265 | extern char *opt_mysql_tmpdir, mysql_charsets_dir[]; |
266 | extern size_t mysql_unpacked_real_data_home_len; |
267 | extern MYSQL_PLUGIN_IMPORT MY_TMPDIR mysql_tmpdir_list; |
268 | extern const char *first_keyword, *delayed_user; |
269 | extern MYSQL_PLUGIN_IMPORT const char *my_localhost; |
270 | extern MYSQL_PLUGIN_IMPORT const char **errmesg; /* Error messages */ |
271 | extern const char *myisam_recover_options_str; |
272 | extern const LEX_CSTRING in_left_expr_name, in_additional_cond, in_having_cond; |
273 | extern SHOW_VAR status_vars[]; |
274 | extern struct system_variables max_system_variables; |
275 | extern struct system_status_var global_status_var; |
276 | extern struct my_rnd_struct sql_rand; |
277 | extern const char *opt_date_time_formats[]; |
278 | extern handlerton *partition_hton; |
279 | extern handlerton *myisam_hton; |
280 | extern handlerton *heap_hton; |
281 | extern const char *load_default_groups[]; |
282 | extern struct my_option my_long_options[]; |
283 | int handle_early_options(); |
284 | extern int mysqld_server_started, mysqld_server_initialized; |
285 | extern "C" MYSQL_PLUGIN_IMPORT int orig_argc; |
286 | extern "C" MYSQL_PLUGIN_IMPORT char **orig_argv; |
287 | extern pthread_attr_t connection_attrib; |
288 | extern MYSQL_FILE *bootstrap_file; |
289 | extern my_bool old_mode; |
290 | extern LEX_STRING opt_init_connect, opt_init_slave; |
291 | extern int bootstrap_error; |
292 | extern I_List<THD> threads; |
293 | extern char err_shared_dir[]; |
294 | extern ulong connection_errors_select; |
295 | extern ulong connection_errors_accept; |
296 | extern ulong connection_errors_tcpwrap; |
297 | extern ulong connection_errors_internal; |
298 | extern ulong connection_errors_max_connection; |
299 | extern ulong connection_errors_peer_addr; |
300 | extern ulong log_warnings; |
301 | extern my_bool encrypt_binlog; |
302 | extern my_bool encrypt_tmp_disk_tables, encrypt_tmp_files; |
303 | extern ulong encryption_algorithm; |
304 | extern const char *encryption_algorithm_names[]; |
305 | extern long opt_secure_timestamp; |
306 | |
307 | enum secure_timestamp { SECTIME_NO, SECTIME_SUPER, SECTIME_REPL, SECTIME_YES }; |
308 | |
309 | #ifdef HAVE_PSI_INTERFACE |
310 | #ifdef HAVE_MMAP |
311 | extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, |
312 | key_LOCK_pool, key_LOCK_pending_checkpoint; |
313 | #endif /* HAVE_MMAP */ |
314 | |
315 | #ifdef HAVE_OPENSSL |
316 | extern PSI_mutex_key key_LOCK_des_key_file; |
317 | #endif |
318 | |
319 | extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, |
320 | key_BINLOG_LOCK_binlog_background_thread, |
321 | key_LOCK_binlog_end_pos, |
322 | key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi, |
323 | key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, |
324 | key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, |
325 | key_LOCK_gdl, key_LOCK_global_system_variables, |
326 | key_LOCK_logger, key_LOCK_manager, |
327 | key_LOCK_prepared_stmt_count, |
328 | key_LOCK_rpl_status, key_LOCK_server_started, |
329 | key_LOCK_status, key_LOCK_show_status, |
330 | key_LOCK_thd_data, key_LOCK_thd_kill, |
331 | key_LOCK_user_conn, key_LOG_LOCK_log, |
332 | key_master_info_data_lock, key_master_info_run_lock, |
333 | key_master_info_sleep_lock, key_master_info_start_stop_lock, |
334 | key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock, |
335 | key_relay_log_info_log_space_lock, key_relay_log_info_run_lock, |
336 | key_rpl_group_info_sleep_lock, |
337 | key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, |
338 | key_LOCK_start_thread, |
339 | key_LOCK_error_messages, key_LOCK_thread_count, key_PARTITION_LOCK_auto_inc; |
340 | extern PSI_mutex_key key_RELAYLOG_LOCK_index; |
341 | extern PSI_mutex_key key_LOCK_relaylog_end_pos; |
342 | extern PSI_mutex_key key_LOCK_slave_state, key_LOCK_binlog_state, |
343 | key_LOCK_rpl_thread, key_LOCK_rpl_thread_pool, key_LOCK_parallel_entry; |
344 | |
345 | extern PSI_mutex_key key_TABLE_SHARE_LOCK_share, key_LOCK_stats, |
346 | key_LOCK_global_user_client_stats, key_LOCK_global_table_stats, |
347 | key_LOCK_global_index_stats, key_LOCK_wakeup_ready, key_LOCK_wait_commit, |
348 | key_TABLE_SHARE_LOCK_rotation; |
349 | extern PSI_mutex_key key_LOCK_gtid_waiting; |
350 | |
351 | extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, |
352 | key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave, |
353 | key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock, |
354 | key_LOCK_SEQUENCE, |
355 | key_rwlock_LOCK_vers_stats, key_rwlock_LOCK_stat_serial; |
356 | |
357 | #ifdef HAVE_MMAP |
358 | extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool; |
359 | #endif /* HAVE_MMAP */ |
360 | |
361 | extern PSI_cond_key key_BINLOG_COND_xid_list, key_BINLOG_update_cond, |
362 | key_BINLOG_COND_binlog_background_thread, |
363 | key_BINLOG_COND_binlog_background_thread_end, |
364 | key_COND_cache_status_changed, key_COND_manager, |
365 | key_COND_rpl_status, key_COND_server_started, |
366 | key_delayed_insert_cond, key_delayed_insert_cond_client, |
367 | key_item_func_sleep_cond, key_master_info_data_cond, |
368 | key_master_info_start_cond, key_master_info_stop_cond, |
369 | key_master_info_sleep_cond, |
370 | key_relay_log_info_data_cond, key_relay_log_info_log_space_cond, |
371 | key_relay_log_info_start_cond, key_relay_log_info_stop_cond, |
372 | key_rpl_group_info_sleep_cond, |
373 | key_TABLE_SHARE_cond, key_user_level_lock_cond, |
374 | key_COND_start_thread, |
375 | key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache; |
376 | extern PSI_cond_key key_RELAYLOG_COND_relay_log_updated, |
377 | key_RELAYLOG_COND_bin_log_updated, key_COND_wakeup_ready, |
378 | key_COND_wait_commit; |
379 | extern PSI_cond_key key_RELAYLOG_COND_queue_busy; |
380 | extern PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy; |
381 | extern PSI_cond_key key_COND_rpl_thread, key_COND_rpl_thread_queue, |
382 | key_COND_rpl_thread_stop, key_COND_rpl_thread_pool, |
383 | key_COND_parallel_entry, key_COND_group_commit_orderer; |
384 | extern PSI_cond_key key_COND_wait_gtid, key_COND_gtid_ignore_duplicates; |
385 | extern PSI_cond_key key_TABLE_SHARE_COND_rotation; |
386 | |
387 | extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert, |
388 | key_thread_handle_manager, key_thread_kill_server, key_thread_main, |
389 | key_thread_one_connection, key_thread_signal_hand, |
390 | key_thread_slave_background, key_rpl_parallel_thread; |
391 | |
392 | extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest, |
393 | key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file, |
394 | key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load, |
395 | key_file_loadfile, key_file_log_event_data, key_file_log_event_info, |
396 | key_file_master_info, key_file_misc, key_file_partition, |
397 | key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog, |
398 | key_file_trg, key_file_trn, key_file_init; |
399 | extern PSI_file_key key_file_query_log, key_file_slow_log; |
400 | extern PSI_file_key key_file_relaylog, key_file_relaylog_index; |
401 | extern PSI_socket_key key_socket_tcpip, key_socket_unix, |
402 | key_socket_client_connection; |
403 | extern PSI_file_key key_file_binlog_state; |
404 | |
405 | void init_server_psi_keys(); |
406 | #endif /* HAVE_PSI_INTERFACE */ |
407 | |
408 | /* |
409 | MAINTAINER: Please keep this list in order, to limit merge collisions. |
410 | Hint: grep PSI_stage_info | sort -u |
411 | */ |
412 | extern PSI_stage_info stage_apply_event; |
413 | extern PSI_stage_info stage_after_create; |
414 | extern PSI_stage_info stage_after_opening_tables; |
415 | extern PSI_stage_info stage_after_table_lock; |
416 | extern PSI_stage_info stage_allocating_local_table; |
417 | extern PSI_stage_info stage_alter_inplace_prepare; |
418 | extern PSI_stage_info stage_alter_inplace; |
419 | extern PSI_stage_info stage_alter_inplace_commit; |
420 | extern PSI_stage_info stage_after_apply_event; |
421 | extern PSI_stage_info stage_changing_master; |
422 | extern PSI_stage_info stage_checking_master_version; |
423 | extern PSI_stage_info stage_checking_permissions; |
424 | extern PSI_stage_info stage_checking_privileges_on_cached_query; |
425 | extern PSI_stage_info stage_checking_query_cache_for_query; |
426 | extern PSI_stage_info stage_cleaning_up; |
427 | extern PSI_stage_info stage_closing_tables; |
428 | extern PSI_stage_info stage_connecting_to_master; |
429 | extern PSI_stage_info stage_converting_heap_to_myisam; |
430 | extern PSI_stage_info stage_copying_to_group_table; |
431 | extern PSI_stage_info stage_copying_to_tmp_table; |
432 | extern PSI_stage_info stage_copy_to_tmp_table; |
433 | extern PSI_stage_info stage_creating_delayed_handler; |
434 | extern PSI_stage_info stage_creating_sort_index; |
435 | extern PSI_stage_info stage_creating_table; |
436 | extern PSI_stage_info stage_creating_tmp_table; |
437 | extern PSI_stage_info stage_deleting_from_main_table; |
438 | extern PSI_stage_info stage_deleting_from_reference_tables; |
439 | extern PSI_stage_info stage_discard_or_import_tablespace; |
440 | extern PSI_stage_info stage_end; |
441 | extern PSI_stage_info stage_enabling_keys; |
442 | extern PSI_stage_info stage_executing; |
443 | extern PSI_stage_info stage_execution_of_init_command; |
444 | extern PSI_stage_info stage_explaining; |
445 | extern PSI_stage_info stage_finding_key_cache; |
446 | extern PSI_stage_info stage_finished_reading_one_binlog_switching_to_next_binlog; |
447 | extern PSI_stage_info stage_flushing_relay_log_and_master_info_repository; |
448 | extern PSI_stage_info stage_flushing_relay_log_info_file; |
449 | extern PSI_stage_info stage_freeing_items; |
450 | extern PSI_stage_info stage_fulltext_initialization; |
451 | extern PSI_stage_info stage_got_handler_lock; |
452 | extern PSI_stage_info stage_got_old_table; |
453 | extern PSI_stage_info stage_init; |
454 | extern PSI_stage_info stage_init_update; |
455 | extern PSI_stage_info stage_insert; |
456 | extern PSI_stage_info stage_invalidating_query_cache_entries_table; |
457 | extern PSI_stage_info stage_invalidating_query_cache_entries_table_list; |
458 | extern PSI_stage_info stage_killing_slave; |
459 | extern PSI_stage_info stage_logging_slow_query; |
460 | extern PSI_stage_info stage_making_temp_file_append_before_load_data; |
461 | extern PSI_stage_info stage_making_temp_file_create_before_load_data; |
462 | extern PSI_stage_info stage_manage_keys; |
463 | extern PSI_stage_info stage_master_has_sent_all_binlog_to_slave; |
464 | extern PSI_stage_info stage_opening_tables; |
465 | extern PSI_stage_info stage_optimizing; |
466 | extern PSI_stage_info stage_preparing; |
467 | extern PSI_stage_info stage_purging_old_relay_logs; |
468 | extern PSI_stage_info stage_query_end; |
469 | extern PSI_stage_info stage_starting_cleanup; |
470 | extern PSI_stage_info stage_rollback; |
471 | extern PSI_stage_info stage_rollback_implicit; |
472 | extern PSI_stage_info stage_commit; |
473 | extern PSI_stage_info stage_commit_implicit; |
474 | extern PSI_stage_info stage_queueing_master_event_to_the_relay_log; |
475 | extern PSI_stage_info stage_reading_event_from_the_relay_log; |
476 | extern PSI_stage_info stage_recreating_table; |
477 | extern PSI_stage_info stage_registering_slave_on_master; |
478 | extern PSI_stage_info stage_removing_duplicates; |
479 | extern PSI_stage_info stage_removing_tmp_table; |
480 | extern PSI_stage_info stage_rename; |
481 | extern PSI_stage_info stage_rename_result_table; |
482 | extern PSI_stage_info stage_requesting_binlog_dump; |
483 | extern PSI_stage_info stage_reschedule; |
484 | extern PSI_stage_info stage_searching_rows_for_update; |
485 | extern PSI_stage_info stage_sending_binlog_event_to_slave; |
486 | extern PSI_stage_info stage_sending_cached_result_to_client; |
487 | extern PSI_stage_info stage_sending_data; |
488 | extern PSI_stage_info stage_setup; |
489 | extern PSI_stage_info stage_slave_has_read_all_relay_log; |
490 | extern PSI_stage_info stage_show_explain; |
491 | extern PSI_stage_info stage_sorting; |
492 | extern PSI_stage_info stage_sorting_for_group; |
493 | extern PSI_stage_info stage_sorting_for_order; |
494 | extern PSI_stage_info stage_sorting_result; |
495 | extern PSI_stage_info stage_sql_thd_waiting_until_delay; |
496 | extern PSI_stage_info stage_statistics; |
497 | extern PSI_stage_info stage_storing_result_in_query_cache; |
498 | extern PSI_stage_info stage_storing_row_into_queue; |
499 | extern PSI_stage_info stage_system_lock; |
500 | extern PSI_stage_info stage_unlocking_tables; |
501 | extern PSI_stage_info stage_table_lock; |
502 | extern PSI_stage_info stage_filling_schema_table; |
503 | extern PSI_stage_info stage_update; |
504 | extern PSI_stage_info stage_updating; |
505 | extern PSI_stage_info stage_updating_main_table; |
506 | extern PSI_stage_info stage_updating_reference_tables; |
507 | extern PSI_stage_info stage_upgrading_lock; |
508 | extern PSI_stage_info stage_user_lock; |
509 | extern PSI_stage_info stage_user_sleep; |
510 | extern PSI_stage_info stage_verifying_table; |
511 | extern PSI_stage_info stage_waiting_for_delay_list; |
512 | extern PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log; |
513 | extern PSI_stage_info stage_waiting_for_handler_insert; |
514 | extern PSI_stage_info stage_waiting_for_handler_lock; |
515 | extern PSI_stage_info stage_waiting_for_handler_open; |
516 | extern PSI_stage_info stage_waiting_for_insert; |
517 | extern PSI_stage_info stage_waiting_for_master_to_send_event; |
518 | extern PSI_stage_info stage_waiting_for_master_update; |
519 | extern PSI_stage_info stage_waiting_for_relay_log_space; |
520 | extern PSI_stage_info stage_waiting_for_slave_mutex_on_exit; |
521 | extern PSI_stage_info stage_waiting_for_slave_thread_to_start; |
522 | extern PSI_stage_info stage_waiting_for_query_cache_lock; |
523 | extern PSI_stage_info stage_waiting_for_table_flush; |
524 | extern PSI_stage_info stage_waiting_for_the_next_event_in_relay_log; |
525 | extern PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position; |
526 | extern PSI_stage_info stage_waiting_to_finalize_termination; |
527 | extern PSI_stage_info stage_waiting_to_get_readlock; |
528 | extern PSI_stage_info stage_binlog_waiting_background_tasks; |
529 | extern PSI_stage_info stage_binlog_write; |
530 | extern PSI_stage_info stage_binlog_processing_checkpoint_notify; |
531 | extern PSI_stage_info stage_binlog_stopping_background_thread; |
532 | extern PSI_stage_info stage_waiting_for_work_from_sql_thread; |
533 | extern PSI_stage_info stage_waiting_for_prior_transaction_to_commit; |
534 | extern PSI_stage_info stage_waiting_for_prior_transaction_to_start_commit; |
535 | extern PSI_stage_info stage_waiting_for_room_in_worker_thread; |
536 | extern PSI_stage_info stage_waiting_for_workers_idle; |
537 | extern PSI_stage_info stage_waiting_for_ftwrl; |
538 | extern PSI_stage_info stage_waiting_for_ftwrl_threads_to_pause; |
539 | extern PSI_stage_info stage_waiting_for_rpl_thread_pool; |
540 | extern PSI_stage_info stage_master_gtid_wait_primary; |
541 | extern PSI_stage_info stage_master_gtid_wait; |
542 | extern PSI_stage_info stage_gtid_wait_other_connection; |
543 | extern PSI_stage_info stage_slave_background_process_request; |
544 | extern PSI_stage_info stage_slave_background_wait_request; |
545 | extern PSI_stage_info stage_waiting_for_deadlock_kill; |
546 | |
547 | #ifdef HAVE_PSI_STATEMENT_INTERFACE |
548 | /** |
549 | Statement instrumentation keys (sql). |
550 | The last entry, at [SQLCOM_END], is for parsing errors. |
551 | */ |
552 | extern PSI_statement_info sql_statement_info[(uint) SQLCOM_END + 1]; |
553 | |
554 | /** |
555 | Statement instrumentation keys (com). |
556 | The last entry, at [COM_END], is for packet errors. |
557 | */ |
558 | extern PSI_statement_info com_statement_info[(uint) COM_END + 1]; |
559 | |
560 | /** |
561 | Statement instrumentation key for replication. |
562 | */ |
563 | extern PSI_statement_info stmt_info_rpl; |
564 | |
565 | void init_sql_statement_info(); |
566 | void init_com_statement_info(); |
567 | #endif /* HAVE_PSI_STATEMENT_INTERFACE */ |
568 | |
569 | #ifndef __WIN__ |
570 | extern pthread_t signal_thread; |
571 | #endif |
572 | |
573 | #ifdef HAVE_OPENSSL |
574 | extern struct st_VioSSLFd * ssl_acceptor_fd; |
575 | #endif /* HAVE_OPENSSL */ |
576 | |
577 | extern ulonglong my_pcre_frame_size; |
578 | |
579 | /* |
580 | The following variables were under INNODB_COMPABILITY_HOOKS |
581 | */ |
582 | extern my_bool opt_large_pages; |
583 | extern uint opt_large_page_size; |
584 | extern char lc_messages_dir[FN_REFLEN]; |
585 | extern char *lc_messages_dir_ptr, *log_error_file_ptr; |
586 | extern MYSQL_PLUGIN_IMPORT char reg_ext[FN_EXTLEN]; |
587 | extern MYSQL_PLUGIN_IMPORT uint reg_ext_length; |
588 | extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names; |
589 | extern MYSQL_PLUGIN_IMPORT bool mysqld_embedded; |
590 | extern ulong specialflag; |
591 | extern uint mysql_data_home_len; |
592 | extern uint mysql_real_data_home_len; |
593 | extern const char *mysql_real_data_home_ptr; |
594 | extern ulong thread_handling; |
595 | extern "C" MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH]; |
596 | extern char *server_version_ptr; |
597 | extern bool using_custom_server_version; |
598 | extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[]; |
599 | extern char mysql_unpacked_real_data_home[]; |
600 | extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables; |
601 | extern char default_logfile_name[FN_REFLEN]; |
602 | extern char *my_proxy_protocol_networks; |
603 | |
604 | #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list)) |
605 | |
606 | extern MYSQL_PLUGIN_IMPORT const key_map key_map_empty; |
607 | extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded as const */ |
608 | |
609 | /* |
610 | Server mutex locks and condition variables. |
611 | */ |
612 | extern mysql_mutex_t |
613 | LOCK_item_func_sleep, LOCK_status, LOCK_show_status, |
614 | LOCK_error_log, LOCK_delayed_insert, LOCK_short_uuid_generator, |
615 | LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, |
616 | LOCK_slave_list, LOCK_active_mi, LOCK_manager, |
617 | LOCK_global_system_variables, LOCK_user_conn, |
618 | LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count, |
619 | LOCK_slave_background; |
620 | extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count; |
621 | extern mysql_mutex_t LOCK_start_thread; |
622 | #ifdef HAVE_OPENSSL |
623 | extern char* des_key_file; |
624 | extern mysql_mutex_t LOCK_des_key_file; |
625 | #endif |
626 | extern mysql_mutex_t LOCK_server_started; |
627 | extern mysql_cond_t COND_server_started; |
628 | extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; |
629 | extern mysql_prlock_t LOCK_system_variables_hash; |
630 | extern mysql_cond_t COND_thread_count, COND_start_thread; |
631 | extern mysql_cond_t COND_manager; |
632 | extern mysql_cond_t COND_slave_background; |
633 | extern int32 thread_count, service_thread_count; |
634 | |
635 | extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher, |
636 | *opt_ssl_key, *opt_ssl_crl, *opt_ssl_crlpath; |
637 | |
638 | extern MYSQL_PLUGIN_IMPORT pthread_key(THD*, THR_THD); |
639 | |
640 | #ifdef MYSQL_SERVER |
641 | |
642 | /** |
643 | only options that need special treatment in get_one_option() deserve |
644 | to be listed below |
645 | */ |
646 | enum options_mysqld |
647 | { |
648 | OPT_to_set_the_start_number=256, |
649 | OPT_BINLOG_DO_DB, |
650 | OPT_BINLOG_FORMAT, |
651 | OPT_BINLOG_IGNORE_DB, |
652 | OPT_BIN_LOG, |
653 | OPT_BOOTSTRAP, |
654 | OPT_CONSOLE, |
655 | OPT_DEBUG_SYNC_TIMEOUT, |
656 | OPT_DEPRECATED_OPTION, |
657 | OPT_IGNORE_DB_DIRECTORY, |
658 | OPT_ISAM_LOG, |
659 | OPT_KEY_BUFFER_SIZE, |
660 | OPT_KEY_CACHE_AGE_THRESHOLD, |
661 | OPT_KEY_CACHE_BLOCK_SIZE, |
662 | OPT_KEY_CACHE_DIVISION_LIMIT, |
663 | OPT_KEY_CACHE_PARTITIONS, |
664 | OPT_KEY_CACHE_CHANGED_BLOCKS_HASH_SIZE, |
665 | OPT_LOG_BASENAME, |
666 | OPT_LOG_ERROR, |
667 | OPT_LOWER_CASE_TABLE_NAMES, |
668 | OPT_MAX_LONG_DATA_SIZE, |
669 | OPT_PLUGIN_LOAD, |
670 | OPT_PLUGIN_LOAD_ADD, |
671 | OPT_PFS_INSTRUMENT, |
672 | OPT_REPLICATE_DO_DB, |
673 | OPT_REPLICATE_DO_TABLE, |
674 | OPT_REPLICATE_IGNORE_DB, |
675 | OPT_REPLICATE_IGNORE_TABLE, |
676 | OPT_REPLICATE_REWRITE_DB, |
677 | OPT_REPLICATE_WILD_DO_TABLE, |
678 | OPT_REPLICATE_WILD_IGNORE_TABLE, |
679 | OPT_SAFE, |
680 | OPT_SERVER_ID, |
681 | OPT_SILENT, |
682 | OPT_SKIP_HOST_CACHE, |
683 | OPT_SKIP_RESOLVE, |
684 | OPT_SLAVE_PARALLEL_MODE, |
685 | OPT_SSL_CA, |
686 | OPT_SSL_CAPATH, |
687 | OPT_SSL_CERT, |
688 | OPT_SSL_CIPHER, |
689 | OPT_SSL_CRL, |
690 | OPT_SSL_CRLPATH, |
691 | OPT_SSL_KEY, |
692 | OPT_THREAD_CONCURRENCY, |
693 | OPT_WANT_CORE, |
694 | #ifdef WITH_WSREP |
695 | OPT_WSREP_CAUSAL_READS, |
696 | OPT_WSREP_SYNC_WAIT, |
697 | #endif /* WITH_WSREP */ |
698 | OPT_MYSQL_COMPATIBILITY, |
699 | OPT_MYSQL_TO_BE_IMPLEMENTED, |
700 | OPT_which_is_always_the_last |
701 | }; |
702 | #endif |
703 | |
704 | /** |
705 | Query type constants (usable as bitmap flags). |
706 | */ |
707 | enum enum_query_type |
708 | { |
709 | /// Nothing specific, ordinary SQL query. |
710 | QT_ORDINARY= 0, |
711 | /// In utf8. |
712 | QT_TO_SYSTEM_CHARSET= (1 << 0), |
713 | /// Without character set introducers. |
714 | QT_WITHOUT_INTRODUCERS= (1 << 1), |
715 | /// view internal representation (like QT_ORDINARY except ORDER BY clause) |
716 | QT_VIEW_INTERNAL= (1 << 2), |
717 | /// If identifiers should not include database names, where unambiguous |
718 | QT_ITEM_IDENT_SKIP_DB_NAMES= (1 << 3), |
719 | /// If identifiers should not include table names, where unambiguous |
720 | QT_ITEM_IDENT_SKIP_TABLE_NAMES= (1 << 4), |
721 | /// If Item_cache_wrapper should not print <expr_cache> |
722 | QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS= (1 << 5), |
723 | /// If Item_subselect should print as just "(subquery#1)" |
724 | /// rather than display the subquery body |
725 | QT_ITEM_SUBSELECT_ID_ONLY= (1 << 6), |
726 | /// If NULLIF(a,b) should print itself as |
727 | /// CASE WHEN a_for_comparison=b THEN NULL ELSE a_for_return_value END |
728 | /// when "a" was replaced to two different items |
729 | /// (e.g. by equal fields propagation in optimize_cond()) |
730 | /// or always as NULLIF(a, b). |
731 | /// The default behaviour is to use CASE syntax when |
732 | /// a_for_return_value is not the same as a_for_comparison. |
733 | /// SHOW CREATE {VIEW|PROCEDURE|FUNCTION} and other cases where the |
734 | /// original representation is required, should set this flag. |
735 | QT_ITEM_ORIGINAL_FUNC_NULLIF= (1 << 7), |
736 | |
737 | /// This value means focus on readability, not on ability to parse back, etc. |
738 | QT_EXPLAIN= QT_TO_SYSTEM_CHARSET | |
739 | QT_ITEM_IDENT_SKIP_DB_NAMES | |
740 | QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS | |
741 | QT_ITEM_SUBSELECT_ID_ONLY, |
742 | |
743 | QT_SHOW_SELECT_NUMBER= (1<<10), |
744 | /// This is used for EXPLAIN EXTENDED extra warnings / Be more detailed |
745 | /// Be more detailed than QT_EXPLAIN. |
746 | /// Perhaps we should eventually include QT_ITEM_IDENT_SKIP_CURRENT_DATABASE |
747 | /// here, as it would give better readable results |
748 | QT_EXPLAIN_EXTENDED= QT_TO_SYSTEM_CHARSET| |
749 | QT_SHOW_SELECT_NUMBER, |
750 | |
751 | // If an expression is constant, print the expression, not the value |
752 | // it evaluates to. Should be used for error messages, so that they |
753 | // don't reveal values. |
754 | QT_NO_DATA_EXPANSION= (1 << 9), |
755 | }; |
756 | |
757 | |
758 | /* query_id */ |
759 | extern query_id_t global_query_id; |
760 | |
761 | ATTRIBUTE_NORETURN void unireg_end(void); |
762 | |
763 | /* increment query_id and return it. */ |
764 | inline __attribute__((warn_unused_result)) query_id_t next_query_id() |
765 | { |
766 | return my_atomic_add64_explicit(&global_query_id, 1, MY_MEMORY_ORDER_RELAXED); |
767 | } |
768 | |
769 | inline query_id_t get_query_id() |
770 | { |
771 | return my_atomic_load64_explicit(&global_query_id, MY_MEMORY_ORDER_RELAXED); |
772 | } |
773 | |
774 | /* increment global_thread_id and return it. */ |
775 | extern __attribute__((warn_unused_result)) my_thread_id next_thread_id(void); |
776 | |
777 | /* |
778 | TODO: Replace this with an inline function. |
779 | */ |
780 | #ifndef EMBEDDED_LIBRARY |
781 | extern "C" void unireg_abort(int exit_code) __attribute__((noreturn)); |
782 | #else |
783 | extern "C" void unireg_clear(int exit_code); |
784 | #define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0) |
785 | #endif |
786 | |
787 | inline void table_case_convert(char * name, uint length) |
788 | { |
789 | if (lower_case_table_names) |
790 | files_charset_info->cset->casedn(files_charset_info, |
791 | name, length, name, length); |
792 | } |
793 | |
794 | inline void thread_safe_increment32(int32 *value) |
795 | { |
796 | (void) my_atomic_add32_explicit(value, 1, MY_MEMORY_ORDER_RELAXED); |
797 | } |
798 | |
799 | inline void thread_safe_decrement32(int32 *value) |
800 | { |
801 | (void) my_atomic_add32_explicit(value, -1, MY_MEMORY_ORDER_RELAXED); |
802 | } |
803 | |
804 | inline void thread_safe_increment64(int64 *value) |
805 | { |
806 | (void) my_atomic_add64_explicit(value, 1, MY_MEMORY_ORDER_RELAXED); |
807 | } |
808 | |
809 | inline void thread_safe_decrement64(int64 *value) |
810 | { |
811 | (void) my_atomic_add64_explicit(value, -1, MY_MEMORY_ORDER_RELAXED); |
812 | } |
813 | |
814 | extern void set_server_version(char *buf, size_t size); |
815 | |
816 | #define current_thd _current_thd() |
817 | inline int set_current_thd(THD *thd) |
818 | { |
819 | return my_pthread_setspecific_ptr(THR_THD, thd); |
820 | } |
821 | |
822 | |
823 | /* |
824 | @todo remove, make it static in ha_maria.cc |
825 | currently it's needed for sql_select.cc |
826 | */ |
827 | extern handlerton *maria_hton; |
828 | |
829 | extern uint ; |
830 | extern uint64 global_gtid_counter; |
831 | extern my_bool opt_gtid_strict_mode; |
832 | extern my_bool opt_userstat_running, debug_assert_if_crashed_table; |
833 | extern uint ; |
834 | extern ulong opt_progress_report_time; |
835 | extern ulong ; |
836 | extern ulonglong denied_connections; |
837 | extern ulong thread_created; |
838 | extern scheduler_functions *thread_scheduler, *; |
839 | extern char *opt_log_basename; |
840 | extern my_bool opt_master_verify_checksum; |
841 | extern my_bool opt_stack_trace, disable_log_notes; |
842 | extern my_bool opt_expect_abort; |
843 | extern my_bool opt_slave_sql_verify_checksum; |
844 | extern my_bool opt_mysql56_temporal_format, strict_password_validation; |
845 | extern my_bool opt_explicit_defaults_for_timestamp; |
846 | extern ulong binlog_checksum_options; |
847 | extern bool max_user_connections_checking; |
848 | extern ulong opt_binlog_dbug_fsync_sleep; |
849 | |
850 | extern uint volatile global_disable_checkpoint; |
851 | extern my_bool opt_help; |
852 | |
853 | #endif /* MYSQLD_INCLUDED */ |
854 | |