| 1 | /* Copyright (c) 2002, 2015, Oracle and/or its affiliates. |
| 2 | Copyright (c) 2012, 2018, 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 | /** |
| 18 | @file |
| 19 | Definitions of all server's session or global variables. |
| 20 | |
| 21 | How to add new variables: |
| 22 | |
| 23 | 1. copy one of the existing variables, and edit the declaration. |
| 24 | 2. if you need special behavior on assignment or additional checks |
| 25 | use ON_CHECK and ON_UPDATE callbacks. |
| 26 | 3. *Don't* add new Sys_var classes or uncle Occam will come |
| 27 | with his razor to haunt you at nights |
| 28 | |
| 29 | Note - all storage engine variables (for example myisam_whatever) |
| 30 | should go into the corresponding storage engine sources |
| 31 | (for example in storage/myisam/ha_myisam.cc) ! |
| 32 | */ |
| 33 | |
| 34 | #include "sql_plugin.h" |
| 35 | #include "sql_priv.h" |
| 36 | #include "sql_class.h" // set_var.h: THD |
| 37 | #include "sys_vars.ic" |
| 38 | #include "my_sys.h" |
| 39 | |
| 40 | #include "events.h" |
| 41 | #include <thr_alarm.h> |
| 42 | #include "slave.h" |
| 43 | #include "rpl_mi.h" |
| 44 | #include "transaction.h" |
| 45 | #include "mysqld.h" |
| 46 | #include "lock.h" |
| 47 | #include "sql_time.h" // known_date_time_formats |
| 48 | #include "sql_acl.h" // SUPER_ACL, |
| 49 | // mysql_user_table_is_in_short_password_format |
| 50 | #include "derror.h" // read_texts |
| 51 | #include "sql_base.h" // close_cached_tables |
| 52 | #include "hostname.h" // host_cache_size |
| 53 | #include <myisam.h> |
| 54 | #include "debug_sync.h" // DEBUG_SYNC |
| 55 | #include "sql_show.h" |
| 56 | |
| 57 | #include "log_event.h" |
| 58 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE |
| 59 | #include "../storage/perfschema/pfs_server.h" |
| 60 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ |
| 61 | #include "threadpool.h" |
| 62 | #include "sql_repl.h" |
| 63 | #include "opt_range.h" |
| 64 | #include "rpl_parallel.h" |
| 65 | #include "semisync_master.h" |
| 66 | #include "semisync_slave.h" |
| 67 | #include <ssl_compat.h> |
| 68 | |
| 69 | /* |
| 70 | The rule for this file: everything should be 'static'. When a sys_var |
| 71 | variable or a function from this file is - in very rare cases - needed |
| 72 | elsewhere it should be explicitly declared 'export' here to show that it's |
| 73 | not a mistakenly forgotten 'static' keyword. |
| 74 | */ |
| 75 | #define export /* not static */ |
| 76 | |
| 77 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE |
| 78 | |
| 79 | static Sys_var_mybool Sys_pfs_enabled( |
| 80 | "performance_schema" , |
| 81 | "Enable the performance schema." , |
| 82 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_enabled), |
| 83 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 84 | |
| 85 | static Sys_var_long Sys_pfs_events_waits_history_long_size( |
| 86 | "performance_schema_events_waits_history_long_size" , |
| 87 | "Number of rows in EVENTS_WAITS_HISTORY_LONG." |
| 88 | " Use 0 to disable, -1 for automated sizing." , |
| 89 | PARSED_EARLY READ_ONLY |
| 90 | GLOBAL_VAR(pfs_param.m_events_waits_history_long_sizing), |
| 91 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 92 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 93 | |
| 94 | static Sys_var_long Sys_pfs_events_waits_history_size( |
| 95 | "performance_schema_events_waits_history_size" , |
| 96 | "Number of rows per thread in EVENTS_WAITS_HISTORY." |
| 97 | " Use 0 to disable, -1 for automated sizing." , |
| 98 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_events_waits_history_sizing), |
| 99 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024), |
| 100 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 101 | |
| 102 | static Sys_var_ulong Sys_pfs_max_cond_classes( |
| 103 | "performance_schema_max_cond_classes" , |
| 104 | "Maximum number of condition instruments." , |
| 105 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_cond_class_sizing), |
| 106 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 107 | DEFAULT(PFS_MAX_COND_CLASS), BLOCK_SIZE(1)); |
| 108 | |
| 109 | static Sys_var_long Sys_pfs_max_cond_instances( |
| 110 | "performance_schema_max_cond_instances" , |
| 111 | "Maximum number of instrumented condition objects." |
| 112 | " Use 0 to disable, -1 for automated sizing." , |
| 113 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_cond_sizing), |
| 114 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 115 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 116 | |
| 117 | static Sys_var_ulong Sys_pfs_max_file_classes( |
| 118 | "performance_schema_max_file_classes" , |
| 119 | "Maximum number of file instruments." , |
| 120 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_file_class_sizing), |
| 121 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 122 | DEFAULT(PFS_MAX_FILE_CLASS), BLOCK_SIZE(1)); |
| 123 | |
| 124 | static Sys_var_ulong Sys_pfs_max_file_handles( |
| 125 | "performance_schema_max_file_handles" , |
| 126 | "Maximum number of opened instrumented files." , |
| 127 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_file_handle_sizing), |
| 128 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024), |
| 129 | DEFAULT(PFS_MAX_FILE_HANDLE), BLOCK_SIZE(1)); |
| 130 | |
| 131 | static Sys_var_long Sys_pfs_max_file_instances( |
| 132 | "performance_schema_max_file_instances" , |
| 133 | "Maximum number of instrumented files." |
| 134 | " Use 0 to disable, -1 for automated sizing." , |
| 135 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_file_sizing), |
| 136 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 137 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 138 | |
| 139 | static Sys_var_long Sys_pfs_max_sockets( |
| 140 | "performance_schema_max_socket_instances" , |
| 141 | "Maximum number of opened instrumented sockets." |
| 142 | " Use 0 to disable, -1 for automated sizing." , |
| 143 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_socket_sizing), |
| 144 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 145 | DEFAULT(-1), |
| 146 | BLOCK_SIZE(1)); |
| 147 | |
| 148 | static Sys_var_ulong Sys_pfs_max_socket_classes( |
| 149 | "performance_schema_max_socket_classes" , |
| 150 | "Maximum number of socket instruments." , |
| 151 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_socket_class_sizing), |
| 152 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 153 | DEFAULT(PFS_MAX_SOCKET_CLASS), |
| 154 | BLOCK_SIZE(1)); |
| 155 | |
| 156 | static Sys_var_ulong Sys_pfs_max_mutex_classes( |
| 157 | "performance_schema_max_mutex_classes" , |
| 158 | "Maximum number of mutex instruments." , |
| 159 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_mutex_class_sizing), |
| 160 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 161 | DEFAULT(PFS_MAX_MUTEX_CLASS), BLOCK_SIZE(1)); |
| 162 | |
| 163 | static Sys_var_long Sys_pfs_max_mutex_instances( |
| 164 | "performance_schema_max_mutex_instances" , |
| 165 | "Maximum number of instrumented MUTEX objects." |
| 166 | " Use 0 to disable, -1 for automated sizing." , |
| 167 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_mutex_sizing), |
| 168 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 100*1024*1024), |
| 169 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 170 | |
| 171 | static Sys_var_ulong Sys_pfs_max_rwlock_classes( |
| 172 | "performance_schema_max_rwlock_classes" , |
| 173 | "Maximum number of rwlock instruments." , |
| 174 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_rwlock_class_sizing), |
| 175 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 176 | DEFAULT(PFS_MAX_RWLOCK_CLASS), BLOCK_SIZE(1)); |
| 177 | |
| 178 | static Sys_var_long Sys_pfs_max_rwlock_instances( |
| 179 | "performance_schema_max_rwlock_instances" , |
| 180 | "Maximum number of instrumented RWLOCK objects." |
| 181 | " Use 0 to disable, -1 for automated sizing." , |
| 182 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_rwlock_sizing), |
| 183 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 100*1024*1024), |
| 184 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 185 | |
| 186 | static Sys_var_long Sys_pfs_max_table_handles( |
| 187 | "performance_schema_max_table_handles" , |
| 188 | "Maximum number of opened instrumented tables." |
| 189 | " Use 0 to disable, -1 for automated sizing." , |
| 190 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_table_sizing), |
| 191 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 192 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 193 | |
| 194 | static Sys_var_long Sys_pfs_max_table_instances( |
| 195 | "performance_schema_max_table_instances" , |
| 196 | "Maximum number of instrumented tables." |
| 197 | " Use 0 to disable, -1 for automated sizing." , |
| 198 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_table_share_sizing), |
| 199 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 200 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 201 | |
| 202 | static Sys_var_ulong Sys_pfs_max_thread_classes( |
| 203 | "performance_schema_max_thread_classes" , |
| 204 | "Maximum number of thread instruments." , |
| 205 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_thread_class_sizing), |
| 206 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 207 | DEFAULT(PFS_MAX_THREAD_CLASS), BLOCK_SIZE(1)); |
| 208 | |
| 209 | static Sys_var_long Sys_pfs_max_thread_instances( |
| 210 | "performance_schema_max_thread_instances" , |
| 211 | "Maximum number of instrumented threads." |
| 212 | " Use 0 to disable, -1 for automated sizing." , |
| 213 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_thread_sizing), |
| 214 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 215 | DEFAULT(-1), BLOCK_SIZE(1)); |
| 216 | |
| 217 | static Sys_var_ulong Sys_pfs_setup_actors_size( |
| 218 | "performance_schema_setup_actors_size" , |
| 219 | "Maximum number of rows in SETUP_ACTORS." , |
| 220 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_setup_actor_sizing), |
| 221 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024), |
| 222 | DEFAULT(PFS_MAX_SETUP_ACTOR), |
| 223 | BLOCK_SIZE(1)); |
| 224 | |
| 225 | static Sys_var_ulong Sys_pfs_setup_objects_size( |
| 226 | "performance_schema_setup_objects_size" , |
| 227 | "Maximum number of rows in SETUP_OBJECTS." , |
| 228 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_setup_object_sizing), |
| 229 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024), |
| 230 | DEFAULT(PFS_MAX_SETUP_OBJECT), |
| 231 | BLOCK_SIZE(1)); |
| 232 | |
| 233 | static Sys_var_long Sys_pfs_accounts_size( |
| 234 | "performance_schema_accounts_size" , |
| 235 | "Maximum number of instrumented user@host accounts." |
| 236 | " Use 0 to disable, -1 for automated sizing." , |
| 237 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_account_sizing), |
| 238 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 239 | DEFAULT(-1), |
| 240 | BLOCK_SIZE(1)); |
| 241 | |
| 242 | static Sys_var_long Sys_pfs_hosts_size( |
| 243 | "performance_schema_hosts_size" , |
| 244 | "Maximum number of instrumented hosts." |
| 245 | " Use 0 to disable, -1 for automated sizing." , |
| 246 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_host_sizing), |
| 247 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 248 | DEFAULT(-1), |
| 249 | BLOCK_SIZE(1)); |
| 250 | |
| 251 | static Sys_var_long Sys_pfs_users_size( |
| 252 | "performance_schema_users_size" , |
| 253 | "Maximum number of instrumented users." |
| 254 | " Use 0 to disable, -1 for automated sizing." , |
| 255 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_user_sizing), |
| 256 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 257 | DEFAULT(-1), |
| 258 | BLOCK_SIZE(1)); |
| 259 | |
| 260 | static Sys_var_ulong Sys_pfs_max_stage_classes( |
| 261 | "performance_schema_max_stage_classes" , |
| 262 | "Maximum number of stage instruments." , |
| 263 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_stage_class_sizing), |
| 264 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 265 | DEFAULT(PFS_MAX_STAGE_CLASS), |
| 266 | BLOCK_SIZE(1)); |
| 267 | |
| 268 | static Sys_var_long Sys_pfs_events_stages_history_long_size( |
| 269 | "performance_schema_events_stages_history_long_size" , |
| 270 | "Number of rows in EVENTS_STAGES_HISTORY_LONG." |
| 271 | " Use 0 to disable, -1 for automated sizing." , |
| 272 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_events_stages_history_long_sizing), |
| 273 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 274 | DEFAULT(-1), |
| 275 | BLOCK_SIZE(1)); |
| 276 | |
| 277 | static Sys_var_long Sys_pfs_events_stages_history_size( |
| 278 | "performance_schema_events_stages_history_size" , |
| 279 | "Number of rows per thread in EVENTS_STAGES_HISTORY." |
| 280 | " Use 0 to disable, -1 for automated sizing." , |
| 281 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_events_stages_history_sizing), |
| 282 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024), |
| 283 | DEFAULT(-1), |
| 284 | BLOCK_SIZE(1)); |
| 285 | |
| 286 | /** |
| 287 | Variable performance_schema_max_statement_classes. |
| 288 | The default number of statement classes is the sum of: |
| 289 | - (COM_END - mariadb gap) for all regular "statement/com/...", |
| 290 | - 1 for "statement/com/new_packet", for unknown enum_server_command |
| 291 | - 1 for "statement/com/Error", for invalid enum_server_command |
| 292 | - SQLCOM_END for all regular "statement/sql/...", |
| 293 | - 1 for "statement/sql/error", for invalid enum_sql_command |
| 294 | - 1 for "statement/rpl/relay_log", for replicated statements. |
| 295 | */ |
| 296 | static Sys_var_ulong Sys_pfs_max_statement_classes( |
| 297 | "performance_schema_max_statement_classes" , |
| 298 | "Maximum number of statement instruments." , |
| 299 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_statement_class_sizing), |
| 300 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), |
| 301 | DEFAULT((ulong) SQLCOM_END + |
| 302 | (ulong) (COM_END -(COM_MDB_GAP_END - COM_MDB_GAP_BEG + 1)) + 4), |
| 303 | BLOCK_SIZE(1)); |
| 304 | |
| 305 | static Sys_var_long Sys_pfs_events_statements_history_long_size( |
| 306 | "performance_schema_events_statements_history_long_size" , |
| 307 | "Number of rows in EVENTS_STATEMENTS_HISTORY_LONG." |
| 308 | " Use 0 to disable, -1 for automated sizing." , |
| 309 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_events_statements_history_long_sizing), |
| 310 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024), |
| 311 | DEFAULT(-1), |
| 312 | BLOCK_SIZE(1)); |
| 313 | |
| 314 | static Sys_var_long Sys_pfs_events_statements_history_size( |
| 315 | "performance_schema_events_statements_history_size" , |
| 316 | "Number of rows per thread in EVENTS_STATEMENTS_HISTORY." |
| 317 | " Use 0 to disable, -1 for automated sizing." , |
| 318 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_events_statements_history_sizing), |
| 319 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024), |
| 320 | DEFAULT(-1), |
| 321 | BLOCK_SIZE(1)); |
| 322 | |
| 323 | static Sys_var_long Sys_pfs_digest_size( |
| 324 | "performance_schema_digests_size" , |
| 325 | "Size of the statement digest." |
| 326 | " Use 0 to disable, -1 for automated sizing." , |
| 327 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_digest_sizing), |
| 328 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 200), |
| 329 | DEFAULT(-1), |
| 330 | BLOCK_SIZE(1)); |
| 331 | |
| 332 | static Sys_var_long Sys_pfs_max_digest_length( |
| 333 | "performance_schema_max_digest_length" , |
| 334 | "Maximum length considered for digest text, when stored in performance_schema tables." , |
| 335 | PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_max_digest_length), |
| 336 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024 * 1024), |
| 337 | DEFAULT(1024), |
| 338 | BLOCK_SIZE(1)); |
| 339 | |
| 340 | static Sys_var_long Sys_pfs_connect_attrs_size( |
| 341 | "performance_schema_session_connect_attrs_size" , |
| 342 | "Size of session attribute string buffer per thread." |
| 343 | " Use 0 to disable, -1 for automated sizing." , |
| 344 | PARSED_EARLY READ_ONLY |
| 345 | GLOBAL_VAR(pfs_param.m_session_connect_attrs_sizing), |
| 346 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024 * 1024), |
| 347 | DEFAULT(-1), |
| 348 | BLOCK_SIZE(1)); |
| 349 | |
| 350 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ |
| 351 | |
| 352 | static Sys_var_ulong Sys_auto_increment_increment( |
| 353 | "auto_increment_increment" , |
| 354 | "Auto-increment columns are incremented by this" , |
| 355 | SESSION_VAR(auto_increment_increment), |
| 356 | CMD_LINE(OPT_ARG), |
| 357 | VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1), |
| 358 | NO_MUTEX_GUARD, IN_BINLOG); |
| 359 | |
| 360 | static Sys_var_ulong Sys_auto_increment_offset( |
| 361 | "auto_increment_offset" , |
| 362 | "Offset added to Auto-increment columns. Used when " |
| 363 | "auto-increment-increment != 1" , |
| 364 | SESSION_VAR(auto_increment_offset), |
| 365 | CMD_LINE(OPT_ARG), |
| 366 | VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1), |
| 367 | NO_MUTEX_GUARD, IN_BINLOG); |
| 368 | |
| 369 | static Sys_var_mybool Sys_automatic_sp_privileges( |
| 370 | "automatic_sp_privileges" , |
| 371 | "Creating and dropping stored procedures alters ACLs" , |
| 372 | GLOBAL_VAR(sp_automatic_privileges), |
| 373 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 374 | |
| 375 | static Sys_var_ulong Sys_back_log( |
| 376 | "back_log" , "The number of outstanding connection requests " |
| 377 | "MariaDB can have. This comes into play when the main MariaDB thread " |
| 378 | "gets very many connection requests in a very short time" , |
| 379 | AUTO_SET READ_ONLY GLOBAL_VAR(back_log), CMD_LINE(REQUIRED_ARG), |
| 380 | VALID_RANGE(0, 65535), DEFAULT(150), BLOCK_SIZE(1)); |
| 381 | |
| 382 | static Sys_var_charptr Sys_basedir( |
| 383 | "basedir" , "Path to installation directory. All paths are " |
| 384 | "usually resolved relative to this" , |
| 385 | READ_ONLY GLOBAL_VAR(mysql_home_ptr), CMD_LINE(REQUIRED_ARG, 'b'), |
| 386 | IN_FS_CHARSET, DEFAULT(0)); |
| 387 | |
| 388 | static Sys_var_charptr Sys_my_bind_addr( |
| 389 | "bind_address" , "IP address to bind to." , |
| 390 | READ_ONLY GLOBAL_VAR(my_bind_addr_str), CMD_LINE(REQUIRED_ARG), |
| 391 | IN_FS_CHARSET, DEFAULT(0)); |
| 392 | |
| 393 | const char *Sys_var_vers_asof::asof_keywords[]= {"DEFAULT" , NULL}; |
| 394 | static Sys_var_vers_asof Sys_vers_asof_timestamp( |
| 395 | "system_versioning_asof" , "Default value for the FOR SYSTEM_TIME AS OF clause" , |
| 396 | SESSION_VAR(vers_asof_timestamp.type), NO_CMD_LINE, |
| 397 | Sys_var_vers_asof::asof_keywords, DEFAULT(SYSTEM_TIME_UNSPECIFIED)); |
| 398 | |
| 399 | static const char *vers_alter_history_keywords[]= {"ERROR" , "KEEP" , NullS}; |
| 400 | static Sys_var_enum Sys_vers_alter_history( |
| 401 | "system_versioning_alter_history" , "Versioning ALTER TABLE mode. " |
| 402 | "ERROR: Fail ALTER with error; " /* TODO: fail only when history non-empty */ |
| 403 | "KEEP: Keep historical system rows and subject them to ALTER" , |
| 404 | SESSION_VAR(vers_alter_history), CMD_LINE(REQUIRED_ARG), |
| 405 | vers_alter_history_keywords, DEFAULT(VERS_ALTER_HISTORY_ERROR)); |
| 406 | |
| 407 | static Sys_var_ulonglong Sys_binlog_cache_size( |
| 408 | "binlog_cache_size" , "The size of the transactional cache for " |
| 409 | "updates to transactional engines for the binary log. " |
| 410 | "If you often use transactions containing many statements, " |
| 411 | "you can increase this to get more performance" , |
| 412 | GLOBAL_VAR(binlog_cache_size), |
| 413 | CMD_LINE(REQUIRED_ARG), |
| 414 | VALID_RANGE(IO_SIZE, SIZE_T_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); |
| 415 | |
| 416 | static Sys_var_ulonglong Sys_binlog_file_cache_size( |
| 417 | "binlog_file_cache_size" , |
| 418 | "The size of file cache for the binary log" , |
| 419 | GLOBAL_VAR(binlog_file_cache_size), |
| 420 | CMD_LINE(REQUIRED_ARG), |
| 421 | VALID_RANGE(IO_SIZE*2, SIZE_T_MAX), DEFAULT(IO_SIZE*4), BLOCK_SIZE(IO_SIZE)); |
| 422 | |
| 423 | static Sys_var_ulonglong Sys_binlog_stmt_cache_size( |
| 424 | "binlog_stmt_cache_size" , "The size of the statement cache for " |
| 425 | "updates to non-transactional engines for the binary log. " |
| 426 | "If you often use statements updating a great number of rows, " |
| 427 | "you can increase this to get more performance." , |
| 428 | GLOBAL_VAR(binlog_stmt_cache_size), |
| 429 | CMD_LINE(REQUIRED_ARG), |
| 430 | VALID_RANGE(IO_SIZE, SIZE_T_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); |
| 431 | |
| 432 | /* |
| 433 | Some variables like @sql_log_bin and @binlog_format change how/if binlogging |
| 434 | is done. We must not change them inside a running transaction or statement, |
| 435 | otherwise the event group eventually written to the binlog may become |
| 436 | incomplete or otherwise garbled. |
| 437 | |
| 438 | This function does the appropriate check. |
| 439 | |
| 440 | It returns true if an error is caused by incorrect usage, false if ok. |
| 441 | */ |
| 442 | static bool |
| 443 | error_if_in_trans_or_substatement(THD *thd, int in_substatement_error, |
| 444 | int in_transaction_error) |
| 445 | { |
| 446 | if (unlikely(thd->in_sub_stmt)) |
| 447 | { |
| 448 | my_error(in_substatement_error, MYF(0)); |
| 449 | return true; |
| 450 | } |
| 451 | |
| 452 | if (unlikely(thd->in_active_multi_stmt_transaction())) |
| 453 | { |
| 454 | my_error(in_transaction_error, MYF(0)); |
| 455 | return true; |
| 456 | } |
| 457 | |
| 458 | return false; |
| 459 | } |
| 460 | |
| 461 | static bool check_has_super(sys_var *self, THD *thd, set_var *var) |
| 462 | { |
| 463 | DBUG_ASSERT(self->scope() != sys_var::GLOBAL);// don't abuse check_has_super() |
| 464 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
| 465 | if (!(thd->security_ctx->master_access & SUPER_ACL)) |
| 466 | { |
| 467 | my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER" ); |
| 468 | return true; |
| 469 | } |
| 470 | #endif |
| 471 | return false; |
| 472 | } |
| 473 | |
| 474 | |
| 475 | static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) |
| 476 | { |
| 477 | if (check_has_super(self, thd, var)) |
| 478 | return true; |
| 479 | |
| 480 | /* |
| 481 | MariaDB Galera does not support STATEMENT or MIXED binlog format currently. |
| 482 | */ |
| 483 | if ((WSREP(thd) || opt_support_flashback) && |
| 484 | var->save_result.ulonglong_value != BINLOG_FORMAT_ROW) |
| 485 | { |
| 486 | // Push a warning to the error log. |
| 487 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, |
| 488 | "MariaDB Galera and flashback do not support binlog format: %s" , |
| 489 | binlog_format_names[var->save_result.ulonglong_value]); |
| 490 | /* |
| 491 | We allow setting up binlog_format other then ROW for session scope when |
| 492 | wsrep/flasback is enabled.This is done because of 2 reasons |
| 493 | 1. User might want to run pt-table-checksum. |
| 494 | 2. SuperUser knows what is doing :-) |
| 495 | |
| 496 | For refrence:- MDEV-7322 |
| 497 | */ |
| 498 | if (var->type == OPT_GLOBAL) |
| 499 | { |
| 500 | if (WSREP(thd)) |
| 501 | WSREP_ERROR("MariaDB Galera does not support binlog format: %s" , |
| 502 | binlog_format_names[var->save_result.ulonglong_value]); |
| 503 | else |
| 504 | my_error(ER_FLASHBACK_NOT_SUPPORTED,MYF(0),"binlog_format" , |
| 505 | binlog_format_names[var->save_result.ulonglong_value]); |
| 506 | return true; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | if (var->type == OPT_GLOBAL) |
| 511 | return false; |
| 512 | |
| 513 | /* |
| 514 | If RBR and open temporary tables, their CREATE TABLE may not be in the |
| 515 | binlog, so we can't toggle to SBR in this connection. |
| 516 | |
| 517 | If binlog_format=MIXED, there are open temporary tables, and an unsafe |
| 518 | statement is executed, then subsequent statements are logged in row |
| 519 | format and hence changes to temporary tables may be lost. So we forbid |
| 520 | switching @@SESSION.binlog_format from MIXED to STATEMENT when there are |
| 521 | open temp tables and we are logging in row format. |
| 522 | */ |
| 523 | if (thd->has_thd_temporary_tables() && |
| 524 | var->type == OPT_SESSION && |
| 525 | var->save_result.ulonglong_value == BINLOG_FORMAT_STMT && |
| 526 | ((thd->variables.binlog_format == BINLOG_FORMAT_MIXED && |
| 527 | thd->is_current_stmt_binlog_format_row()) || |
| 528 | thd->variables.binlog_format == BINLOG_FORMAT_ROW)) |
| 529 | { |
| 530 | my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0)); |
| 531 | return true; |
| 532 | } |
| 533 | |
| 534 | if (unlikely(error_if_in_trans_or_substatement(thd, |
| 535 | ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, |
| 536 | ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT))) |
| 537 | return true; |
| 538 | |
| 539 | return false; |
| 540 | } |
| 541 | |
| 542 | static bool fix_binlog_format_after_update(sys_var *self, THD *thd, |
| 543 | enum_var_type type) |
| 544 | { |
| 545 | if (type == OPT_SESSION) |
| 546 | thd->reset_current_stmt_binlog_format_row(); |
| 547 | return false; |
| 548 | } |
| 549 | |
| 550 | static Sys_var_enum Sys_binlog_format( |
| 551 | "binlog_format" , "What form of binary logging the master will " |
| 552 | "use: either ROW for row-based binary logging, STATEMENT " |
| 553 | "for statement-based binary logging, or MIXED. MIXED is statement-" |
| 554 | "based binary logging except for those statements where only row-" |
| 555 | "based is correct: those which involve user-defined functions (i.e. " |
| 556 | "UDFs) or the UUID() function; for those, row-based binary logging is " |
| 557 | "automatically used." , |
| 558 | SESSION_VAR(binlog_format), CMD_LINE(REQUIRED_ARG, OPT_BINLOG_FORMAT), |
| 559 | binlog_format_names, DEFAULT(BINLOG_FORMAT_MIXED), |
| 560 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_format_check), |
| 561 | ON_UPDATE(fix_binlog_format_after_update)); |
| 562 | |
| 563 | static bool binlog_direct_check(sys_var *self, THD *thd, set_var *var) |
| 564 | { |
| 565 | if (check_has_super(self, thd, var)) |
| 566 | return true; |
| 567 | |
| 568 | if (var->type == OPT_GLOBAL) |
| 569 | return false; |
| 570 | |
| 571 | if (unlikely(error_if_in_trans_or_substatement(thd, |
| 572 | ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT, |
| 573 | ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT))) |
| 574 | return true; |
| 575 | |
| 576 | return false; |
| 577 | } |
| 578 | |
| 579 | static Sys_var_mybool Sys_binlog_direct( |
| 580 | "binlog_direct_non_transactional_updates" , |
| 581 | "Causes updates to non-transactional engines using statement format to " |
| 582 | "be written directly to binary log. Before using this option make sure " |
| 583 | "that there are no dependencies between transactional and " |
| 584 | "non-transactional tables such as in the statement INSERT INTO t_myisam " |
| 585 | "SELECT * FROM t_innodb; otherwise, slaves may diverge from the master." , |
| 586 | SESSION_VAR(binlog_direct_non_trans_update), |
| 587 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 588 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_direct_check)); |
| 589 | |
| 590 | |
| 591 | static Sys_var_mybool Sys_explicit_defaults_for_timestamp( |
| 592 | "explicit_defaults_for_timestamp" , |
| 593 | "This option causes CREATE TABLE to create all TIMESTAMP columns " |
| 594 | "as NULL with DEFAULT NULL attribute, Without this option, " |
| 595 | "TIMESTAMP columns are NOT NULL and have implicit DEFAULT clauses." , |
| 596 | READ_ONLY GLOBAL_VAR(opt_explicit_defaults_for_timestamp), |
| 597 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG); |
| 598 | |
| 599 | |
| 600 | static Sys_var_ulonglong Sys_bulk_insert_buff_size( |
| 601 | "bulk_insert_buffer_size" , "Size of tree cache used in bulk " |
| 602 | "insert optimisation. Note that this is a limit per thread!" , |
| 603 | SESSION_VAR(bulk_insert_buff_size), CMD_LINE(REQUIRED_ARG), |
| 604 | VALID_RANGE(0, SIZE_T_MAX), DEFAULT(8192*1024), BLOCK_SIZE(1)); |
| 605 | |
| 606 | static Sys_var_charptr Sys_character_sets_dir( |
| 607 | "character_sets_dir" , "Directory where character sets are" , |
| 608 | READ_ONLY GLOBAL_VAR(charsets_dir), CMD_LINE(REQUIRED_ARG), |
| 609 | IN_FS_CHARSET, DEFAULT(0)); |
| 610 | |
| 611 | static bool check_not_null(sys_var *self, THD *thd, set_var *var) |
| 612 | { |
| 613 | return var->value && var->value->is_null(); |
| 614 | } |
| 615 | static bool check_charset(sys_var *self, THD *thd, set_var *var) |
| 616 | { |
| 617 | if (!var->value) |
| 618 | return false; |
| 619 | |
| 620 | char buff[STRING_BUFFER_USUAL_SIZE]; |
| 621 | if (var->value->result_type() == STRING_RESULT) |
| 622 | { |
| 623 | String str(buff, sizeof(buff), system_charset_info), *res; |
| 624 | if (!(res= var->value->val_str(&str))) |
| 625 | var->save_result.ptr= NULL; |
| 626 | else |
| 627 | { |
| 628 | ErrConvString err(res); /* Get utf8 '\0' terminated string */ |
| 629 | if (!(var->save_result.ptr= get_charset_by_csname(err.ptr(), |
| 630 | MY_CS_PRIMARY, |
| 631 | MYF(0))) && |
| 632 | !(var->save_result.ptr= get_old_charset_by_name(err.ptr()))) |
| 633 | { |
| 634 | my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), err.ptr()); |
| 635 | return true; |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | else // INT_RESULT |
| 640 | { |
| 641 | int csno= (int)var->value->val_int(); |
| 642 | if (!(var->save_result.ptr= get_charset(csno, MYF(0)))) |
| 643 | { |
| 644 | my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), llstr(csno, buff)); |
| 645 | return true; |
| 646 | } |
| 647 | } |
| 648 | return false; |
| 649 | } |
| 650 | static bool check_charset_not_null(sys_var *self, THD *thd, set_var *var) |
| 651 | { |
| 652 | return check_charset(self, thd, var) || check_not_null(self, thd, var); |
| 653 | } |
| 654 | static Sys_var_struct Sys_character_set_system( |
| 655 | "character_set_system" , "The character set used by the server " |
| 656 | "for storing identifiers" , |
| 657 | READ_ONLY GLOBAL_VAR(system_charset_info), NO_CMD_LINE, |
| 658 | offsetof(CHARSET_INFO, csname), DEFAULT(0)); |
| 659 | |
| 660 | static Sys_var_struct Sys_character_set_server( |
| 661 | "character_set_server" , "The default character set" , |
| 662 | SESSION_VAR(collation_server), NO_CMD_LINE, |
| 663 | offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), |
| 664 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_not_null)); |
| 665 | |
| 666 | static bool check_charset_db(sys_var *self, THD *thd, set_var *var) |
| 667 | { |
| 668 | if (check_charset_not_null(self, thd, var)) |
| 669 | return true; |
| 670 | if (!var->value) // = DEFAULT |
| 671 | var->save_result.ptr= thd->db_charset; |
| 672 | return false; |
| 673 | } |
| 674 | static Sys_var_struct Sys_character_set_database( |
| 675 | "character_set_database" , |
| 676 | "The character set used by the default database" , |
| 677 | SESSION_VAR(collation_database), NO_CMD_LINE, |
| 678 | offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), |
| 679 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_db)); |
| 680 | |
| 681 | static bool check_cs_client(sys_var *self, THD *thd, set_var *var) |
| 682 | { |
| 683 | if (check_charset_not_null(self, thd, var)) |
| 684 | return true; |
| 685 | |
| 686 | // Currently, UCS-2 cannot be used as a client character set |
| 687 | if (!is_supported_parser_charset((CHARSET_INFO *)(var->save_result.ptr))) |
| 688 | return true; |
| 689 | |
| 690 | return false; |
| 691 | } |
| 692 | static bool fix_thd_charset(sys_var *self, THD *thd, enum_var_type type) |
| 693 | { |
| 694 | if (type == OPT_SESSION) |
| 695 | thd->update_charset(); |
| 696 | return false; |
| 697 | } |
| 698 | static Sys_var_struct Sys_character_set_client( |
| 699 | "character_set_client" , "The character set for statements " |
| 700 | "that arrive from the client" , |
| 701 | NO_SET_STMT SESSION_VAR(character_set_client), NO_CMD_LINE, |
| 702 | offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), |
| 703 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_cs_client), |
| 704 | ON_UPDATE(fix_thd_charset)); |
| 705 | |
| 706 | static Sys_var_struct Sys_character_set_connection( |
| 707 | "character_set_connection" , "The character set used for " |
| 708 | "literals that do not have a character set introducer and for " |
| 709 | "number-to-string conversion" , |
| 710 | NO_SET_STMT SESSION_VAR(collation_connection), NO_CMD_LINE, |
| 711 | offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), |
| 712 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_charset_not_null), |
| 713 | ON_UPDATE(fix_thd_charset)); |
| 714 | |
| 715 | static Sys_var_struct Sys_character_set_results( |
| 716 | "character_set_results" , "The character set used for returning " |
| 717 | "query results to the client" , |
| 718 | SESSION_VAR(character_set_results), NO_CMD_LINE, |
| 719 | offsetof(CHARSET_INFO, csname), DEFAULT(&default_charset_info), |
| 720 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_charset)); |
| 721 | |
| 722 | static Sys_var_struct Sys_character_set_filesystem( |
| 723 | "character_set_filesystem" , "The filesystem character set" , |
| 724 | NO_SET_STMT SESSION_VAR(character_set_filesystem), NO_CMD_LINE, |
| 725 | offsetof(CHARSET_INFO, csname), DEFAULT(&character_set_filesystem), |
| 726 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_charset_not_null), |
| 727 | ON_UPDATE(fix_thd_charset)); |
| 728 | |
| 729 | static const char *completion_type_names[]= {"NO_CHAIN" , "CHAIN" , "RELEASE" , 0}; |
| 730 | static Sys_var_enum Sys_completion_type( |
| 731 | "completion_type" , "The transaction completion type" , |
| 732 | SESSION_VAR(completion_type), CMD_LINE(REQUIRED_ARG), |
| 733 | completion_type_names, DEFAULT(0)); |
| 734 | |
| 735 | static bool check_collation_not_null(sys_var *self, THD *thd, set_var *var) |
| 736 | { |
| 737 | if (!var->value) |
| 738 | return false; |
| 739 | |
| 740 | char buff[STRING_BUFFER_USUAL_SIZE]; |
| 741 | if (var->value->result_type() == STRING_RESULT) |
| 742 | { |
| 743 | String str(buff, sizeof(buff), system_charset_info), *res; |
| 744 | if (!(res= var->value->val_str(&str))) |
| 745 | var->save_result.ptr= NULL; |
| 746 | else |
| 747 | { |
| 748 | ErrConvString err(res); /* Get utf8 '\0'-terminated string */ |
| 749 | if (!(var->save_result.ptr= get_charset_by_name(err.ptr(), MYF(0)))) |
| 750 | { |
| 751 | my_error(ER_UNKNOWN_COLLATION, MYF(0), err.ptr()); |
| 752 | return true; |
| 753 | } |
| 754 | } |
| 755 | } |
| 756 | else // INT_RESULT |
| 757 | { |
| 758 | int csno= (int)var->value->val_int(); |
| 759 | if (!(var->save_result.ptr= get_charset(csno, MYF(0)))) |
| 760 | { |
| 761 | my_error(ER_UNKNOWN_COLLATION, MYF(0), llstr(csno, buff)); |
| 762 | return true; |
| 763 | } |
| 764 | } |
| 765 | return check_not_null(self, thd, var); |
| 766 | } |
| 767 | static Sys_var_struct Sys_collation_connection( |
| 768 | "collation_connection" , "The collation of the connection " |
| 769 | "character set" , |
| 770 | NO_SET_STMT SESSION_VAR(collation_connection), NO_CMD_LINE, |
| 771 | offsetof(CHARSET_INFO, name), DEFAULT(&default_charset_info), |
| 772 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_collation_not_null), |
| 773 | ON_UPDATE(fix_thd_charset)); |
| 774 | |
| 775 | static bool check_collation_db(sys_var *self, THD *thd, set_var *var) |
| 776 | { |
| 777 | if (check_collation_not_null(self, thd, var)) |
| 778 | return true; |
| 779 | if (!var->value) // = DEFAULT |
| 780 | var->save_result.ptr= thd->db_charset; |
| 781 | return false; |
| 782 | } |
| 783 | static Sys_var_struct Sys_collation_database( |
| 784 | "collation_database" , "The collation of the database " |
| 785 | "character set" , |
| 786 | SESSION_VAR(collation_database), NO_CMD_LINE, |
| 787 | offsetof(CHARSET_INFO, name), DEFAULT(&default_charset_info), |
| 788 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_collation_db)); |
| 789 | |
| 790 | static Sys_var_struct Sys_collation_server( |
| 791 | "collation_server" , "The server default collation" , |
| 792 | SESSION_VAR(collation_server), NO_CMD_LINE, |
| 793 | offsetof(CHARSET_INFO, name), DEFAULT(&default_charset_info), |
| 794 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_collation_not_null)); |
| 795 | |
| 796 | static Sys_var_uint Sys_column_compression_threshold( |
| 797 | "column_compression_threshold" , |
| 798 | "Minimum column data length eligible for compression" , |
| 799 | SESSION_VAR(column_compression_threshold), CMD_LINE(REQUIRED_ARG), |
| 800 | VALID_RANGE(0, UINT_MAX), DEFAULT(100), BLOCK_SIZE(1)); |
| 801 | |
| 802 | static Sys_var_uint Sys_column_compression_zlib_level( |
| 803 | "column_compression_zlib_level" , |
| 804 | "zlib compression level (1 gives best speed, 9 gives best compression)" , |
| 805 | SESSION_VAR(column_compression_zlib_level), CMD_LINE(REQUIRED_ARG), |
| 806 | VALID_RANGE(0, 9), DEFAULT(6), BLOCK_SIZE(1)); |
| 807 | |
| 808 | /* |
| 809 | Note that names must correspond to zlib strategy definition. So that we can |
| 810 | pass column_compression_zlib_strategy directly to deflateInit2(). |
| 811 | */ |
| 812 | static const char *column_compression_zlib_strategy_names[]= |
| 813 | { "DEFAULT_STRATEGY" , "FILTERED" , "HUFFMAN_ONLY" , "RLE" , "FIXED" , 0 }; |
| 814 | |
| 815 | static Sys_var_enum Sys_column_compression_zlib_strategy( |
| 816 | "column_compression_zlib_strategy" , |
| 817 | "The strategy parameter is used to tune the compression algorithm. Use " |
| 818 | "the value DEFAULT_STRATEGY for normal data, FILTERED for data produced " |
| 819 | "by a filter (or predictor), HUFFMAN_ONLY to force Huffman encoding " |
| 820 | "only (no string match), or RLE to limit match distances to one " |
| 821 | "(run-length encoding). Filtered data consists mostly of small values " |
| 822 | "with a somewhat random distribution. In this case, the compression " |
| 823 | "algorithm is tuned to compress them better. The effect of FILTERED is " |
| 824 | "to force more Huffman coding and less string matching; it is somewhat " |
| 825 | "intermediate between DEFAULT_STRATEGY and HUFFMAN_ONLY. RLE is " |
| 826 | "designed to be almost as fast as HUFFMAN_ONLY, but give better " |
| 827 | "compression for PNG image data. The strategy parameter only affects " |
| 828 | "the compression ratio but not the correctness of the compressed output " |
| 829 | "even if it is not set appropriately. FIXED prevents the use of dynamic " |
| 830 | "Huffman codes, allowing for a simpler decoder for special " |
| 831 | "applications." , |
| 832 | SESSION_VAR(column_compression_zlib_strategy), CMD_LINE(REQUIRED_ARG), |
| 833 | column_compression_zlib_strategy_names, DEFAULT(0)); |
| 834 | |
| 835 | static Sys_var_mybool Sys_column_compression_zlib_wrap( |
| 836 | "column_compression_zlib_wrap" , |
| 837 | "Generate zlib header and trailer and compute adler32 check value. " |
| 838 | "It can be used with storage engines that don't provide data integrity " |
| 839 | "verification to detect data corruption." , |
| 840 | SESSION_VAR(column_compression_zlib_wrap), CMD_LINE(OPT_ARG), |
| 841 | DEFAULT(FALSE)); |
| 842 | |
| 843 | static const char *concurrent_insert_names[]= {"NEVER" , "AUTO" , "ALWAYS" , 0}; |
| 844 | static Sys_var_enum Sys_concurrent_insert( |
| 845 | "concurrent_insert" , "Use concurrent insert with MyISAM" , |
| 846 | GLOBAL_VAR(myisam_concurrent_insert), CMD_LINE(OPT_ARG), |
| 847 | concurrent_insert_names, DEFAULT(1)); |
| 848 | |
| 849 | static Sys_var_ulong Sys_connect_timeout( |
| 850 | "connect_timeout" , |
| 851 | "The number of seconds the mysqld server is waiting for a connect " |
| 852 | "packet before responding with 'Bad handshake'" , |
| 853 | GLOBAL_VAR(connect_timeout), CMD_LINE(REQUIRED_ARG), |
| 854 | VALID_RANGE(2, LONG_TIMEOUT), DEFAULT(CONNECT_TIMEOUT), BLOCK_SIZE(1)); |
| 855 | |
| 856 | static Sys_var_charptr Sys_datadir( |
| 857 | "datadir" , "Path to the database root directory" , |
| 858 | READ_ONLY GLOBAL_VAR(mysql_real_data_home_ptr), |
| 859 | CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(mysql_real_data_home)); |
| 860 | |
| 861 | #ifndef DBUG_OFF |
| 862 | static Sys_var_dbug Sys_dbug( |
| 863 | "debug" , "Built-in DBUG debugger" , sys_var::SESSION, |
| 864 | CMD_LINE(OPT_ARG, '#'), DEFAULT("" ), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 865 | ON_CHECK(check_has_super), ON_UPDATE(0), |
| 866 | DEPRECATED("'@@debug_dbug'" )); |
| 867 | |
| 868 | static Sys_var_dbug Sys_debug_dbug( |
| 869 | "debug_dbug" , "Built-in DBUG debugger" , sys_var::SESSION, |
| 870 | CMD_LINE(OPT_ARG, '#'), DEFAULT("" ), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 871 | ON_CHECK(check_has_super)); |
| 872 | #endif |
| 873 | |
| 874 | /** |
| 875 | @todo |
| 876 | When updating myisam_delay_key_write, we should do a 'flush tables' |
| 877 | of all MyISAM tables to ensure that they are reopen with the |
| 878 | new attribute. |
| 879 | */ |
| 880 | export bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type) |
| 881 | { |
| 882 | switch (delay_key_write_options) { |
| 883 | case DELAY_KEY_WRITE_NONE: |
| 884 | myisam_delay_key_write=0; |
| 885 | ha_open_options&= ~HA_OPEN_DELAY_KEY_WRITE; |
| 886 | break; |
| 887 | case DELAY_KEY_WRITE_ON: |
| 888 | myisam_delay_key_write=1; |
| 889 | ha_open_options&= ~HA_OPEN_DELAY_KEY_WRITE; |
| 890 | break; |
| 891 | case DELAY_KEY_WRITE_ALL: |
| 892 | myisam_delay_key_write=1; |
| 893 | ha_open_options|= HA_OPEN_DELAY_KEY_WRITE; |
| 894 | break; |
| 895 | } |
| 896 | #ifdef WITH_ARIA_STORAGE_ENGINE |
| 897 | maria_delay_key_write= myisam_delay_key_write; |
| 898 | #endif |
| 899 | return false; |
| 900 | } |
| 901 | static const char *delay_key_write_names[]= { "OFF" , "ON" , "ALL" , NullS }; |
| 902 | static Sys_var_enum Sys_delay_key_write( |
| 903 | "delay_key_write" , "Specifies how MyISAM tables handles CREATE " |
| 904 | "TABLE DELAY_KEY_WRITE. If set to ON, the default, any DELAY KEY " |
| 905 | "WRITEs are honored. The key buffer is then flushed only when the " |
| 906 | "table closes, speeding up writes. MyISAM tables should be " |
| 907 | "automatically checked upon startup in this case, and " |
| 908 | "--external locking should not be used, as it can lead to index " |
| 909 | "corruption. If set to OFF, DELAY KEY WRITEs are ignored, while if " |
| 910 | "set to ALL, all new opened tables are treated as if created with " |
| 911 | "DELAY KEY WRITEs enabled." , |
| 912 | GLOBAL_VAR(delay_key_write_options), CMD_LINE(OPT_ARG), |
| 913 | delay_key_write_names, DEFAULT(DELAY_KEY_WRITE_ON), |
| 914 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 915 | ON_UPDATE(fix_delay_key_write)); |
| 916 | |
| 917 | static Sys_var_ulong Sys_delayed_insert_limit( |
| 918 | "delayed_insert_limit" , |
| 919 | "After inserting delayed_insert_limit rows, the INSERT DELAYED " |
| 920 | "handler will check if there are any SELECT statements pending. " |
| 921 | "If so, it allows these to execute before continuing." , |
| 922 | GLOBAL_VAR(delayed_insert_limit), CMD_LINE(REQUIRED_ARG), |
| 923 | VALID_RANGE(1, UINT_MAX), DEFAULT(DELAYED_LIMIT), BLOCK_SIZE(1)); |
| 924 | |
| 925 | static Sys_var_ulong Sys_delayed_insert_timeout( |
| 926 | "delayed_insert_timeout" , |
| 927 | "How long a INSERT DELAYED thread should wait for INSERT statements " |
| 928 | "before terminating" , |
| 929 | GLOBAL_VAR(delayed_insert_timeout), CMD_LINE(REQUIRED_ARG), |
| 930 | VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(DELAYED_WAIT_TIMEOUT), |
| 931 | BLOCK_SIZE(1)); |
| 932 | |
| 933 | static Sys_var_ulong Sys_delayed_queue_size( |
| 934 | "delayed_queue_size" , |
| 935 | "What size queue (in rows) should be allocated for handling INSERT " |
| 936 | "DELAYED. If the queue becomes full, any client that does INSERT " |
| 937 | "DELAYED will wait until there is room in the queue again" , |
| 938 | GLOBAL_VAR(delayed_queue_size), CMD_LINE(REQUIRED_ARG), |
| 939 | VALID_RANGE(1, UINT_MAX), DEFAULT(DELAYED_QUEUE_SIZE), BLOCK_SIZE(1)); |
| 940 | |
| 941 | #ifdef HAVE_EVENT_SCHEDULER |
| 942 | static const char *event_scheduler_names[]= { "OFF" , "ON" , "DISABLED" , |
| 943 | "ORIGINAL" , NullS }; |
| 944 | static bool event_scheduler_check(sys_var *self, THD *thd, set_var *var) |
| 945 | { |
| 946 | if (Events::opt_event_scheduler == Events::EVENTS_DISABLED) |
| 947 | { |
| 948 | my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), |
| 949 | "--event-scheduler=DISABLED or --skip-grant-tables" ); |
| 950 | return true; |
| 951 | } |
| 952 | /* DISABLED is only accepted on the command line */ |
| 953 | if (var->save_result.ulonglong_value == Events::EVENTS_DISABLED) |
| 954 | return true; |
| 955 | return false; |
| 956 | } |
| 957 | |
| 958 | static bool event_scheduler_update(sys_var *self, THD *thd, enum_var_type type) |
| 959 | { |
| 960 | int err_no= 0; |
| 961 | bool ret; |
| 962 | uint opt_event_scheduler_value= Events::opt_event_scheduler; |
| 963 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 964 | /* |
| 965 | Events::start() is heavyweight. In particular it creates a new THD, |
| 966 | which takes LOCK_global_system_variables internally. |
| 967 | Thus we have to release it here. |
| 968 | We need to re-take it before returning, though. |
| 969 | |
| 970 | Note that since we release LOCK_global_system_variables before calling |
| 971 | start/stop, there is a possibility that the server variable |
| 972 | can become out of sync with the real event scheduler state. |
| 973 | |
| 974 | This can happen with two concurrent statments if the first gets |
| 975 | interrupted after start/stop but before retaking |
| 976 | LOCK_global_system_variables. However, this problem should be quite |
| 977 | rare and it's difficult to avoid it without opening up possibilities |
| 978 | for deadlocks. See bug#51160. |
| 979 | */ |
| 980 | |
| 981 | /* EVENTS_ORIGINAL means we should revert back to the startup state */ |
| 982 | if (opt_event_scheduler_value == Events::EVENTS_ORIGINAL) |
| 983 | { |
| 984 | opt_event_scheduler_value= Events::opt_event_scheduler= |
| 985 | Events::startup_state; |
| 986 | } |
| 987 | |
| 988 | /* |
| 989 | If the scheduler was not properly inited (because of wrong system tables), |
| 990 | try to init it again. This is needed for mysql_upgrade to work properly if |
| 991 | the event tables where upgraded. |
| 992 | */ |
| 993 | if (!Events::inited && (Events::init(thd, 0) || !Events::inited)) |
| 994 | ret= 1; |
| 995 | else |
| 996 | ret= opt_event_scheduler_value == Events::EVENTS_ON ? |
| 997 | Events::start(&err_no) : |
| 998 | Events::stop(); |
| 999 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 1000 | if (ret) |
| 1001 | { |
| 1002 | Events::opt_event_scheduler= Events::EVENTS_OFF; |
| 1003 | my_error(ER_EVENT_SET_VAR_ERROR, MYF(0), err_no); |
| 1004 | } |
| 1005 | return ret; |
| 1006 | } |
| 1007 | |
| 1008 | static Sys_var_enum Sys_event_scheduler( |
| 1009 | "event_scheduler" , "Enable the event scheduler. Possible values are " |
| 1010 | "ON, OFF, and DISABLED (keep the event scheduler completely " |
| 1011 | "deactivated, it cannot be activated run-time)" , |
| 1012 | GLOBAL_VAR(Events::opt_event_scheduler), CMD_LINE(OPT_ARG), |
| 1013 | event_scheduler_names, DEFAULT(Events::EVENTS_OFF), |
| 1014 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 1015 | ON_CHECK(event_scheduler_check), ON_UPDATE(event_scheduler_update)); |
| 1016 | #endif |
| 1017 | |
| 1018 | static Sys_var_ulong Sys_expire_logs_days( |
| 1019 | "expire_logs_days" , |
| 1020 | "If non-zero, binary logs will be purged after expire_logs_days " |
| 1021 | "days; possible purges happen at startup and at binary log rotation" , |
| 1022 | GLOBAL_VAR(expire_logs_days), |
| 1023 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 99), DEFAULT(0), BLOCK_SIZE(1)); |
| 1024 | |
| 1025 | static Sys_var_mybool Sys_flush( |
| 1026 | "flush" , "Flush MyISAM tables to disk between SQL commands" , |
| 1027 | GLOBAL_VAR(myisam_flush), |
| 1028 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 1029 | |
| 1030 | static Sys_var_ulong Sys_flush_time( |
| 1031 | "flush_time" , |
| 1032 | "A dedicated thread is created to flush all tables at the " |
| 1033 | "given interval" , |
| 1034 | GLOBAL_VAR(flush_time), |
| 1035 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), |
| 1036 | DEFAULT(0), BLOCK_SIZE(1)); |
| 1037 | |
| 1038 | static bool check_ftb_syntax(sys_var *self, THD *thd, set_var *var) |
| 1039 | { |
| 1040 | return ft_boolean_check_syntax_string((uchar*) |
| 1041 | (var->save_result.string_value.str)); |
| 1042 | } |
| 1043 | static bool query_cache_flush(sys_var *self, THD *thd, enum_var_type type) |
| 1044 | { |
| 1045 | #ifdef HAVE_QUERY_CACHE |
| 1046 | query_cache.flush(); |
| 1047 | #endif /* HAVE_QUERY_CACHE */ |
| 1048 | return false; |
| 1049 | } |
| 1050 | /// @todo make SESSION_VAR (usability enhancement and a fix for a race condition) |
| 1051 | static Sys_var_charptr Sys_ft_boolean_syntax( |
| 1052 | "ft_boolean_syntax" , "List of operators for " |
| 1053 | "MATCH ... AGAINST ( ... IN BOOLEAN MODE)" , |
| 1054 | GLOBAL_VAR(ft_boolean_syntax), |
| 1055 | CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 1056 | DEFAULT(DEFAULT_FTB_SYNTAX), NO_MUTEX_GUARD, |
| 1057 | NOT_IN_BINLOG, ON_CHECK(check_ftb_syntax), ON_UPDATE(query_cache_flush)); |
| 1058 | |
| 1059 | static Sys_var_ulong Sys_ft_max_word_len( |
| 1060 | "ft_max_word_len" , |
| 1061 | "The maximum length of the word to be included in a FULLTEXT index. " |
| 1062 | "Note: FULLTEXT indexes must be rebuilt after changing this variable" , |
| 1063 | READ_ONLY GLOBAL_VAR(ft_max_word_len), CMD_LINE(REQUIRED_ARG), |
| 1064 | VALID_RANGE(10, HA_FT_MAXCHARLEN), DEFAULT(HA_FT_MAXCHARLEN), |
| 1065 | BLOCK_SIZE(1)); |
| 1066 | |
| 1067 | static Sys_var_ulong Sys_ft_min_word_len( |
| 1068 | "ft_min_word_len" , |
| 1069 | "The minimum length of the word to be included in a FULLTEXT index. " |
| 1070 | "Note: FULLTEXT indexes must be rebuilt after changing this variable" , |
| 1071 | READ_ONLY GLOBAL_VAR(ft_min_word_len), CMD_LINE(REQUIRED_ARG), |
| 1072 | VALID_RANGE(1, HA_FT_MAXCHARLEN), DEFAULT(4), BLOCK_SIZE(1)); |
| 1073 | |
| 1074 | /// @todo make it an updatable SESSION_VAR |
| 1075 | static Sys_var_ulong Sys_ft_query_expansion_limit( |
| 1076 | "ft_query_expansion_limit" , |
| 1077 | "Number of best matches to use for query expansion" , |
| 1078 | READ_ONLY GLOBAL_VAR(ft_query_expansion_limit), |
| 1079 | CMD_LINE(REQUIRED_ARG), |
| 1080 | VALID_RANGE(0, 1000), DEFAULT(20), BLOCK_SIZE(1)); |
| 1081 | |
| 1082 | static Sys_var_charptr Sys_ft_stopword_file( |
| 1083 | "ft_stopword_file" , |
| 1084 | "Use stopwords from this file instead of built-in list" , |
| 1085 | READ_ONLY GLOBAL_VAR(ft_stopword_file), CMD_LINE(REQUIRED_ARG), |
| 1086 | IN_FS_CHARSET, DEFAULT(0)); |
| 1087 | |
| 1088 | static Sys_var_mybool Sys_ignore_builtin_innodb( |
| 1089 | "ignore_builtin_innodb" , |
| 1090 | "Disable initialization of builtin InnoDB plugin" , |
| 1091 | READ_ONLY GLOBAL_VAR(opt_ignore_builtin_innodb), |
| 1092 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 1093 | |
| 1094 | static bool check_init_string(sys_var *self, THD *thd, set_var *var) |
| 1095 | { |
| 1096 | if (var->save_result.string_value.str == 0) |
| 1097 | { |
| 1098 | var->save_result.string_value.str= const_cast<char*>("" ); |
| 1099 | var->save_result.string_value.length= 0; |
| 1100 | } |
| 1101 | return false; |
| 1102 | } |
| 1103 | static PolyLock_rwlock PLock_sys_init_connect(&LOCK_sys_init_connect); |
| 1104 | static Sys_var_lexstring Sys_init_connect( |
| 1105 | "init_connect" , "Command(s) that are executed for each " |
| 1106 | "new connection (unless the user has SUPER privilege)" , |
| 1107 | GLOBAL_VAR(opt_init_connect), CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 1108 | DEFAULT("" ), &PLock_sys_init_connect, NOT_IN_BINLOG, |
| 1109 | ON_CHECK(check_init_string)); |
| 1110 | |
| 1111 | #ifdef HAVE_REPLICATION |
| 1112 | static bool check_master_connection(sys_var *self, THD *thd, set_var *var) |
| 1113 | { |
| 1114 | LEX_CSTRING tmp; |
| 1115 | tmp.str= var->save_result.string_value.str; |
| 1116 | tmp.length= var->save_result.string_value.length; |
| 1117 | if (!tmp.str || check_master_connection_name(&tmp)) |
| 1118 | return true; |
| 1119 | |
| 1120 | return false; |
| 1121 | } |
| 1122 | |
| 1123 | static Sys_var_session_lexstring Sys_default_master_connection( |
| 1124 | "default_master_connection" , |
| 1125 | "Master connection to use for all slave variables and slave commands" , |
| 1126 | SESSION_ONLY(default_master_connection), |
| 1127 | NO_CMD_LINE, IN_SYSTEM_CHARSET, |
| 1128 | DEFAULT("" ), MAX_CONNECTION_NAME, ON_CHECK(check_master_connection)); |
| 1129 | #endif |
| 1130 | |
| 1131 | static Sys_var_charptr Sys_init_file( |
| 1132 | "init_file" , "Read SQL commands from this file at startup" , |
| 1133 | READ_ONLY GLOBAL_VAR(opt_init_file), |
| 1134 | #ifdef DISABLE_GRANT_OPTIONS |
| 1135 | NO_CMD_LINE, |
| 1136 | #else |
| 1137 | CMD_LINE(REQUIRED_ARG), |
| 1138 | #endif |
| 1139 | IN_FS_CHARSET, DEFAULT(0)); |
| 1140 | |
| 1141 | static PolyLock_rwlock PLock_sys_init_slave(&LOCK_sys_init_slave); |
| 1142 | static Sys_var_lexstring Sys_init_slave( |
| 1143 | "init_slave" , "Command(s) that are executed by a slave server " |
| 1144 | "each time the SQL thread starts" , GLOBAL_VAR(opt_init_slave), |
| 1145 | CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 1146 | DEFAULT("" ), &PLock_sys_init_slave, |
| 1147 | NOT_IN_BINLOG, ON_CHECK(check_init_string)); |
| 1148 | |
| 1149 | static Sys_var_ulong Sys_interactive_timeout( |
| 1150 | "interactive_timeout" , |
| 1151 | "The number of seconds the server waits for activity on an interactive " |
| 1152 | "connection before closing it" , |
| 1153 | NO_SET_STMT SESSION_VAR(net_interactive_timeout), |
| 1154 | CMD_LINE(REQUIRED_ARG), |
| 1155 | VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1)); |
| 1156 | |
| 1157 | static Sys_var_ulonglong Sys_join_buffer_size( |
| 1158 | "join_buffer_size" , |
| 1159 | "The size of the buffer that is used for joins" , |
| 1160 | SESSION_VAR(join_buff_size), CMD_LINE(REQUIRED_ARG), |
| 1161 | VALID_RANGE(128, SIZE_T_MAX), DEFAULT(256*1024), BLOCK_SIZE(128)); |
| 1162 | |
| 1163 | static Sys_var_keycache Sys_key_buffer_size( |
| 1164 | "key_buffer_size" , "The size of the buffer used for " |
| 1165 | "index blocks for MyISAM tables. Increase this to get better index " |
| 1166 | "handling (for all reads and multiple writes) to as much as you can " |
| 1167 | "afford" , |
| 1168 | KEYCACHE_VAR(param_buff_size), |
| 1169 | CMD_LINE(REQUIRED_ARG, OPT_KEY_BUFFER_SIZE), |
| 1170 | VALID_RANGE(0, SIZE_T_MAX), DEFAULT(KEY_CACHE_SIZE), |
| 1171 | BLOCK_SIZE(IO_SIZE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1172 | ON_UPDATE(update_buffer_size)); |
| 1173 | |
| 1174 | static Sys_var_keycache Sys_key_cache_block_size( |
| 1175 | "key_cache_block_size" , "The default size of key cache blocks" , |
| 1176 | KEYCACHE_VAR(param_block_size), |
| 1177 | CMD_LINE(REQUIRED_ARG, OPT_KEY_CACHE_BLOCK_SIZE), |
| 1178 | VALID_RANGE(512, 1024*16), DEFAULT(KEY_CACHE_BLOCK_SIZE), |
| 1179 | BLOCK_SIZE(512), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1180 | ON_UPDATE(resize_keycache)); |
| 1181 | |
| 1182 | static Sys_var_keycache Sys_key_cache_division_limit( |
| 1183 | "key_cache_division_limit" , |
| 1184 | "The minimum percentage of warm blocks in key cache" , |
| 1185 | KEYCACHE_VAR(param_division_limit), |
| 1186 | CMD_LINE(REQUIRED_ARG, OPT_KEY_CACHE_DIVISION_LIMIT), |
| 1187 | VALID_RANGE(1, 100), DEFAULT(100), |
| 1188 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1189 | ON_UPDATE(change_keycache_param)); |
| 1190 | |
| 1191 | static Sys_var_keycache Sys_key_cache_age_threshold( |
| 1192 | "key_cache_age_threshold" , "This characterizes the number of " |
| 1193 | "hits a hot block has to be untouched until it is considered aged " |
| 1194 | "enough to be downgraded to a warm block. This specifies the " |
| 1195 | "percentage ratio of that number of hits to the total number of " |
| 1196 | "blocks in key cache" , |
| 1197 | KEYCACHE_VAR(param_age_threshold), |
| 1198 | CMD_LINE(REQUIRED_ARG, OPT_KEY_CACHE_AGE_THRESHOLD), |
| 1199 | VALID_RANGE(100, UINT_MAX), DEFAULT(300), |
| 1200 | BLOCK_SIZE(100), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1201 | ON_UPDATE(change_keycache_param)); |
| 1202 | |
| 1203 | static Sys_var_keycache Sys_key_cache_file_hash_size( |
| 1204 | "key_cache_file_hash_size" , |
| 1205 | "Number of hash buckets for open and changed files. If you have a lot of MyISAM " |
| 1206 | "files open you should increase this for faster flush of changes. A good " |
| 1207 | "value is probably 1/10 of number of possible open MyISAM files." , |
| 1208 | KEYCACHE_VAR(changed_blocks_hash_size), |
| 1209 | CMD_LINE(REQUIRED_ARG, OPT_KEY_CACHE_CHANGED_BLOCKS_HASH_SIZE), |
| 1210 | VALID_RANGE(128, 16384), DEFAULT(512), |
| 1211 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1212 | ON_UPDATE(resize_keycache)); |
| 1213 | |
| 1214 | static Sys_var_mybool Sys_large_files_support( |
| 1215 | "large_files_support" , |
| 1216 | "Whether mysqld was compiled with options for large file support" , |
| 1217 | READ_ONLY GLOBAL_VAR(opt_large_files), |
| 1218 | CMD_LINE_HELP_ONLY, DEFAULT(sizeof(my_off_t) > 4)); |
| 1219 | |
| 1220 | static Sys_var_uint Sys_large_page_size( |
| 1221 | "large_page_size" , |
| 1222 | "If large page support is enabled, this shows the size of memory pages" , |
| 1223 | READ_ONLY GLOBAL_VAR(opt_large_page_size), NO_CMD_LINE, |
| 1224 | VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 1225 | |
| 1226 | static Sys_var_mybool Sys_large_pages( |
| 1227 | "large_pages" , "Enable support for large pages" , |
| 1228 | READ_ONLY GLOBAL_VAR(opt_large_pages), |
| 1229 | IF_WIN(NO_CMD_LINE, CMD_LINE(OPT_ARG)), DEFAULT(FALSE)); |
| 1230 | |
| 1231 | static Sys_var_charptr Sys_language( |
| 1232 | "lc_messages_dir" , "Directory where error messages are" , |
| 1233 | READ_ONLY GLOBAL_VAR(lc_messages_dir_ptr), CMD_LINE(REQUIRED_ARG, 'L'), |
| 1234 | IN_FS_CHARSET, DEFAULT(0)); |
| 1235 | |
| 1236 | static Sys_var_mybool Sys_local_infile( |
| 1237 | "local_infile" , "Enable LOAD DATA LOCAL INFILE" , |
| 1238 | GLOBAL_VAR(opt_local_infile), CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 1239 | |
| 1240 | static Sys_var_ulong Sys_lock_wait_timeout( |
| 1241 | "lock_wait_timeout" , |
| 1242 | "Timeout in seconds to wait for a lock before returning an error." , |
| 1243 | SESSION_VAR(lock_wait_timeout), CMD_LINE(REQUIRED_ARG), |
| 1244 | VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(24 * 60 * 60), BLOCK_SIZE(1)); |
| 1245 | |
| 1246 | #ifdef HAVE_MLOCKALL |
| 1247 | static Sys_var_mybool Sys_locked_in_memory( |
| 1248 | "locked_in_memory" , |
| 1249 | "Whether mysqld was locked in memory with --memlock" , |
| 1250 | READ_ONLY GLOBAL_VAR(locked_in_memory), NO_CMD_LINE, DEFAULT(FALSE)); |
| 1251 | #endif |
| 1252 | |
| 1253 | /* this says NO_CMD_LINE, as command-line option takes a string, not a bool */ |
| 1254 | static Sys_var_mybool Sys_log_bin( |
| 1255 | "log_bin" , "Whether the binary log is enabled" , |
| 1256 | READ_ONLY GLOBAL_VAR(opt_bin_log), NO_CMD_LINE, DEFAULT(FALSE)); |
| 1257 | |
| 1258 | static Sys_var_mybool Sys_log_bin_compress( |
| 1259 | "log_bin_compress" , "Whether the binary log can be compressed" , |
| 1260 | GLOBAL_VAR(opt_bin_log_compress), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 1261 | |
| 1262 | /* the min length is 10, means that Begin/Commit/Rollback would never be compressed! */ |
| 1263 | static Sys_var_uint Sys_log_bin_compress_min_len( |
| 1264 | "log_bin_compress_min_len" , |
| 1265 | "Minimum length of sql statement(in statement mode) or record(in row mode)" |
| 1266 | "that can be compressed." , |
| 1267 | GLOBAL_VAR(opt_bin_log_compress_min_len), |
| 1268 | CMD_LINE(OPT_ARG), VALID_RANGE(10, 1024), DEFAULT(256), BLOCK_SIZE(1)); |
| 1269 | |
| 1270 | static Sys_var_mybool Sys_trust_function_creators( |
| 1271 | "log_bin_trust_function_creators" , |
| 1272 | "If set to FALSE (the default), then when --log-bin is used, creation " |
| 1273 | "of a stored function (or trigger) is allowed only to users having the " |
| 1274 | "SUPER privilege and only if this stored function (trigger) may not " |
| 1275 | "break binary logging. Note that if ALL connections to this server " |
| 1276 | "ALWAYS use row-based binary logging, the security issues do not " |
| 1277 | "exist and the binary logging cannot break, so you can safely set " |
| 1278 | "this to TRUE" , |
| 1279 | GLOBAL_VAR(trust_function_creators), |
| 1280 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 1281 | |
| 1282 | static Sys_var_charptr Sys_log_error( |
| 1283 | "log_error" , |
| 1284 | "Log errors to file (instead of stdout). If file name is not specified " |
| 1285 | "then 'datadir'/'log-basename'.err or the 'pid-file' path with extension " |
| 1286 | ".err is used" , |
| 1287 | READ_ONLY GLOBAL_VAR(log_error_file_ptr), |
| 1288 | CMD_LINE(OPT_ARG, OPT_LOG_ERROR), |
| 1289 | IN_FS_CHARSET, DEFAULT(disabled_my_option)); |
| 1290 | |
| 1291 | static Sys_var_bit Sys_log_queries_not_using_indexes( |
| 1292 | "log_queries_not_using_indexes" , |
| 1293 | "Log queries that are executed without benefit of any index to the " |
| 1294 | "slow log if it is open. Same as log_slow_filter='not_using_index'" , |
| 1295 | SESSION_VAR(log_slow_filter), CMD_LINE(OPT_ARG), QPLAN_NOT_USING_INDEX, |
| 1296 | DEFAULT(FALSE)); |
| 1297 | |
| 1298 | static Sys_var_bit Sys_log_slow_admin_statements( |
| 1299 | "log_slow_admin_statements" , |
| 1300 | "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements " |
| 1301 | "to the slow log if it is open. Resets or sets the option 'admin' in " |
| 1302 | "log_slow_disabled_statements" , |
| 1303 | SESSION_VAR(log_slow_disabled_statements), |
| 1304 | CMD_LINE(OPT_ARG), REVERSE(LOG_SLOW_DISABLE_ADMIN), DEFAULT(TRUE)); |
| 1305 | |
| 1306 | static Sys_var_bit Sys_log_slow_slave_statements( |
| 1307 | "log_slow_slave_statements" , |
| 1308 | "Log slow statements executed by slave thread to the slow log if it is " |
| 1309 | "open. Resets or sets the option 'slave' in " |
| 1310 | "log_slow_disabled_statements" , |
| 1311 | SESSION_VAR(log_slow_disabled_statements), |
| 1312 | CMD_LINE(OPT_ARG), REVERSE(LOG_SLOW_DISABLE_SLAVE), DEFAULT(TRUE)); |
| 1313 | |
| 1314 | static Sys_var_ulong Sys_log_warnings( |
| 1315 | "log_warnings" , |
| 1316 | "Log some not critical warnings to the general log file." |
| 1317 | "Value can be between 0 and 11. Higher values mean more verbosity" , |
| 1318 | SESSION_VAR(log_warnings), |
| 1319 | CMD_LINE(OPT_ARG, 'W'), |
| 1320 | VALID_RANGE(0, UINT_MAX), DEFAULT(2), BLOCK_SIZE(1)); |
| 1321 | |
| 1322 | static bool update_cached_long_query_time(sys_var *self, THD *thd, |
| 1323 | enum_var_type type) |
| 1324 | { |
| 1325 | if (type == OPT_SESSION) |
| 1326 | thd->variables.long_query_time= |
| 1327 | double2ulonglong(thd->variables.long_query_time_double * 1e6); |
| 1328 | else |
| 1329 | global_system_variables.long_query_time= |
| 1330 | double2ulonglong(global_system_variables.long_query_time_double * 1e6); |
| 1331 | return false; |
| 1332 | } |
| 1333 | |
| 1334 | static Sys_var_double Sys_long_query_time( |
| 1335 | "long_query_time" , |
| 1336 | "Log all queries that have taken more than long_query_time seconds " |
| 1337 | "to execute to the slow query log file. The argument will be treated " |
| 1338 | "as a decimal value with microsecond precision" , |
| 1339 | SESSION_VAR(long_query_time_double), |
| 1340 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(10), |
| 1341 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1342 | ON_UPDATE(update_cached_long_query_time)); |
| 1343 | |
| 1344 | |
| 1345 | static bool update_cached_max_statement_time(sys_var *self, THD *thd, |
| 1346 | enum_var_type type) |
| 1347 | { |
| 1348 | if (type == OPT_SESSION) |
| 1349 | thd->variables.max_statement_time= |
| 1350 | double2ulonglong(thd->variables.max_statement_time_double * 1e6); |
| 1351 | else |
| 1352 | global_system_variables.max_statement_time= |
| 1353 | double2ulonglong(global_system_variables.max_statement_time_double * 1e6); |
| 1354 | return false; |
| 1355 | } |
| 1356 | |
| 1357 | static Sys_var_double Sys_max_statement_time( |
| 1358 | "max_statement_time" , |
| 1359 | "A query that has taken more than max_statement_time seconds " |
| 1360 | "will be aborted. The argument will be treated as a decimal value " |
| 1361 | "with microsecond precision. A value of 0 (default) means no timeout" , |
| 1362 | SESSION_VAR(max_statement_time_double), |
| 1363 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(0), |
| 1364 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1365 | ON_UPDATE(update_cached_max_statement_time)); |
| 1366 | |
| 1367 | static bool fix_low_prio_updates(sys_var *self, THD *thd, enum_var_type type) |
| 1368 | { |
| 1369 | if (type == OPT_SESSION) |
| 1370 | thd->update_lock_default= (thd->variables.low_priority_updates ? |
| 1371 | TL_WRITE_LOW_PRIORITY : TL_WRITE); |
| 1372 | else |
| 1373 | thr_upgraded_concurrent_insert_lock= |
| 1374 | (global_system_variables.low_priority_updates ? |
| 1375 | TL_WRITE_LOW_PRIORITY : TL_WRITE); |
| 1376 | return false; |
| 1377 | } |
| 1378 | static Sys_var_mybool Sys_low_priority_updates( |
| 1379 | "low_priority_updates" , |
| 1380 | "INSERT/DELETE/UPDATE has lower priority than selects" , |
| 1381 | SESSION_VAR(low_priority_updates), |
| 1382 | CMD_LINE(OPT_ARG), |
| 1383 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1384 | ON_UPDATE(fix_low_prio_updates)); |
| 1385 | |
| 1386 | static Sys_var_mybool Sys_lower_case_file_system( |
| 1387 | "lower_case_file_system" , |
| 1388 | "Case sensitivity of file names on the file system where the " |
| 1389 | "data directory is located" , |
| 1390 | READ_ONLY GLOBAL_VAR(lower_case_file_system), |
| 1391 | CMD_LINE_HELP_ONLY, |
| 1392 | DEFAULT(FALSE)); |
| 1393 | |
| 1394 | static Sys_var_uint Sys_lower_case_table_names( |
| 1395 | "lower_case_table_names" , |
| 1396 | "If set to 1 table names are stored in lowercase on disk and table " |
| 1397 | "names will be case-insensitive. Should be set to 2 if you are using " |
| 1398 | "a case insensitive file system" , |
| 1399 | READ_ONLY GLOBAL_VAR(lower_case_table_names), |
| 1400 | CMD_LINE(OPT_ARG, OPT_LOWER_CASE_TABLE_NAMES), |
| 1401 | VALID_RANGE(0, 2), |
| 1402 | #ifdef FN_NO_CASE_SENSE |
| 1403 | DEFAULT(1), |
| 1404 | #else |
| 1405 | DEFAULT(0), |
| 1406 | #endif |
| 1407 | BLOCK_SIZE(1)); |
| 1408 | |
| 1409 | static bool session_readonly(sys_var *self, THD *thd, set_var *var) |
| 1410 | { |
| 1411 | if (var->type == OPT_GLOBAL) |
| 1412 | return false; |
| 1413 | my_error(ER_VARIABLE_IS_READONLY, MYF(0), "SESSION" , |
| 1414 | self->name.str, "GLOBAL" ); |
| 1415 | return true; |
| 1416 | } |
| 1417 | |
| 1418 | static bool check_max_allowed_packet(sys_var *self, THD *thd, set_var *var) |
| 1419 | { |
| 1420 | longlong val; |
| 1421 | if (session_readonly(self, thd, var)) |
| 1422 | return true; |
| 1423 | |
| 1424 | val= var->save_result.ulonglong_value; |
| 1425 | if (val < (longlong) global_system_variables.net_buffer_length) |
| 1426 | { |
| 1427 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, |
| 1428 | WARN_OPTION_BELOW_LIMIT, |
| 1429 | ER_THD(thd, WARN_OPTION_BELOW_LIMIT), |
| 1430 | "max_allowed_packet" , "net_buffer_length" ); |
| 1431 | } |
| 1432 | return false; |
| 1433 | } |
| 1434 | |
| 1435 | |
| 1436 | static Sys_var_ulong Sys_max_allowed_packet( |
| 1437 | "max_allowed_packet" , |
| 1438 | "Max packet length to send to or receive from the server" , |
| 1439 | SESSION_VAR(max_allowed_packet), CMD_LINE(REQUIRED_ARG), |
| 1440 | VALID_RANGE(1024, 1024*1024*1024), DEFAULT(16*1024*1024), |
| 1441 | BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 1442 | ON_CHECK(check_max_allowed_packet)); |
| 1443 | |
| 1444 | static Sys_var_ulong Sys_slave_max_allowed_packet( |
| 1445 | "slave_max_allowed_packet" , |
| 1446 | "The maximum packet length to sent successfully from the master to slave." , |
| 1447 | GLOBAL_VAR(slave_max_allowed_packet), CMD_LINE(REQUIRED_ARG), |
| 1448 | VALID_RANGE(1024, MAX_MAX_ALLOWED_PACKET), |
| 1449 | DEFAULT(MAX_MAX_ALLOWED_PACKET), |
| 1450 | BLOCK_SIZE(1024)); |
| 1451 | |
| 1452 | static Sys_var_ulonglong Sys_max_binlog_cache_size( |
| 1453 | "max_binlog_cache_size" , |
| 1454 | "Sets the total size of the transactional cache" , |
| 1455 | GLOBAL_VAR(max_binlog_cache_size), CMD_LINE(REQUIRED_ARG), |
| 1456 | VALID_RANGE(IO_SIZE, SIZE_T_MAX), |
| 1457 | DEFAULT((SIZE_T_MAX/IO_SIZE)*IO_SIZE), |
| 1458 | BLOCK_SIZE(IO_SIZE)); |
| 1459 | |
| 1460 | static Sys_var_ulonglong Sys_max_binlog_stmt_cache_size( |
| 1461 | "max_binlog_stmt_cache_size" , |
| 1462 | "Sets the total size of the statement cache" , |
| 1463 | GLOBAL_VAR(max_binlog_stmt_cache_size), CMD_LINE(REQUIRED_ARG), |
| 1464 | VALID_RANGE(IO_SIZE, SIZE_T_MAX), |
| 1465 | DEFAULT((SIZE_T_MAX/IO_SIZE)*IO_SIZE), |
| 1466 | BLOCK_SIZE(IO_SIZE)); |
| 1467 | |
| 1468 | static bool fix_max_binlog_size(sys_var *self, THD *thd, enum_var_type type) |
| 1469 | { |
| 1470 | mysql_bin_log.set_max_size(max_binlog_size); |
| 1471 | return false; |
| 1472 | } |
| 1473 | static Sys_var_ulong Sys_max_binlog_size( |
| 1474 | "max_binlog_size" , |
| 1475 | "Binary log will be rotated automatically when the size exceeds this " |
| 1476 | "value." , |
| 1477 | GLOBAL_VAR(max_binlog_size), CMD_LINE(REQUIRED_ARG), |
| 1478 | VALID_RANGE(IO_SIZE, 1024*1024L*1024L), DEFAULT(1024*1024L*1024L), |
| 1479 | BLOCK_SIZE(IO_SIZE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 1480 | ON_UPDATE(fix_max_binlog_size)); |
| 1481 | |
| 1482 | static bool fix_max_connections(sys_var *self, THD *thd, enum_var_type type) |
| 1483 | { |
| 1484 | #ifndef EMBEDDED_LIBRARY |
| 1485 | resize_thr_alarm(max_connections + extra_max_connections + |
| 1486 | global_system_variables.max_insert_delayed_threads + 10); |
| 1487 | #endif |
| 1488 | return false; |
| 1489 | } |
| 1490 | |
| 1491 | // Default max_connections of 151 is larger than Apache's default max |
| 1492 | // children, to avoid "too many connections" error in a common setup |
| 1493 | static Sys_var_ulong Sys_max_connections( |
| 1494 | "max_connections" , "The number of simultaneous clients allowed" , |
| 1495 | PARSED_EARLY GLOBAL_VAR(max_connections), CMD_LINE(REQUIRED_ARG), |
| 1496 | VALID_RANGE(10, 100000), |
| 1497 | DEFAULT(MAX_CONNECTIONS_DEFAULT), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 1498 | NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_max_connections)); |
| 1499 | |
| 1500 | static Sys_var_ulong Sys_max_connect_errors( |
| 1501 | "max_connect_errors" , |
| 1502 | "If there is more than this number of interrupted connections from " |
| 1503 | "a host this host will be blocked from further connections" , |
| 1504 | GLOBAL_VAR(max_connect_errors), CMD_LINE(REQUIRED_ARG), |
| 1505 | VALID_RANGE(1, UINT_MAX), DEFAULT(MAX_CONNECT_ERRORS), |
| 1506 | BLOCK_SIZE(1)); |
| 1507 | |
| 1508 | static Sys_var_uint Sys_max_digest_length( |
| 1509 | "max_digest_length" , "Maximum length considered for digest text." , |
| 1510 | READ_ONLY GLOBAL_VAR(max_digest_length), |
| 1511 | CMD_LINE(REQUIRED_ARG), |
| 1512 | VALID_RANGE(0, 1024 * 1024), DEFAULT(1024), BLOCK_SIZE(1)); |
| 1513 | |
| 1514 | static bool check_max_delayed_threads(sys_var *self, THD *thd, set_var *var) |
| 1515 | { |
| 1516 | return var->type != OPT_GLOBAL && |
| 1517 | var->save_result.ulonglong_value != 0 && |
| 1518 | var->save_result.ulonglong_value != |
| 1519 | global_system_variables.max_insert_delayed_threads; |
| 1520 | } |
| 1521 | |
| 1522 | // Alias for max_delayed_threads |
| 1523 | static Sys_var_ulong Sys_max_insert_delayed_threads( |
| 1524 | "max_insert_delayed_threads" , |
| 1525 | "Don't start more than this number of threads to handle INSERT " |
| 1526 | "DELAYED statements. If set to zero INSERT DELAYED will be not used" , |
| 1527 | SESSION_VAR(max_insert_delayed_threads), |
| 1528 | NO_CMD_LINE, VALID_RANGE(0, 16384), DEFAULT(20), |
| 1529 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 1530 | ON_CHECK(check_max_delayed_threads), ON_UPDATE(fix_max_connections)); |
| 1531 | |
| 1532 | static Sys_var_ulong Sys_max_delayed_threads( |
| 1533 | "max_delayed_threads" , |
| 1534 | "Don't start more than this number of threads to handle INSERT " |
| 1535 | "DELAYED statements. If set to zero INSERT DELAYED will be not used" , |
| 1536 | SESSION_VAR(max_insert_delayed_threads), |
| 1537 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 16384), DEFAULT(20), |
| 1538 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 1539 | ON_CHECK(check_max_delayed_threads), ON_UPDATE(fix_max_connections)); |
| 1540 | |
| 1541 | static Sys_var_ulong Sys_max_error_count( |
| 1542 | "max_error_count" , |
| 1543 | "Max number of errors/warnings to store for a statement" , |
| 1544 | SESSION_VAR(max_error_count), CMD_LINE(REQUIRED_ARG), |
| 1545 | VALID_RANGE(0, 65535), DEFAULT(DEFAULT_ERROR_COUNT), BLOCK_SIZE(1)); |
| 1546 | |
| 1547 | static Sys_var_ulonglong Sys_max_heap_table_size( |
| 1548 | "max_heap_table_size" , |
| 1549 | "Don't allow creation of heap tables bigger than this" , |
| 1550 | SESSION_VAR(max_heap_table_size), CMD_LINE(REQUIRED_ARG), |
| 1551 | VALID_RANGE(16384, SIZE_T_MAX), DEFAULT(16*1024*1024), |
| 1552 | BLOCK_SIZE(1024)); |
| 1553 | |
| 1554 | static ulong mdl_locks_cache_size; |
| 1555 | static Sys_var_ulong Sys_metadata_locks_cache_size( |
| 1556 | "metadata_locks_cache_size" , "Unused" , |
| 1557 | READ_ONLY GLOBAL_VAR(mdl_locks_cache_size), CMD_LINE(REQUIRED_ARG), |
| 1558 | VALID_RANGE(1, 1024*1024), DEFAULT(1024), |
| 1559 | BLOCK_SIZE(1)); |
| 1560 | |
| 1561 | static ulong mdl_locks_hash_partitions; |
| 1562 | static Sys_var_ulong Sys_metadata_locks_hash_instances( |
| 1563 | "metadata_locks_hash_instances" , "Unused" , |
| 1564 | READ_ONLY GLOBAL_VAR(mdl_locks_hash_partitions), CMD_LINE(REQUIRED_ARG), |
| 1565 | VALID_RANGE(1, 1024), DEFAULT(8), |
| 1566 | BLOCK_SIZE(1)); |
| 1567 | |
| 1568 | static Sys_var_ulonglong Sys_pseudo_thread_id( |
| 1569 | "pseudo_thread_id" , |
| 1570 | "This variable is for internal server use" , |
| 1571 | SESSION_ONLY(pseudo_thread_id), |
| 1572 | NO_CMD_LINE, VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), |
| 1573 | BLOCK_SIZE(1), NO_MUTEX_GUARD, IN_BINLOG, |
| 1574 | ON_CHECK(check_has_super)); |
| 1575 | |
| 1576 | static bool |
| 1577 | check_gtid_domain_id(sys_var *self, THD *thd, set_var *var) |
| 1578 | { |
| 1579 | if (check_has_super(self, thd, var)) |
| 1580 | return true; |
| 1581 | if (var->type != OPT_GLOBAL && |
| 1582 | error_if_in_trans_or_substatement(thd, |
| 1583 | ER_STORED_FUNCTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO, |
| 1584 | ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO)) |
| 1585 | return true; |
| 1586 | |
| 1587 | return false; |
| 1588 | } |
| 1589 | |
| 1590 | |
| 1591 | static Sys_var_uint Sys_gtid_domain_id( |
| 1592 | "gtid_domain_id" , |
| 1593 | "Used with global transaction ID to identify logically independent " |
| 1594 | "replication streams. When events can propagate through multiple " |
| 1595 | "parallel paths (for example multiple masters), each independent " |
| 1596 | "source server must use a distinct domain_id. For simple tree-shaped " |
| 1597 | "replication topologies, it can be left at its default, 0." , |
| 1598 | SESSION_VAR(gtid_domain_id), |
| 1599 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, UINT_MAX32), DEFAULT(0), |
| 1600 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 1601 | ON_CHECK(check_gtid_domain_id)); |
| 1602 | |
| 1603 | |
| 1604 | static bool check_gtid_seq_no(sys_var *self, THD *thd, set_var *var) |
| 1605 | { |
| 1606 | uint32 domain_id, server_id; |
| 1607 | uint64 seq_no; |
| 1608 | |
| 1609 | if (check_has_super(self, thd, var)) |
| 1610 | return true; |
| 1611 | if (unlikely(error_if_in_trans_or_substatement(thd, |
| 1612 | ER_STORED_FUNCTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO, |
| 1613 | ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO))) |
| 1614 | return true; |
| 1615 | |
| 1616 | domain_id= thd->variables.gtid_domain_id; |
| 1617 | server_id= thd->variables.server_id; |
| 1618 | seq_no= (uint64)var->value->val_uint(); |
| 1619 | DBUG_EXECUTE_IF("ignore_set_gtid_seq_no_check" , return 0;); |
| 1620 | if (opt_gtid_strict_mode && opt_bin_log && |
| 1621 | mysql_bin_log.check_strict_gtid_sequence(domain_id, server_id, seq_no)) |
| 1622 | return true; |
| 1623 | |
| 1624 | return false; |
| 1625 | } |
| 1626 | |
| 1627 | |
| 1628 | static Sys_var_ulonglong Sys_gtid_seq_no( |
| 1629 | "gtid_seq_no" , |
| 1630 | "Internal server usage, for replication with global transaction id. " |
| 1631 | "When set, next event group logged to the binary log will use this " |
| 1632 | "sequence number, not generate a new one, thus allowing to preserve " |
| 1633 | "master's GTID in slave's binlog." , |
| 1634 | SESSION_ONLY(gtid_seq_no), |
| 1635 | NO_CMD_LINE, VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), |
| 1636 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 1637 | ON_CHECK(check_gtid_seq_no)); |
| 1638 | |
| 1639 | |
| 1640 | #ifdef HAVE_REPLICATION |
| 1641 | static unsigned char opt_gtid_binlog_pos_dummy; |
| 1642 | static Sys_var_gtid_binlog_pos Sys_gtid_binlog_pos( |
| 1643 | "gtid_binlog_pos" , "Last GTID logged to the binary log, per replication" |
| 1644 | "domain" , |
| 1645 | READ_ONLY GLOBAL_VAR(opt_gtid_binlog_pos_dummy), NO_CMD_LINE); |
| 1646 | |
| 1647 | |
| 1648 | uchar * |
| 1649 | Sys_var_gtid_binlog_pos::global_value_ptr(THD *thd, const LEX_CSTRING *base) |
| 1650 | { |
| 1651 | char buf[128]; |
| 1652 | String str(buf, sizeof(buf), system_charset_info); |
| 1653 | char *p; |
| 1654 | |
| 1655 | str.length(0); |
| 1656 | if ((opt_bin_log && mysql_bin_log.append_state_pos(&str)) || |
| 1657 | !(p= thd->strmake(str.ptr(), str.length()))) |
| 1658 | { |
| 1659 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1660 | return NULL; |
| 1661 | } |
| 1662 | |
| 1663 | return (uchar *)p; |
| 1664 | } |
| 1665 | |
| 1666 | |
| 1667 | static unsigned char opt_gtid_current_pos_dummy; |
| 1668 | static Sys_var_gtid_current_pos Sys_gtid_current_pos( |
| 1669 | "gtid_current_pos" , "Current GTID position of the server. Per " |
| 1670 | "replication domain, this is either the last GTID replicated by a " |
| 1671 | "slave thread, or the GTID logged to the binary log, whichever is " |
| 1672 | "most recent." , |
| 1673 | READ_ONLY GLOBAL_VAR(opt_gtid_current_pos_dummy), NO_CMD_LINE); |
| 1674 | |
| 1675 | |
| 1676 | uchar * |
| 1677 | Sys_var_gtid_current_pos::global_value_ptr(THD *thd, const LEX_CSTRING *base) |
| 1678 | { |
| 1679 | String str; |
| 1680 | char *p; |
| 1681 | |
| 1682 | str.length(0); |
| 1683 | if (rpl_append_gtid_state(&str, true) || |
| 1684 | !(p= thd->strmake(str.ptr(), str.length()))) |
| 1685 | { |
| 1686 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1687 | return NULL; |
| 1688 | } |
| 1689 | |
| 1690 | return (uchar *)p; |
| 1691 | } |
| 1692 | |
| 1693 | |
| 1694 | bool |
| 1695 | Sys_var_gtid_slave_pos::do_check(THD *thd, set_var *var) |
| 1696 | { |
| 1697 | String str, *res; |
| 1698 | |
| 1699 | DBUG_ASSERT(var->type == OPT_GLOBAL); |
| 1700 | |
| 1701 | if (rpl_load_gtid_slave_state(thd)) |
| 1702 | { |
| 1703 | my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql" , |
| 1704 | rpl_gtid_slave_state_table_name.str); |
| 1705 | return true; |
| 1706 | } |
| 1707 | |
| 1708 | if (give_error_if_slave_running(0)) |
| 1709 | return true; |
| 1710 | if (!(res= var->value->val_str(&str))) |
| 1711 | return true; |
| 1712 | if (thd->in_active_multi_stmt_transaction()) |
| 1713 | { |
| 1714 | my_error(ER_CANT_DO_THIS_DURING_AN_TRANSACTION, MYF(0)); |
| 1715 | return true; |
| 1716 | } |
| 1717 | if (rpl_gtid_pos_check(thd, &((*res)[0]), res->length())) |
| 1718 | return true; |
| 1719 | |
| 1720 | if (!(var->save_result.string_value.str= |
| 1721 | thd->strmake(res->ptr(), res->length()))) |
| 1722 | { |
| 1723 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1724 | return true; |
| 1725 | } |
| 1726 | var->save_result.string_value.length= res->length(); |
| 1727 | return false; |
| 1728 | } |
| 1729 | |
| 1730 | |
| 1731 | bool |
| 1732 | Sys_var_gtid_slave_pos::global_update(THD *thd, set_var *var) |
| 1733 | { |
| 1734 | bool err; |
| 1735 | |
| 1736 | DBUG_ASSERT(var->type == OPT_GLOBAL); |
| 1737 | |
| 1738 | if (!var->value) |
| 1739 | { |
| 1740 | my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); |
| 1741 | return true; |
| 1742 | } |
| 1743 | |
| 1744 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 1745 | mysql_mutex_lock(&LOCK_active_mi); |
| 1746 | if (give_error_if_slave_running(1)) |
| 1747 | err= true; |
| 1748 | else |
| 1749 | err= rpl_gtid_pos_update(thd, var->save_result.string_value.str, |
| 1750 | var->save_result.string_value.length); |
| 1751 | mysql_mutex_unlock(&LOCK_active_mi); |
| 1752 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 1753 | return err; |
| 1754 | } |
| 1755 | |
| 1756 | |
| 1757 | uchar * |
| 1758 | Sys_var_gtid_slave_pos::global_value_ptr(THD *thd, const LEX_CSTRING *base) |
| 1759 | { |
| 1760 | String str; |
| 1761 | char *p; |
| 1762 | |
| 1763 | str.length(0); |
| 1764 | /* |
| 1765 | If the mysql.rpl_slave_pos table could not be loaded, then we cannot |
| 1766 | easily automatically try to reload it here - we may be inside a statement |
| 1767 | that already has tables locked and so opening more tables is problematic. |
| 1768 | |
| 1769 | But if the table is not loaded (eg. missing mysql_upgrade_db or some such), |
| 1770 | then the slave state must be empty anyway. |
| 1771 | */ |
| 1772 | if ((rpl_global_gtid_slave_state->loaded && |
| 1773 | rpl_append_gtid_state(&str, false)) || |
| 1774 | !(p= thd->strmake(str.ptr(), str.length()))) |
| 1775 | { |
| 1776 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1777 | return NULL; |
| 1778 | } |
| 1779 | |
| 1780 | return (uchar *)p; |
| 1781 | } |
| 1782 | |
| 1783 | |
| 1784 | static unsigned char opt_gtid_slave_pos_dummy; |
| 1785 | static Sys_var_gtid_slave_pos Sys_gtid_slave_pos( |
| 1786 | "gtid_slave_pos" , |
| 1787 | "The list of global transaction IDs that were last replicated on the " |
| 1788 | "server, one for each replication domain." , |
| 1789 | GLOBAL_VAR(opt_gtid_slave_pos_dummy), NO_CMD_LINE); |
| 1790 | |
| 1791 | |
| 1792 | static Sys_var_mybool Sys_gtid_strict_mode( |
| 1793 | "gtid_strict_mode" , |
| 1794 | "Enforce strict seq_no ordering of events in the binary log. Slave " |
| 1795 | "stops with an error if it encounters an event that would cause it to " |
| 1796 | "generate an out-of-order binlog if executed." , |
| 1797 | GLOBAL_VAR(opt_gtid_strict_mode), |
| 1798 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 1799 | |
| 1800 | |
| 1801 | struct gtid_binlog_state_data { rpl_gtid *list; uint32 list_len; }; |
| 1802 | |
| 1803 | bool |
| 1804 | Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var) |
| 1805 | { |
| 1806 | String str, *res; |
| 1807 | struct gtid_binlog_state_data *data; |
| 1808 | rpl_gtid *list; |
| 1809 | uint32 list_len; |
| 1810 | |
| 1811 | DBUG_ASSERT(var->type == OPT_GLOBAL); |
| 1812 | |
| 1813 | if (!(res= var->value->val_str(&str))) |
| 1814 | return true; |
| 1815 | if (thd->in_active_multi_stmt_transaction()) |
| 1816 | { |
| 1817 | my_error(ER_CANT_DO_THIS_DURING_AN_TRANSACTION, MYF(0)); |
| 1818 | return true; |
| 1819 | } |
| 1820 | if (!mysql_bin_log.is_open()) |
| 1821 | { |
| 1822 | my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(0)); |
| 1823 | return true; |
| 1824 | } |
| 1825 | if (!mysql_bin_log.is_empty_state()) |
| 1826 | { |
| 1827 | my_error(ER_BINLOG_MUST_BE_EMPTY, MYF(0)); |
| 1828 | return true; |
| 1829 | } |
| 1830 | if (res->length() == 0) |
| 1831 | { |
| 1832 | list= NULL; |
| 1833 | list_len= 0; |
| 1834 | } |
| 1835 | else if (!(list= gtid_parse_string_to_list(res->ptr(), res->length(), |
| 1836 | &list_len))) |
| 1837 | { |
| 1838 | my_error(ER_INCORRECT_GTID_STATE, MYF(0)); |
| 1839 | return true; |
| 1840 | } |
| 1841 | if (!(data= (gtid_binlog_state_data *)my_malloc(sizeof(*data), MYF(0)))) |
| 1842 | { |
| 1843 | my_free(list); |
| 1844 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1845 | return true; |
| 1846 | } |
| 1847 | data->list= list; |
| 1848 | data->list_len= list_len; |
| 1849 | var->save_result.ptr= data; |
| 1850 | return false; |
| 1851 | } |
| 1852 | |
| 1853 | |
| 1854 | bool |
| 1855 | Sys_var_gtid_binlog_state::global_update(THD *thd, set_var *var) |
| 1856 | { |
| 1857 | bool res; |
| 1858 | |
| 1859 | DBUG_ASSERT(var->type == OPT_GLOBAL); |
| 1860 | |
| 1861 | if (!var->value) |
| 1862 | { |
| 1863 | my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); |
| 1864 | return true; |
| 1865 | } |
| 1866 | |
| 1867 | struct gtid_binlog_state_data *data= |
| 1868 | (struct gtid_binlog_state_data *)var->save_result.ptr; |
| 1869 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 1870 | res= (reset_master(thd, data->list, data->list_len, 0) != 0); |
| 1871 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 1872 | my_free(data->list); |
| 1873 | my_free(data); |
| 1874 | return res; |
| 1875 | } |
| 1876 | |
| 1877 | |
| 1878 | uchar * |
| 1879 | Sys_var_gtid_binlog_state::global_value_ptr(THD *thd, const LEX_CSTRING *base) |
| 1880 | { |
| 1881 | char buf[512]; |
| 1882 | String str(buf, sizeof(buf), system_charset_info); |
| 1883 | char *p; |
| 1884 | |
| 1885 | str.length(0); |
| 1886 | if ((opt_bin_log && mysql_bin_log.append_state(&str)) || |
| 1887 | !(p= thd->strmake(str.ptr(), str.length()))) |
| 1888 | { |
| 1889 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1890 | return NULL; |
| 1891 | } |
| 1892 | |
| 1893 | return (uchar *)p; |
| 1894 | } |
| 1895 | |
| 1896 | |
| 1897 | static unsigned char opt_gtid_binlog_state_dummy; |
| 1898 | static Sys_var_gtid_binlog_state Sys_gtid_binlog_state( |
| 1899 | "gtid_binlog_state" , |
| 1900 | "The internal GTID state of the binlog, used to keep track of all " |
| 1901 | "GTIDs ever logged to the binlog." , |
| 1902 | GLOBAL_VAR(opt_gtid_binlog_state_dummy), NO_CMD_LINE); |
| 1903 | |
| 1904 | |
| 1905 | static Sys_var_last_gtid Sys_last_gtid( |
| 1906 | "last_gtid" , "The GTID of the last commit (if binlogging was enabled), " |
| 1907 | "or the empty string if none." , |
| 1908 | READ_ONLY sys_var::ONLY_SESSION, NO_CMD_LINE); |
| 1909 | |
| 1910 | |
| 1911 | uchar * |
| 1912 | Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_CSTRING *base) |
| 1913 | { |
| 1914 | char buf[10+1+10+1+20+1]; |
| 1915 | String str(buf, sizeof(buf), system_charset_info); |
| 1916 | char *p; |
| 1917 | bool first= true; |
| 1918 | |
| 1919 | str.length(0); |
| 1920 | if ((thd->last_commit_gtid.seq_no > 0 && |
| 1921 | rpl_slave_state_tostring_helper(&str, &thd->last_commit_gtid, &first)) || |
| 1922 | !(p= thd->strmake(str.ptr(), str.length()))) |
| 1923 | { |
| 1924 | my_error(ER_OUT_OF_RESOURCES, MYF(0)); |
| 1925 | return NULL; |
| 1926 | } |
| 1927 | |
| 1928 | return (uchar *)p; |
| 1929 | } |
| 1930 | |
| 1931 | |
| 1932 | static bool |
| 1933 | check_slave_parallel_threads(sys_var *self, THD *thd, set_var *var) |
| 1934 | { |
| 1935 | return give_error_if_slave_running(0); |
| 1936 | } |
| 1937 | |
| 1938 | static bool |
| 1939 | fix_slave_parallel_threads(sys_var *self, THD *thd, enum_var_type type) |
| 1940 | { |
| 1941 | bool err; |
| 1942 | |
| 1943 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 1944 | err= give_error_if_slave_running(0); |
| 1945 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 1946 | |
| 1947 | return err; |
| 1948 | } |
| 1949 | |
| 1950 | |
| 1951 | static Sys_var_ulong Sys_slave_parallel_threads( |
| 1952 | "slave_parallel_threads" , |
| 1953 | "If non-zero, number of threads to spawn to apply in parallel events " |
| 1954 | "on the slave that were group-committed on the master or were logged " |
| 1955 | "with GTID in different replication domains. Note that these threads " |
| 1956 | "are in addition to the IO and SQL threads, which are always created " |
| 1957 | "by a replication slave" , |
| 1958 | GLOBAL_VAR(opt_slave_parallel_threads), CMD_LINE(REQUIRED_ARG), |
| 1959 | VALID_RANGE(0,16383), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 1960 | NOT_IN_BINLOG, ON_CHECK(check_slave_parallel_threads), |
| 1961 | ON_UPDATE(fix_slave_parallel_threads)); |
| 1962 | |
| 1963 | /* Alias for @@slave_parallel_threads to match what MySQL 5.7 uses. */ |
| 1964 | static Sys_var_ulong Sys_slave_parallel_workers( |
| 1965 | "slave_parallel_workers" , |
| 1966 | "Alias for slave_parallel_threads" , |
| 1967 | GLOBAL_VAR(opt_slave_parallel_threads), CMD_LINE(REQUIRED_ARG), |
| 1968 | VALID_RANGE(0,16383), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 1969 | NOT_IN_BINLOG, ON_CHECK(check_slave_parallel_threads), |
| 1970 | ON_UPDATE(fix_slave_parallel_threads)); |
| 1971 | |
| 1972 | |
| 1973 | static bool |
| 1974 | check_slave_domain_parallel_threads(sys_var *self, THD *thd, set_var *var) |
| 1975 | { |
| 1976 | return give_error_if_slave_running(0); |
| 1977 | } |
| 1978 | |
| 1979 | static bool |
| 1980 | fix_slave_domain_parallel_threads(sys_var *self, THD *thd, enum_var_type type) |
| 1981 | { |
| 1982 | bool running; |
| 1983 | |
| 1984 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 1985 | running= give_error_if_slave_running(0); |
| 1986 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 1987 | |
| 1988 | return running; |
| 1989 | } |
| 1990 | |
| 1991 | |
| 1992 | static Sys_var_ulong Sys_slave_domain_parallel_threads( |
| 1993 | "slave_domain_parallel_threads" , |
| 1994 | "Maximum number of parallel threads to use on slave for events in a " |
| 1995 | "single replication domain. When using multiple domains, this can be " |
| 1996 | "used to limit a single domain from grabbing all threads and thus " |
| 1997 | "stalling other domains. The default of 0 means to allow a domain to " |
| 1998 | "grab as many threads as it wants, up to the value of " |
| 1999 | "slave_parallel_threads." , |
| 2000 | GLOBAL_VAR(opt_slave_domain_parallel_threads), CMD_LINE(REQUIRED_ARG), |
| 2001 | VALID_RANGE(0,16383), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 2002 | NOT_IN_BINLOG, ON_CHECK(check_slave_domain_parallel_threads), |
| 2003 | ON_UPDATE(fix_slave_domain_parallel_threads)); |
| 2004 | |
| 2005 | |
| 2006 | static Sys_var_ulong Sys_slave_parallel_max_queued( |
| 2007 | "slave_parallel_max_queued" , |
| 2008 | "Limit on how much memory SQL threads should use per parallel " |
| 2009 | "replication thread when reading ahead in the relay log looking for " |
| 2010 | "opportunities for parallel replication. Only used when " |
| 2011 | "--slave-parallel-threads > 0." , |
| 2012 | GLOBAL_VAR(opt_slave_parallel_max_queued), CMD_LINE(REQUIRED_ARG), |
| 2013 | VALID_RANGE(0,2147483647), DEFAULT(131072), BLOCK_SIZE(1)); |
| 2014 | |
| 2015 | |
| 2016 | bool |
| 2017 | Sys_var_slave_parallel_mode::global_update(THD *thd, set_var *var) |
| 2018 | { |
| 2019 | enum_slave_parallel_mode new_value= |
| 2020 | (enum_slave_parallel_mode)var->save_result.ulonglong_value; |
| 2021 | LEX_CSTRING *base_name= &var->base; |
| 2022 | Master_info *mi; |
| 2023 | bool res= false; |
| 2024 | |
| 2025 | if (!base_name->length) |
| 2026 | base_name= &thd->variables.default_master_connection; |
| 2027 | |
| 2028 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 2029 | mysql_mutex_lock(&LOCK_active_mi); |
| 2030 | |
| 2031 | mi= master_info_index-> |
| 2032 | get_master_info(base_name, !base_name->length ? |
| 2033 | Sql_condition::WARN_LEVEL_ERROR : |
| 2034 | Sql_condition::WARN_LEVEL_WARN); |
| 2035 | |
| 2036 | if (mi) |
| 2037 | { |
| 2038 | if (mi->rli.slave_running) |
| 2039 | { |
| 2040 | my_error(ER_SLAVE_MUST_STOP, MYF(0), |
| 2041 | (int) mi->connection_name.length, mi->connection_name.str); |
| 2042 | res= true; |
| 2043 | } |
| 2044 | else |
| 2045 | { |
| 2046 | mi->parallel_mode= new_value; |
| 2047 | if (!base_name->length) |
| 2048 | { |
| 2049 | /* Use as default value for new connections */ |
| 2050 | opt_slave_parallel_mode= new_value; |
| 2051 | } |
| 2052 | } |
| 2053 | } |
| 2054 | |
| 2055 | mysql_mutex_unlock(&LOCK_active_mi); |
| 2056 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 2057 | |
| 2058 | return res; |
| 2059 | } |
| 2060 | |
| 2061 | |
| 2062 | uchar * |
| 2063 | Sys_var_slave_parallel_mode::global_value_ptr(THD *thd, |
| 2064 | const LEX_CSTRING *base_name) |
| 2065 | { |
| 2066 | Master_info *mi; |
| 2067 | enum_slave_parallel_mode val= |
| 2068 | (enum_slave_parallel_mode)opt_slave_parallel_mode; |
| 2069 | |
| 2070 | if (!base_name->length) |
| 2071 | base_name= &thd->variables.default_master_connection; |
| 2072 | |
| 2073 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 2074 | mysql_mutex_lock(&LOCK_active_mi); |
| 2075 | |
| 2076 | mi= master_info_index-> |
| 2077 | get_master_info(base_name, !base_name->length ? |
| 2078 | Sql_condition::WARN_LEVEL_ERROR : |
| 2079 | Sql_condition::WARN_LEVEL_WARN); |
| 2080 | if (mi) |
| 2081 | val= mi->parallel_mode; |
| 2082 | |
| 2083 | mysql_mutex_unlock(&LOCK_active_mi); |
| 2084 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 2085 | if (!mi) |
| 2086 | return 0; |
| 2087 | |
| 2088 | return valptr(thd, val); |
| 2089 | } |
| 2090 | |
| 2091 | |
| 2092 | /* The order here must match enum_slave_parallel_mode in mysqld.h. */ |
| 2093 | static const char *slave_parallel_mode_names[] = { |
| 2094 | "none" , "minimal" , "conservative" , "optimistic" , "aggressive" , NULL |
| 2095 | }; |
| 2096 | export TYPELIB slave_parallel_mode_typelib = { |
| 2097 | array_elements(slave_parallel_mode_names)-1, |
| 2098 | "" , |
| 2099 | slave_parallel_mode_names, |
| 2100 | NULL |
| 2101 | }; |
| 2102 | |
| 2103 | static Sys_var_slave_parallel_mode Sys_slave_parallel_mode( |
| 2104 | "slave_parallel_mode" , |
| 2105 | "Controls what transactions are applied in parallel when using " |
| 2106 | "--slave-parallel-threads. Possible values: \"optimistic\" tries to " |
| 2107 | "apply most transactional DML in parallel, and handles any conflicts " |
| 2108 | "with rollback and retry. \"conservative\" limits parallelism in an " |
| 2109 | "effort to avoid any conflicts. \"aggressive\" tries to maximise the " |
| 2110 | "parallelism, possibly at the cost of increased conflict rate. " |
| 2111 | "\"minimal\" only parallelizes the commit steps of transactions. " |
| 2112 | "\"none\" disables parallel apply completely." , |
| 2113 | GLOBAL_VAR(opt_slave_parallel_mode), NO_CMD_LINE, |
| 2114 | slave_parallel_mode_names, DEFAULT(SLAVE_PARALLEL_CONSERVATIVE)); |
| 2115 | |
| 2116 | |
| 2117 | static Sys_var_bit Sys_skip_parallel_replication( |
| 2118 | "skip_parallel_replication" , |
| 2119 | "If set when a transaction is written to the binlog, parallel apply of " |
| 2120 | "that transaction will be avoided on a slave where slave_parallel_mode " |
| 2121 | "is not \"aggressive\". Can be used to avoid unnecessary rollback and " |
| 2122 | "retry for transactions that are likely to cause a conflict if " |
| 2123 | "replicated in parallel." , |
| 2124 | SESSION_ONLY(option_bits), NO_CMD_LINE, OPTION_RPL_SKIP_PARALLEL, |
| 2125 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG); |
| 2126 | |
| 2127 | |
| 2128 | static bool |
| 2129 | check_gtid_ignore_duplicates(sys_var *self, THD *thd, set_var *var) |
| 2130 | { |
| 2131 | return give_error_if_slave_running(0); |
| 2132 | } |
| 2133 | |
| 2134 | static bool |
| 2135 | fix_gtid_ignore_duplicates(sys_var *self, THD *thd, enum_var_type type) |
| 2136 | { |
| 2137 | bool running; |
| 2138 | |
| 2139 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 2140 | running= give_error_if_slave_running(0); |
| 2141 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 2142 | |
| 2143 | return running; |
| 2144 | } |
| 2145 | |
| 2146 | |
| 2147 | static Sys_var_mybool Sys_gtid_ignore_duplicates( |
| 2148 | "gtid_ignore_duplicates" , |
| 2149 | "When set, different master connections in multi-source replication are " |
| 2150 | "allowed to receive and process event groups with the same GTID (when " |
| 2151 | "using GTID mode). Only one will be applied, any others will be " |
| 2152 | "ignored. Within a given replication domain, just the sequence number " |
| 2153 | "will be used to decide whether a given GTID has been already applied; " |
| 2154 | "this means it is the responsibility of the user to ensure that GTID " |
| 2155 | "sequence numbers are strictly increasing." , |
| 2156 | GLOBAL_VAR(opt_gtid_ignore_duplicates), CMD_LINE(OPT_ARG), |
| 2157 | DEFAULT(FALSE), NO_MUTEX_GUARD, |
| 2158 | NOT_IN_BINLOG, ON_CHECK(check_gtid_ignore_duplicates), |
| 2159 | ON_UPDATE(fix_gtid_ignore_duplicates)); |
| 2160 | #endif |
| 2161 | |
| 2162 | |
| 2163 | static Sys_var_ulong Sys_binlog_commit_wait_count( |
| 2164 | "binlog_commit_wait_count" , |
| 2165 | "If non-zero, binlog write will wait at most binlog_commit_wait_usec " |
| 2166 | "microseconds for at least this many commits to queue up for group " |
| 2167 | "commit to the binlog. This can reduce I/O on the binlog and provide " |
| 2168 | "increased opportunity for parallel apply on the slave, but too high " |
| 2169 | "a value will decrease commit throughput." , |
| 2170 | GLOBAL_VAR(opt_binlog_commit_wait_count), CMD_LINE(REQUIRED_ARG), |
| 2171 | VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 2172 | |
| 2173 | |
| 2174 | static Sys_var_ulong Sys_binlog_commit_wait_usec( |
| 2175 | "binlog_commit_wait_usec" , |
| 2176 | "Maximum time, in microseconds, to wait for more commits to queue up " |
| 2177 | "for binlog group commit. Only takes effect if the value of " |
| 2178 | "binlog_commit_wait_count is non-zero." , |
| 2179 | GLOBAL_VAR(opt_binlog_commit_wait_usec), CMD_LINE(REQUIRED_ARG), |
| 2180 | VALID_RANGE(0, ULONG_MAX), DEFAULT(100000), BLOCK_SIZE(1)); |
| 2181 | |
| 2182 | |
| 2183 | static bool fix_max_join_size(sys_var *self, THD *thd, enum_var_type type) |
| 2184 | { |
| 2185 | SV *sv= type == OPT_GLOBAL ? &global_system_variables : &thd->variables; |
| 2186 | if (sv->max_join_size == HA_POS_ERROR) |
| 2187 | sv->option_bits|= OPTION_BIG_SELECTS; |
| 2188 | else |
| 2189 | sv->option_bits&= ~OPTION_BIG_SELECTS; |
| 2190 | return false; |
| 2191 | } |
| 2192 | static Sys_var_harows Sys_max_join_size( |
| 2193 | "max_join_size" , |
| 2194 | "Joins that are probably going to read more than max_join_size " |
| 2195 | "records return an error" , |
| 2196 | SESSION_VAR(max_join_size), CMD_LINE(REQUIRED_ARG), |
| 2197 | VALID_RANGE(1, HA_POS_ERROR), DEFAULT(HA_POS_ERROR), BLOCK_SIZE(1), |
| 2198 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2199 | ON_UPDATE(fix_max_join_size)); |
| 2200 | |
| 2201 | static Sys_var_ulong Sys_max_seeks_for_key( |
| 2202 | "max_seeks_for_key" , |
| 2203 | "Limit assumed max number of seeks when looking up rows based on a key" , |
| 2204 | SESSION_VAR(max_seeks_for_key), CMD_LINE(REQUIRED_ARG), |
| 2205 | VALID_RANGE(1, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1)); |
| 2206 | |
| 2207 | static Sys_var_ulong Sys_max_length_for_sort_data( |
| 2208 | "max_length_for_sort_data" , |
| 2209 | "Max number of bytes in sorted records" , |
| 2210 | SESSION_VAR(max_length_for_sort_data), CMD_LINE(REQUIRED_ARG), |
| 2211 | VALID_RANGE(4, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1)); |
| 2212 | |
| 2213 | static Sys_var_ulong Sys_max_long_data_size( |
| 2214 | "max_long_data_size" , |
| 2215 | "The maximum BLOB length to send to server from " |
| 2216 | "mysql_send_long_data API. Deprecated option; " |
| 2217 | "use max_allowed_packet instead." , |
| 2218 | READ_ONLY GLOBAL_VAR(max_long_data_size), |
| 2219 | CMD_LINE(REQUIRED_ARG, OPT_MAX_LONG_DATA_SIZE), |
| 2220 | VALID_RANGE(1024, UINT_MAX32), DEFAULT(1024*1024), |
| 2221 | BLOCK_SIZE(1)); |
| 2222 | |
| 2223 | static PolyLock_mutex PLock_prepared_stmt_count(&LOCK_prepared_stmt_count); |
| 2224 | static Sys_var_uint Sys_max_prepared_stmt_count( |
| 2225 | "max_prepared_stmt_count" , |
| 2226 | "Maximum number of prepared statements in the server" , |
| 2227 | GLOBAL_VAR(max_prepared_stmt_count), CMD_LINE(REQUIRED_ARG), |
| 2228 | VALID_RANGE(0, UINT_MAX32), DEFAULT(16382), BLOCK_SIZE(1), |
| 2229 | &PLock_prepared_stmt_count); |
| 2230 | |
| 2231 | static Sys_var_ulong Sys_max_recursive_iterations( |
| 2232 | "max_recursive_iterations" , |
| 2233 | "Maximum number of iterations when executing recursive queries" , |
| 2234 | SESSION_VAR(max_recursive_iterations), CMD_LINE(OPT_ARG), |
| 2235 | VALID_RANGE(0, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1)); |
| 2236 | |
| 2237 | static Sys_var_ulong Sys_max_sort_length( |
| 2238 | "max_sort_length" , |
| 2239 | "The number of bytes to use when sorting BLOB or TEXT values (only " |
| 2240 | "the first max_sort_length bytes of each value are used; the rest " |
| 2241 | "are ignored)" , |
| 2242 | SESSION_VAR(max_sort_length), CMD_LINE(REQUIRED_ARG), |
| 2243 | VALID_RANGE(4, 8192*1024L), DEFAULT(1024), BLOCK_SIZE(1)); |
| 2244 | |
| 2245 | static Sys_var_ulong Sys_max_sp_recursion_depth( |
| 2246 | "max_sp_recursion_depth" , |
| 2247 | "Maximum stored procedure recursion depth" , |
| 2248 | SESSION_VAR(max_sp_recursion_depth), CMD_LINE(OPT_ARG), |
| 2249 | VALID_RANGE(0, 255), DEFAULT(0), BLOCK_SIZE(1)); |
| 2250 | |
| 2251 | |
| 2252 | static bool if_checking_enabled(sys_var *self, THD *thd, set_var *var) |
| 2253 | { |
| 2254 | if (session_readonly(self, thd, var)) |
| 2255 | return true; |
| 2256 | |
| 2257 | if (!max_user_connections_checking) |
| 2258 | { |
| 2259 | my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--max-user-connections=0" ); |
| 2260 | return true; |
| 2261 | } |
| 2262 | |
| 2263 | return false; |
| 2264 | } |
| 2265 | // non-standard session_value_ptr() here |
| 2266 | static Sys_var_max_user_conn Sys_max_user_connections( |
| 2267 | "max_user_connections" , |
| 2268 | "The maximum number of active connections for a single user " |
| 2269 | "(0 = no limit)" , |
| 2270 | SESSION_VAR(max_user_connections), CMD_LINE(REQUIRED_ARG), |
| 2271 | VALID_RANGE(-1, INT_MAX), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 2272 | NOT_IN_BINLOG, ON_CHECK(if_checking_enabled)); |
| 2273 | |
| 2274 | static Sys_var_ulong Sys_max_tmp_tables( |
| 2275 | "max_tmp_tables" , "Unused, will be removed." , |
| 2276 | SESSION_VAR(max_tmp_tables), CMD_LINE(REQUIRED_ARG), |
| 2277 | VALID_RANGE(1, UINT_MAX), DEFAULT(32), BLOCK_SIZE(1), |
| 2278 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), |
| 2279 | DEPRECATED("" )); |
| 2280 | |
| 2281 | static Sys_var_ulong Sys_max_write_lock_count( |
| 2282 | "max_write_lock_count" , |
| 2283 | "After this many write locks, allow some read locks to run in between" , |
| 2284 | GLOBAL_VAR(max_write_lock_count), CMD_LINE(REQUIRED_ARG), |
| 2285 | VALID_RANGE(1, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1)); |
| 2286 | |
| 2287 | static Sys_var_ulong Sys_min_examined_row_limit( |
| 2288 | "min_examined_row_limit" , |
| 2289 | "Don't write queries to slow log that examine fewer rows " |
| 2290 | "than that" , |
| 2291 | SESSION_VAR(min_examined_row_limit), CMD_LINE(REQUIRED_ARG), |
| 2292 | VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 2293 | |
| 2294 | #ifdef _WIN32 |
| 2295 | static Sys_var_mybool Sys_named_pipe( |
| 2296 | "named_pipe" , "Enable the named pipe (NT)" , |
| 2297 | READ_ONLY GLOBAL_VAR(opt_enable_named_pipe), CMD_LINE(OPT_ARG), |
| 2298 | DEFAULT(FALSE)); |
| 2299 | #endif |
| 2300 | |
| 2301 | |
| 2302 | static bool check_net_buffer_length(sys_var *self, THD *thd, set_var *var) |
| 2303 | { |
| 2304 | longlong val; |
| 2305 | if (session_readonly(self, thd, var)) |
| 2306 | return true; |
| 2307 | |
| 2308 | val= var->save_result.ulonglong_value; |
| 2309 | if (val > (longlong) global_system_variables.max_allowed_packet) |
| 2310 | { |
| 2311 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, |
| 2312 | WARN_OPTION_BELOW_LIMIT, |
| 2313 | ER_THD(thd, WARN_OPTION_BELOW_LIMIT), |
| 2314 | "max_allowed_packet" , "net_buffer_length" ); |
| 2315 | } |
| 2316 | return false; |
| 2317 | } |
| 2318 | static Sys_var_ulong Sys_net_buffer_length( |
| 2319 | "net_buffer_length" , |
| 2320 | "Buffer length for TCP/IP and socket communication" , |
| 2321 | SESSION_VAR(net_buffer_length), CMD_LINE(REQUIRED_ARG), |
| 2322 | VALID_RANGE(1024, 1024*1024), DEFAULT(16384), BLOCK_SIZE(1024), |
| 2323 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_net_buffer_length)); |
| 2324 | |
| 2325 | static bool fix_net_read_timeout(sys_var *self, THD *thd, enum_var_type type) |
| 2326 | { |
| 2327 | if (type != OPT_GLOBAL) |
| 2328 | my_net_set_read_timeout(&thd->net, thd->variables.net_read_timeout); |
| 2329 | return false; |
| 2330 | } |
| 2331 | static Sys_var_ulong Sys_net_read_timeout( |
| 2332 | "net_read_timeout" , |
| 2333 | "Number of seconds to wait for more data from a connection before " |
| 2334 | "aborting the read" , |
| 2335 | SESSION_VAR(net_read_timeout), CMD_LINE(REQUIRED_ARG), |
| 2336 | VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_READ_TIMEOUT), BLOCK_SIZE(1), |
| 2337 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2338 | ON_UPDATE(fix_net_read_timeout)); |
| 2339 | |
| 2340 | static bool fix_net_write_timeout(sys_var *self, THD *thd, enum_var_type type) |
| 2341 | { |
| 2342 | if (type != OPT_GLOBAL) |
| 2343 | my_net_set_write_timeout(&thd->net, thd->variables.net_write_timeout); |
| 2344 | return false; |
| 2345 | } |
| 2346 | static Sys_var_ulong Sys_net_write_timeout( |
| 2347 | "net_write_timeout" , |
| 2348 | "Number of seconds to wait for a block to be written to a connection " |
| 2349 | "before aborting the write" , |
| 2350 | SESSION_VAR(net_write_timeout), CMD_LINE(REQUIRED_ARG), |
| 2351 | VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_WRITE_TIMEOUT), BLOCK_SIZE(1), |
| 2352 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2353 | ON_UPDATE(fix_net_write_timeout)); |
| 2354 | |
| 2355 | static bool fix_net_retry_count(sys_var *self, THD *thd, enum_var_type type) |
| 2356 | { |
| 2357 | if (type != OPT_GLOBAL) |
| 2358 | thd->net.retry_count=thd->variables.net_retry_count; |
| 2359 | return false; |
| 2360 | } |
| 2361 | static Sys_var_ulong Sys_net_retry_count( |
| 2362 | "net_retry_count" , |
| 2363 | "If a read on a communication port is interrupted, retry this " |
| 2364 | "many times before giving up" , |
| 2365 | SESSION_VAR(net_retry_count), CMD_LINE(REQUIRED_ARG), |
| 2366 | VALID_RANGE(1, UINT_MAX), DEFAULT(MYSQLD_NET_RETRY_COUNT), |
| 2367 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2368 | ON_UPDATE(fix_net_retry_count)); |
| 2369 | |
| 2370 | static Sys_var_mybool Sys_old_mode( |
| 2371 | "old" , "Use compatible behavior from previous MariaDB version. See also --old-mode" , |
| 2372 | SESSION_VAR(old_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 2373 | |
| 2374 | static const char *alter_algorithm_modes[]= {"DEFAULT" , "COPY" , "INPLACE" , |
| 2375 | "NOCOPY" , "INSTANT" , NULL}; |
| 2376 | |
| 2377 | static Sys_var_enum Sys_alter_algorithm( |
| 2378 | "alter_algorithm" , "Specify the alter table algorithm" , |
| 2379 | SESSION_VAR(alter_algorithm), CMD_LINE(OPT_ARG), |
| 2380 | alter_algorithm_modes, DEFAULT(0)); |
| 2381 | |
| 2382 | static Sys_var_enum Sys_old_alter_table( |
| 2383 | "old_alter_table" , "Alias for alter_algorithm. " |
| 2384 | "Deprecated. Use --alter-algorithm instead." , |
| 2385 | SESSION_VAR(alter_algorithm), CMD_LINE(OPT_ARG), |
| 2386 | alter_algorithm_modes, DEFAULT(0)); |
| 2387 | |
| 2388 | static bool check_old_passwords(sys_var *self, THD *thd, set_var *var) |
| 2389 | { |
| 2390 | return mysql_user_table_is_in_short_password_format; |
| 2391 | } |
| 2392 | static Sys_var_mybool Sys_old_passwords( |
| 2393 | "old_passwords" , |
| 2394 | "Use old password encryption method (needed for 4.0 and older clients)" , |
| 2395 | SESSION_VAR(old_passwords), CMD_LINE(OPT_ARG), |
| 2396 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 2397 | ON_CHECK(check_old_passwords)); |
| 2398 | export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc |
| 2399 | |
| 2400 | static Sys_var_ulong Sys_open_files_limit( |
| 2401 | "open_files_limit" , |
| 2402 | "If this is not 0, then mysqld will use this value to reserve file " |
| 2403 | "descriptors to use with setrlimit(). If this value is 0 or autoset " |
| 2404 | "then mysqld will reserve max_connections*5 or max_connections + " |
| 2405 | "table_cache*2 (whichever is larger) number of file descriptors" , |
| 2406 | AUTO_SET READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG), |
| 2407 | VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1)); |
| 2408 | |
| 2409 | /// @todo change to enum |
| 2410 | static Sys_var_ulong Sys_optimizer_prune_level( |
| 2411 | "optimizer_prune_level" , |
| 2412 | "Controls the heuristic(s) applied during query optimization to prune " |
| 2413 | "less-promising partial plans from the optimizer search space. " |
| 2414 | "Meaning: 0 - do not apply any heuristic, thus perform exhaustive " |
| 2415 | "search; 1 - prune plans based on number of retrieved rows" , |
| 2416 | SESSION_VAR(optimizer_prune_level), CMD_LINE(REQUIRED_ARG), |
| 2417 | VALID_RANGE(0, 1), DEFAULT(1), BLOCK_SIZE(1)); |
| 2418 | |
| 2419 | static Sys_var_ulong Sys_optimizer_selectivity_sampling_limit( |
| 2420 | "optimizer_selectivity_sampling_limit" , |
| 2421 | "Controls number of record samples to check condition selectivity" , |
| 2422 | SESSION_VAR(optimizer_selectivity_sampling_limit), |
| 2423 | CMD_LINE(REQUIRED_ARG), |
| 2424 | VALID_RANGE(SELECTIVITY_SAMPLING_THRESHOLD, UINT_MAX), |
| 2425 | DEFAULT(SELECTIVITY_SAMPLING_LIMIT), BLOCK_SIZE(1)); |
| 2426 | |
| 2427 | static Sys_var_ulong Sys_optimizer_use_condition_selectivity( |
| 2428 | "optimizer_use_condition_selectivity" , |
| 2429 | "Controls selectivity of which conditions the optimizer takes into " |
| 2430 | "account to calculate cardinality of a partial join when it searches " |
| 2431 | "for the best execution plan " |
| 2432 | "Meaning: " |
| 2433 | "1 - use selectivity of index backed range conditions to calculate " |
| 2434 | "the cardinality of a partial join if the last joined table is " |
| 2435 | "accessed by full table scan or an index scan, " |
| 2436 | "2 - use selectivity of index backed range conditions to calculate " |
| 2437 | "the cardinality of a partial join in any case, " |
| 2438 | "3 - additionally always use selectivity of range conditions that are " |
| 2439 | "not backed by any index to calculate the cardinality of a partial join, " |
| 2440 | "4 - use histograms to calculate selectivity of range conditions that " |
| 2441 | "are not backed by any index to calculate the cardinality of " |
| 2442 | "a partial join." |
| 2443 | "5 - additionally use selectivity of certain non-range predicates " |
| 2444 | "calculated on record samples" , |
| 2445 | SESSION_VAR(optimizer_use_condition_selectivity), CMD_LINE(REQUIRED_ARG), |
| 2446 | VALID_RANGE(1, 5), DEFAULT(1), BLOCK_SIZE(1)); |
| 2447 | |
| 2448 | static Sys_var_ulong Sys_optimizer_search_depth( |
| 2449 | "optimizer_search_depth" , |
| 2450 | "Maximum depth of search performed by the query optimizer. Values " |
| 2451 | "larger than the number of relations in a query result in better " |
| 2452 | "query plans, but take longer to compile a query. Values smaller " |
| 2453 | "than the number of tables in a relation result in faster " |
| 2454 | "optimization, but may produce very bad query plans. If set to 0, " |
| 2455 | "the system will automatically pick a reasonable value." , |
| 2456 | SESSION_VAR(optimizer_search_depth), CMD_LINE(REQUIRED_ARG), |
| 2457 | VALID_RANGE(0, MAX_TABLES+1), DEFAULT(MAX_TABLES+1), BLOCK_SIZE(1)); |
| 2458 | |
| 2459 | /* this is used in the sigsegv handler */ |
| 2460 | export const char *optimizer_switch_names[]= |
| 2461 | { |
| 2462 | "index_merge" ,"index_merge_union" ,"index_merge_sort_union" , |
| 2463 | "index_merge_intersection" ,"index_merge_sort_intersection" , |
| 2464 | "engine_condition_pushdown" , |
| 2465 | "index_condition_pushdown" , |
| 2466 | "derived_merge" , "derived_with_keys" , |
| 2467 | "firstmatch" ,"loosescan" ,"materialization" ,"in_to_exists" ,"semijoin" , |
| 2468 | "partial_match_rowid_merge" , |
| 2469 | "partial_match_table_scan" , |
| 2470 | "subquery_cache" , |
| 2471 | "mrr" , |
| 2472 | "mrr_cost_based" , |
| 2473 | "mrr_sort_keys" , |
| 2474 | "outer_join_with_cache" , |
| 2475 | "semijoin_with_cache" , |
| 2476 | "join_cache_incremental" , |
| 2477 | "join_cache_hashed" , |
| 2478 | "join_cache_bka" , |
| 2479 | "optimize_join_buffer_size" , |
| 2480 | "table_elimination" , |
| 2481 | "extended_keys" , |
| 2482 | "exists_to_in" , |
| 2483 | "orderby_uses_equalities" , |
| 2484 | "condition_pushdown_for_derived" , |
| 2485 | "split_materialized" , |
| 2486 | "default" , |
| 2487 | NullS |
| 2488 | }; |
| 2489 | static bool fix_optimizer_switch(sys_var *self, THD *thd, |
| 2490 | enum_var_type type) |
| 2491 | { |
| 2492 | SV *sv= (type == OPT_GLOBAL) ? &global_system_variables : &thd->variables; |
| 2493 | if (sv->optimizer_switch & deprecated_ENGINE_CONDITION_PUSHDOWN) |
| 2494 | push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, |
| 2495 | ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, |
| 2496 | ER_THD(thd, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), |
| 2497 | "engine_condition_pushdown=on" ); |
| 2498 | return false; |
| 2499 | } |
| 2500 | static Sys_var_flagset Sys_optimizer_switch( |
| 2501 | "optimizer_switch" , |
| 2502 | "Fine-tune the optimizer behavior" , |
| 2503 | SESSION_VAR(optimizer_switch), CMD_LINE(REQUIRED_ARG), |
| 2504 | optimizer_switch_names, DEFAULT(OPTIMIZER_SWITCH_DEFAULT), |
| 2505 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), |
| 2506 | ON_UPDATE(fix_optimizer_switch)); |
| 2507 | |
| 2508 | static Sys_var_charptr Sys_pid_file( |
| 2509 | "pid_file" , "Pid file used by safe_mysqld" , |
| 2510 | READ_ONLY GLOBAL_VAR(pidfile_name_ptr), CMD_LINE(REQUIRED_ARG), |
| 2511 | IN_FS_CHARSET, DEFAULT(0)); |
| 2512 | |
| 2513 | static Sys_var_charptr Sys_plugin_dir( |
| 2514 | "plugin_dir" , "Directory for plugins" , |
| 2515 | READ_ONLY GLOBAL_VAR(opt_plugin_dir_ptr), CMD_LINE(REQUIRED_ARG), |
| 2516 | IN_FS_CHARSET, DEFAULT(0)); |
| 2517 | |
| 2518 | static Sys_var_uint Sys_port( |
| 2519 | "port" , |
| 2520 | "Port number to use for connection or 0 to default to, " |
| 2521 | "my.cnf, $MYSQL_TCP_PORT, " |
| 2522 | #if MYSQL_PORT_DEFAULT == 0 |
| 2523 | "/etc/services, " |
| 2524 | #endif |
| 2525 | "built-in default (" STRINGIFY_ARG(MYSQL_PORT) "), whatever comes first" , |
| 2526 | READ_ONLY GLOBAL_VAR(mysqld_port), CMD_LINE(REQUIRED_ARG, 'P'), |
| 2527 | VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1)); |
| 2528 | |
| 2529 | static Sys_var_ulong Sys_preload_buff_size( |
| 2530 | "preload_buffer_size" , |
| 2531 | "The size of the buffer that is allocated when preloading indexes" , |
| 2532 | SESSION_VAR(preload_buff_size), CMD_LINE(REQUIRED_ARG), |
| 2533 | VALID_RANGE(1024, 1024*1024*1024), DEFAULT(32768), BLOCK_SIZE(1)); |
| 2534 | |
| 2535 | static Sys_var_uint Sys_protocol_version( |
| 2536 | "protocol_version" , |
| 2537 | "The version of the client/server protocol used by the MariaDB server" , |
| 2538 | READ_ONLY GLOBAL_VAR(protocol_version), CMD_LINE_HELP_ONLY, |
| 2539 | VALID_RANGE(0, ~0U), DEFAULT(PROTOCOL_VERSION), BLOCK_SIZE(1)); |
| 2540 | |
| 2541 | static Sys_var_proxy_user Sys_proxy_user( |
| 2542 | "proxy_user" , "The proxy user account name used when logging in" , |
| 2543 | IN_SYSTEM_CHARSET); |
| 2544 | |
| 2545 | static Sys_var_external_user Sys_exterenal_user( |
| 2546 | "external_user" , "The external user account used when logging in" , |
| 2547 | IN_SYSTEM_CHARSET); |
| 2548 | |
| 2549 | static Sys_var_ulong Sys_read_buff_size( |
| 2550 | "read_buffer_size" , |
| 2551 | "Each thread that does a sequential scan allocates a buffer of " |
| 2552 | "this size for each table it scans. If you do many sequential scans, " |
| 2553 | "you may want to increase this value" , |
| 2554 | SESSION_VAR(read_buff_size), CMD_LINE(REQUIRED_ARG), |
| 2555 | VALID_RANGE(IO_SIZE*2, INT_MAX32), DEFAULT(128*1024), |
| 2556 | BLOCK_SIZE(IO_SIZE)); |
| 2557 | |
| 2558 | static bool check_read_only(sys_var *self, THD *thd, set_var *var) |
| 2559 | { |
| 2560 | /* Prevent self dead-lock */ |
| 2561 | if (thd->locked_tables_mode || thd->in_active_multi_stmt_transaction()) |
| 2562 | { |
| 2563 | my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); |
| 2564 | return true; |
| 2565 | } |
| 2566 | return false; |
| 2567 | } |
| 2568 | static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type) |
| 2569 | { |
| 2570 | bool result= true; |
| 2571 | my_bool new_read_only= read_only; // make a copy before releasing a mutex |
| 2572 | DBUG_ENTER("sys_var_opt_readonly::update" ); |
| 2573 | |
| 2574 | if (read_only == FALSE || read_only == opt_readonly) |
| 2575 | { |
| 2576 | opt_readonly= read_only; |
| 2577 | DBUG_RETURN(false); |
| 2578 | } |
| 2579 | |
| 2580 | if (check_read_only(self, thd, 0)) // just in case |
| 2581 | goto end; |
| 2582 | |
| 2583 | if (thd->global_read_lock.is_acquired()) |
| 2584 | { |
| 2585 | /* |
| 2586 | This connection already holds the global read lock. |
| 2587 | This can be the case with: |
| 2588 | - FLUSH TABLES WITH READ LOCK |
| 2589 | - SET GLOBAL READ_ONLY = 1 |
| 2590 | */ |
| 2591 | opt_readonly= read_only; |
| 2592 | DBUG_RETURN(false); |
| 2593 | } |
| 2594 | |
| 2595 | /* |
| 2596 | READ_ONLY=1 prevents write locks from being taken on tables and |
| 2597 | blocks transactions from committing. We therefore should make sure |
| 2598 | that no such events occur while setting the read_only variable. |
| 2599 | This is a 2 step process: |
| 2600 | [1] lock_global_read_lock() |
| 2601 | Prevents connections from obtaining new write locks on |
| 2602 | tables. Note that we can still have active rw transactions. |
| 2603 | [2] make_global_read_lock_block_commit() |
| 2604 | Prevents transactions from committing. |
| 2605 | */ |
| 2606 | |
| 2607 | read_only= opt_readonly; |
| 2608 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 2609 | |
| 2610 | if (thd->global_read_lock.lock_global_read_lock(thd)) |
| 2611 | goto end_with_mutex_unlock; |
| 2612 | |
| 2613 | if ((result= thd->global_read_lock.make_global_read_lock_block_commit(thd))) |
| 2614 | goto end_with_read_lock; |
| 2615 | |
| 2616 | /* Change the opt_readonly system variable, safe because the lock is held */ |
| 2617 | opt_readonly= new_read_only; |
| 2618 | result= false; |
| 2619 | |
| 2620 | end_with_read_lock: |
| 2621 | /* Release the lock */ |
| 2622 | thd->global_read_lock.unlock_global_read_lock(thd); |
| 2623 | end_with_mutex_unlock: |
| 2624 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 2625 | end: |
| 2626 | read_only= opt_readonly; |
| 2627 | DBUG_RETURN(result); |
| 2628 | } |
| 2629 | |
| 2630 | |
| 2631 | /** |
| 2632 | The read_only boolean is always equal to the opt_readonly boolean except |
| 2633 | during fix_read_only(); when that function is entered, opt_readonly is |
| 2634 | the pre-update value and read_only is the post-update value. |
| 2635 | fix_read_only() compares them and runs needed operations for the |
| 2636 | transition (especially when transitioning from false to true) and |
| 2637 | synchronizes both booleans in the end. |
| 2638 | */ |
| 2639 | static Sys_var_mybool Sys_readonly( |
| 2640 | "read_only" , |
| 2641 | "Make all non-temporary tables read-only, with the exception for " |
| 2642 | "replication (slave) threads and users with the SUPER privilege" , |
| 2643 | GLOBAL_VAR(read_only), CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 2644 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 2645 | ON_CHECK(check_read_only), ON_UPDATE(fix_read_only)); |
| 2646 | |
| 2647 | // Small lower limit to be able to test MRR |
| 2648 | static Sys_var_ulong Sys_read_rnd_buff_size( |
| 2649 | "read_rnd_buffer_size" , |
| 2650 | "When reading rows in sorted order after a sort, the rows are read " |
| 2651 | "through this buffer to avoid a disk seeks" , |
| 2652 | SESSION_VAR(read_rnd_buff_size), CMD_LINE(REQUIRED_ARG), |
| 2653 | VALID_RANGE(1, INT_MAX32), DEFAULT(256*1024), BLOCK_SIZE(1)); |
| 2654 | |
| 2655 | static Sys_var_ulong Sys_div_precincrement( |
| 2656 | "div_precision_increment" , "Precision of the result of '/' " |
| 2657 | "operator will be increased on that value" , |
| 2658 | SESSION_VAR(div_precincrement), CMD_LINE(REQUIRED_ARG), |
| 2659 | VALID_RANGE(0, DECIMAL_MAX_SCALE), DEFAULT(4), BLOCK_SIZE(1)); |
| 2660 | |
| 2661 | static Sys_var_ulong Sys_range_alloc_block_size( |
| 2662 | "range_alloc_block_size" , |
| 2663 | "Allocation block size for storing ranges during optimization" , |
| 2664 | SESSION_VAR(range_alloc_block_size), CMD_LINE(REQUIRED_ARG), |
| 2665 | VALID_RANGE(RANGE_ALLOC_BLOCK_SIZE, UINT_MAX), |
| 2666 | DEFAULT(RANGE_ALLOC_BLOCK_SIZE), BLOCK_SIZE(1024)); |
| 2667 | |
| 2668 | static Sys_var_ulong Sys_multi_range_count( |
| 2669 | "multi_range_count" , "Ignored. Use mrr_buffer_size instead" , |
| 2670 | SESSION_VAR(multi_range_count), CMD_LINE(REQUIRED_ARG), |
| 2671 | VALID_RANGE(1, ULONG_MAX), DEFAULT(256), BLOCK_SIZE(1), |
| 2672 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), |
| 2673 | DEPRECATED("'@@mrr_buffer_size'" )); |
| 2674 | |
| 2675 | static bool fix_thd_mem_root(sys_var *self, THD *thd, enum_var_type type) |
| 2676 | { |
| 2677 | if (type != OPT_GLOBAL) |
| 2678 | reset_root_defaults(thd->mem_root, |
| 2679 | thd->variables.query_alloc_block_size, |
| 2680 | thd->variables.query_prealloc_size); |
| 2681 | return false; |
| 2682 | } |
| 2683 | static Sys_var_ulong Sys_query_alloc_block_size( |
| 2684 | "query_alloc_block_size" , |
| 2685 | "Allocation block size for query parsing and execution" , |
| 2686 | SESSION_VAR(query_alloc_block_size), CMD_LINE(REQUIRED_ARG), |
| 2687 | VALID_RANGE(1024, UINT_MAX), DEFAULT(QUERY_ALLOC_BLOCK_SIZE), |
| 2688 | BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2689 | ON_UPDATE(fix_thd_mem_root)); |
| 2690 | |
| 2691 | static Sys_var_ulong Sys_query_prealloc_size( |
| 2692 | "query_prealloc_size" , |
| 2693 | "Persistent buffer for query parsing and execution" , |
| 2694 | SESSION_VAR(query_prealloc_size), CMD_LINE(REQUIRED_ARG), |
| 2695 | VALID_RANGE(1024, UINT_MAX), |
| 2696 | DEFAULT(QUERY_ALLOC_PREALLOC_SIZE), |
| 2697 | BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2698 | ON_UPDATE(fix_thd_mem_root)); |
| 2699 | |
| 2700 | #ifdef HAVE_SMEM |
| 2701 | static Sys_var_mybool Sys_shared_memory( |
| 2702 | "shared_memory" , "Enable the shared memory" , |
| 2703 | READ_ONLY GLOBAL_VAR(opt_enable_shared_memory), CMD_LINE(OPT_ARG), |
| 2704 | DEFAULT(FALSE)); |
| 2705 | |
| 2706 | static Sys_var_charptr Sys_shared_memory_base_name( |
| 2707 | "shared_memory_base_name" , "Base name of shared memory" , |
| 2708 | READ_ONLY GLOBAL_VAR(shared_memory_base_name), CMD_LINE(REQUIRED_ARG), |
| 2709 | IN_FS_CHARSET, DEFAULT(0)); |
| 2710 | #endif |
| 2711 | |
| 2712 | // this has to be NO_CMD_LINE as the command-line option has a different name |
| 2713 | static Sys_var_mybool Sys_skip_external_locking( |
| 2714 | "skip_external_locking" , "Don't use system (external) locking" , |
| 2715 | READ_ONLY GLOBAL_VAR(my_disable_locking), NO_CMD_LINE, DEFAULT(TRUE)); |
| 2716 | |
| 2717 | static Sys_var_mybool Sys_skip_networking( |
| 2718 | "skip_networking" , "Don't allow connection with TCP/IP" , |
| 2719 | READ_ONLY GLOBAL_VAR(opt_disable_networking), CMD_LINE(OPT_ARG), |
| 2720 | DEFAULT(FALSE)); |
| 2721 | |
| 2722 | static Sys_var_mybool Sys_skip_name_resolve( |
| 2723 | "skip_name_resolve" , |
| 2724 | "Don't resolve hostnames. All hostnames are IP's or 'localhost'." , |
| 2725 | READ_ONLY GLOBAL_VAR(opt_skip_name_resolve), |
| 2726 | CMD_LINE(OPT_ARG, OPT_SKIP_RESOLVE), |
| 2727 | DEFAULT(FALSE)); |
| 2728 | |
| 2729 | static Sys_var_mybool Sys_skip_show_database( |
| 2730 | "skip_show_database" , "Don't allow 'SHOW DATABASE' commands" , |
| 2731 | READ_ONLY GLOBAL_VAR(opt_skip_show_db), CMD_LINE(OPT_ARG), |
| 2732 | DEFAULT(FALSE)); |
| 2733 | |
| 2734 | static Sys_var_charptr Sys_socket( |
| 2735 | "socket" , "Socket file to use for connection" , |
| 2736 | READ_ONLY GLOBAL_VAR(mysqld_unix_port), CMD_LINE(REQUIRED_ARG), |
| 2737 | IN_FS_CHARSET, DEFAULT(0)); |
| 2738 | |
| 2739 | /* |
| 2740 | thread_concurrency is a no-op on all platforms since |
| 2741 | MySQL 5.1. It will be removed in the context of |
| 2742 | WL#5265 |
| 2743 | */ |
| 2744 | static Sys_var_ulong Sys_thread_concurrency( |
| 2745 | "thread_concurrency" , |
| 2746 | "Permits the application to give the threads system a hint for " |
| 2747 | "the desired number of threads that should be run at the same time." |
| 2748 | "This variable has no effect, and is deprecated. " |
| 2749 | "It will be removed in a future release." , |
| 2750 | READ_ONLY GLOBAL_VAR(concurrency), |
| 2751 | CMD_LINE(REQUIRED_ARG, OPT_THREAD_CONCURRENCY), |
| 2752 | VALID_RANGE(1, 512), DEFAULT(DEFAULT_CONCURRENCY), BLOCK_SIZE(1), |
| 2753 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), |
| 2754 | DEPRECATED("" )); |
| 2755 | |
| 2756 | static Sys_var_ulonglong Sys_thread_stack( |
| 2757 | "thread_stack" , "The stack size for each thread" , |
| 2758 | READ_ONLY GLOBAL_VAR(my_thread_stack_size), CMD_LINE(REQUIRED_ARG), |
| 2759 | VALID_RANGE(128*1024, ULONGLONG_MAX), DEFAULT(DEFAULT_THREAD_STACK), |
| 2760 | BLOCK_SIZE(1024)); |
| 2761 | |
| 2762 | static Sys_var_charptr Sys_tmpdir( |
| 2763 | "tmpdir" , "Path for temporary files. Several paths may " |
| 2764 | "be specified, separated by a " |
| 2765 | #if defined(__WIN__) |
| 2766 | "semicolon (;)" |
| 2767 | #else |
| 2768 | "colon (:)" |
| 2769 | #endif |
| 2770 | ", in this case they are used in a round-robin fashion" , |
| 2771 | READ_ONLY GLOBAL_VAR(opt_mysql_tmpdir), CMD_LINE(REQUIRED_ARG, 't'), |
| 2772 | IN_FS_CHARSET, DEFAULT(0)); |
| 2773 | |
| 2774 | static bool fix_trans_mem_root(sys_var *self, THD *thd, enum_var_type type) |
| 2775 | { |
| 2776 | if (type != OPT_GLOBAL) |
| 2777 | reset_root_defaults(&thd->transaction.mem_root, |
| 2778 | thd->variables.trans_alloc_block_size, |
| 2779 | thd->variables.trans_prealloc_size); |
| 2780 | return false; |
| 2781 | } |
| 2782 | static Sys_var_ulong Sys_trans_alloc_block_size( |
| 2783 | "transaction_alloc_block_size" , |
| 2784 | "Allocation block size for transactions to be stored in binary log" , |
| 2785 | SESSION_VAR(trans_alloc_block_size), CMD_LINE(REQUIRED_ARG), |
| 2786 | VALID_RANGE(1024, 128 * 1024 * 1024), DEFAULT(TRANS_ALLOC_BLOCK_SIZE), |
| 2787 | BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2788 | ON_UPDATE(fix_trans_mem_root)); |
| 2789 | |
| 2790 | static Sys_var_ulong Sys_trans_prealloc_size( |
| 2791 | "transaction_prealloc_size" , |
| 2792 | "Persistent buffer for transactions to be stored in binary log" , |
| 2793 | SESSION_VAR(trans_prealloc_size), CMD_LINE(REQUIRED_ARG), |
| 2794 | VALID_RANGE(1024, 128 * 1024 * 1024), DEFAULT(TRANS_ALLOC_PREALLOC_SIZE), |
| 2795 | BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2796 | ON_UPDATE(fix_trans_mem_root)); |
| 2797 | |
| 2798 | static const char *thread_handling_names[]= |
| 2799 | { |
| 2800 | "one-thread-per-connection" , "no-threads" , |
| 2801 | #ifdef HAVE_POOL_OF_THREADS |
| 2802 | "pool-of-threads" , |
| 2803 | #endif |
| 2804 | 0 |
| 2805 | }; |
| 2806 | |
| 2807 | #if defined (_WIN32) && defined (HAVE_POOL_OF_THREADS) |
| 2808 | /* Windows is using OS threadpool, so we're pretty sure it works well */ |
| 2809 | #define DEFAULT_THREAD_HANDLING 2 |
| 2810 | #else |
| 2811 | #define DEFAULT_THREAD_HANDLING 0 |
| 2812 | #endif |
| 2813 | |
| 2814 | static Sys_var_enum Sys_thread_handling( |
| 2815 | "thread_handling" , |
| 2816 | "Define threads usage for handling queries" , |
| 2817 | READ_ONLY GLOBAL_VAR(thread_handling), CMD_LINE(REQUIRED_ARG), |
| 2818 | thread_handling_names, |
| 2819 | DEFAULT(DEFAULT_THREAD_HANDLING) |
| 2820 | ); |
| 2821 | |
| 2822 | #ifdef HAVE_QUERY_CACHE |
| 2823 | static bool fix_query_cache_size(sys_var *self, THD *thd, enum_var_type type) |
| 2824 | { |
| 2825 | size_t new_cache_size= query_cache.resize((size_t)query_cache_size); |
| 2826 | /* |
| 2827 | Note: query_cache_size is a global variable reflecting the |
| 2828 | requested cache size. See also query_cache_size_arg |
| 2829 | */ |
| 2830 | if (query_cache_size != new_cache_size) |
| 2831 | push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, |
| 2832 | ER_WARN_QC_RESIZE, ER_THD(thd, ER_WARN_QC_RESIZE), |
| 2833 | query_cache_size, (ulong)new_cache_size); |
| 2834 | |
| 2835 | query_cache_size= new_cache_size; |
| 2836 | |
| 2837 | return false; |
| 2838 | } |
| 2839 | |
| 2840 | static bool fix_query_cache_limit(sys_var *self, THD *thd, enum_var_type type) |
| 2841 | { |
| 2842 | query_cache.result_size_limit(query_cache_limit); |
| 2843 | return false; |
| 2844 | } |
| 2845 | static Sys_var_ulonglong Sys_query_cache_size( |
| 2846 | "query_cache_size" , |
| 2847 | "The memory allocated to store results from old queries" , |
| 2848 | GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG), |
| 2849 | VALID_RANGE(0, ULONG_MAX), DEFAULT(1024*1024), BLOCK_SIZE(1024), |
| 2850 | NO_MUTEX_GUARD, NOT_IN_BINLOG, NULL, |
| 2851 | ON_UPDATE(fix_query_cache_size)); |
| 2852 | |
| 2853 | static Sys_var_ulong Sys_query_cache_limit( |
| 2854 | "query_cache_limit" , |
| 2855 | "Don't cache results that are bigger than this" , |
| 2856 | GLOBAL_VAR(query_cache_limit), CMD_LINE(REQUIRED_ARG), |
| 2857 | VALID_RANGE(0, UINT_MAX), DEFAULT(1024*1024), BLOCK_SIZE(1), |
| 2858 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), |
| 2859 | ON_UPDATE(fix_query_cache_limit)); |
| 2860 | |
| 2861 | static bool fix_qcache_min_res_unit(sys_var *self, THD *thd, enum_var_type type) |
| 2862 | { |
| 2863 | query_cache_min_res_unit= |
| 2864 | (ulong)query_cache.set_min_res_unit(query_cache_min_res_unit); |
| 2865 | return false; |
| 2866 | } |
| 2867 | static Sys_var_ulong Sys_query_cache_min_res_unit( |
| 2868 | "query_cache_min_res_unit" , |
| 2869 | "The minimum size for blocks allocated by the query cache" , |
| 2870 | GLOBAL_VAR(query_cache_min_res_unit), CMD_LINE(REQUIRED_ARG), |
| 2871 | VALID_RANGE(0, UINT_MAX), DEFAULT(QUERY_CACHE_MIN_RESULT_DATA_SIZE), |
| 2872 | BLOCK_SIZE(8), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 2873 | ON_UPDATE(fix_qcache_min_res_unit)); |
| 2874 | |
| 2875 | static const char *query_cache_type_names[]= { "OFF" , "ON" , "DEMAND" , 0 }; |
| 2876 | |
| 2877 | static bool check_query_cache_type(sys_var *self, THD *thd, set_var *var) |
| 2878 | { |
| 2879 | if (query_cache.is_disable_in_progress()) |
| 2880 | { |
| 2881 | my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0)); |
| 2882 | return true; |
| 2883 | } |
| 2884 | |
| 2885 | if (var->type != OPT_GLOBAL && global_system_variables.query_cache_type == 0) |
| 2886 | { |
| 2887 | if (var->value) |
| 2888 | { |
| 2889 | if (var->save_result.ulonglong_value != 0) |
| 2890 | { |
| 2891 | my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0)); |
| 2892 | return true; |
| 2893 | } |
| 2894 | } |
| 2895 | } |
| 2896 | return false; |
| 2897 | } |
| 2898 | |
| 2899 | |
| 2900 | static bool fix_query_cache_type(sys_var *self, THD *thd, enum_var_type type) |
| 2901 | { |
| 2902 | if (type != OPT_GLOBAL) |
| 2903 | return false; |
| 2904 | |
| 2905 | if (global_system_variables.query_cache_type != 0 && |
| 2906 | query_cache.is_disabled()) |
| 2907 | { |
| 2908 | /* if disabling in progress variable will not be set */ |
| 2909 | DBUG_ASSERT(!query_cache.is_disable_in_progress()); |
| 2910 | /* Enable query cache because it was disabled */ |
| 2911 | fix_query_cache_size(0, thd, type); |
| 2912 | } |
| 2913 | else if (global_system_variables.query_cache_type == 0) |
| 2914 | query_cache.disable_query_cache(thd); |
| 2915 | return false; |
| 2916 | } |
| 2917 | static Sys_var_enum Sys_query_cache_type( |
| 2918 | "query_cache_type" , |
| 2919 | "OFF = Don't cache or retrieve results. ON = Cache all results " |
| 2920 | "except SELECT SQL_NO_CACHE ... queries. DEMAND = Cache only " |
| 2921 | "SELECT SQL_CACHE ... queries" , |
| 2922 | NO_SET_STMT SESSION_VAR(query_cache_type), CMD_LINE(REQUIRED_ARG), |
| 2923 | query_cache_type_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 2924 | ON_CHECK(check_query_cache_type), |
| 2925 | ON_UPDATE(fix_query_cache_type)); |
| 2926 | |
| 2927 | static Sys_var_mybool Sys_query_cache_wlock_invalidate( |
| 2928 | "query_cache_wlock_invalidate" , |
| 2929 | "Invalidate queries in query cache on LOCK for write" , |
| 2930 | SESSION_VAR(query_cache_wlock_invalidate), CMD_LINE(OPT_ARG), |
| 2931 | DEFAULT(FALSE)); |
| 2932 | #endif /* HAVE_QUERY_CACHE */ |
| 2933 | |
| 2934 | static Sys_var_mybool Sys_secure_auth( |
| 2935 | "secure_auth" , |
| 2936 | "Disallow authentication for accounts that have old (pre-4.1) " |
| 2937 | "passwords" , |
| 2938 | GLOBAL_VAR(opt_secure_auth), CMD_LINE(OPT_ARG), |
| 2939 | DEFAULT(TRUE)); |
| 2940 | |
| 2941 | static Sys_var_charptr Sys_secure_file_priv( |
| 2942 | "secure_file_priv" , |
| 2943 | "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files " |
| 2944 | "within specified directory" , |
| 2945 | PREALLOCATED READ_ONLY GLOBAL_VAR(opt_secure_file_priv), |
| 2946 | CMD_LINE(REQUIRED_ARG), IN_FS_CHARSET, DEFAULT(0)); |
| 2947 | |
| 2948 | static bool fix_server_id(sys_var *self, THD *thd, enum_var_type type) |
| 2949 | { |
| 2950 | if (type == OPT_GLOBAL) |
| 2951 | { |
| 2952 | thd->variables.server_id= global_system_variables.server_id; |
| 2953 | /* |
| 2954 | Historically, server_id was a global variable that is exported to |
| 2955 | plugins. Now it is a session variable, and lives in the |
| 2956 | global_system_variables struct, but we still need to export the |
| 2957 | value for reading to plugins for backwards compatibility reasons. |
| 2958 | */ |
| 2959 | ::server_id= global_system_variables.server_id; |
| 2960 | } |
| 2961 | return false; |
| 2962 | } |
| 2963 | static Sys_var_ulong Sys_server_id( |
| 2964 | "server_id" , |
| 2965 | "Uniquely identifies the server instance in the community of " |
| 2966 | "replication partners" , |
| 2967 | SESSION_VAR(server_id), CMD_LINE(REQUIRED_ARG, OPT_SERVER_ID), |
| 2968 | VALID_RANGE(1, UINT_MAX32), DEFAULT(1), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 2969 | NOT_IN_BINLOG, ON_CHECK(check_has_super), ON_UPDATE(fix_server_id)); |
| 2970 | |
| 2971 | static Sys_var_mybool Sys_slave_compressed_protocol( |
| 2972 | "slave_compressed_protocol" , |
| 2973 | "Use compression on master/slave protocol" , |
| 2974 | GLOBAL_VAR(opt_slave_compressed_protocol), CMD_LINE(OPT_ARG), |
| 2975 | DEFAULT(FALSE)); |
| 2976 | |
| 2977 | #ifdef HAVE_REPLICATION |
| 2978 | static const char *slave_exec_mode_names[]= {"STRICT" , "IDEMPOTENT" , 0}; |
| 2979 | static Sys_var_enum Slave_exec_mode( |
| 2980 | "slave_exec_mode" , |
| 2981 | "How replication events should be executed. Legal values " |
| 2982 | "are STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, " |
| 2983 | "replication will not stop for operations that are idempotent. " |
| 2984 | "For example, in row based replication attempts to delete rows that " |
| 2985 | "doesn't exist will be ignored. " |
| 2986 | "In STRICT mode, replication will stop on any unexpected difference " |
| 2987 | "between the master and the slave." , |
| 2988 | GLOBAL_VAR(slave_exec_mode_options), CMD_LINE(REQUIRED_ARG), |
| 2989 | slave_exec_mode_names, DEFAULT(SLAVE_EXEC_MODE_STRICT)); |
| 2990 | |
| 2991 | static Sys_var_enum Slave_ddl_exec_mode( |
| 2992 | "slave_ddl_exec_mode" , |
| 2993 | "How replication events should be executed. Legal values " |
| 2994 | "are STRICT and IDEMPOTENT (default). In IDEMPOTENT mode, " |
| 2995 | "replication will not stop for DDL operations that are idempotent. " |
| 2996 | "This means that CREATE TABLE is treated as CREATE TABLE OR REPLACE and " |
| 2997 | "DROP TABLE is treated as DROP TABLE IF EXISTS." , |
| 2998 | GLOBAL_VAR(slave_ddl_exec_mode_options), CMD_LINE(REQUIRED_ARG), |
| 2999 | slave_exec_mode_names, DEFAULT(SLAVE_EXEC_MODE_IDEMPOTENT)); |
| 3000 | |
| 3001 | static const char *slave_run_triggers_for_rbr_names[]= |
| 3002 | {"NO" , "YES" , "LOGGING" , 0}; |
| 3003 | static Sys_var_enum Slave_run_triggers_for_rbr( |
| 3004 | "slave_run_triggers_for_rbr" , |
| 3005 | "Modes for how triggers in row-base replication on slave side will be " |
| 3006 | "executed. Legal values are NO (default), YES and LOGGING. NO means " |
| 3007 | "that trigger for RBR will not be running on slave. YES and LOGGING " |
| 3008 | "means that triggers will be running on slave, if there was not " |
| 3009 | "triggers running on the master for the statement. LOGGING also means " |
| 3010 | "results of that the executed triggers work will be written to " |
| 3011 | "the binlog." , |
| 3012 | GLOBAL_VAR(slave_run_triggers_for_rbr), CMD_LINE(REQUIRED_ARG), |
| 3013 | slave_run_triggers_for_rbr_names, |
| 3014 | DEFAULT(SLAVE_RUN_TRIGGERS_FOR_RBR_NO)); |
| 3015 | |
| 3016 | static const char *slave_type_conversions_name[]= {"ALL_LOSSY" , "ALL_NON_LOSSY" , 0}; |
| 3017 | static Sys_var_set Slave_type_conversions( |
| 3018 | "slave_type_conversions" , |
| 3019 | "Set of slave type conversions that are enabled." |
| 3020 | " If the variable is empty, no conversions are" |
| 3021 | " allowed and it is expected that the types match exactly" , |
| 3022 | GLOBAL_VAR(slave_type_conversions_options), CMD_LINE(REQUIRED_ARG), |
| 3023 | slave_type_conversions_name, |
| 3024 | DEFAULT(0)); |
| 3025 | |
| 3026 | static Sys_var_mybool Sys_slave_sql_verify_checksum( |
| 3027 | "slave_sql_verify_checksum" , |
| 3028 | "Force checksum verification of replication events after reading them " |
| 3029 | "from relay log. Note: Events are always checksum-verified by slave on " |
| 3030 | "receiving them from the network before writing them to the relay log" , |
| 3031 | GLOBAL_VAR(opt_slave_sql_verify_checksum), CMD_LINE(OPT_ARG), |
| 3032 | DEFAULT(TRUE)); |
| 3033 | |
| 3034 | static Sys_var_mybool Sys_master_verify_checksum( |
| 3035 | "master_verify_checksum" , |
| 3036 | "Force checksum verification of logged events in the binary log before " |
| 3037 | "sending them to slaves or printing them in the output of " |
| 3038 | "SHOW BINLOG EVENTS" , |
| 3039 | GLOBAL_VAR(opt_master_verify_checksum), CMD_LINE(OPT_ARG), |
| 3040 | DEFAULT(FALSE)); |
| 3041 | |
| 3042 | /* These names must match RPL_SKIP_XXX #defines in slave.h. */ |
| 3043 | static const char *replicate_events_marked_for_skip_names[]= { |
| 3044 | "REPLICATE" , "FILTER_ON_SLAVE" , "FILTER_ON_MASTER" , 0 |
| 3045 | }; |
| 3046 | |
| 3047 | bool |
| 3048 | Sys_var_replicate_events_marked_for_skip::global_update(THD *thd, set_var *var) |
| 3049 | { |
| 3050 | bool result= true; // Assume error |
| 3051 | DBUG_ENTER("Sys_var_replicate_events_marked_for_skip::global_update" ); |
| 3052 | |
| 3053 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 3054 | if (!give_error_if_slave_running(0)) |
| 3055 | result= Sys_var_enum::global_update(thd, var); |
| 3056 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 3057 | DBUG_RETURN(result); |
| 3058 | } |
| 3059 | |
| 3060 | static Sys_var_replicate_events_marked_for_skip Replicate_events_marked_for_skip |
| 3061 | ("replicate_events_marked_for_skip" , |
| 3062 | "Whether the slave should replicate events that were created with " |
| 3063 | "@@skip_replication=1 on the master. Default REPLICATE (no events are " |
| 3064 | "skipped). Other values are FILTER_ON_SLAVE (events will be sent by the " |
| 3065 | "master but ignored by the slave) and FILTER_ON_MASTER (events marked with " |
| 3066 | "@@skip_replication=1 will be filtered on the master and never be sent to " |
| 3067 | "the slave)." , |
| 3068 | GLOBAL_VAR(opt_replicate_events_marked_for_skip), CMD_LINE(REQUIRED_ARG), |
| 3069 | replicate_events_marked_for_skip_names, DEFAULT(RPL_SKIP_REPLICATE)); |
| 3070 | |
| 3071 | /* new options for semisync */ |
| 3072 | |
| 3073 | static bool fix_rpl_semi_sync_master_enabled(sys_var *self, THD *thd, |
| 3074 | enum_var_type type) |
| 3075 | { |
| 3076 | if (rpl_semi_sync_master_enabled) |
| 3077 | { |
| 3078 | if (repl_semisync_master.enable_master() != 0) |
| 3079 | rpl_semi_sync_master_enabled= false; |
| 3080 | else if (ack_receiver.start()) |
| 3081 | { |
| 3082 | repl_semisync_master.disable_master(); |
| 3083 | rpl_semi_sync_master_enabled= false; |
| 3084 | } |
| 3085 | } |
| 3086 | else |
| 3087 | { |
| 3088 | if (repl_semisync_master.disable_master() != 0) |
| 3089 | rpl_semi_sync_master_enabled= true; |
| 3090 | if (!rpl_semi_sync_master_enabled) |
| 3091 | ack_receiver.stop(); |
| 3092 | } |
| 3093 | return false; |
| 3094 | } |
| 3095 | |
| 3096 | static bool fix_rpl_semi_sync_master_timeout(sys_var *self, THD *thd, |
| 3097 | enum_var_type type) |
| 3098 | { |
| 3099 | repl_semisync_master.set_wait_timeout(rpl_semi_sync_master_timeout); |
| 3100 | return false; |
| 3101 | } |
| 3102 | |
| 3103 | static bool fix_rpl_semi_sync_master_trace_level(sys_var *self, THD *thd, |
| 3104 | enum_var_type type) |
| 3105 | { |
| 3106 | repl_semisync_master.set_trace_level(rpl_semi_sync_master_trace_level); |
| 3107 | ack_receiver.set_trace_level(rpl_semi_sync_master_trace_level); |
| 3108 | return false; |
| 3109 | } |
| 3110 | |
| 3111 | static bool fix_rpl_semi_sync_master_wait_point(sys_var *self, THD *thd, |
| 3112 | enum_var_type type) |
| 3113 | { |
| 3114 | repl_semisync_master.set_wait_point(rpl_semi_sync_master_wait_point); |
| 3115 | return false; |
| 3116 | } |
| 3117 | |
| 3118 | static bool fix_rpl_semi_sync_master_wait_no_slave(sys_var *self, THD *thd, |
| 3119 | enum_var_type type) |
| 3120 | { |
| 3121 | repl_semisync_master.check_and_switch(); |
| 3122 | return false; |
| 3123 | } |
| 3124 | |
| 3125 | static Sys_var_mybool Sys_semisync_master_enabled( |
| 3126 | "rpl_semi_sync_master_enabled" , |
| 3127 | "Enable semi-synchronous replication master (disabled by default)." , |
| 3128 | GLOBAL_VAR(rpl_semi_sync_master_enabled), |
| 3129 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 3130 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3131 | ON_UPDATE(fix_rpl_semi_sync_master_enabled)); |
| 3132 | |
| 3133 | static Sys_var_ulong Sys_semisync_master_timeout( |
| 3134 | "rpl_semi_sync_master_timeout" , |
| 3135 | "The timeout value (in ms) for semi-synchronous replication in the " |
| 3136 | "master" , |
| 3137 | GLOBAL_VAR(rpl_semi_sync_master_timeout), |
| 3138 | CMD_LINE(REQUIRED_ARG), |
| 3139 | VALID_RANGE(0,~0L),DEFAULT(10000),BLOCK_SIZE(1), |
| 3140 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3141 | ON_UPDATE(fix_rpl_semi_sync_master_timeout)); |
| 3142 | |
| 3143 | static Sys_var_mybool Sys_semisync_master_wait_no_slave( |
| 3144 | "rpl_semi_sync_master_wait_no_slave" , |
| 3145 | "Wait until timeout when no semi-synchronous replication slave " |
| 3146 | "available (enabled by default)." , |
| 3147 | GLOBAL_VAR(rpl_semi_sync_master_wait_no_slave), |
| 3148 | CMD_LINE(OPT_ARG), DEFAULT(TRUE), |
| 3149 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3150 | ON_UPDATE(fix_rpl_semi_sync_master_wait_no_slave)); |
| 3151 | |
| 3152 | static Sys_var_ulong Sys_semisync_master_trace_level( |
| 3153 | "rpl_semi_sync_master_trace_level" , |
| 3154 | "The tracing level for semi-sync replication." , |
| 3155 | GLOBAL_VAR(rpl_semi_sync_master_trace_level), |
| 3156 | CMD_LINE(REQUIRED_ARG), |
| 3157 | VALID_RANGE(0,~0L),DEFAULT(32),BLOCK_SIZE(1), |
| 3158 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3159 | ON_UPDATE(fix_rpl_semi_sync_master_trace_level)); |
| 3160 | |
| 3161 | static const char *repl_semisync_wait_point[]= |
| 3162 | {"AFTER_SYNC" , "AFTER_COMMIT" , NullS}; |
| 3163 | |
| 3164 | static Sys_var_enum Sys_semisync_master_wait_point( |
| 3165 | "rpl_semi_sync_master_wait_point" , |
| 3166 | "Should transaction wait for semi-sync ack after having synced binlog, " |
| 3167 | "or after having committed in storage engine." , |
| 3168 | GLOBAL_VAR(rpl_semi_sync_master_wait_point), CMD_LINE(REQUIRED_ARG), |
| 3169 | repl_semisync_wait_point, DEFAULT(1), |
| 3170 | NO_MUTEX_GUARD, NOT_IN_BINLOG,ON_CHECK(0), |
| 3171 | ON_UPDATE(fix_rpl_semi_sync_master_wait_point)); |
| 3172 | |
| 3173 | static bool fix_rpl_semi_sync_slave_enabled(sys_var *self, THD *thd, |
| 3174 | enum_var_type type) |
| 3175 | { |
| 3176 | repl_semisync_slave.set_slave_enabled(rpl_semi_sync_slave_enabled != 0); |
| 3177 | return false; |
| 3178 | } |
| 3179 | |
| 3180 | static bool fix_rpl_semi_sync_slave_trace_level(sys_var *self, THD *thd, |
| 3181 | enum_var_type type) |
| 3182 | { |
| 3183 | repl_semisync_slave.set_trace_level(rpl_semi_sync_slave_trace_level); |
| 3184 | return false; |
| 3185 | } |
| 3186 | |
| 3187 | static bool fix_rpl_semi_sync_slave_delay_master(sys_var *self, THD *thd, |
| 3188 | enum_var_type type) |
| 3189 | { |
| 3190 | repl_semisync_slave.set_delay_master(rpl_semi_sync_slave_delay_master); |
| 3191 | return false; |
| 3192 | } |
| 3193 | |
| 3194 | static bool fix_rpl_semi_sync_slave_kill_conn_timeout(sys_var *self, THD *thd, |
| 3195 | enum_var_type type) |
| 3196 | { |
| 3197 | repl_semisync_slave. |
| 3198 | set_kill_conn_timeout(rpl_semi_sync_slave_kill_conn_timeout); |
| 3199 | return false; |
| 3200 | } |
| 3201 | |
| 3202 | static Sys_var_mybool Sys_semisync_slave_enabled( |
| 3203 | "rpl_semi_sync_slave_enabled" , |
| 3204 | "Enable semi-synchronous replication slave (disabled by default)." , |
| 3205 | GLOBAL_VAR(rpl_semi_sync_slave_enabled), |
| 3206 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 3207 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3208 | ON_UPDATE(fix_rpl_semi_sync_slave_enabled)); |
| 3209 | |
| 3210 | static Sys_var_ulong Sys_semisync_slave_trace_level( |
| 3211 | "rpl_semi_sync_slave_trace_level" , |
| 3212 | "The tracing level for semi-sync replication." , |
| 3213 | GLOBAL_VAR(rpl_semi_sync_slave_trace_level), |
| 3214 | CMD_LINE(REQUIRED_ARG), |
| 3215 | VALID_RANGE(0,~0L),DEFAULT(32),BLOCK_SIZE(1), |
| 3216 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3217 | ON_UPDATE(fix_rpl_semi_sync_slave_trace_level)); |
| 3218 | |
| 3219 | static Sys_var_mybool Sys_semisync_slave_delay_master( |
| 3220 | "rpl_semi_sync_slave_delay_master" , |
| 3221 | "Only write master info file when ack is needed." , |
| 3222 | GLOBAL_VAR(rpl_semi_sync_slave_delay_master), |
| 3223 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 3224 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3225 | ON_UPDATE(fix_rpl_semi_sync_slave_delay_master)); |
| 3226 | |
| 3227 | static Sys_var_uint Sys_semisync_slave_kill_conn_timeout( |
| 3228 | "rpl_semi_sync_slave_kill_conn_timeout" , |
| 3229 | "Timeout for the mysql connection used to kill the slave io_thread's " |
| 3230 | "connection on master. This timeout comes into play when stop slave " |
| 3231 | "is executed." , |
| 3232 | GLOBAL_VAR(rpl_semi_sync_slave_kill_conn_timeout), |
| 3233 | CMD_LINE(OPT_ARG), |
| 3234 | VALID_RANGE(0, UINT_MAX), DEFAULT(5), BLOCK_SIZE(1), |
| 3235 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3236 | ON_UPDATE(fix_rpl_semi_sync_slave_kill_conn_timeout)); |
| 3237 | #endif /* HAVE_REPLICATION */ |
| 3238 | |
| 3239 | static Sys_var_ulong Sys_slow_launch_time( |
| 3240 | "slow_launch_time" , |
| 3241 | "If creating the thread takes longer than this value (in seconds), " |
| 3242 | "the Slow_launch_threads counter will be incremented" , |
| 3243 | GLOBAL_VAR(slow_launch_time), CMD_LINE(REQUIRED_ARG), |
| 3244 | VALID_RANGE(0, LONG_TIMEOUT), DEFAULT(2), BLOCK_SIZE(1)); |
| 3245 | |
| 3246 | static Sys_var_ulonglong Sys_sort_buffer( |
| 3247 | "sort_buffer_size" , |
| 3248 | "Each thread that needs to do a sort allocates a buffer of this size" , |
| 3249 | SESSION_VAR(sortbuff_size), CMD_LINE(REQUIRED_ARG), |
| 3250 | VALID_RANGE(MIN_SORT_MEMORY, SIZE_T_MAX), DEFAULT(MAX_SORT_MEMORY), |
| 3251 | BLOCK_SIZE(1)); |
| 3252 | |
| 3253 | export sql_mode_t expand_sql_mode(sql_mode_t sql_mode) |
| 3254 | { |
| 3255 | if (sql_mode & MODE_ANSI) |
| 3256 | { |
| 3257 | /* |
| 3258 | Note that we dont set |
| 3259 | MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | MODE_NO_FIELD_OPTIONS |
| 3260 | to allow one to get full use of MySQL in this mode. |
| 3261 | |
| 3262 | MODE_ONLY_FULL_GROUP_BY was removed from ANSI mode because it is |
| 3263 | currently overly restrictive (see BUG#8510). |
| 3264 | */ |
| 3265 | sql_mode|= (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | |
| 3266 | MODE_IGNORE_SPACE); |
| 3267 | } |
| 3268 | if (sql_mode & MODE_ORACLE) |
| 3269 | sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | |
| 3270 | MODE_IGNORE_SPACE | |
| 3271 | MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | |
| 3272 | MODE_NO_FIELD_OPTIONS | MODE_NO_AUTO_CREATE_USER | |
| 3273 | MODE_SIMULTANEOUS_ASSIGNMENT); |
| 3274 | if (sql_mode & MODE_MSSQL) |
| 3275 | sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | |
| 3276 | MODE_IGNORE_SPACE | |
| 3277 | MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | |
| 3278 | MODE_NO_FIELD_OPTIONS); |
| 3279 | if (sql_mode & MODE_POSTGRESQL) |
| 3280 | sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | |
| 3281 | MODE_IGNORE_SPACE | |
| 3282 | MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | |
| 3283 | MODE_NO_FIELD_OPTIONS); |
| 3284 | if (sql_mode & MODE_DB2) |
| 3285 | sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | |
| 3286 | MODE_IGNORE_SPACE | |
| 3287 | MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | |
| 3288 | MODE_NO_FIELD_OPTIONS); |
| 3289 | if (sql_mode & MODE_MAXDB) |
| 3290 | sql_mode|= (MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | |
| 3291 | MODE_IGNORE_SPACE | |
| 3292 | MODE_NO_KEY_OPTIONS | MODE_NO_TABLE_OPTIONS | |
| 3293 | MODE_NO_FIELD_OPTIONS | MODE_NO_AUTO_CREATE_USER); |
| 3294 | if (sql_mode & MODE_MYSQL40) |
| 3295 | sql_mode|= MODE_HIGH_NOT_PRECEDENCE; |
| 3296 | if (sql_mode & MODE_MYSQL323) |
| 3297 | sql_mode|= MODE_HIGH_NOT_PRECEDENCE; |
| 3298 | if (sql_mode & MODE_TRADITIONAL) |
| 3299 | sql_mode|= (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES | |
| 3300 | MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | |
| 3301 | MODE_ERROR_FOR_DIVISION_BY_ZERO | MODE_NO_AUTO_CREATE_USER | |
| 3302 | MODE_NO_ENGINE_SUBSTITUTION); |
| 3303 | return sql_mode; |
| 3304 | } |
| 3305 | static bool check_sql_mode(sys_var *self, THD *thd, set_var *var) |
| 3306 | { |
| 3307 | var->save_result.ulonglong_value= |
| 3308 | (ulonglong) expand_sql_mode(var->save_result.ulonglong_value); |
| 3309 | return false; |
| 3310 | } |
| 3311 | static bool fix_sql_mode(sys_var *self, THD *thd, enum_var_type type) |
| 3312 | { |
| 3313 | if (type != OPT_GLOBAL) |
| 3314 | { |
| 3315 | /* Update thd->server_status */ |
| 3316 | if (thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) |
| 3317 | thd->server_status|= SERVER_STATUS_NO_BACKSLASH_ESCAPES; |
| 3318 | else |
| 3319 | thd->server_status&= ~SERVER_STATUS_NO_BACKSLASH_ESCAPES; |
| 3320 | if (thd->variables.sql_mode & MODE_ANSI_QUOTES) |
| 3321 | thd->server_status|= SERVER_STATUS_ANSI_QUOTES; |
| 3322 | else |
| 3323 | thd->server_status&= ~SERVER_STATUS_ANSI_QUOTES; |
| 3324 | } |
| 3325 | return false; |
| 3326 | } |
| 3327 | /* |
| 3328 | WARNING: When adding new SQL modes don't forget to update the |
| 3329 | tables definitions that stores it's value (ie: mysql.event, mysql.proc) |
| 3330 | */ |
| 3331 | static const char *sql_mode_names[]= |
| 3332 | { |
| 3333 | "REAL_AS_FLOAT" , "PIPES_AS_CONCAT" , "ANSI_QUOTES" , "IGNORE_SPACE" , |
| 3334 | "IGNORE_BAD_TABLE_OPTIONS" , |
| 3335 | "ONLY_FULL_GROUP_BY" , "NO_UNSIGNED_SUBTRACTION" , "NO_DIR_IN_CREATE" , |
| 3336 | "POSTGRESQL" , "ORACLE" , "MSSQL" , "DB2" , "MAXDB" , "NO_KEY_OPTIONS" , |
| 3337 | "NO_TABLE_OPTIONS" , "NO_FIELD_OPTIONS" , "MYSQL323" , "MYSQL40" , "ANSI" , |
| 3338 | "NO_AUTO_VALUE_ON_ZERO" , "NO_BACKSLASH_ESCAPES" , "STRICT_TRANS_TABLES" , |
| 3339 | "STRICT_ALL_TABLES" , "NO_ZERO_IN_DATE" , "NO_ZERO_DATE" , |
| 3340 | "ALLOW_INVALID_DATES" , "ERROR_FOR_DIVISION_BY_ZERO" , "TRADITIONAL" , |
| 3341 | "NO_AUTO_CREATE_USER" , "HIGH_NOT_PRECEDENCE" , "NO_ENGINE_SUBSTITUTION" , |
| 3342 | "PAD_CHAR_TO_FULL_LENGTH" , "EMPTY_STRING_IS_NULL" , "SIMULTANEOUS_ASSIGNMENT" , |
| 3343 | 0 |
| 3344 | }; |
| 3345 | |
| 3346 | export bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, |
| 3347 | LEX_CSTRING *ls) |
| 3348 | { |
| 3349 | set_to_string(thd, ls, sql_mode, sql_mode_names); |
| 3350 | return ls->str == 0; |
| 3351 | } |
| 3352 | /* |
| 3353 | sql_mode should *not* be IN_BINLOG: even though it is written to the binlog, |
| 3354 | the slave ignores the MODE_NO_DIR_IN_CREATE variable, so slave's value |
| 3355 | differs from master's (see log_event.cc: Query_log_event::do_apply_event()). |
| 3356 | */ |
| 3357 | static Sys_var_set Sys_sql_mode( |
| 3358 | "sql_mode" , |
| 3359 | "Sets the sql mode" , |
| 3360 | SESSION_VAR(sql_mode), CMD_LINE(REQUIRED_ARG), |
| 3361 | sql_mode_names, |
| 3362 | DEFAULT(MODE_STRICT_TRANS_TABLES | |
| 3363 | MODE_ERROR_FOR_DIVISION_BY_ZERO | |
| 3364 | MODE_NO_ENGINE_SUBSTITUTION | |
| 3365 | MODE_NO_AUTO_CREATE_USER), |
| 3366 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 3367 | ON_CHECK(check_sql_mode), ON_UPDATE(fix_sql_mode)); |
| 3368 | |
| 3369 | static const char *old_mode_names[]= |
| 3370 | { |
| 3371 | "NO_DUP_KEY_WARNINGS_WITH_IGNORE" , |
| 3372 | "NO_PROGRESS_INFO" , |
| 3373 | "ZERO_DATE_TIME_CAST" , |
| 3374 | 0 |
| 3375 | }; |
| 3376 | |
| 3377 | /* |
| 3378 | sql_mode should *not* be IN_BINLOG as the slave can't remember this |
| 3379 | anyway on restart. |
| 3380 | */ |
| 3381 | static Sys_var_set Sys_old_behavior( |
| 3382 | "old_mode" , |
| 3383 | "Used to emulate old behavior from earlier MariaDB or MySQL versions" , |
| 3384 | SESSION_VAR(old_behavior), CMD_LINE(REQUIRED_ARG), |
| 3385 | old_mode_names, DEFAULT(0)); |
| 3386 | |
| 3387 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) |
| 3388 | #define SSL_OPT(X) CMD_LINE(REQUIRED_ARG,X) |
| 3389 | #else |
| 3390 | #define SSL_OPT(X) NO_CMD_LINE |
| 3391 | #endif |
| 3392 | |
| 3393 | static Sys_var_charptr Sys_ssl_ca( |
| 3394 | "ssl_ca" , |
| 3395 | "CA file in PEM format (check OpenSSL docs, implies --ssl)" , |
| 3396 | READ_ONLY GLOBAL_VAR(opt_ssl_ca), SSL_OPT(OPT_SSL_CA), |
| 3397 | IN_FS_CHARSET, DEFAULT(0)); |
| 3398 | |
| 3399 | static Sys_var_charptr Sys_ssl_capath( |
| 3400 | "ssl_capath" , |
| 3401 | "CA directory (check OpenSSL docs, implies --ssl)" , |
| 3402 | READ_ONLY GLOBAL_VAR(opt_ssl_capath), SSL_OPT(OPT_SSL_CAPATH), |
| 3403 | IN_FS_CHARSET, DEFAULT(0)); |
| 3404 | |
| 3405 | static Sys_var_charptr Sys_ssl_cert( |
| 3406 | "ssl_cert" , "X509 cert in PEM format (implies --ssl)" , |
| 3407 | READ_ONLY GLOBAL_VAR(opt_ssl_cert), SSL_OPT(OPT_SSL_CERT), |
| 3408 | IN_FS_CHARSET, DEFAULT(0)); |
| 3409 | |
| 3410 | static Sys_var_charptr Sys_ssl_cipher( |
| 3411 | "ssl_cipher" , "SSL cipher to use (implies --ssl)" , |
| 3412 | READ_ONLY GLOBAL_VAR(opt_ssl_cipher), SSL_OPT(OPT_SSL_CIPHER), |
| 3413 | IN_FS_CHARSET, DEFAULT(0)); |
| 3414 | |
| 3415 | static Sys_var_charptr Sys_ssl_key( |
| 3416 | "ssl_key" , "X509 key in PEM format (implies --ssl)" , |
| 3417 | READ_ONLY GLOBAL_VAR(opt_ssl_key), SSL_OPT(OPT_SSL_KEY), |
| 3418 | IN_FS_CHARSET, DEFAULT(0)); |
| 3419 | |
| 3420 | static Sys_var_charptr Sys_ssl_crl( |
| 3421 | "ssl_crl" , |
| 3422 | "CRL file in PEM format (check OpenSSL docs, implies --ssl)" , |
| 3423 | READ_ONLY GLOBAL_VAR(opt_ssl_crl), SSL_OPT(OPT_SSL_CRL), |
| 3424 | IN_FS_CHARSET, DEFAULT(0)); |
| 3425 | |
| 3426 | static Sys_var_charptr Sys_ssl_crlpath( |
| 3427 | "ssl_crlpath" , |
| 3428 | "CRL directory (check OpenSSL docs, implies --ssl)" , |
| 3429 | READ_ONLY GLOBAL_VAR(opt_ssl_crlpath), SSL_OPT(OPT_SSL_CRLPATH), |
| 3430 | IN_FS_CHARSET, DEFAULT(0)); |
| 3431 | |
| 3432 | static Sys_var_mybool Sys_standard_compliant_cte( |
| 3433 | "standard_compliant_cte" , |
| 3434 | "Allow only CTEs compliant to SQL standard" , |
| 3435 | SESSION_VAR(only_standard_compliant_cte), CMD_LINE(OPT_ARG), |
| 3436 | DEFAULT(TRUE)); |
| 3437 | |
| 3438 | |
| 3439 | // why ENUM and not BOOL ? |
| 3440 | static const char *updatable_views_with_limit_names[]= {"NO" , "YES" , 0}; |
| 3441 | static Sys_var_enum Sys_updatable_views_with_limit( |
| 3442 | "updatable_views_with_limit" , |
| 3443 | "YES = Don't issue an error message (warning only) if a VIEW without " |
| 3444 | "presence of a key of the underlying table is used in queries with a " |
| 3445 | "LIMIT clause for updating. NO = Prohibit update of a VIEW, which " |
| 3446 | "does not contain a key of the underlying table and the query uses " |
| 3447 | "a LIMIT clause (usually get from GUI tools)" , |
| 3448 | SESSION_VAR(updatable_views_with_limit), CMD_LINE(REQUIRED_ARG), |
| 3449 | updatable_views_with_limit_names, DEFAULT(TRUE)); |
| 3450 | |
| 3451 | static Sys_var_mybool Sys_sync_frm( |
| 3452 | "sync_frm" , "Sync .frm files to disk on creation" , |
| 3453 | GLOBAL_VAR(opt_sync_frm), CMD_LINE(OPT_ARG), |
| 3454 | DEFAULT(TRUE)); |
| 3455 | |
| 3456 | static char *system_time_zone_ptr; |
| 3457 | static Sys_var_charptr Sys_system_time_zone( |
| 3458 | "system_time_zone" , "The server system time zone" , |
| 3459 | READ_ONLY GLOBAL_VAR(system_time_zone_ptr), |
| 3460 | CMD_LINE_HELP_ONLY, |
| 3461 | IN_SYSTEM_CHARSET, DEFAULT(system_time_zone)); |
| 3462 | |
| 3463 | static Sys_var_ulong Sys_table_def_size( |
| 3464 | "table_definition_cache" , |
| 3465 | "The number of cached table definitions" , |
| 3466 | GLOBAL_VAR(tdc_size), CMD_LINE(REQUIRED_ARG), |
| 3467 | VALID_RANGE(TABLE_DEF_CACHE_MIN, 512*1024), |
| 3468 | DEFAULT(TABLE_DEF_CACHE_DEFAULT), BLOCK_SIZE(1)); |
| 3469 | |
| 3470 | |
| 3471 | static bool fix_table_open_cache(sys_var *, THD *, enum_var_type) |
| 3472 | { |
| 3473 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 3474 | tc_purge(); |
| 3475 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 3476 | return false; |
| 3477 | } |
| 3478 | |
| 3479 | |
| 3480 | static Sys_var_ulong Sys_table_cache_size( |
| 3481 | "table_open_cache" , "The number of cached open tables" , |
| 3482 | GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG), |
| 3483 | VALID_RANGE(10, 1024*1024), DEFAULT(TABLE_OPEN_CACHE_DEFAULT), |
| 3484 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3485 | ON_UPDATE(fix_table_open_cache)); |
| 3486 | |
| 3487 | static Sys_var_uint Sys_table_cache_instances( |
| 3488 | "table_open_cache_instances" , "Maximum number of table cache instances" , |
| 3489 | READ_ONLY GLOBAL_VAR(tc_instances), CMD_LINE(REQUIRED_ARG), |
| 3490 | VALID_RANGE(1, 64), DEFAULT(8), BLOCK_SIZE(1)); |
| 3491 | |
| 3492 | static Sys_var_ulong Sys_thread_cache_size( |
| 3493 | "thread_cache_size" , |
| 3494 | "How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time" , |
| 3495 | GLOBAL_VAR(thread_cache_size), CMD_LINE(REQUIRED_ARG), |
| 3496 | VALID_RANGE(0, 16384), DEFAULT(256), BLOCK_SIZE(1)); |
| 3497 | |
| 3498 | #ifdef HAVE_POOL_OF_THREADS |
| 3499 | static bool fix_tp_max_threads(sys_var *, THD *, enum_var_type) |
| 3500 | { |
| 3501 | tp_set_max_threads(threadpool_max_threads); |
| 3502 | return false; |
| 3503 | } |
| 3504 | |
| 3505 | |
| 3506 | #ifdef _WIN32 |
| 3507 | static bool fix_tp_min_threads(sys_var *, THD *, enum_var_type) |
| 3508 | { |
| 3509 | tp_set_min_threads(threadpool_min_threads); |
| 3510 | return false; |
| 3511 | } |
| 3512 | #endif |
| 3513 | |
| 3514 | static bool check_threadpool_size(sys_var *self, THD *thd, set_var *var) |
| 3515 | { |
| 3516 | ulonglong v= var->save_result.ulonglong_value; |
| 3517 | if (v > threadpool_max_size) |
| 3518 | { |
| 3519 | var->save_result.ulonglong_value= threadpool_max_size; |
| 3520 | return throw_bounds_warning(thd, self->name.str, true, true, v); |
| 3521 | } |
| 3522 | return false; |
| 3523 | } |
| 3524 | |
| 3525 | |
| 3526 | static bool fix_threadpool_size(sys_var*, THD*, enum_var_type) |
| 3527 | { |
| 3528 | tp_set_threadpool_size(threadpool_size); |
| 3529 | return false; |
| 3530 | } |
| 3531 | |
| 3532 | |
| 3533 | static bool fix_threadpool_stall_limit(sys_var*, THD*, enum_var_type) |
| 3534 | { |
| 3535 | tp_set_threadpool_stall_limit(threadpool_stall_limit); |
| 3536 | return false; |
| 3537 | } |
| 3538 | |
| 3539 | #ifdef _WIN32 |
| 3540 | static Sys_var_uint Sys_threadpool_min_threads( |
| 3541 | "thread_pool_min_threads" , |
| 3542 | "Minimum number of threads in the thread pool." , |
| 3543 | GLOBAL_VAR(threadpool_min_threads), CMD_LINE(REQUIRED_ARG), |
| 3544 | VALID_RANGE(1, 256), DEFAULT(1), BLOCK_SIZE(1), |
| 3545 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3546 | ON_UPDATE(fix_tp_min_threads) |
| 3547 | ); |
| 3548 | |
| 3549 | static const char *threadpool_mode_names[]={ "windows" , "generic" , 0 }; |
| 3550 | static Sys_var_enum Sys_threadpool_mode( |
| 3551 | "thread_pool_mode" , |
| 3552 | "Chose implementation of the threadpool" , |
| 3553 | READ_ONLY GLOBAL_VAR(threadpool_mode), CMD_LINE(REQUIRED_ARG), |
| 3554 | threadpool_mode_names, DEFAULT(TP_MODE_WINDOWS) |
| 3555 | ); |
| 3556 | #endif |
| 3557 | |
| 3558 | static const char *threadpool_priority_names[]={ "high" , "low" , "auto" , 0 }; |
| 3559 | static Sys_var_enum Sys_thread_pool_priority( |
| 3560 | "thread_pool_priority" , |
| 3561 | "Threadpool priority. High priority connections usually start executing earlier than low priority." |
| 3562 | "If priority set to 'auto', the the actual priority(low or high) is determined based on whether or not connection is inside transaction." , |
| 3563 | SESSION_VAR(threadpool_priority), CMD_LINE(REQUIRED_ARG), |
| 3564 | threadpool_priority_names, DEFAULT(TP_PRIORITY_AUTO)); |
| 3565 | |
| 3566 | static Sys_var_uint Sys_threadpool_idle_thread_timeout( |
| 3567 | "thread_pool_idle_timeout" , |
| 3568 | "Timeout in seconds for an idle thread in the thread pool." |
| 3569 | "Worker thread will be shut down after timeout" , |
| 3570 | GLOBAL_VAR(threadpool_idle_timeout), CMD_LINE(REQUIRED_ARG), |
| 3571 | VALID_RANGE(1, UINT_MAX), DEFAULT(60), BLOCK_SIZE(1) |
| 3572 | ); |
| 3573 | static Sys_var_uint Sys_threadpool_oversubscribe( |
| 3574 | "thread_pool_oversubscribe" , |
| 3575 | "How many additional active worker threads in a group are allowed." , |
| 3576 | GLOBAL_VAR(threadpool_oversubscribe), CMD_LINE(REQUIRED_ARG), |
| 3577 | VALID_RANGE(1, 1000), DEFAULT(3), BLOCK_SIZE(1) |
| 3578 | ); |
| 3579 | static Sys_var_uint Sys_threadpool_size( |
| 3580 | "thread_pool_size" , |
| 3581 | "Number of thread groups in the pool. " |
| 3582 | "This parameter is roughly equivalent to maximum number of concurrently " |
| 3583 | "executing threads (threads in a waiting state do not count as executing)." , |
| 3584 | GLOBAL_VAR(threadpool_size), CMD_LINE(REQUIRED_ARG), |
| 3585 | VALID_RANGE(1, MAX_THREAD_GROUPS), DEFAULT(8), BLOCK_SIZE(1), |
| 3586 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_threadpool_size), |
| 3587 | ON_UPDATE(fix_threadpool_size) |
| 3588 | ); |
| 3589 | static Sys_var_uint Sys_threadpool_stall_limit( |
| 3590 | "thread_pool_stall_limit" , |
| 3591 | "Maximum query execution time in milliseconds," |
| 3592 | "before an executing non-yielding thread is considered stalled." |
| 3593 | "If a worker thread is stalled, additional worker thread " |
| 3594 | "may be created to handle remaining clients." , |
| 3595 | GLOBAL_VAR(threadpool_stall_limit), CMD_LINE(REQUIRED_ARG), |
| 3596 | VALID_RANGE(10, UINT_MAX), DEFAULT(500), BLOCK_SIZE(1), |
| 3597 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3598 | ON_UPDATE(fix_threadpool_stall_limit) |
| 3599 | ); |
| 3600 | |
| 3601 | static Sys_var_uint Sys_threadpool_max_threads( |
| 3602 | "thread_pool_max_threads" , |
| 3603 | "Maximum allowed number of worker threads in the thread pool" , |
| 3604 | GLOBAL_VAR(threadpool_max_threads), CMD_LINE(REQUIRED_ARG), |
| 3605 | VALID_RANGE(1, 65536), DEFAULT(65536), BLOCK_SIZE(1), |
| 3606 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 3607 | ON_UPDATE(fix_tp_max_threads) |
| 3608 | ); |
| 3609 | |
| 3610 | static Sys_var_uint Sys_threadpool_threadpool_prio_kickup_timer( |
| 3611 | "thread_pool_prio_kickup_timer" , |
| 3612 | "The number of milliseconds before a dequeued low-priority statement is moved to the high-priority queue" , |
| 3613 | GLOBAL_VAR(threadpool_prio_kickup_timer), CMD_LINE(REQUIRED_ARG), |
| 3614 | VALID_RANGE(0, UINT_MAX), DEFAULT(1000), BLOCK_SIZE(1) |
| 3615 | ); |
| 3616 | #endif /* HAVE_POOL_OF_THREADS */ |
| 3617 | |
| 3618 | /** |
| 3619 | Can't change the 'next' tx_isolation if we are already in a |
| 3620 | transaction. |
| 3621 | */ |
| 3622 | |
| 3623 | static bool check_tx_isolation(sys_var *self, THD *thd, set_var *var) |
| 3624 | { |
| 3625 | if (var->type == OPT_DEFAULT && thd->in_active_multi_stmt_transaction()) |
| 3626 | { |
| 3627 | DBUG_ASSERT(thd->in_multi_stmt_transaction_mode()); |
| 3628 | my_error(ER_CANT_CHANGE_TX_CHARACTERISTICS, MYF(0)); |
| 3629 | return TRUE; |
| 3630 | } |
| 3631 | return FALSE; |
| 3632 | } |
| 3633 | |
| 3634 | // NO_CMD_LINE - different name of the option |
| 3635 | static Sys_var_tx_isolation Sys_tx_isolation( |
| 3636 | "tx_isolation" , "Default transaction isolation level" , |
| 3637 | NO_SET_STMT SESSION_VAR(tx_isolation), NO_CMD_LINE, |
| 3638 | tx_isolation_names, DEFAULT(ISO_REPEATABLE_READ), |
| 3639 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_tx_isolation)); |
| 3640 | |
| 3641 | |
| 3642 | /** |
| 3643 | Can't change the tx_read_only state if we are already in a |
| 3644 | transaction. |
| 3645 | */ |
| 3646 | |
| 3647 | static bool check_tx_read_only(sys_var *self, THD *thd, set_var *var) |
| 3648 | { |
| 3649 | if (var->type == OPT_DEFAULT && thd->in_active_multi_stmt_transaction()) |
| 3650 | { |
| 3651 | DBUG_ASSERT(thd->in_multi_stmt_transaction_mode()); |
| 3652 | my_error(ER_CANT_CHANGE_TX_CHARACTERISTICS, MYF(0)); |
| 3653 | return true; |
| 3654 | } |
| 3655 | return false; |
| 3656 | } |
| 3657 | |
| 3658 | |
| 3659 | bool Sys_var_tx_read_only::session_update(THD *thd, set_var *var) |
| 3660 | { |
| 3661 | if (var->type == OPT_SESSION && Sys_var_mybool::session_update(thd, var)) |
| 3662 | return true; |
| 3663 | if (var->type == OPT_DEFAULT || !thd->in_active_multi_stmt_transaction()) |
| 3664 | { |
| 3665 | // @see Sys_var_tx_isolation::session_update() above for the rules. |
| 3666 | thd->tx_read_only= var->save_result.ulonglong_value; |
| 3667 | |
| 3668 | #ifndef EMBEDDED_LIBRARY |
| 3669 | if (thd->variables.session_track_transaction_info > TX_TRACK_NONE) |
| 3670 | { |
| 3671 | Transaction_state_tracker *tst= (Transaction_state_tracker *) |
| 3672 | thd->session_tracker.get_tracker(TRANSACTION_INFO_TRACKER); |
| 3673 | |
| 3674 | if (var->type == OPT_DEFAULT) |
| 3675 | tst->set_read_flags(thd, |
| 3676 | thd->tx_read_only ? TX_READ_ONLY : TX_READ_WRITE); |
| 3677 | else |
| 3678 | tst->set_read_flags(thd, TX_READ_INHERIT); |
| 3679 | } |
| 3680 | #endif //EMBEDDED_LIBRARY |
| 3681 | } |
| 3682 | return false; |
| 3683 | } |
| 3684 | |
| 3685 | |
| 3686 | static Sys_var_tx_read_only Sys_tx_read_only( |
| 3687 | "tx_read_only" , "Default transaction access mode. If set to OFF, " |
| 3688 | "the default, access is read/write. If set to ON, access is read-only. " |
| 3689 | "The SET TRANSACTION statement can also change the value of this variable. " |
| 3690 | "See SET TRANSACTION and START TRANSACTION." , |
| 3691 | SESSION_VAR(tx_read_only), NO_CMD_LINE, DEFAULT(0), |
| 3692 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_tx_read_only)); |
| 3693 | |
| 3694 | static Sys_var_ulonglong Sys_tmp_table_size( |
| 3695 | "tmp_table_size" , |
| 3696 | "Alias for tmp_memory_table_size. " |
| 3697 | "If an internal in-memory temporary table exceeds this size, MariaDB " |
| 3698 | "will automatically convert it to an on-disk MyISAM or Aria table." , |
| 3699 | SESSION_VAR(tmp_memory_table_size), CMD_LINE(REQUIRED_ARG), |
| 3700 | VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), |
| 3701 | BLOCK_SIZE(1)); |
| 3702 | |
| 3703 | static Sys_var_ulonglong Sys_tmp_memory_table_size( |
| 3704 | "tmp_memory_table_size" , |
| 3705 | "If an internal in-memory temporary table exceeds this size, MariaDB " |
| 3706 | "will automatically convert it to an on-disk MyISAM or Aria table. " |
| 3707 | "Same as tmp_table_size." , |
| 3708 | SESSION_VAR(tmp_memory_table_size), CMD_LINE(REQUIRED_ARG), |
| 3709 | VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), |
| 3710 | BLOCK_SIZE(1)); |
| 3711 | |
| 3712 | static Sys_var_ulonglong Sys_tmp_disk_table_size( |
| 3713 | "tmp_disk_table_size" , |
| 3714 | "Max size for data for an internal temporary on-disk MyISAM or Aria table." , |
| 3715 | SESSION_VAR(tmp_disk_table_size), CMD_LINE(REQUIRED_ARG), |
| 3716 | VALID_RANGE(1024, (ulonglong)~(intptr)0), |
| 3717 | DEFAULT((ulonglong)~(intptr)0), |
| 3718 | BLOCK_SIZE(1)); |
| 3719 | |
| 3720 | static Sys_var_mybool Sys_timed_mutexes( |
| 3721 | "timed_mutexes" , |
| 3722 | "Specify whether to time mutexes. Deprecated, has no effect." , |
| 3723 | GLOBAL_VAR(timed_mutexes), CMD_LINE(OPT_ARG), DEFAULT(0), |
| 3724 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL), |
| 3725 | DEPRECATED("" )); |
| 3726 | |
| 3727 | static Sys_var_charptr Sys_version( |
| 3728 | "version" , "Server version number. It may also include a suffix " |
| 3729 | "with configuration or build information. -debug indicates " |
| 3730 | "debugging support was enabled on the server, and -log indicates " |
| 3731 | "at least one of the binary log, general log or slow query log are " |
| 3732 | "enabled, for example 10.1.1-MariaDB-mariadb1precise-log." , |
| 3733 | READ_ONLY GLOBAL_VAR(server_version_ptr), |
| 3734 | CMD_LINE_HELP_ONLY, |
| 3735 | IN_SYSTEM_CHARSET, DEFAULT(server_version)); |
| 3736 | |
| 3737 | static char *; |
| 3738 | static Sys_var_charptr ( |
| 3739 | "version_comment" , "Value of the COMPILATION_COMMENT option " |
| 3740 | "specified by CMake when building MariaDB, for example " |
| 3741 | "mariadb.org binary distribution." , |
| 3742 | READ_ONLY GLOBAL_VAR(server_version_comment_ptr), |
| 3743 | CMD_LINE_HELP_ONLY, |
| 3744 | IN_SYSTEM_CHARSET, DEFAULT(MYSQL_COMPILATION_COMMENT)); |
| 3745 | |
| 3746 | static char *server_version_compile_machine_ptr; |
| 3747 | static Sys_var_charptr Sys_version_compile_machine( |
| 3748 | "version_compile_machine" , "The machine type or architecture " |
| 3749 | "MariaDB was built on, for example i686." , |
| 3750 | READ_ONLY GLOBAL_VAR(server_version_compile_machine_ptr), |
| 3751 | CMD_LINE_HELP_ONLY, IN_SYSTEM_CHARSET, DEFAULT(DEFAULT_MACHINE)); |
| 3752 | |
| 3753 | static char *server_version_compile_os_ptr; |
| 3754 | static Sys_var_charptr Sys_version_compile_os( |
| 3755 | "version_compile_os" , "Operating system that MariaDB was built " |
| 3756 | "on, for example debian-linux-gnu." , |
| 3757 | READ_ONLY GLOBAL_VAR(server_version_compile_os_ptr), |
| 3758 | CMD_LINE_HELP_ONLY, |
| 3759 | IN_SYSTEM_CHARSET, DEFAULT(SYSTEM_TYPE)); |
| 3760 | |
| 3761 | #include <source_revision.h> |
| 3762 | static char *server_version_source_revision; |
| 3763 | static Sys_var_charptr Sys_version_source_revision( |
| 3764 | "version_source_revision" , "Source control revision id for MariaDB source code" , |
| 3765 | READ_ONLY GLOBAL_VAR(server_version_source_revision), |
| 3766 | CMD_LINE_HELP_ONLY, |
| 3767 | IN_SYSTEM_CHARSET, DEFAULT(SOURCE_REVISION)); |
| 3768 | |
| 3769 | static char *malloc_library; |
| 3770 | static Sys_var_charptr Sys_malloc_library( |
| 3771 | "version_malloc_library" , "Version of the used malloc library" , |
| 3772 | READ_ONLY GLOBAL_VAR(malloc_library), CMD_LINE_HELP_ONLY, |
| 3773 | IN_SYSTEM_CHARSET, DEFAULT(guess_malloc_library())); |
| 3774 | |
| 3775 | static char *ssl_library; |
| 3776 | static Sys_var_charptr Sys_ssl_library( |
| 3777 | "version_ssl_library" , "Version of the used SSL library" , |
| 3778 | READ_ONLY GLOBAL_VAR(ssl_library), CMD_LINE_HELP_ONLY, |
| 3779 | IN_SYSTEM_CHARSET, DEFAULT(SSL_LIBRARY)); |
| 3780 | |
| 3781 | static Sys_var_ulong Sys_net_wait_timeout( |
| 3782 | "wait_timeout" , |
| 3783 | "The number of seconds the server waits for activity on a " |
| 3784 | "connection before closing it" , |
| 3785 | NO_SET_STMT SESSION_VAR(net_wait_timeout), CMD_LINE(REQUIRED_ARG), |
| 3786 | VALID_RANGE(1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)), |
| 3787 | DEFAULT(NET_WAIT_TIMEOUT), BLOCK_SIZE(1)); |
| 3788 | |
| 3789 | static Sys_var_uint Sys_idle_transaction_timeout( |
| 3790 | "idle_transaction_timeout" , |
| 3791 | "The number of seconds the server waits for idle transaction" , |
| 3792 | SESSION_VAR(idle_transaction_timeout), CMD_LINE(REQUIRED_ARG), |
| 3793 | VALID_RANGE(0, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)), |
| 3794 | DEFAULT(0), BLOCK_SIZE(1)); |
| 3795 | |
| 3796 | static Sys_var_uint Sys_idle_readonly_transaction_timeout( |
| 3797 | "idle_readonly_transaction_timeout" , |
| 3798 | "The number of seconds the server waits for read-only idle transaction" , |
| 3799 | SESSION_VAR(idle_readonly_transaction_timeout), CMD_LINE(REQUIRED_ARG), |
| 3800 | VALID_RANGE(0, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)), |
| 3801 | DEFAULT(0), BLOCK_SIZE(1)); |
| 3802 | |
| 3803 | static Sys_var_uint Sys_idle_write_transaction_timeout( |
| 3804 | "idle_write_transaction_timeout" , |
| 3805 | "The number of seconds the server waits for write idle transaction" , |
| 3806 | SESSION_VAR(idle_write_transaction_timeout), CMD_LINE(REQUIRED_ARG), |
| 3807 | VALID_RANGE(0, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT)), |
| 3808 | DEFAULT(0), BLOCK_SIZE(1)); |
| 3809 | |
| 3810 | static Sys_var_plugin Sys_default_storage_engine( |
| 3811 | "default_storage_engine" , "The default storage engine for new tables" , |
| 3812 | SESSION_VAR(table_plugin), NO_CMD_LINE, |
| 3813 | MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_storage_engine), |
| 3814 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_null)); |
| 3815 | |
| 3816 | // Alias for @@default_storage_engine |
| 3817 | static Sys_var_plugin Sys_storage_engine( |
| 3818 | "storage_engine" , "Alias for @@default_storage_engine. Deprecated" , |
| 3819 | SESSION_VAR(table_plugin), NO_CMD_LINE, |
| 3820 | MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_storage_engine), |
| 3821 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_not_null)); |
| 3822 | |
| 3823 | static Sys_var_plugin Sys_default_tmp_storage_engine( |
| 3824 | "default_tmp_storage_engine" , "The default storage engine for user-created temporary tables" , |
| 3825 | SESSION_VAR(tmp_table_plugin), NO_CMD_LINE, |
| 3826 | MYSQL_STORAGE_ENGINE_PLUGIN, DEFAULT(&default_tmp_storage_engine)); |
| 3827 | |
| 3828 | static Sys_var_plugin Sys_enforce_storage_engine( |
| 3829 | "enforce_storage_engine" , "Force the use of a storage engine for new tables" , |
| 3830 | SESSION_VAR(enforced_table_plugin), |
| 3831 | NO_CMD_LINE, MYSQL_STORAGE_ENGINE_PLUGIN, |
| 3832 | DEFAULT(&enforced_storage_engine), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super)); |
| 3833 | |
| 3834 | |
| 3835 | #ifdef HAVE_REPLICATION |
| 3836 | /* |
| 3837 | Check |
| 3838 | 1. Value for gtid_pos_auto_engines is not NULL. |
| 3839 | 2. No slave SQL thread is running. |
| 3840 | */ |
| 3841 | static bool |
| 3842 | check_gtid_pos_auto_engines(sys_var *self, THD *thd, set_var *var) |
| 3843 | { |
| 3844 | bool running; |
| 3845 | bool err= false; |
| 3846 | |
| 3847 | DBUG_ASSERT(var->type == OPT_GLOBAL); |
| 3848 | if (var->value && var->value->is_null()) |
| 3849 | err= true; |
| 3850 | else |
| 3851 | { |
| 3852 | running= give_error_if_slave_running(false); |
| 3853 | if (running) |
| 3854 | err= true; |
| 3855 | } |
| 3856 | return err; |
| 3857 | } |
| 3858 | |
| 3859 | |
| 3860 | static Sys_var_pluginlist Sys_gtid_pos_auto_engines( |
| 3861 | "gtid_pos_auto_engines" , |
| 3862 | "List of engines for which to automatically create a " |
| 3863 | "mysql.gtid_slave_pos_ENGINE table, if a transaction using that engine " |
| 3864 | "is replicated. This can be used to avoid introducing cross-engine " |
| 3865 | "transactions, if engines are used different from that used by table " |
| 3866 | "mysql.gtid_slave_pos" , |
| 3867 | GLOBAL_VAR(opt_gtid_pos_auto_plugins), NO_CMD_LINE, |
| 3868 | DEFAULT(>id_pos_auto_engines), |
| 3869 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_gtid_pos_auto_engines)); |
| 3870 | #endif |
| 3871 | |
| 3872 | |
| 3873 | #if defined(ENABLED_DEBUG_SYNC) |
| 3874 | /* |
| 3875 | Variable can be set for the session only. |
| 3876 | |
| 3877 | This could be changed later. Then we need to have a global array of |
| 3878 | actions in addition to the thread local ones. SET GLOBAL would |
| 3879 | manage the global array, SET [SESSION] the local array. A sync point |
| 3880 | would need to look for a local and a global action. Setting and |
| 3881 | executing of global actions need to be protected by a mutex. |
| 3882 | |
| 3883 | The purpose of global actions could be to allow synchronizing with |
| 3884 | connectionless threads that cannot execute SET statements. |
| 3885 | */ |
| 3886 | static Sys_var_debug_sync Sys_debug_sync( |
| 3887 | "debug_sync" , "Debug Sync Facility" , |
| 3888 | NO_SET_STMT sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 3889 | DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super)); |
| 3890 | #endif /* defined(ENABLED_DEBUG_SYNC) */ |
| 3891 | |
| 3892 | /** |
| 3893 | "time_format" "date_format" "datetime_format" |
| 3894 | |
| 3895 | the following three variables are unused, and the source of confusion |
| 3896 | (bug reports like "I've changed date_format, but date format hasn't changed. |
| 3897 | I've made them read-only, to alleviate the situation somewhat. |
| 3898 | |
| 3899 | @todo make them NO_CMD_LINE ? |
| 3900 | */ |
| 3901 | static Sys_var_charptr Sys_date_format( |
| 3902 | "date_format" , "The DATE format (ignored)" , |
| 3903 | READ_ONLY GLOBAL_VAR(global_date_format.format.str), |
| 3904 | CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 3905 | DEFAULT(known_date_time_formats[ISO_FORMAT].date_format), |
| 3906 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), DEPRECATED("" )); |
| 3907 | |
| 3908 | static Sys_var_charptr Sys_datetime_format( |
| 3909 | "datetime_format" , "The DATETIME format (ignored)" , |
| 3910 | READ_ONLY GLOBAL_VAR(global_datetime_format.format.str), |
| 3911 | CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 3912 | DEFAULT(known_date_time_formats[ISO_FORMAT].datetime_format), |
| 3913 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), DEPRECATED("" )); |
| 3914 | |
| 3915 | static Sys_var_charptr Sys_time_format( |
| 3916 | "time_format" , "The TIME format (ignored)" , |
| 3917 | READ_ONLY GLOBAL_VAR(global_time_format.format.str), |
| 3918 | CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 3919 | DEFAULT(known_date_time_formats[ISO_FORMAT].time_format), |
| 3920 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), DEPRECATED("" )); |
| 3921 | |
| 3922 | static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type) |
| 3923 | { |
| 3924 | if (type == OPT_GLOBAL) |
| 3925 | { |
| 3926 | if (global_system_variables.option_bits & OPTION_AUTOCOMMIT) |
| 3927 | global_system_variables.option_bits&= ~OPTION_NOT_AUTOCOMMIT; |
| 3928 | else |
| 3929 | global_system_variables.option_bits|= OPTION_NOT_AUTOCOMMIT; |
| 3930 | return false; |
| 3931 | } |
| 3932 | |
| 3933 | if (test_all_bits(thd->variables.option_bits, |
| 3934 | (OPTION_AUTOCOMMIT | OPTION_NOT_AUTOCOMMIT))) |
| 3935 | { |
| 3936 | // activating autocommit |
| 3937 | if (trans_commit_stmt(thd) || trans_commit(thd)) |
| 3938 | { |
| 3939 | thd->variables.option_bits&= ~OPTION_AUTOCOMMIT; |
| 3940 | thd->mdl_context.release_transactional_locks(); |
| 3941 | WSREP_DEBUG("autocommit, MDL TRX lock released: %lld" , |
| 3942 | (longlong) thd->thread_id); |
| 3943 | return true; |
| 3944 | } |
| 3945 | /* |
| 3946 | Don't close thread tables or release metadata locks: if we do so, we |
| 3947 | risk releasing locks/closing tables of expressions used to assign |
| 3948 | other variables, as in: |
| 3949 | set @var=my_stored_function1(), @@autocommit=1, @var2=(select MY_MAX(a) |
| 3950 | from my_table), ... |
| 3951 | The locks will be released at statement end anyway, as SET |
| 3952 | statement that assigns autocommit is marked to commit |
| 3953 | transaction implicitly at the end (@sa stmt_causes_implicitcommit()). |
| 3954 | */ |
| 3955 | thd->variables.option_bits&= |
| 3956 | ~(OPTION_BEGIN | OPTION_KEEP_LOG | OPTION_NOT_AUTOCOMMIT | |
| 3957 | OPTION_GTID_BEGIN); |
| 3958 | thd->transaction.all.modified_non_trans_table= false; |
| 3959 | thd->transaction.all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; |
| 3960 | thd->server_status|= SERVER_STATUS_AUTOCOMMIT; |
| 3961 | return false; |
| 3962 | } |
| 3963 | |
| 3964 | if ((thd->variables.option_bits & |
| 3965 | (OPTION_AUTOCOMMIT |OPTION_NOT_AUTOCOMMIT)) == 0) |
| 3966 | { |
| 3967 | // disabling autocommit |
| 3968 | thd->transaction.all.modified_non_trans_table= false; |
| 3969 | thd->transaction.all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; |
| 3970 | thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT; |
| 3971 | thd->variables.option_bits|= OPTION_NOT_AUTOCOMMIT; |
| 3972 | return false; |
| 3973 | } |
| 3974 | |
| 3975 | return false; // autocommit value wasn't changed |
| 3976 | } |
| 3977 | |
| 3978 | static Sys_var_bit Sys_autocommit( |
| 3979 | "autocommit" , "If set to 1, the default, all queries are committed " |
| 3980 | "immediately. If set to 0, they are only committed upon a COMMIT statement" |
| 3981 | ", or rolled back with a ROLLBACK statement. If autocommit is set to 0, " |
| 3982 | "and then changed to 1, all open transactions are immediately committed." , |
| 3983 | NO_SET_STMT SESSION_VAR(option_bits), NO_CMD_LINE, |
| 3984 | OPTION_AUTOCOMMIT, DEFAULT(TRUE), |
| 3985 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_autocommit)); |
| 3986 | export sys_var *Sys_autocommit_ptr= &Sys_autocommit; // for sql_yacc.yy |
| 3987 | |
| 3988 | static Sys_var_mybool Sys_big_tables( |
| 3989 | "big_tables" , "Old variable, which if set to 1, allows large result sets " |
| 3990 | "by saving all temporary sets to disk, avoiding 'table full' errors. No " |
| 3991 | "longer needed, as the server now handles this automatically. " |
| 3992 | "sql_big_tables is a synonym." , |
| 3993 | SESSION_VAR(big_tables), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 3994 | |
| 3995 | static Sys_var_bit Sys_big_selects( |
| 3996 | "sql_big_selects" , "If set to 0, MariaDB will not perform large SELECTs." |
| 3997 | " See max_join_size for details. If max_join_size is set to anything but " |
| 3998 | "DEFAULT, sql_big_selects is automatically set to 0. If sql_big_selects " |
| 3999 | "is again set, max_join_size will be ignored." , |
| 4000 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_BIG_SELECTS, |
| 4001 | DEFAULT(FALSE)); |
| 4002 | |
| 4003 | static Sys_var_bit Sys_log_off( |
| 4004 | "sql_log_off" , "If set to 1 (0 is the default), no logging to the general " |
| 4005 | "query log is done for the client. Only clients with the SUPER privilege " |
| 4006 | "can update this variable." , |
| 4007 | NO_SET_STMT SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_LOG_OFF, |
| 4008 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super)); |
| 4009 | |
| 4010 | /** |
| 4011 | This function sets the session variable thd->variables.sql_log_bin |
| 4012 | to reflect changes to @@session.sql_log_bin. |
| 4013 | |
| 4014 | @param[IN] self A pointer to the sys_var, i.e. Sys_log_binlog. |
| 4015 | @param[IN] type The type either session or global. |
| 4016 | |
| 4017 | @return @c FALSE. |
| 4018 | */ |
| 4019 | static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd, |
| 4020 | enum_var_type type) |
| 4021 | { |
| 4022 | DBUG_ASSERT(type == OPT_SESSION); |
| 4023 | |
| 4024 | if (thd->variables.sql_log_bin) |
| 4025 | thd->variables.option_bits |= OPTION_BIN_LOG; |
| 4026 | else |
| 4027 | thd->variables.option_bits &= ~OPTION_BIN_LOG; |
| 4028 | |
| 4029 | return FALSE; |
| 4030 | } |
| 4031 | |
| 4032 | /** |
| 4033 | This function checks if the sql_log_bin can be changed, |
| 4034 | what is possible if: |
| 4035 | - the user is a super user; |
| 4036 | - the set is not called from within a function/trigger; |
| 4037 | - there is no on-going transaction. |
| 4038 | |
| 4039 | @param[IN] self A pointer to the sys_var, i.e. Sys_log_binlog. |
| 4040 | @param[IN] var A pointer to the set_var created by the parser. |
| 4041 | |
| 4042 | @return @c FALSE if the change is allowed, otherwise @c TRUE. |
| 4043 | */ |
| 4044 | static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var) |
| 4045 | { |
| 4046 | if (check_has_super(self, thd, var)) |
| 4047 | return TRUE; |
| 4048 | |
| 4049 | if (unlikely(var->type == OPT_GLOBAL)) |
| 4050 | { |
| 4051 | my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), self->name.str, "SESSION" ); |
| 4052 | return TRUE; |
| 4053 | } |
| 4054 | |
| 4055 | if (unlikely(error_if_in_trans_or_substatement(thd, |
| 4056 | ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN, |
| 4057 | ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN))) |
| 4058 | return TRUE; |
| 4059 | |
| 4060 | return FALSE; |
| 4061 | } |
| 4062 | |
| 4063 | static Sys_var_mybool Sys_log_binlog( |
| 4064 | "sql_log_bin" , "If set to 0 (1 is the default), no logging to the binary " |
| 4065 | "log is done for the client. Only clients with the SUPER privilege can " |
| 4066 | "update this variable. Can have unintended consequences if set globally, " |
| 4067 | "see SET SQL_LOG_BIN. Starting MariaDB 10.1.7, this variable does not " |
| 4068 | "affect the replication of events in a Galera cluster." , |
| 4069 | SESSION_VAR(sql_log_bin), NO_CMD_LINE, DEFAULT(TRUE), |
| 4070 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_log_bin), |
| 4071 | ON_UPDATE(fix_sql_log_bin_after_update)); |
| 4072 | |
| 4073 | static Sys_var_bit Sys_sql_warnings( |
| 4074 | "sql_warnings" , "If set to 1, single-row INSERTs will produce a string " |
| 4075 | "containing warning information if a warning occurs." , |
| 4076 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_WARNINGS, |
| 4077 | DEFAULT(FALSE)); |
| 4078 | |
| 4079 | static Sys_var_bit Sys_sql_notes( |
| 4080 | "sql_notes" , "If set to 1, the default, warning_count is incremented each " |
| 4081 | "time a Note warning is encountered. If set to 0, Note warnings are not " |
| 4082 | "recorded. mysqldump has outputs to set this variable to 0 so that no " |
| 4083 | "unnecessary increments occur when data is reloaded." , |
| 4084 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_SQL_NOTES, |
| 4085 | DEFAULT(TRUE)); |
| 4086 | |
| 4087 | static Sys_var_bit Sys_auto_is_null( |
| 4088 | "sql_auto_is_null" , "If set to 1, the query SELECT * FROM table_name WHERE " |
| 4089 | "auto_increment_column IS NULL will return an auto-increment that has just " |
| 4090 | "been successfully inserted, the same as the LAST_INSERT_ID() function. Some" |
| 4091 | " ODBC programs make use of this IS NULL comparison." , |
| 4092 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_AUTO_IS_NULL, |
| 4093 | DEFAULT(FALSE), NO_MUTEX_GUARD, IN_BINLOG); |
| 4094 | |
| 4095 | static Sys_var_bit Sys_safe_updates( |
| 4096 | "sql_safe_updates" , "If set to 1, UPDATEs and DELETEs need either a key in " |
| 4097 | "the WHERE clause, or a LIMIT clause, or else they will aborted. Prevents " |
| 4098 | "the common mistake of accidentally deleting or updating every row in a table." , |
| 4099 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_SAFE_UPDATES, |
| 4100 | DEFAULT(FALSE)); |
| 4101 | |
| 4102 | static Sys_var_bit Sys_buffer_results( |
| 4103 | "sql_buffer_result" , "If set to 1 (0 is default), results from SELECT " |
| 4104 | "statements are always placed into temporary tables. This can help the " |
| 4105 | "server when it takes a long time to send the results to the client by " |
| 4106 | "allowing the table locks to be freed early." , |
| 4107 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_BUFFER_RESULT, |
| 4108 | DEFAULT(FALSE)); |
| 4109 | |
| 4110 | static Sys_var_bit Sys_quote_show_create( |
| 4111 | "sql_quote_show_create" , "If set to 1, the default, the server will " |
| 4112 | "quote identifiers for SHOW CREATE DATABASE, SHOW CREATE TABLE and " |
| 4113 | "SHOW CREATE VIEW statements. Quoting is disabled if set to 0. Enable " |
| 4114 | "to ensure replications works when identifiers require quoting." , |
| 4115 | SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_QUOTE_SHOW_CREATE, |
| 4116 | DEFAULT(TRUE)); |
| 4117 | |
| 4118 | static Sys_var_bit Sys_foreign_key_checks( |
| 4119 | "foreign_key_checks" , "If set to 1 (the default) foreign key constraints" |
| 4120 | " (including ON UPDATE and ON DELETE behavior) InnoDB tables are checked," |
| 4121 | " while if set to 0, they are not checked. 0 is not recommended for normal " |
| 4122 | "use, though it can be useful in situations where you know the data is " |
| 4123 | "consistent, but want to reload data in a different order from that that " |
| 4124 | "specified by parent/child relationships. Setting this variable to 1 does " |
| 4125 | "not retrospectively check for inconsistencies introduced while set to 0." , |
| 4126 | SESSION_VAR(option_bits), NO_CMD_LINE, |
| 4127 | REVERSE(OPTION_NO_FOREIGN_KEY_CHECKS), |
| 4128 | DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG); |
| 4129 | |
| 4130 | static Sys_var_bit Sys_unique_checks( |
| 4131 | "unique_checks" , "If set to 1, the default, secondary indexes in InnoDB " |
| 4132 | "tables are performed. If set to 0, storage engines can (but are not " |
| 4133 | "required to) assume that duplicate keys are not present in input data. " |
| 4134 | "Set to 0 to speed up imports of large tables to InnoDB. The storage " |
| 4135 | "engine will still issue a duplicate key error if it detects one, even " |
| 4136 | "if set to 0." , |
| 4137 | SESSION_VAR(option_bits), NO_CMD_LINE, |
| 4138 | REVERSE(OPTION_RELAXED_UNIQUE_CHECKS), |
| 4139 | DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG); |
| 4140 | |
| 4141 | static Sys_var_bit Sys_no_check_constraint( |
| 4142 | "check_constraint_checks" , "check_constraint_checks" , |
| 4143 | SESSION_VAR(option_bits), NO_CMD_LINE, |
| 4144 | REVERSE(OPTION_NO_CHECK_CONSTRAINT_CHECKS), |
| 4145 | DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG); |
| 4146 | |
| 4147 | #ifdef ENABLED_PROFILING |
| 4148 | static bool update_profiling(sys_var *self, THD *thd, enum_var_type type) |
| 4149 | { |
| 4150 | if (type == OPT_SESSION) |
| 4151 | thd->profiling.reset(); |
| 4152 | return false; |
| 4153 | } |
| 4154 | |
| 4155 | static Sys_var_bit Sys_profiling( |
| 4156 | "profiling" , "If set to 1 (0 is default), statement profiling will be " |
| 4157 | "enabled. See SHOW PROFILES and SHOW PROFILE." , |
| 4158 | NO_SET_STMT SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_PROFILING, |
| 4159 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 4160 | ON_UPDATE(update_profiling)); |
| 4161 | |
| 4162 | static Sys_var_ulong Sys_profiling_history_size( |
| 4163 | "profiling_history_size" , "Number of statements about which profiling " |
| 4164 | "information is maintained. If set to 0, no profiles are stored. " |
| 4165 | "See SHOW PROFILES." , |
| 4166 | NO_SET_STMT SESSION_VAR(profiling_history_size), CMD_LINE(REQUIRED_ARG), |
| 4167 | VALID_RANGE(0, 100), DEFAULT(15), BLOCK_SIZE(1)); |
| 4168 | #endif |
| 4169 | |
| 4170 | /* |
| 4171 | When this is set by a connection, binlogged events will be marked with a |
| 4172 | corresponding flag. The slave can be configured to not replicate events |
| 4173 | so marked. |
| 4174 | In the binlog dump thread on the master, this variable is re-used for a |
| 4175 | related purpose: The slave sets this flag when connecting to the master to |
| 4176 | request that the master filter out (ie. not send) any events with the flag |
| 4177 | set, thus saving network traffic on events that would be ignored by the |
| 4178 | slave anyway. |
| 4179 | */ |
| 4180 | static bool check_skip_replication(sys_var *self, THD *thd, set_var *var) |
| 4181 | { |
| 4182 | /* |
| 4183 | We must not change @@skip_replication in the middle of a transaction or |
| 4184 | statement, as that could result in only part of the transaction / statement |
| 4185 | being replicated. |
| 4186 | (This would be particularly serious if we were to replicate eg. |
| 4187 | Rows_log_event without Table_map_log_event or transactional updates without |
| 4188 | the COMMIT). |
| 4189 | */ |
| 4190 | if (unlikely(error_if_in_trans_or_substatement(thd, |
| 4191 | ER_STORED_FUNCTION_PREVENTS_SWITCH_SKIP_REPLICATION, |
| 4192 | ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SKIP_REPLICATION))) |
| 4193 | return 1; |
| 4194 | |
| 4195 | return 0; |
| 4196 | } |
| 4197 | |
| 4198 | static Sys_var_bit Sys_skip_replication( |
| 4199 | "skip_replication" , "Changes are logged into the binary log with the " |
| 4200 | "@@skip_replication flag set. Such events will not be replicated by " |
| 4201 | "slaves that run with --replicate-events-marked-for-skip set different " |
| 4202 | "from its default of REPLICATE. See Selectively skipping replication " |
| 4203 | "of binlog events for more information." , |
| 4204 | NO_SET_STMT SESSION_ONLY(option_bits), |
| 4205 | NO_CMD_LINE, OPTION_SKIP_REPLICATION, |
| 4206 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 4207 | ON_CHECK(check_skip_replication)); |
| 4208 | |
| 4209 | static Sys_var_harows Sys_select_limit( |
| 4210 | "sql_select_limit" , |
| 4211 | "The maximum number of rows to return from SELECT statements" , |
| 4212 | SESSION_VAR(select_limit), NO_CMD_LINE, |
| 4213 | VALID_RANGE(0, HA_POS_ERROR), DEFAULT(HA_POS_ERROR), BLOCK_SIZE(1)); |
| 4214 | |
| 4215 | static const char *secure_timestamp_levels[]= {"NO" , "SUPER" , "REPLICATION" , "YES" , 0}; |
| 4216 | static bool check_timestamp(sys_var *self, THD *thd, set_var *var) |
| 4217 | { |
| 4218 | if (opt_secure_timestamp == SECTIME_NO) |
| 4219 | return false; |
| 4220 | if (opt_secure_timestamp == SECTIME_SUPER) |
| 4221 | return check_has_super(self, thd, var); |
| 4222 | char buf[1024]; |
| 4223 | strxnmov(buf, sizeof(buf), "--secure-timestamp=" , |
| 4224 | secure_timestamp_levels[opt_secure_timestamp], NULL); |
| 4225 | my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), buf); |
| 4226 | return true; |
| 4227 | } |
| 4228 | static Sys_var_timestamp Sys_timestamp( |
| 4229 | "timestamp" , "Set the time for this client" , |
| 4230 | sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4231 | VALID_RANGE(0, TIMESTAMP_MAX_VALUE), |
| 4232 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_timestamp)); |
| 4233 | |
| 4234 | static bool update_last_insert_id(THD *thd, set_var *var) |
| 4235 | { |
| 4236 | if (!var->value) |
| 4237 | { |
| 4238 | my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); |
| 4239 | return true; |
| 4240 | } |
| 4241 | thd->first_successful_insert_id_in_prev_stmt= |
| 4242 | var->save_result.ulonglong_value; |
| 4243 | return false; |
| 4244 | } |
| 4245 | static ulonglong read_last_insert_id(THD *thd) |
| 4246 | { |
| 4247 | return (ulonglong) thd->read_first_successful_insert_id_in_prev_stmt(); |
| 4248 | } |
| 4249 | static Sys_var_session_special Sys_last_insert_id( |
| 4250 | "last_insert_id" , "The value to be returned from LAST_INSERT_ID()" , |
| 4251 | sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4252 | VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1), |
| 4253 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), |
| 4254 | ON_UPDATE(update_last_insert_id), ON_READ(read_last_insert_id)); |
| 4255 | |
| 4256 | // alias for last_insert_id(), Sybase-style |
| 4257 | static Sys_var_session_special Sys_identity( |
| 4258 | "identity" , "Synonym for the last_insert_id variable" , |
| 4259 | sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4260 | VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1), |
| 4261 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), |
| 4262 | ON_UPDATE(update_last_insert_id), ON_READ(read_last_insert_id)); |
| 4263 | |
| 4264 | /* |
| 4265 | insert_id should *not* be marked as written to the binlog (i.e., it |
| 4266 | should *not* be IN_BINLOG), because we want any statement that |
| 4267 | refers to insert_id explicitly to be unsafe. (By "explicitly", we |
| 4268 | mean using @@session.insert_id, whereas insert_id is used |
| 4269 | "implicitly" when NULL value is inserted into an auto_increment |
| 4270 | column). |
| 4271 | |
| 4272 | We want statements referring explicitly to @@session.insert_id to be |
| 4273 | unsafe, because insert_id is modified internally by the slave sql |
| 4274 | thread when NULL values are inserted in an AUTO_INCREMENT column. |
| 4275 | This modification interfers with the value of the |
| 4276 | @@session.insert_id variable if @@session.insert_id is referred |
| 4277 | explicitly by an insert statement (as is seen by executing "SET |
| 4278 | @@session.insert_id=0; CREATE TABLE t (a INT, b INT KEY |
| 4279 | AUTO_INCREMENT); INSERT INTO t(a) VALUES (@@session.insert_id);" in |
| 4280 | statement-based logging mode: t will be different on master and |
| 4281 | slave). |
| 4282 | */ |
| 4283 | static bool update_insert_id(THD *thd, set_var *var) |
| 4284 | { |
| 4285 | if (!var->value) |
| 4286 | { |
| 4287 | my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); |
| 4288 | return true; |
| 4289 | } |
| 4290 | thd->force_one_auto_inc_interval(var->save_result.ulonglong_value); |
| 4291 | return false; |
| 4292 | } |
| 4293 | |
| 4294 | static ulonglong read_insert_id(THD *thd) |
| 4295 | { |
| 4296 | return thd->auto_inc_intervals_forced.minimum(); |
| 4297 | } |
| 4298 | static Sys_var_session_special Sys_insert_id( |
| 4299 | "insert_id" , "The value to be used by the following INSERT " |
| 4300 | "or ALTER TABLE statement when inserting an AUTO_INCREMENT value" , |
| 4301 | sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4302 | VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1), |
| 4303 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 4304 | ON_UPDATE(update_insert_id), ON_READ(read_insert_id)); |
| 4305 | |
| 4306 | static bool update_rand_seed1(THD *thd, set_var *var) |
| 4307 | { |
| 4308 | if (!var->value) |
| 4309 | { |
| 4310 | my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); |
| 4311 | return true; |
| 4312 | } |
| 4313 | thd->rand.seed1= (ulong) var->save_result.ulonglong_value; |
| 4314 | return false; |
| 4315 | } |
| 4316 | static ulonglong read_rand_seed1(THD *thd) |
| 4317 | { |
| 4318 | return thd->rand.seed1; |
| 4319 | } |
| 4320 | static Sys_var_session_special Sys_rand_seed1( |
| 4321 | "rand_seed1" , "Sets the internal state of the RAND() " |
| 4322 | "generator for replication purposes" , |
| 4323 | sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4324 | VALID_RANGE(0, ULONG_MAX), BLOCK_SIZE(1), |
| 4325 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), |
| 4326 | ON_UPDATE(update_rand_seed1), ON_READ(read_rand_seed1)); |
| 4327 | |
| 4328 | static bool update_rand_seed2(THD *thd, set_var *var) |
| 4329 | { |
| 4330 | if (!var->value) |
| 4331 | { |
| 4332 | my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); |
| 4333 | return true; |
| 4334 | } |
| 4335 | thd->rand.seed2= (ulong) var->save_result.ulonglong_value; |
| 4336 | return false; |
| 4337 | } |
| 4338 | static ulonglong read_rand_seed2(THD *thd) |
| 4339 | { |
| 4340 | return thd->rand.seed2; |
| 4341 | } |
| 4342 | static Sys_var_session_special Sys_rand_seed2( |
| 4343 | "rand_seed2" , "Sets the internal state of the RAND() " |
| 4344 | "generator for replication purposes" , |
| 4345 | sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4346 | VALID_RANGE(0, ULONG_MAX), BLOCK_SIZE(1), |
| 4347 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0), |
| 4348 | ON_UPDATE(update_rand_seed2), ON_READ(read_rand_seed2)); |
| 4349 | |
| 4350 | static ulonglong read_error_count(THD *thd) |
| 4351 | { |
| 4352 | return thd->get_stmt_da()->error_count(); |
| 4353 | } |
| 4354 | // this really belongs to the SHOW STATUS |
| 4355 | static Sys_var_session_special Sys_error_count( |
| 4356 | "error_count" , "The number of errors that resulted from the " |
| 4357 | "last statement that generated messages" , |
| 4358 | READ_ONLY sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4359 | VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 4360 | NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), ON_READ(read_error_count)); |
| 4361 | |
| 4362 | static ulonglong read_warning_count(THD *thd) |
| 4363 | { |
| 4364 | return thd->get_stmt_da()->warn_count(); |
| 4365 | } |
| 4366 | // this really belongs to the SHOW STATUS |
| 4367 | static Sys_var_session_special Sys_warning_count( |
| 4368 | "warning_count" , "The number of errors, warnings, and notes " |
| 4369 | "that resulted from the last statement that generated messages" , |
| 4370 | READ_ONLY sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 4371 | VALID_RANGE(0, ULONGLONG_MAX), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 4372 | NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), ON_READ(read_warning_count)); |
| 4373 | |
| 4374 | static Sys_var_ulong Sys_default_week_format( |
| 4375 | "default_week_format" , |
| 4376 | "The default week format used by WEEK() functions" , |
| 4377 | SESSION_VAR(default_week_format), CMD_LINE(REQUIRED_ARG), |
| 4378 | VALID_RANGE(0, 7), DEFAULT(0), BLOCK_SIZE(1)); |
| 4379 | |
| 4380 | static Sys_var_ulonglong Sys_group_concat_max_len( |
| 4381 | "group_concat_max_len" , |
| 4382 | "The maximum length of the result of function GROUP_CONCAT()" , |
| 4383 | SESSION_VAR(group_concat_max_len), CMD_LINE(REQUIRED_ARG), |
| 4384 | VALID_RANGE(4, SIZE_T_MAX), DEFAULT(1024*1024), BLOCK_SIZE(1)); |
| 4385 | |
| 4386 | static char *glob_hostname_ptr; |
| 4387 | static Sys_var_charptr Sys_hostname( |
| 4388 | "hostname" , "Server host name" , |
| 4389 | READ_ONLY GLOBAL_VAR(glob_hostname_ptr), NO_CMD_LINE, |
| 4390 | IN_SYSTEM_CHARSET, DEFAULT(glob_hostname)); |
| 4391 | |
| 4392 | #ifndef EMBEDDED_LIBRARY |
| 4393 | static Sys_var_charptr Sys_repl_report_host( |
| 4394 | "report_host" , |
| 4395 | "Hostname or IP of the slave to be reported to the master during " |
| 4396 | "slave registration. Will appear in the output of SHOW SLAVE HOSTS. " |
| 4397 | "Leave unset if you do not want the slave to register itself with the " |
| 4398 | "master. Note that it is not sufficient for the master to simply read " |
| 4399 | "the IP of the slave off the socket once the slave connects. Due to " |
| 4400 | "NAT and other routing issues, that IP may not be valid for connecting " |
| 4401 | "to the slave from the master or other hosts" , |
| 4402 | READ_ONLY GLOBAL_VAR(report_host), CMD_LINE(REQUIRED_ARG), |
| 4403 | IN_SYSTEM_CHARSET, DEFAULT(0)); |
| 4404 | |
| 4405 | static Sys_var_charptr Sys_repl_report_user( |
| 4406 | "report_user" , |
| 4407 | "The account user name of the slave to be reported to the master " |
| 4408 | "during slave registration" , |
| 4409 | READ_ONLY GLOBAL_VAR(report_user), CMD_LINE(REQUIRED_ARG), |
| 4410 | IN_SYSTEM_CHARSET, DEFAULT(0)); |
| 4411 | |
| 4412 | static Sys_var_charptr Sys_repl_report_password( |
| 4413 | "report_password" , |
| 4414 | "The account password of the slave to be reported to the master " |
| 4415 | "during slave registration" , |
| 4416 | READ_ONLY GLOBAL_VAR(report_password), CMD_LINE(REQUIRED_ARG), |
| 4417 | IN_SYSTEM_CHARSET, DEFAULT(0)); |
| 4418 | |
| 4419 | static Sys_var_uint Sys_repl_report_port( |
| 4420 | "report_port" , |
| 4421 | "Port for connecting to slave reported to the master during slave " |
| 4422 | "registration. Set it only if the slave is listening on a non-default " |
| 4423 | "port or if you have a special tunnel from the master or other clients " |
| 4424 | "to the slave. If not sure, leave this option unset" , |
| 4425 | READ_ONLY GLOBAL_VAR(report_port), CMD_LINE(REQUIRED_ARG), |
| 4426 | VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 4427 | #endif |
| 4428 | |
| 4429 | static Sys_var_mybool Sys_keep_files_on_create( |
| 4430 | "keep_files_on_create" , |
| 4431 | "Don't overwrite stale .MYD and .MYI even if no directory is specified" , |
| 4432 | SESSION_VAR(keep_files_on_create), CMD_LINE(OPT_ARG), |
| 4433 | DEFAULT(FALSE)); |
| 4434 | |
| 4435 | static char *license; |
| 4436 | static Sys_var_charptr Sys_license( |
| 4437 | "license" , "The type of license the server has" , |
| 4438 | READ_ONLY GLOBAL_VAR(license), NO_CMD_LINE, IN_SYSTEM_CHARSET, |
| 4439 | DEFAULT(STRINGIFY_ARG(LICENSE))); |
| 4440 | |
| 4441 | #include <proxy_protocol.h> |
| 4442 | char *my_proxy_protocol_networks; |
| 4443 | static bool check_proxy_protocol_networks(sys_var *, THD *, set_var *var) |
| 4444 | { |
| 4445 | if (!var->value) |
| 4446 | return false; |
| 4447 | return !proxy_protocol_networks_valid(var->save_result.string_value.str); |
| 4448 | } |
| 4449 | |
| 4450 | |
| 4451 | static bool fix_proxy_protocol_networks(sys_var *, THD *, enum_var_type) |
| 4452 | { |
| 4453 | return (bool)set_proxy_protocol_networks(my_proxy_protocol_networks); |
| 4454 | } |
| 4455 | |
| 4456 | |
| 4457 | static Sys_var_charptr Sys_proxy_protocol_networks( |
| 4458 | "proxy_protocol_networks" , "Enable proxy protocol for these source " |
| 4459 | "networks. The syntax is a comma separated list of IPv4 and IPv6 " |
| 4460 | "networks. If the network doesn't contain mask, it is considered to be " |
| 4461 | "a single host. \"*\" represents all networks and must the only " |
| 4462 | "directive on the line. String \"localhost\" represents non-TCP " |
| 4463 | "local connections (Unix domain socket, Windows named pipe or shared memory)." , |
| 4464 | GLOBAL_VAR(my_proxy_protocol_networks), CMD_LINE(REQUIRED_ARG), |
| 4465 | IN_FS_CHARSET, DEFAULT("" ), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 4466 | ON_CHECK(check_proxy_protocol_networks), ON_UPDATE(fix_proxy_protocol_networks)); |
| 4467 | |
| 4468 | |
| 4469 | static bool check_log_path(sys_var *self, THD *thd, set_var *var) |
| 4470 | { |
| 4471 | if (!var->value) |
| 4472 | return false; // DEFAULT is ok |
| 4473 | |
| 4474 | if (!var->save_result.string_value.str) |
| 4475 | return true; |
| 4476 | |
| 4477 | LEX_STRING *val= &var->save_result.string_value; |
| 4478 | |
| 4479 | if (val->length > FN_REFLEN) |
| 4480 | { // path is too long |
| 4481 | my_error(ER_PATH_LENGTH, MYF(0), self->name.str); |
| 4482 | return true; |
| 4483 | } |
| 4484 | |
| 4485 | char path[FN_REFLEN]; |
| 4486 | size_t path_length= unpack_filename(path, val->str); |
| 4487 | |
| 4488 | if (!path_length) |
| 4489 | return true; |
| 4490 | |
| 4491 | if (!is_filename_allowed(var->save_result.string_value.str, |
| 4492 | var->save_result.string_value.length, TRUE)) |
| 4493 | { |
| 4494 | my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), |
| 4495 | self->name.str, var->save_result.string_value.str); |
| 4496 | return true; |
| 4497 | } |
| 4498 | |
| 4499 | static const LEX_CSTRING my_cnf= { STRING_WITH_LEN("my.cnf" ) }; |
| 4500 | static const LEX_CSTRING my_ini= { STRING_WITH_LEN("my.ini" ) }; |
| 4501 | if (path_length >= my_cnf.length) |
| 4502 | { |
| 4503 | if (strcasecmp(path + path_length - my_cnf.length, my_cnf.str) == 0) |
| 4504 | return true; // log file name ends with "my.cnf" |
| 4505 | DBUG_ASSERT(my_cnf.length == my_ini.length); |
| 4506 | if (strcasecmp(path + path_length - my_ini.length, my_ini.str) == 0) |
| 4507 | return true; // log file name ends with "my.ini" |
| 4508 | } |
| 4509 | |
| 4510 | MY_STAT f_stat; |
| 4511 | |
| 4512 | if (my_stat(path, &f_stat, MYF(0))) |
| 4513 | { |
| 4514 | if (!MY_S_ISREG(f_stat.st_mode) || !(f_stat.st_mode & MY_S_IWRITE)) |
| 4515 | return true; // not a regular writable file |
| 4516 | return false; |
| 4517 | } |
| 4518 | |
| 4519 | (void) dirname_part(path, val->str, &path_length); |
| 4520 | |
| 4521 | if (val->length - path_length >= FN_LEN) |
| 4522 | { // filename is too long |
| 4523 | my_error(ER_PATH_LENGTH, MYF(0), self->name.str); |
| 4524 | return true; |
| 4525 | } |
| 4526 | |
| 4527 | if (!path_length) // no path is good path (remember, relative to datadir) |
| 4528 | return false; |
| 4529 | |
| 4530 | if (my_access(path, (F_OK|W_OK))) |
| 4531 | return true; // directory is not writable |
| 4532 | |
| 4533 | return false; |
| 4534 | } |
| 4535 | static bool fix_log(char** logname, const char* default_logname, |
| 4536 | const char*ext, bool enabled, void (*reopen)(char*)) |
| 4537 | { |
| 4538 | if (!*logname) // SET ... = DEFAULT |
| 4539 | { |
| 4540 | make_default_log_name(logname, ext, false); |
| 4541 | if (!*logname) |
| 4542 | return true; |
| 4543 | } |
| 4544 | logger.lock_exclusive(); |
| 4545 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 4546 | if (enabled) |
| 4547 | reopen(*logname); |
| 4548 | logger.unlock(); |
| 4549 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 4550 | return false; |
| 4551 | } |
| 4552 | static void reopen_general_log(char* name) |
| 4553 | { |
| 4554 | logger.get_log_file_handler()->close(0); |
| 4555 | logger.get_log_file_handler()->open_query_log(name); |
| 4556 | } |
| 4557 | static bool fix_general_log_file(sys_var *self, THD *thd, enum_var_type type) |
| 4558 | { |
| 4559 | return fix_log(&opt_logname, opt_log_basename, ".log" , opt_log, |
| 4560 | reopen_general_log); |
| 4561 | } |
| 4562 | static Sys_var_charptr Sys_general_log_path( |
| 4563 | "general_log_file" , "Log connections and queries to given file" , |
| 4564 | PREALLOCATED GLOBAL_VAR(opt_logname), CMD_LINE(REQUIRED_ARG), |
| 4565 | IN_FS_CHARSET, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 4566 | ON_CHECK(check_log_path), ON_UPDATE(fix_general_log_file)); |
| 4567 | |
| 4568 | static void reopen_slow_log(char* name) |
| 4569 | { |
| 4570 | logger.get_slow_log_file_handler()->close(0); |
| 4571 | logger.get_slow_log_file_handler()->open_slow_log(name); |
| 4572 | } |
| 4573 | static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type) |
| 4574 | { |
| 4575 | return fix_log(&opt_slow_logname, opt_log_basename, "-slow.log" , |
| 4576 | global_system_variables.sql_log_slow, reopen_slow_log); |
| 4577 | } |
| 4578 | static Sys_var_charptr Sys_slow_log_path( |
| 4579 | "slow_query_log_file" , "Log slow queries to given log file. " |
| 4580 | "Defaults logging to 'hostname'-slow.log. Must be enabled to activate " |
| 4581 | "other slow log options" , |
| 4582 | PREALLOCATED GLOBAL_VAR(opt_slow_logname), CMD_LINE(REQUIRED_ARG), |
| 4583 | IN_FS_CHARSET, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 4584 | ON_CHECK(check_log_path), ON_UPDATE(fix_slow_log_file)); |
| 4585 | |
| 4586 | static Sys_var_have Sys_have_compress( |
| 4587 | "have_compress" , "If the zlib compression library is accessible to the " |
| 4588 | "server, this will be set to YES, otherwise it will be NO. The COMPRESS() " |
| 4589 | "and UNCOMPRESS() functions will only be available if set to YES." , |
| 4590 | READ_ONLY GLOBAL_VAR(have_compress), NO_CMD_LINE); |
| 4591 | |
| 4592 | static Sys_var_have Sys_have_crypt( |
| 4593 | "have_crypt" , "If the crypt() system call is available this variable will " |
| 4594 | "be set to YES, otherwise it will be set to NO. If set to NO, the " |
| 4595 | "ENCRYPT() function cannot be used." , |
| 4596 | READ_ONLY GLOBAL_VAR(have_crypt), NO_CMD_LINE); |
| 4597 | |
| 4598 | static Sys_var_have Sys_have_dlopen( |
| 4599 | "have_dynamic_loading" , "If the server supports dynamic loading of plugins, " |
| 4600 | "will be set to YES, otherwise will be set to NO." , |
| 4601 | READ_ONLY GLOBAL_VAR(have_dlopen), NO_CMD_LINE); |
| 4602 | |
| 4603 | static Sys_var_have Sys_have_geometry( |
| 4604 | "have_geometry" , "If the server supports spatial data types, will be set to " |
| 4605 | "YES, otherwise will be set to NO." , |
| 4606 | READ_ONLY GLOBAL_VAR(have_geometry), NO_CMD_LINE); |
| 4607 | |
| 4608 | static Sys_var_have Sys_have_openssl( |
| 4609 | "have_openssl" , "Comparing have_openssl with have_ssl will indicate whether " |
| 4610 | "YaSSL or openssl was used. If YaSSL, have_ssl will be YES, but have_openssl " |
| 4611 | "will be NO." , |
| 4612 | READ_ONLY GLOBAL_VAR(have_openssl), NO_CMD_LINE); |
| 4613 | |
| 4614 | static Sys_var_have Sys_have_profiling( |
| 4615 | "have_profiling" , "If statement profiling is available, will be set to YES, " |
| 4616 | "otherwise will be set to NO. See SHOW PROFILES and SHOW PROFILE." , |
| 4617 | READ_ONLY GLOBAL_VAR(have_profiling), NO_CMD_LINE); |
| 4618 | |
| 4619 | static Sys_var_have Sys_have_query_cache( |
| 4620 | "have_query_cache" , "If the server supports the query cache, will be set to " |
| 4621 | "YES, otherwise will be set to NO." , |
| 4622 | READ_ONLY GLOBAL_VAR(have_query_cache), NO_CMD_LINE); |
| 4623 | |
| 4624 | static Sys_var_have Sys_have_rtree_keys( |
| 4625 | "have_rtree_keys" , "If RTREE indexes (used for spatial indexes) " |
| 4626 | "are available, will be set to YES, otherwise will be set to NO." , |
| 4627 | READ_ONLY GLOBAL_VAR(have_rtree_keys), NO_CMD_LINE); |
| 4628 | |
| 4629 | static Sys_var_have Sys_have_ssl( |
| 4630 | "have_ssl" , "If the server supports secure connections, will be set to YES, " |
| 4631 | "otherwise will be set to NO. If set to DISABLED, the server was compiled with " |
| 4632 | "TLS support, but was not started with TLS support (see the mysqld options). " |
| 4633 | "See also have_openssl." , |
| 4634 | READ_ONLY GLOBAL_VAR(have_ssl), NO_CMD_LINE); |
| 4635 | |
| 4636 | static Sys_var_have Sys_have_symlink( |
| 4637 | "have_symlink" , "If symbolic link support is enabled, will be set to YES, " |
| 4638 | "otherwise will be set to NO. Required for the INDEX DIRECTORY and DATA " |
| 4639 | "DIRECTORY table options (see CREATE TABLE) and Windows symlink support. " |
| 4640 | "Will be set to DISABLED if the server is started with the " |
| 4641 | "--skip-symbolic-links option." , |
| 4642 | READ_ONLY GLOBAL_VAR(have_symlink), NO_CMD_LINE); |
| 4643 | |
| 4644 | static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type); |
| 4645 | |
| 4646 | static Sys_var_mybool Sys_general_log( |
| 4647 | "general_log" , "Log connections and queries to a table or log file. " |
| 4648 | "Defaults logging to a file 'hostname'.log or a table mysql.general_log" |
| 4649 | "if --log-output=TABLE is used." , |
| 4650 | GLOBAL_VAR(opt_log), CMD_LINE(OPT_ARG), |
| 4651 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 4652 | ON_UPDATE(fix_log_state)); |
| 4653 | |
| 4654 | static Sys_var_mybool Sys_slow_query_log( |
| 4655 | "slow_query_log" , |
| 4656 | "Log slow queries to a table or log file. Defaults logging to a file " |
| 4657 | "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " |
| 4658 | "used. Must be enabled to activate other slow log options." , |
| 4659 | SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG), |
| 4660 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 4661 | ON_CHECK(0), ON_UPDATE(fix_log_state)); |
| 4662 | |
| 4663 | static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) |
| 4664 | { |
| 4665 | bool res; |
| 4666 | my_bool *UNINIT_VAR(newvalptr), newval, UNINIT_VAR(oldval); |
| 4667 | uint UNINIT_VAR(log_type); |
| 4668 | |
| 4669 | if (type != OPT_GLOBAL) |
| 4670 | return 0; |
| 4671 | |
| 4672 | if (self == &Sys_general_log) |
| 4673 | { |
| 4674 | newvalptr= &opt_log; |
| 4675 | oldval= logger.get_log_file_handler()->is_open(); |
| 4676 | log_type= QUERY_LOG_GENERAL; |
| 4677 | } |
| 4678 | else |
| 4679 | { |
| 4680 | DBUG_ASSERT(self == &Sys_slow_query_log); |
| 4681 | newvalptr= &global_system_variables.sql_log_slow; |
| 4682 | oldval= logger.get_slow_log_file_handler()->is_open(); |
| 4683 | log_type= QUERY_LOG_SLOW; |
| 4684 | } |
| 4685 | |
| 4686 | newval= *newvalptr; |
| 4687 | if (oldval == newval) |
| 4688 | return false; |
| 4689 | |
| 4690 | *newvalptr= oldval; // [de]activate_log_handler works that way (sigh) |
| 4691 | |
| 4692 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 4693 | if (!newval) |
| 4694 | { |
| 4695 | logger.deactivate_log_handler(thd, log_type); |
| 4696 | res= false; |
| 4697 | } |
| 4698 | else |
| 4699 | res= logger.activate_log_handler(thd, log_type); |
| 4700 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 4701 | return res; |
| 4702 | } |
| 4703 | |
| 4704 | |
| 4705 | static bool check_not_empty_set(sys_var *self, THD *thd, set_var *var) |
| 4706 | { |
| 4707 | return var->save_result.ulonglong_value == 0; |
| 4708 | } |
| 4709 | static bool fix_log_output(sys_var *self, THD *thd, enum_var_type type) |
| 4710 | { |
| 4711 | logger.lock_exclusive(); |
| 4712 | logger.init_slow_log(log_output_options); |
| 4713 | logger.init_general_log(log_output_options); |
| 4714 | logger.unlock(); |
| 4715 | return false; |
| 4716 | } |
| 4717 | |
| 4718 | static const char *log_output_names[] = { "NONE" , "FILE" , "TABLE" , NULL}; |
| 4719 | |
| 4720 | static Sys_var_set Sys_log_output( |
| 4721 | "log_output" , "How logs should be written" , |
| 4722 | GLOBAL_VAR(log_output_options), CMD_LINE(REQUIRED_ARG), |
| 4723 | log_output_names, DEFAULT(LOG_FILE), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 4724 | ON_CHECK(check_not_empty_set), ON_UPDATE(fix_log_output)); |
| 4725 | |
| 4726 | #ifdef HAVE_REPLICATION |
| 4727 | static Sys_var_mybool Sys_log_slave_updates( |
| 4728 | "log_slave_updates" , "Tells the slave to log the updates from " |
| 4729 | "the slave thread to the binary log. You will need to turn it on if " |
| 4730 | "you plan to daisy-chain the slaves." , |
| 4731 | READ_ONLY GLOBAL_VAR(opt_log_slave_updates), CMD_LINE(OPT_ARG), |
| 4732 | DEFAULT(0)); |
| 4733 | |
| 4734 | static Sys_var_charptr Sys_relay_log( |
| 4735 | "relay_log" , "The location and name to use for relay logs." , |
| 4736 | READ_ONLY GLOBAL_VAR(opt_relay_logname), CMD_LINE(REQUIRED_ARG), |
| 4737 | IN_FS_CHARSET, DEFAULT(0)); |
| 4738 | |
| 4739 | /* |
| 4740 | Uses NO_CMD_LINE since the --relay-log-index option set |
| 4741 | opt_relaylog_index_name variable and computes a value for the |
| 4742 | relay_log_index variable. |
| 4743 | */ |
| 4744 | static Sys_var_charptr Sys_relay_log_index( |
| 4745 | "relay_log_index" , "The location and name to use for the file " |
| 4746 | "that keeps a list of the last relay logs." , |
| 4747 | READ_ONLY GLOBAL_VAR(relay_log_index), NO_CMD_LINE, |
| 4748 | IN_FS_CHARSET, DEFAULT(0)); |
| 4749 | |
| 4750 | /* |
| 4751 | Uses NO_CMD_LINE since the --log-bin-index option set |
| 4752 | opt_binlog_index_name variable and computes a value for the |
| 4753 | log_bin_index variable. |
| 4754 | */ |
| 4755 | static Sys_var_charptr Sys_binlog_index( |
| 4756 | "log_bin_index" , "File that holds the names for last binary log files." , |
| 4757 | READ_ONLY GLOBAL_VAR(log_bin_index), NO_CMD_LINE, |
| 4758 | IN_FS_CHARSET, DEFAULT(0)); |
| 4759 | |
| 4760 | static Sys_var_charptr Sys_relay_log_basename( |
| 4761 | "relay_log_basename" , |
| 4762 | "The full path of the relay log file names, excluding the extension." , |
| 4763 | READ_ONLY GLOBAL_VAR(relay_log_basename), NO_CMD_LINE, |
| 4764 | IN_FS_CHARSET, DEFAULT(0)); |
| 4765 | |
| 4766 | static Sys_var_charptr Sys_log_bin_basename( |
| 4767 | "log_bin_basename" , |
| 4768 | "The full path of the binary log file names, excluding the extension." , |
| 4769 | READ_ONLY GLOBAL_VAR(log_bin_basename), NO_CMD_LINE, |
| 4770 | IN_FS_CHARSET, DEFAULT(0)); |
| 4771 | |
| 4772 | static Sys_var_charptr Sys_relay_log_info_file( |
| 4773 | "relay_log_info_file" , "The location and name of the file that " |
| 4774 | "remembers where the SQL replication thread is in the relay logs." , |
| 4775 | READ_ONLY GLOBAL_VAR(relay_log_info_file), CMD_LINE(REQUIRED_ARG), |
| 4776 | IN_FS_CHARSET, DEFAULT(0)); |
| 4777 | |
| 4778 | static Sys_var_mybool Sys_relay_log_purge( |
| 4779 | "relay_log_purge" , "if disabled - do not purge relay logs. " |
| 4780 | "if enabled - purge them as soon as they are no more needed." , |
| 4781 | GLOBAL_VAR(relay_log_purge), CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 4782 | |
| 4783 | static Sys_var_mybool Sys_relay_log_recovery( |
| 4784 | "relay_log_recovery" , "Enables automatic relay log recovery " |
| 4785 | "right after the database startup, which means that the IO Thread " |
| 4786 | "starts re-fetching from the master right after the last transaction " |
| 4787 | "processed." , |
| 4788 | GLOBAL_VAR(relay_log_recovery), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 4789 | |
| 4790 | |
| 4791 | bool Sys_var_rpl_filter::global_update(THD *thd, set_var *var) |
| 4792 | { |
| 4793 | bool result= true; // Assume error |
| 4794 | LEX_CSTRING *base_name= &var->base; |
| 4795 | |
| 4796 | if (!base_name->length) |
| 4797 | base_name= &thd->variables.default_master_connection; |
| 4798 | |
| 4799 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 4800 | |
| 4801 | if (Master_info *mi= get_master_info(base_name, !var->base.length ? |
| 4802 | Sql_condition::WARN_LEVEL_ERROR : |
| 4803 | Sql_condition::WARN_LEVEL_WARN)) |
| 4804 | { |
| 4805 | if (mi->rli.slave_running) |
| 4806 | { |
| 4807 | my_error(ER_SLAVE_MUST_STOP, MYF(0), |
| 4808 | (int) mi->connection_name.length, |
| 4809 | mi->connection_name.str); |
| 4810 | result= true; |
| 4811 | } |
| 4812 | else |
| 4813 | { |
| 4814 | result= set_filter_value(var->save_result.string_value.str, mi); |
| 4815 | } |
| 4816 | mi->release(); |
| 4817 | } |
| 4818 | |
| 4819 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 4820 | return result; |
| 4821 | } |
| 4822 | |
| 4823 | bool Sys_var_rpl_filter::set_filter_value(const char *value, Master_info *mi) |
| 4824 | { |
| 4825 | bool status= true; |
| 4826 | Rpl_filter* rpl_filter= mi->rpl_filter; |
| 4827 | |
| 4828 | /* Proctect against other threads */ |
| 4829 | mysql_mutex_lock(&LOCK_active_mi); |
| 4830 | switch (opt_id) { |
| 4831 | case OPT_REPLICATE_DO_DB: |
| 4832 | status= rpl_filter->set_do_db(value); |
| 4833 | break; |
| 4834 | case OPT_REPLICATE_DO_TABLE: |
| 4835 | status= rpl_filter->set_do_table(value); |
| 4836 | break; |
| 4837 | case OPT_REPLICATE_IGNORE_DB: |
| 4838 | status= rpl_filter->set_ignore_db(value); |
| 4839 | break; |
| 4840 | case OPT_REPLICATE_IGNORE_TABLE: |
| 4841 | status= rpl_filter->set_ignore_table(value); |
| 4842 | break; |
| 4843 | case OPT_REPLICATE_WILD_DO_TABLE: |
| 4844 | status= rpl_filter->set_wild_do_table(value); |
| 4845 | break; |
| 4846 | case OPT_REPLICATE_WILD_IGNORE_TABLE: |
| 4847 | status= rpl_filter->set_wild_ignore_table(value); |
| 4848 | break; |
| 4849 | } |
| 4850 | mysql_mutex_unlock(&LOCK_active_mi); |
| 4851 | return status; |
| 4852 | } |
| 4853 | |
| 4854 | uchar *Sys_var_rpl_filter::global_value_ptr(THD *thd, |
| 4855 | const LEX_CSTRING *base_name) |
| 4856 | { |
| 4857 | char buf[256]; |
| 4858 | String tmp(buf, sizeof(buf), &my_charset_bin); |
| 4859 | uchar *ret; |
| 4860 | Master_info *mi; |
| 4861 | Rpl_filter *rpl_filter; |
| 4862 | |
| 4863 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 4864 | mi= get_master_info(base_name, !base_name->length ? |
| 4865 | Sql_condition::WARN_LEVEL_ERROR : |
| 4866 | Sql_condition::WARN_LEVEL_WARN); |
| 4867 | |
| 4868 | if (!mi) |
| 4869 | { |
| 4870 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 4871 | return 0; |
| 4872 | } |
| 4873 | |
| 4874 | rpl_filter= mi->rpl_filter; |
| 4875 | tmp.length(0); |
| 4876 | |
| 4877 | mysql_mutex_lock(&LOCK_active_mi); |
| 4878 | switch (opt_id) { |
| 4879 | case OPT_REPLICATE_DO_DB: |
| 4880 | rpl_filter->get_do_db(&tmp); |
| 4881 | break; |
| 4882 | case OPT_REPLICATE_DO_TABLE: |
| 4883 | rpl_filter->get_do_table(&tmp); |
| 4884 | break; |
| 4885 | case OPT_REPLICATE_IGNORE_DB: |
| 4886 | rpl_filter->get_ignore_db(&tmp); |
| 4887 | break; |
| 4888 | case OPT_REPLICATE_IGNORE_TABLE: |
| 4889 | rpl_filter->get_ignore_table(&tmp); |
| 4890 | break; |
| 4891 | case OPT_REPLICATE_WILD_DO_TABLE: |
| 4892 | rpl_filter->get_wild_do_table(&tmp); |
| 4893 | break; |
| 4894 | case OPT_REPLICATE_WILD_IGNORE_TABLE: |
| 4895 | rpl_filter->get_wild_ignore_table(&tmp); |
| 4896 | break; |
| 4897 | } |
| 4898 | mysql_mutex_unlock(&LOCK_active_mi); |
| 4899 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 4900 | |
| 4901 | mi->release(); |
| 4902 | |
| 4903 | ret= (uchar *) thd->strmake(tmp.ptr(), tmp.length()); |
| 4904 | |
| 4905 | return ret; |
| 4906 | } |
| 4907 | |
| 4908 | static Sys_var_rpl_filter Sys_replicate_do_db( |
| 4909 | "replicate_do_db" , OPT_REPLICATE_DO_DB, |
| 4910 | "Tell the slave to restrict replication to updates of tables " |
| 4911 | "whose names appear in the comma-separated list. For " |
| 4912 | "statement-based replication, only the default database (that " |
| 4913 | "is, the one selected by USE) is considered, not any explicitly " |
| 4914 | "mentioned tables in the query. For row-based replication, the " |
| 4915 | "actual names of table(s) being updated are checked." ); |
| 4916 | |
| 4917 | static Sys_var_rpl_filter Sys_replicate_do_table( |
| 4918 | "replicate_do_table" , OPT_REPLICATE_DO_TABLE, |
| 4919 | "Tells the slave to restrict replication to tables in the " |
| 4920 | "comma-separated list." ); |
| 4921 | |
| 4922 | static Sys_var_rpl_filter Sys_replicate_ignore_db( |
| 4923 | "replicate_ignore_db" , OPT_REPLICATE_IGNORE_DB, |
| 4924 | "Tell the slave to restrict replication to updates of tables " |
| 4925 | "whose names do not appear in the comma-separated list. For " |
| 4926 | "statement-based replication, only the default database (that " |
| 4927 | "is, the one selected by USE) is considered, not any explicitly " |
| 4928 | "mentioned tables in the query. For row-based replication, the " |
| 4929 | "actual names of table(s) being updated are checked." ); |
| 4930 | |
| 4931 | static Sys_var_rpl_filter Sys_replicate_ignore_table( |
| 4932 | "replicate_ignore_table" , OPT_REPLICATE_IGNORE_TABLE, |
| 4933 | "Tells the slave thread not to replicate any statement that " |
| 4934 | "updates the specified table, even if any other tables might be " |
| 4935 | "updated by the same statement." ); |
| 4936 | |
| 4937 | static Sys_var_rpl_filter Sys_replicate_wild_do_table( |
| 4938 | "replicate_wild_do_table" , OPT_REPLICATE_WILD_DO_TABLE, |
| 4939 | "Tells the slave thread to restrict replication to statements " |
| 4940 | "where any of the updated tables match the specified database " |
| 4941 | "and table name patterns." ); |
| 4942 | |
| 4943 | static Sys_var_rpl_filter Sys_replicate_wild_ignore_table( |
| 4944 | "replicate_wild_ignore_table" , OPT_REPLICATE_WILD_IGNORE_TABLE, |
| 4945 | "Tells the slave thread to not replicate to the tables that " |
| 4946 | "match the given wildcard pattern." ); |
| 4947 | |
| 4948 | static Sys_var_charptr Sys_slave_load_tmpdir( |
| 4949 | "slave_load_tmpdir" , "The location where the slave should put " |
| 4950 | "its temporary files when replicating a LOAD DATA INFILE command" , |
| 4951 | READ_ONLY GLOBAL_VAR(slave_load_tmpdir), CMD_LINE(REQUIRED_ARG), |
| 4952 | IN_FS_CHARSET, DEFAULT(0)); |
| 4953 | |
| 4954 | static Sys_var_uint Sys_slave_net_timeout( |
| 4955 | "slave_net_timeout" , "Number of seconds to wait for more data " |
| 4956 | "from any master/slave connection before aborting the read" , |
| 4957 | GLOBAL_VAR(slave_net_timeout), CMD_LINE(REQUIRED_ARG), |
| 4958 | VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(SLAVE_NET_TIMEOUT), BLOCK_SIZE(1)); |
| 4959 | |
| 4960 | |
| 4961 | /* |
| 4962 | Access a multi_source variable |
| 4963 | Return 0 + warning if it doesn't exist |
| 4964 | */ |
| 4965 | |
| 4966 | ulonglong Sys_var_multi_source_ulonglong:: |
| 4967 | get_master_info_ulonglong_value(THD *thd, ptrdiff_t offset) |
| 4968 | { |
| 4969 | Master_info *mi; |
| 4970 | ulonglong res= 0; // Default value |
| 4971 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 4972 | if ((mi= get_master_info(&thd->variables.default_master_connection, |
| 4973 | Sql_condition::WARN_LEVEL_WARN))) |
| 4974 | { |
| 4975 | res= *((ulonglong*) (((uchar*) mi) + master_info_offset)); |
| 4976 | mi->release(); |
| 4977 | } |
| 4978 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 4979 | return res; |
| 4980 | } |
| 4981 | |
| 4982 | |
| 4983 | bool update_multi_source_variable(sys_var *self_var, THD *thd, |
| 4984 | enum_var_type type) |
| 4985 | { |
| 4986 | Sys_var_multi_source_ulonglong *self= (Sys_var_multi_source_ulonglong*) self_var; |
| 4987 | bool result= true; |
| 4988 | Master_info *mi; |
| 4989 | |
| 4990 | if (type == OPT_GLOBAL) |
| 4991 | mysql_mutex_unlock(&LOCK_global_system_variables); |
| 4992 | if ((mi= (get_master_info(&thd->variables.default_master_connection, |
| 4993 | Sql_condition::WARN_LEVEL_ERROR)))) |
| 4994 | { |
| 4995 | mysql_mutex_lock(&mi->rli.run_lock); |
| 4996 | mysql_mutex_lock(&mi->rli.data_lock); |
| 4997 | result= self->update_variable(thd, mi); |
| 4998 | mysql_mutex_unlock(&mi->rli.data_lock); |
| 4999 | mysql_mutex_unlock(&mi->rli.run_lock); |
| 5000 | mi->release(); |
| 5001 | } |
| 5002 | if (type == OPT_GLOBAL) |
| 5003 | mysql_mutex_lock(&LOCK_global_system_variables); |
| 5004 | return result; |
| 5005 | } |
| 5006 | |
| 5007 | static bool update_slave_skip_counter(sys_var *self, THD *thd, Master_info *mi) |
| 5008 | { |
| 5009 | if (mi->rli.slave_running) |
| 5010 | { |
| 5011 | my_error(ER_SLAVE_MUST_STOP, MYF(0), (int) mi->connection_name.length, |
| 5012 | mi->connection_name.str); |
| 5013 | return true; |
| 5014 | } |
| 5015 | if (mi->using_gtid != Master_info::USE_GTID_NO && mi->using_parallel()) |
| 5016 | { |
| 5017 | ulong domain_count; |
| 5018 | mysql_mutex_lock(&rpl_global_gtid_slave_state->LOCK_slave_state); |
| 5019 | domain_count= rpl_global_gtid_slave_state->count(); |
| 5020 | mysql_mutex_unlock(&rpl_global_gtid_slave_state->LOCK_slave_state); |
| 5021 | if (domain_count > 1) |
| 5022 | { |
| 5023 | /* |
| 5024 | With domain-based parallel replication, the slave position is |
| 5025 | multi-dimensional, so the relay log position is not very meaningful. |
| 5026 | It might not even correspond to the next GTID to execute in _any_ |
| 5027 | domain (the case after error stop). So slave_skip_counter will most |
| 5028 | likely not do what the user intends. Instead give an error, with a |
| 5029 | suggestion to instead set @@gtid_slave_pos past the point of error; |
| 5030 | this works reliably also in the case of multiple domains. |
| 5031 | */ |
| 5032 | my_error(ER_SLAVE_SKIP_NOT_IN_GTID, MYF(0)); |
| 5033 | return true; |
| 5034 | } |
| 5035 | } |
| 5036 | |
| 5037 | /* The value was stored temporarily in thd */ |
| 5038 | mi->rli.slave_skip_counter= thd->variables.slave_skip_counter; |
| 5039 | return false; |
| 5040 | } |
| 5041 | |
| 5042 | static Sys_var_multi_source_ulonglong Sys_slave_skip_counter( |
| 5043 | "sql_slave_skip_counter" , "Skip the next N events from the master log" , |
| 5044 | SESSION_VAR(slave_skip_counter), NO_CMD_LINE, |
| 5045 | MASTER_INFO_VAR(rli.slave_skip_counter), |
| 5046 | VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1), |
| 5047 | ON_UPDATE(update_slave_skip_counter)); |
| 5048 | |
| 5049 | static bool update_max_relay_log_size(sys_var *self, THD *thd, Master_info *mi) |
| 5050 | { |
| 5051 | mi->rli.max_relay_log_size= thd->variables.max_relay_log_size; |
| 5052 | mi->rli.relay_log.set_max_size((ulong)mi->rli.max_relay_log_size); |
| 5053 | return false; |
| 5054 | } |
| 5055 | |
| 5056 | static Sys_var_multi_source_ulonglong Sys_max_relay_log_size( |
| 5057 | "max_relay_log_size" , |
| 5058 | "relay log will be rotated automatically when the size exceeds this " |
| 5059 | "value. If 0 at startup, it's set to max_binlog_size" , |
| 5060 | SESSION_VAR(max_relay_log_size), CMD_LINE(REQUIRED_ARG), |
| 5061 | MASTER_INFO_VAR(rli.max_relay_log_size), |
| 5062 | VALID_RANGE(0, 1024L*1024*1024), DEFAULT(0), BLOCK_SIZE(IO_SIZE), |
| 5063 | ON_UPDATE(update_max_relay_log_size)); |
| 5064 | |
| 5065 | static Sys_var_charptr Sys_slave_skip_errors( |
| 5066 | "slave_skip_errors" , "Tells the slave thread to continue " |
| 5067 | "replication when a query event returns an error from the " |
| 5068 | "provided list" , |
| 5069 | READ_ONLY GLOBAL_VAR(opt_slave_skip_errors), CMD_LINE(REQUIRED_ARG), |
| 5070 | IN_SYSTEM_CHARSET, DEFAULT(0)); |
| 5071 | |
| 5072 | static Sys_var_ulonglong Sys_read_binlog_speed_limit( |
| 5073 | "read_binlog_speed_limit" , "Maximum speed(KB/s) to read binlog from" |
| 5074 | " master (0 = no limit)" , |
| 5075 | GLOBAL_VAR(opt_read_binlog_speed_limit), CMD_LINE(REQUIRED_ARG), |
| 5076 | VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 5077 | |
| 5078 | static Sys_var_charptr Sys_slave_transaction_retry_errors( |
| 5079 | "slave_transaction_retry_errors" , "Tells the slave thread to retry " |
| 5080 | "transaction for replication when a query event returns an error from " |
| 5081 | "the provided list. Deadlock and elapsed lock wait timeout errors are " |
| 5082 | "automatically added to this list" , |
| 5083 | READ_ONLY GLOBAL_VAR(opt_slave_transaction_retry_errors), CMD_LINE(REQUIRED_ARG), |
| 5084 | IN_SYSTEM_CHARSET, DEFAULT(0)); |
| 5085 | |
| 5086 | static Sys_var_ulonglong Sys_relay_log_space_limit( |
| 5087 | "relay_log_space_limit" , "Maximum space to use for all relay logs" , |
| 5088 | READ_ONLY GLOBAL_VAR(relay_log_space_limit), CMD_LINE(REQUIRED_ARG), |
| 5089 | VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 5090 | |
| 5091 | static Sys_var_uint Sys_sync_relaylog_period( |
| 5092 | "sync_relay_log" , "Synchronously flush relay log to disk after " |
| 5093 | "every #th event. Use 0 to disable synchronous flushing" , |
| 5094 | GLOBAL_VAR(sync_relaylog_period), CMD_LINE(REQUIRED_ARG), |
| 5095 | VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1)); |
| 5096 | |
| 5097 | static Sys_var_uint Sys_sync_relayloginfo_period( |
| 5098 | "sync_relay_log_info" , "Synchronously flush relay log info " |
| 5099 | "to disk after every #th transaction. Use 0 to disable " |
| 5100 | "synchronous flushing" , |
| 5101 | GLOBAL_VAR(sync_relayloginfo_period), CMD_LINE(REQUIRED_ARG), |
| 5102 | VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1)); |
| 5103 | #endif |
| 5104 | |
| 5105 | static Sys_var_uint Sys_sync_binlog_period( |
| 5106 | "sync_binlog" , "Synchronously flush binary log to disk after " |
| 5107 | "every #th event. Use 0 (default) to disable synchronous flushing" , |
| 5108 | GLOBAL_VAR(sync_binlog_period), CMD_LINE(REQUIRED_ARG), |
| 5109 | VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 5110 | |
| 5111 | static Sys_var_uint Sys_sync_masterinfo_period( |
| 5112 | "sync_master_info" , "Synchronously flush master info to disk " |
| 5113 | "after every #th event. Use 0 to disable synchronous flushing" , |
| 5114 | GLOBAL_VAR(sync_masterinfo_period), CMD_LINE(REQUIRED_ARG), |
| 5115 | VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1)); |
| 5116 | |
| 5117 | #ifdef HAVE_REPLICATION |
| 5118 | static Sys_var_ulong Sys_slave_trans_retries( |
| 5119 | "slave_transaction_retries" , "Number of times the slave SQL " |
| 5120 | "thread will retry a transaction in case it failed with a deadlock, " |
| 5121 | "elapsed lock wait timeout or listed in " |
| 5122 | "slave_transaction_retry_errors, before giving up and stopping" , |
| 5123 | GLOBAL_VAR(slave_trans_retries), CMD_LINE(REQUIRED_ARG), |
| 5124 | VALID_RANGE(0, UINT_MAX), DEFAULT(10), BLOCK_SIZE(1)); |
| 5125 | |
| 5126 | static Sys_var_ulong Sys_slave_trans_retry_interval( |
| 5127 | "slave_transaction_retry_interval" , "Interval of the slave SQL " |
| 5128 | "thread will retry a transaction in case it failed with a deadlock " |
| 5129 | "or elapsed lock wait timeout or listed in " |
| 5130 | "slave_transaction_retry_errors" , |
| 5131 | GLOBAL_VAR(slave_trans_retry_interval), CMD_LINE(REQUIRED_ARG), |
| 5132 | VALID_RANGE(0, 3600), DEFAULT(0), BLOCK_SIZE(1)); |
| 5133 | #endif |
| 5134 | |
| 5135 | static bool check_locale(sys_var *self, THD *thd, set_var *var) |
| 5136 | { |
| 5137 | if (!var->value) |
| 5138 | return false; |
| 5139 | |
| 5140 | MY_LOCALE *locale; |
| 5141 | char buff[STRING_BUFFER_USUAL_SIZE]; |
| 5142 | if (var->value->result_type() == INT_RESULT) |
| 5143 | { |
| 5144 | int lcno= (int)var->value->val_int(); |
| 5145 | if (!(locale= my_locale_by_number(lcno))) |
| 5146 | { |
| 5147 | my_error(ER_UNKNOWN_LOCALE, MYF(0), llstr(lcno, buff)); |
| 5148 | return true; |
| 5149 | } |
| 5150 | if (check_not_null(self, thd, var)) |
| 5151 | return true; |
| 5152 | } |
| 5153 | else // STRING_RESULT |
| 5154 | { |
| 5155 | String str(buff, sizeof(buff), system_charset_info), *res; |
| 5156 | if (!(res=var->value->val_str(&str))) |
| 5157 | return true; |
| 5158 | else if (!(locale= my_locale_by_name(res->c_ptr_safe()))) |
| 5159 | { |
| 5160 | ErrConvString err(res); |
| 5161 | my_error(ER_UNKNOWN_LOCALE, MYF(0), err.ptr()); |
| 5162 | return true; |
| 5163 | } |
| 5164 | } |
| 5165 | |
| 5166 | var->save_result.ptr= locale; |
| 5167 | |
| 5168 | if (!locale->errmsgs->errmsgs) |
| 5169 | { |
| 5170 | bool res; |
| 5171 | mysql_mutex_lock(&LOCK_error_messages); |
| 5172 | res= (!locale->errmsgs->errmsgs && |
| 5173 | read_texts(ERRMSG_FILE, locale->errmsgs->language, |
| 5174 | &locale->errmsgs->errmsgs)); |
| 5175 | mysql_mutex_unlock(&LOCK_error_messages); |
| 5176 | if (res) |
| 5177 | { |
| 5178 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, |
| 5179 | "Can't process error message file for locale '%s'" , |
| 5180 | locale->name); |
| 5181 | return true; |
| 5182 | } |
| 5183 | } |
| 5184 | status_var_increment(thd->status_var.feature_locale); |
| 5185 | return false; |
| 5186 | } |
| 5187 | |
| 5188 | static bool update_locale(sys_var *self, THD* thd, enum_var_type type) |
| 5189 | { |
| 5190 | /* Cache pointer to error messages */ |
| 5191 | if (type == OPT_SESSION) |
| 5192 | thd->variables.errmsgs= thd->variables.lc_messages->errmsgs->errmsgs; |
| 5193 | else |
| 5194 | global_system_variables.errmsgs= |
| 5195 | global_system_variables.lc_messages->errmsgs->errmsgs; |
| 5196 | return false; |
| 5197 | } |
| 5198 | |
| 5199 | static Sys_var_struct Sys_lc_messages( |
| 5200 | "lc_messages" , "Set the language used for the error messages" , |
| 5201 | SESSION_VAR(lc_messages), NO_CMD_LINE, |
| 5202 | my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_messages), |
| 5203 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_locale), ON_UPDATE(update_locale)); |
| 5204 | |
| 5205 | static Sys_var_struct Sys_lc_time_names( |
| 5206 | "lc_time_names" , "Set the language used for the month " |
| 5207 | "names and the days of the week" , |
| 5208 | SESSION_VAR(lc_time_names), NO_CMD_LINE, |
| 5209 | my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_time_names), |
| 5210 | NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_locale)); |
| 5211 | |
| 5212 | static Sys_var_tz Sys_time_zone( |
| 5213 | "time_zone" , "The current time zone, used to initialize the time " |
| 5214 | "zone for a client when it connects. Set to SYSTEM by default, in " |
| 5215 | "which the client uses the system time zone value." , |
| 5216 | SESSION_VAR(time_zone), NO_CMD_LINE, |
| 5217 | DEFAULT(&default_tz), NO_MUTEX_GUARD, IN_BINLOG); |
| 5218 | |
| 5219 | #ifdef WITH_WSREP |
| 5220 | #include "wsrep_var.h" |
| 5221 | #include "wsrep_sst.h" |
| 5222 | #include "wsrep_binlog.h" |
| 5223 | |
| 5224 | static Sys_var_charptr Sys_wsrep_provider( |
| 5225 | "wsrep_provider" , "Path to replication provider library" , |
| 5226 | PREALLOCATED GLOBAL_VAR(wsrep_provider), CMD_LINE(REQUIRED_ARG), |
| 5227 | IN_FS_CHARSET, DEFAULT(WSREP_NONE), |
| 5228 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5229 | ON_CHECK(wsrep_provider_check), ON_UPDATE(wsrep_provider_update)); |
| 5230 | |
| 5231 | static Sys_var_charptr Sys_wsrep_provider_options( |
| 5232 | "wsrep_provider_options" , "Semicolon (;) separated list of wsrep " |
| 5233 | "options (see wsrep_provider_options documentation)." , |
| 5234 | PREALLOCATED GLOBAL_VAR(wsrep_provider_options), |
| 5235 | CMD_LINE(REQUIRED_ARG), |
| 5236 | IN_SYSTEM_CHARSET, DEFAULT("" ), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5237 | ON_CHECK(wsrep_provider_options_check), |
| 5238 | ON_UPDATE(wsrep_provider_options_update)); |
| 5239 | |
| 5240 | static Sys_var_charptr Sys_wsrep_data_home_dir( |
| 5241 | "wsrep_data_home_dir" , "home directory for wsrep provider" , |
| 5242 | READ_ONLY GLOBAL_VAR(wsrep_data_home_dir), CMD_LINE(REQUIRED_ARG), |
| 5243 | IN_FS_CHARSET, DEFAULT(mysql_real_data_home)); |
| 5244 | |
| 5245 | static Sys_var_charptr Sys_wsrep_cluster_name( |
| 5246 | "wsrep_cluster_name" , "Name for the cluster" , |
| 5247 | PREALLOCATED GLOBAL_VAR(wsrep_cluster_name), CMD_LINE(REQUIRED_ARG), |
| 5248 | IN_SYSTEM_CHARSET, DEFAULT(WSREP_CLUSTER_NAME), |
| 5249 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5250 | ON_CHECK(wsrep_cluster_name_check), |
| 5251 | ON_UPDATE(wsrep_cluster_name_update)); |
| 5252 | |
| 5253 | static PolyLock_mutex PLock_wsrep_slave_threads(&LOCK_wsrep_slave_threads); |
| 5254 | static Sys_var_charptr Sys_wsrep_cluster_address ( |
| 5255 | "wsrep_cluster_address" , "Address to initially connect to cluster" , |
| 5256 | PREALLOCATED GLOBAL_VAR(wsrep_cluster_address), |
| 5257 | CMD_LINE(REQUIRED_ARG), |
| 5258 | IN_SYSTEM_CHARSET, DEFAULT("" ), |
| 5259 | &PLock_wsrep_slave_threads, NOT_IN_BINLOG, |
| 5260 | ON_CHECK(wsrep_cluster_address_check), |
| 5261 | ON_UPDATE(wsrep_cluster_address_update)); |
| 5262 | |
| 5263 | static Sys_var_charptr Sys_wsrep_node_name ( |
| 5264 | "wsrep_node_name" , "Name of this node. This name can be used in " |
| 5265 | "wsrep_sst_donor as a preferred donor. Note that multiple nodes " |
| 5266 | "in a cluster can have the same name." , |
| 5267 | PREALLOCATED GLOBAL_VAR(wsrep_node_name), CMD_LINE(REQUIRED_ARG), |
| 5268 | IN_SYSTEM_CHARSET, DEFAULT(glob_hostname), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5269 | wsrep_node_name_check, wsrep_node_name_update); |
| 5270 | |
| 5271 | static Sys_var_charptr Sys_wsrep_node_address ( |
| 5272 | "wsrep_node_address" , "Specifies the node's network address, in " |
| 5273 | "the format ip address[:port]. Used in situations where autoguessing " |
| 5274 | "is not reliable. As of MariaDB 10.1.8, supports IPv6." , |
| 5275 | PREALLOCATED GLOBAL_VAR(wsrep_node_address), CMD_LINE(REQUIRED_ARG), |
| 5276 | IN_SYSTEM_CHARSET, DEFAULT("" ), |
| 5277 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5278 | ON_CHECK(wsrep_node_address_check), |
| 5279 | ON_UPDATE(wsrep_node_address_update)); |
| 5280 | |
| 5281 | static Sys_var_charptr Sys_wsrep_node_incoming_address( |
| 5282 | "wsrep_node_incoming_address" , "Client connection address" , |
| 5283 | PREALLOCATED GLOBAL_VAR(wsrep_node_incoming_address),CMD_LINE(REQUIRED_ARG), |
| 5284 | IN_SYSTEM_CHARSET, DEFAULT(WSREP_NODE_INCOMING_AUTO)); |
| 5285 | |
| 5286 | static Sys_var_ulong Sys_wsrep_slave_threads( |
| 5287 | "wsrep_slave_threads" , "Number of slave appliers to launch" , |
| 5288 | GLOBAL_VAR(wsrep_slave_threads), CMD_LINE(REQUIRED_ARG), |
| 5289 | VALID_RANGE(1, 512), DEFAULT(1), BLOCK_SIZE(1), |
| 5290 | &PLock_wsrep_slave_threads, NOT_IN_BINLOG, |
| 5291 | ON_CHECK(NULL), |
| 5292 | ON_UPDATE(wsrep_slave_threads_update)); |
| 5293 | |
| 5294 | static Sys_var_charptr Sys_wsrep_dbug_option( |
| 5295 | "wsrep_dbug_option" , "DBUG options to provider library" , |
| 5296 | GLOBAL_VAR(wsrep_dbug_option),CMD_LINE(REQUIRED_ARG), |
| 5297 | IN_SYSTEM_CHARSET, DEFAULT("" )); |
| 5298 | |
| 5299 | static Sys_var_mybool Sys_wsrep_debug( |
| 5300 | "wsrep_debug" , "To enable debug level logging" , |
| 5301 | GLOBAL_VAR(wsrep_debug), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5302 | |
| 5303 | static Sys_var_mybool Sys_wsrep_convert_LOCK_to_trx( |
| 5304 | "wsrep_convert_LOCK_to_trx" , "To convert locking sessions " |
| 5305 | "into transactions" , |
| 5306 | GLOBAL_VAR(wsrep_convert_LOCK_to_trx), |
| 5307 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5308 | |
| 5309 | static Sys_var_ulong Sys_wsrep_retry_autocommit( |
| 5310 | "wsrep_retry_autocommit" , "Max number of times to retry " |
| 5311 | "a failed autocommit statement" , |
| 5312 | SESSION_VAR(wsrep_retry_autocommit), CMD_LINE(REQUIRED_ARG), |
| 5313 | VALID_RANGE(0, 10000), DEFAULT(1), BLOCK_SIZE(1)); |
| 5314 | |
| 5315 | static Sys_var_mybool Sys_wsrep_auto_increment_control( |
| 5316 | "wsrep_auto_increment_control" , "To automatically control the " |
| 5317 | "assignment of autoincrement variables" , |
| 5318 | GLOBAL_VAR(wsrep_auto_increment_control), |
| 5319 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 5320 | |
| 5321 | static Sys_var_mybool Sys_wsrep_drupal_282555_workaround( |
| 5322 | "wsrep_drupal_282555_workaround" , "Enable a workaround to handle the " |
| 5323 | "cases where inserting a DEFAULT value into an auto-increment column " |
| 5324 | "could fail with duplicate key error" , |
| 5325 | GLOBAL_VAR(wsrep_drupal_282555_workaround), |
| 5326 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5327 | |
| 5328 | static Sys_var_charptr sys_wsrep_sst_method( |
| 5329 | "wsrep_sst_method" , "State snapshot transfer method" , |
| 5330 | GLOBAL_VAR(wsrep_sst_method),CMD_LINE(REQUIRED_ARG), |
| 5331 | IN_SYSTEM_CHARSET, DEFAULT(WSREP_SST_DEFAULT), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5332 | ON_CHECK(wsrep_sst_method_check), |
| 5333 | ON_UPDATE(wsrep_sst_method_update)); |
| 5334 | |
| 5335 | static Sys_var_charptr Sys_wsrep_sst_receive_address( |
| 5336 | "wsrep_sst_receive_address" , "Address where node is waiting for " |
| 5337 | "SST contact" , |
| 5338 | GLOBAL_VAR(wsrep_sst_receive_address),CMD_LINE(REQUIRED_ARG), |
| 5339 | IN_SYSTEM_CHARSET, DEFAULT(WSREP_SST_ADDRESS_AUTO), NO_MUTEX_GUARD, |
| 5340 | NOT_IN_BINLOG, |
| 5341 | ON_CHECK(wsrep_sst_receive_address_check), |
| 5342 | ON_UPDATE(wsrep_sst_receive_address_update)); |
| 5343 | |
| 5344 | static Sys_var_charptr Sys_wsrep_sst_auth( |
| 5345 | "wsrep_sst_auth" , "Authentication for SST connection" , |
| 5346 | PREALLOCATED GLOBAL_VAR(wsrep_sst_auth), CMD_LINE(REQUIRED_ARG), |
| 5347 | IN_SYSTEM_CHARSET, DEFAULT(NULL), NO_MUTEX_GUARD, |
| 5348 | NOT_IN_BINLOG, |
| 5349 | ON_CHECK(wsrep_sst_auth_check), |
| 5350 | ON_UPDATE(wsrep_sst_auth_update)); |
| 5351 | |
| 5352 | static Sys_var_charptr Sys_wsrep_sst_donor( |
| 5353 | "wsrep_sst_donor" , "preferred donor node for the SST" , |
| 5354 | GLOBAL_VAR(wsrep_sst_donor),CMD_LINE(REQUIRED_ARG), |
| 5355 | IN_SYSTEM_CHARSET, DEFAULT("" ), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5356 | ON_CHECK(wsrep_sst_donor_check), |
| 5357 | ON_UPDATE(wsrep_sst_donor_update)); |
| 5358 | |
| 5359 | static Sys_var_mybool Sys_wsrep_sst_donor_rejects_queries( |
| 5360 | "wsrep_sst_donor_rejects_queries" , "Reject client queries " |
| 5361 | "when donating state snapshot transfer" , |
| 5362 | GLOBAL_VAR(wsrep_sst_donor_rejects_queries), |
| 5363 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5364 | |
| 5365 | static Sys_var_mybool Sys_wsrep_on ( |
| 5366 | "wsrep_on" , "To enable wsrep replication " , |
| 5367 | SESSION_VAR(wsrep_on), |
| 5368 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 5369 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5370 | ON_CHECK(wsrep_on_check), |
| 5371 | ON_UPDATE(wsrep_on_update)); |
| 5372 | |
| 5373 | static Sys_var_charptr Sys_wsrep_start_position ( |
| 5374 | "wsrep_start_position" , "global transaction position to start from " , |
| 5375 | PREALLOCATED GLOBAL_VAR(wsrep_start_position), |
| 5376 | CMD_LINE(REQUIRED_ARG), |
| 5377 | IN_SYSTEM_CHARSET, DEFAULT(WSREP_START_POSITION_ZERO), |
| 5378 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5379 | ON_CHECK(wsrep_start_position_check), |
| 5380 | ON_UPDATE(wsrep_start_position_update)); |
| 5381 | |
| 5382 | static Sys_var_ulong Sys_wsrep_max_ws_size ( |
| 5383 | "wsrep_max_ws_size" , "Max write set size (bytes)" , |
| 5384 | GLOBAL_VAR(wsrep_max_ws_size), CMD_LINE(REQUIRED_ARG), |
| 5385 | VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(WSREP_MAX_WS_SIZE), |
| 5386 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 5387 | ON_CHECK(wsrep_max_ws_size_check), ON_UPDATE(wsrep_max_ws_size_update)); |
| 5388 | |
| 5389 | static Sys_var_ulong Sys_wsrep_max_ws_rows ( |
| 5390 | "wsrep_max_ws_rows" , "Max number of rows in write set" , |
| 5391 | GLOBAL_VAR(wsrep_max_ws_rows), CMD_LINE(REQUIRED_ARG), |
| 5392 | VALID_RANGE(0, 1048576), DEFAULT(0), BLOCK_SIZE(1)); |
| 5393 | |
| 5394 | static Sys_var_charptr Sys_wsrep_notify_cmd( |
| 5395 | "wsrep_notify_cmd" , "" , |
| 5396 | GLOBAL_VAR(wsrep_notify_cmd),CMD_LINE(REQUIRED_ARG), |
| 5397 | IN_SYSTEM_CHARSET, DEFAULT("" )); |
| 5398 | |
| 5399 | static Sys_var_mybool Sys_wsrep_certify_nonPK( |
| 5400 | "wsrep_certify_nonPK" , "Certify tables with no primary key" , |
| 5401 | GLOBAL_VAR(wsrep_certify_nonPK), |
| 5402 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 5403 | |
| 5404 | static Sys_var_mybool Sys_wsrep_causal_reads( |
| 5405 | "wsrep_causal_reads" , "Setting this variable is equivalent " |
| 5406 | "to setting wsrep_sync_wait READ flag" , |
| 5407 | SESSION_VAR(wsrep_causal_reads), |
| 5408 | CMD_LINE(OPT_ARG, OPT_WSREP_CAUSAL_READS), DEFAULT(FALSE), |
| 5409 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 5410 | ON_UPDATE(wsrep_causal_reads_update), |
| 5411 | DEPRECATED("'@@wsrep_sync_wait=1'" )); |
| 5412 | |
| 5413 | static Sys_var_uint Sys_wsrep_sync_wait( |
| 5414 | "wsrep_sync_wait" , "Ensure \"synchronous\" read view before executing " |
| 5415 | "an operation of the type specified by bitmask: 1 - READ(includes " |
| 5416 | "SELECT, SHOW and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - " |
| 5417 | "INSERT and REPLACE" , |
| 5418 | SESSION_VAR(wsrep_sync_wait), CMD_LINE(OPT_ARG, OPT_WSREP_SYNC_WAIT), |
| 5419 | VALID_RANGE(WSREP_SYNC_WAIT_NONE, WSREP_SYNC_WAIT_MAX), |
| 5420 | DEFAULT(WSREP_SYNC_WAIT_NONE), BLOCK_SIZE(1), |
| 5421 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 5422 | ON_UPDATE(wsrep_sync_wait_update)); |
| 5423 | |
| 5424 | static const char *wsrep_OSU_method_names[]= { "TOI" , "RSU" , NullS }; |
| 5425 | static Sys_var_enum Sys_wsrep_OSU_method( |
| 5426 | "wsrep_OSU_method" , "Method for Online Schema Upgrade" , |
| 5427 | SESSION_VAR(wsrep_OSU_method), CMD_LINE(OPT_ARG), |
| 5428 | wsrep_OSU_method_names, DEFAULT(WSREP_OSU_TOI)); |
| 5429 | |
| 5430 | static PolyLock_mutex PLock_wsrep_desync(&LOCK_wsrep_desync); |
| 5431 | static Sys_var_mybool Sys_wsrep_desync ( |
| 5432 | "wsrep_desync" , "To desynchronize the node from the cluster" , |
| 5433 | GLOBAL_VAR(wsrep_desync), |
| 5434 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 5435 | &PLock_wsrep_desync, NOT_IN_BINLOG, |
| 5436 | ON_CHECK(wsrep_desync_check), |
| 5437 | ON_UPDATE(wsrep_desync_update)); |
| 5438 | |
| 5439 | static const char *wsrep_reject_queries_names[]= { "NONE" , "ALL" , "ALL_KILL" , NullS }; |
| 5440 | static Sys_var_enum Sys_wsrep_reject_queries( |
| 5441 | "wsrep_reject_queries" , "Variable to set to reject queries" , |
| 5442 | GLOBAL_VAR(wsrep_reject_queries), CMD_LINE(OPT_ARG), |
| 5443 | wsrep_reject_queries_names, DEFAULT(WSREP_REJECT_NONE), |
| 5444 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 5445 | ON_UPDATE(wsrep_reject_queries_update)); |
| 5446 | |
| 5447 | static const char *wsrep_binlog_format_names[]= |
| 5448 | {"MIXED" , "STATEMENT" , "ROW" , "NONE" , NullS}; |
| 5449 | static Sys_var_enum Sys_wsrep_forced_binlog_format( |
| 5450 | "wsrep_forced_binlog_format" , "binlog format to take effect over user's choice" , |
| 5451 | GLOBAL_VAR(wsrep_forced_binlog_format), CMD_LINE(REQUIRED_ARG), |
| 5452 | wsrep_binlog_format_names, DEFAULT(BINLOG_FORMAT_UNSPEC)); |
| 5453 | |
| 5454 | static Sys_var_mybool Sys_wsrep_recover_datadir( |
| 5455 | "wsrep_recover" , "Recover database state after crash and exit" , |
| 5456 | READ_ONLY GLOBAL_VAR(wsrep_recovery), |
| 5457 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5458 | |
| 5459 | static Sys_var_mybool Sys_wsrep_replicate_myisam( |
| 5460 | "wsrep_replicate_myisam" , "To enable myisam replication" , |
| 5461 | GLOBAL_VAR(wsrep_replicate_myisam), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5462 | |
| 5463 | static Sys_var_mybool Sys_wsrep_log_conflicts( |
| 5464 | "wsrep_log_conflicts" , "To log multi-master conflicts" , |
| 5465 | GLOBAL_VAR(wsrep_log_conflicts), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5466 | |
| 5467 | static Sys_var_ulong Sys_wsrep_mysql_replication_bundle( |
| 5468 | "wsrep_mysql_replication_bundle" , "mysql replication group commit " , |
| 5469 | GLOBAL_VAR(wsrep_mysql_replication_bundle), CMD_LINE(REQUIRED_ARG), |
| 5470 | VALID_RANGE(0, 1000), DEFAULT(0), BLOCK_SIZE(1)); |
| 5471 | |
| 5472 | static Sys_var_mybool Sys_wsrep_load_data_splitting( |
| 5473 | "wsrep_load_data_splitting" , "To commit LOAD DATA " |
| 5474 | "transaction after every 10K rows inserted" , |
| 5475 | GLOBAL_VAR(wsrep_load_data_splitting), |
| 5476 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 5477 | |
| 5478 | static Sys_var_mybool Sys_wsrep_slave_FK_checks( |
| 5479 | "wsrep_slave_FK_checks" , "Should slave thread do " |
| 5480 | "foreign key constraint checks" , |
| 5481 | GLOBAL_VAR(wsrep_slave_FK_checks), |
| 5482 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 5483 | |
| 5484 | static Sys_var_mybool Sys_wsrep_slave_UK_checks( |
| 5485 | "wsrep_slave_UK_checks" , "Should slave thread do " |
| 5486 | "secondary index uniqueness checks" , |
| 5487 | GLOBAL_VAR(wsrep_slave_UK_checks), |
| 5488 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5489 | |
| 5490 | static Sys_var_mybool Sys_wsrep_restart_slave( |
| 5491 | "wsrep_restart_slave" , "Should MariaDB slave be restarted automatically, when node joins back to cluster" , |
| 5492 | GLOBAL_VAR(wsrep_restart_slave), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5493 | |
| 5494 | static Sys_var_mybool Sys_wsrep_dirty_reads( |
| 5495 | "wsrep_dirty_reads" , |
| 5496 | "Allow reads even when the node is not in the primary component." , |
| 5497 | SESSION_VAR(wsrep_dirty_reads), CMD_LINE(OPT_ARG), |
| 5498 | DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG); |
| 5499 | |
| 5500 | static Sys_var_uint Sys_wsrep_gtid_domain_id( |
| 5501 | "wsrep_gtid_domain_id" , "When wsrep_gtid_mode is set, this value is " |
| 5502 | "used as gtid_domain_id for galera transactions and also copied to the " |
| 5503 | "joiner nodes during state transfer. It is ignored, otherwise." , |
| 5504 | GLOBAL_VAR(wsrep_gtid_domain_id), CMD_LINE(REQUIRED_ARG), |
| 5505 | VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 5506 | NOT_IN_BINLOG); |
| 5507 | |
| 5508 | static Sys_var_mybool Sys_wsrep_gtid_mode( |
| 5509 | "wsrep_gtid_mode" , "Automatically update the (joiner) node's " |
| 5510 | "wsrep_gtid_domain_id value with that of donor's (received during " |
| 5511 | "state transfer) and use it in place of gtid_domain_id for all galera " |
| 5512 | "transactions. When OFF (default), wsrep_gtid_domain_id is simply " |
| 5513 | "ignored (backward compatibility)." , |
| 5514 | GLOBAL_VAR(wsrep_gtid_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5515 | |
| 5516 | static char *wsrep_patch_version_ptr; |
| 5517 | static Sys_var_charptr Sys_wsrep_patch_version( |
| 5518 | "wsrep_patch_version" , "Wsrep patch version, for example wsrep_25.10." , |
| 5519 | READ_ONLY GLOBAL_VAR(wsrep_patch_version_ptr), CMD_LINE_HELP_ONLY, |
| 5520 | IN_SYSTEM_CHARSET, DEFAULT(WSREP_PATCH_VERSION)); |
| 5521 | |
| 5522 | #endif /* WITH_WSREP */ |
| 5523 | |
| 5524 | static bool fix_host_cache_size(sys_var *, THD *, enum_var_type) |
| 5525 | { |
| 5526 | hostname_cache_resize((uint) host_cache_size); |
| 5527 | return false; |
| 5528 | } |
| 5529 | |
| 5530 | static Sys_var_ulong Sys_host_cache_size( |
| 5531 | "host_cache_size" , |
| 5532 | "How many host names should be cached to avoid resolving." , |
| 5533 | AUTO_SET GLOBAL_VAR(host_cache_size), |
| 5534 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 65536), |
| 5535 | DEFAULT(HOST_CACHE_SIZE), |
| 5536 | BLOCK_SIZE(1), |
| 5537 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), |
| 5538 | ON_UPDATE(fix_host_cache_size)); |
| 5539 | |
| 5540 | vio_keepalive_opts opt_vio_keepalive; |
| 5541 | |
| 5542 | static Sys_var_int Sys_keepalive_time( |
| 5543 | "tcp_keepalive_time" , |
| 5544 | "Timeout, in milliseconds, with no activity until the first TCP keep-alive packet is sent." |
| 5545 | "If set to 0, system dependent default is used." , |
| 5546 | AUTO_SET GLOBAL_VAR(opt_vio_keepalive.idle), |
| 5547 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, INT_MAX32/1000), |
| 5548 | DEFAULT(0), |
| 5549 | BLOCK_SIZE(1), |
| 5550 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL)); |
| 5551 | |
| 5552 | static Sys_var_int Sys_keepalive_interval( |
| 5553 | "tcp_keepalive_interval" , |
| 5554 | "The interval, in seconds, between when successive keep-alive packets are sent if no acknowledgement is received." |
| 5555 | "If set to 0, system dependent default is used." , |
| 5556 | AUTO_SET GLOBAL_VAR(opt_vio_keepalive.interval), |
| 5557 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, INT_MAX32/1000), |
| 5558 | DEFAULT(0), |
| 5559 | BLOCK_SIZE(1), |
| 5560 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL)); |
| 5561 | |
| 5562 | static Sys_var_int Sys_keepalive_probes( |
| 5563 | "tcp_keepalive_probes" , |
| 5564 | "The number of unacknowledged probes to send before considering the connection dead and notifying the application layer." |
| 5565 | "If set to 0, system dependent default is used." , |
| 5566 | AUTO_SET GLOBAL_VAR(opt_vio_keepalive.probes), |
| 5567 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, INT_MAX32/1000), |
| 5568 | DEFAULT(0), |
| 5569 | BLOCK_SIZE(1), |
| 5570 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL)); |
| 5571 | |
| 5572 | static Sys_var_charptr Sys_ignore_db_dirs( |
| 5573 | "ignore_db_dirs" , |
| 5574 | "Specifies a directory to add to the ignore list when collecting " |
| 5575 | "database names from the datadir. Put a blank argument to reset " |
| 5576 | "the list accumulated so far." , |
| 5577 | READ_ONLY GLOBAL_VAR(opt_ignore_db_dirs), |
| 5578 | CMD_LINE(REQUIRED_ARG, OPT_IGNORE_DB_DIRECTORY), |
| 5579 | IN_FS_CHARSET, DEFAULT(0)); |
| 5580 | |
| 5581 | static Sys_var_ulong Sys_sp_cache_size( |
| 5582 | "stored_program_cache" , |
| 5583 | "The soft upper limit for number of cached stored routines for " |
| 5584 | "one connection." , |
| 5585 | GLOBAL_VAR(stored_program_cache_size), CMD_LINE(REQUIRED_ARG), |
| 5586 | VALID_RANGE(0, 512 * 1024), DEFAULT(256), BLOCK_SIZE(1)); |
| 5587 | |
| 5588 | export const char *plugin_maturity_names[]= |
| 5589 | { "unknown" , "experimental" , "alpha" , "beta" , "gamma" , "stable" , 0 }; |
| 5590 | static Sys_var_enum Sys_plugin_maturity( |
| 5591 | "plugin_maturity" , |
| 5592 | "The lowest desirable plugin maturity. " |
| 5593 | "Plugins less mature than that will not be installed or loaded" , |
| 5594 | READ_ONLY GLOBAL_VAR(plugin_maturity), CMD_LINE(REQUIRED_ARG), |
| 5595 | plugin_maturity_names, |
| 5596 | DEFAULT(SERVER_MATURITY_LEVEL > 0 ? |
| 5597 | SERVER_MATURITY_LEVEL - 1 : SERVER_MATURITY_LEVEL)); |
| 5598 | |
| 5599 | static Sys_var_ulong Sys_deadlock_search_depth_short( |
| 5600 | "deadlock_search_depth_short" , |
| 5601 | "Short search depth for the two-step deadlock detection" , |
| 5602 | SESSION_VAR(wt_deadlock_search_depth_short), CMD_LINE(REQUIRED_ARG), |
| 5603 | VALID_RANGE(0, 32), DEFAULT(4), BLOCK_SIZE(1)); |
| 5604 | |
| 5605 | static Sys_var_ulong Sys_deadlock_search_depth_long( |
| 5606 | "deadlock_search_depth_long" , |
| 5607 | "Long search depth for the two-step deadlock detection" , |
| 5608 | SESSION_VAR(wt_deadlock_search_depth_long), CMD_LINE(REQUIRED_ARG), |
| 5609 | VALID_RANGE(0, 33), DEFAULT(15), BLOCK_SIZE(1)); |
| 5610 | |
| 5611 | static Sys_var_ulong Sys_deadlock_timeout_depth_short( |
| 5612 | "deadlock_timeout_short" , |
| 5613 | "Short timeout for the two-step deadlock detection (in microseconds)" , |
| 5614 | SESSION_VAR(wt_timeout_short), CMD_LINE(REQUIRED_ARG), |
| 5615 | VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1)); |
| 5616 | |
| 5617 | static Sys_var_ulong Sys_deadlock_timeout_depth_long( |
| 5618 | "deadlock_timeout_long" , |
| 5619 | "Long timeout for the two-step deadlock detection (in microseconds)" , |
| 5620 | SESSION_VAR(wt_timeout_long), CMD_LINE(REQUIRED_ARG), |
| 5621 | VALID_RANGE(0, UINT_MAX), DEFAULT(50000000), BLOCK_SIZE(1)); |
| 5622 | |
| 5623 | static Sys_var_uint ( |
| 5624 | "extra_port" , |
| 5625 | "Extra port number to use for tcp connections in a " |
| 5626 | "one-thread-per-connection manner. 0 means don't use another port" , |
| 5627 | READ_ONLY GLOBAL_VAR(mysqld_extra_port), CMD_LINE(REQUIRED_ARG), |
| 5628 | VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1)); |
| 5629 | |
| 5630 | static Sys_var_ulong ( |
| 5631 | "extra_max_connections" , "The number of connections on extra-port" , |
| 5632 | GLOBAL_VAR(extra_max_connections), CMD_LINE(REQUIRED_ARG), |
| 5633 | VALID_RANGE(1, 100000), DEFAULT(1), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 5634 | NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_max_connections)); |
| 5635 | |
| 5636 | #ifdef SAFE_MUTEX |
| 5637 | static Sys_var_mybool Sys_mutex_deadlock_detector( |
| 5638 | "debug_mutex_deadlock_detector" , "Enable checking of wrong mutex usage" , |
| 5639 | READ_ONLY GLOBAL_VAR(safe_mutex_deadlock_detector), |
| 5640 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 5641 | #endif |
| 5642 | |
| 5643 | static Sys_var_keycache Sys_key_cache_segments( |
| 5644 | "key_cache_segments" , "The number of segments in a key cache" , |
| 5645 | KEYCACHE_VAR(param_partitions), |
| 5646 | CMD_LINE(REQUIRED_ARG, OPT_KEY_CACHE_PARTITIONS), |
| 5647 | VALID_RANGE(0, MAX_KEY_CACHE_PARTITIONS), |
| 5648 | DEFAULT(DEFAULT_KEY_CACHE_PARTITIONS), |
| 5649 | BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 5650 | ON_UPDATE(repartition_keycache)); |
| 5651 | |
| 5652 | static const char *log_slow_filter_names[]= |
| 5653 | { |
| 5654 | "admin" , "filesort" , "filesort_on_disk" , "filesort_priority_queue" , |
| 5655 | "full_join" , "full_scan" , "not_using_index" , "query_cache" , |
| 5656 | "query_cache_miss" , "tmp_table" , "tmp_table_on_disk" , 0 |
| 5657 | }; |
| 5658 | |
| 5659 | |
| 5660 | static Sys_var_set Sys_log_slow_filter( |
| 5661 | "log_slow_filter" , |
| 5662 | "Log only certain types of queries to the slow log. If variable empty alll kind of queries are logged. All types are bound by slow_query_time, except 'not_using_index' which is always logged if enabled" , |
| 5663 | SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG), |
| 5664 | log_slow_filter_names, |
| 5665 | /* by default we log all queries except 'not_using_index' */ |
| 5666 | DEFAULT(my_set_bits(array_elements(log_slow_filter_names)-1) & |
| 5667 | ~QPLAN_NOT_USING_INDEX)); |
| 5668 | |
| 5669 | static const char *log_slow_disabled_statements_names[]= |
| 5670 | { "admin" , "call" , "slave" , "sp" , 0 }; |
| 5671 | |
| 5672 | static const char *log_disabled_statements_names[]= |
| 5673 | { "slave" , "sp" , 0 }; |
| 5674 | |
| 5675 | static Sys_var_set Sys_log_slow_disabled_statements( |
| 5676 | "log_slow_disabled_statements" , |
| 5677 | "Don't log certain types of statements to slow log" , |
| 5678 | SESSION_VAR(log_slow_disabled_statements), CMD_LINE(REQUIRED_ARG), |
| 5679 | log_slow_disabled_statements_names, |
| 5680 | DEFAULT(LOG_SLOW_DISABLE_SP)); |
| 5681 | |
| 5682 | static Sys_var_set Sys_log_disabled_statements( |
| 5683 | "log_disabled_statements" , |
| 5684 | "Don't log certain types of statements to general log" , |
| 5685 | SESSION_VAR(log_disabled_statements), CMD_LINE(REQUIRED_ARG), |
| 5686 | log_disabled_statements_names, |
| 5687 | DEFAULT(LOG_DISABLE_SP), |
| 5688 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super)); |
| 5689 | |
| 5690 | static const char *default_regex_flags_names[]= |
| 5691 | { |
| 5692 | "DOTALL" , // (?s) . matches anything including NL |
| 5693 | "DUPNAMES" , // (?J) Allow duplicate names for subpatterns |
| 5694 | "EXTENDED" , // (?x) Ignore white space and # comments |
| 5695 | "EXTRA" , // (?X) extra features (e.g. error on unknown escape character) |
| 5696 | "MULTILINE" , // (?m) ^ and $ match newlines within data |
| 5697 | "UNGREEDY" , // (?U) Invert greediness of quantifiers |
| 5698 | 0 |
| 5699 | }; |
| 5700 | static const int default_regex_flags_to_pcre[]= |
| 5701 | { |
| 5702 | PCRE_DOTALL, |
| 5703 | PCRE_DUPNAMES, |
| 5704 | PCRE_EXTENDED, |
| 5705 | PCRE_EXTRA, |
| 5706 | PCRE_MULTILINE, |
| 5707 | PCRE_UNGREEDY, |
| 5708 | 0 |
| 5709 | }; |
| 5710 | int default_regex_flags_pcre(const THD *thd) |
| 5711 | { |
| 5712 | ulonglong src= thd->variables.default_regex_flags; |
| 5713 | int i, res; |
| 5714 | for (i= res= 0; default_regex_flags_to_pcre[i]; i++) |
| 5715 | { |
| 5716 | if (src & (1ULL << i)) |
| 5717 | res|= default_regex_flags_to_pcre[i]; |
| 5718 | } |
| 5719 | return res; |
| 5720 | } |
| 5721 | static Sys_var_set Sys_default_regex_flags( |
| 5722 | "default_regex_flags" , |
| 5723 | "Default flags for the regex library" , |
| 5724 | SESSION_VAR(default_regex_flags), CMD_LINE(REQUIRED_ARG), |
| 5725 | default_regex_flags_names, |
| 5726 | DEFAULT(0)); |
| 5727 | |
| 5728 | static Sys_var_ulong Sys_log_slow_rate_limit( |
| 5729 | "log_slow_rate_limit" , |
| 5730 | "Write to slow log every #th slow query. Set to 1 to log everything. " |
| 5731 | "Increase it to reduce the size of the slow or the performance impact " |
| 5732 | "of slow logging" , |
| 5733 | SESSION_VAR(log_slow_rate_limit), CMD_LINE(REQUIRED_ARG), |
| 5734 | VALID_RANGE(1, UINT_MAX), DEFAULT(1), BLOCK_SIZE(1)); |
| 5735 | |
| 5736 | static const char *log_slow_verbosity_names[]= { "innodb" , "query_plan" , |
| 5737 | "explain" , 0 }; |
| 5738 | static Sys_var_set Sys_log_slow_verbosity( |
| 5739 | "log_slow_verbosity" , |
| 5740 | "Verbosity level for the slow log" , |
| 5741 | SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG), |
| 5742 | log_slow_verbosity_names, DEFAULT(LOG_SLOW_VERBOSITY_INIT)); |
| 5743 | |
| 5744 | static Sys_var_ulong Sys_join_cache_level( |
| 5745 | "join_cache_level" , |
| 5746 | "Controls what join operations can be executed with join buffers. Odd " |
| 5747 | "numbers are used for plain join buffers while even numbers are used " |
| 5748 | "for linked buffers" , |
| 5749 | SESSION_VAR(join_cache_level), CMD_LINE(REQUIRED_ARG), |
| 5750 | VALID_RANGE(0, 8), DEFAULT(2), BLOCK_SIZE(1)); |
| 5751 | |
| 5752 | static Sys_var_ulong Sys_mrr_buffer_size( |
| 5753 | "mrr_buffer_size" , |
| 5754 | "Size of buffer to use when using MRR with range access" , |
| 5755 | SESSION_VAR(mrr_buff_size), CMD_LINE(REQUIRED_ARG), |
| 5756 | VALID_RANGE(IO_SIZE*2, INT_MAX32), DEFAULT(256*1024), BLOCK_SIZE(1)); |
| 5757 | |
| 5758 | static Sys_var_ulong Sys_rowid_merge_buff_size( |
| 5759 | "rowid_merge_buff_size" , |
| 5760 | "The size of the buffers used [NOT] IN evaluation via partial matching" , |
| 5761 | SESSION_VAR(rowid_merge_buff_size), CMD_LINE(REQUIRED_ARG), |
| 5762 | VALID_RANGE(0, LONG_MAX), DEFAULT(8*1024*1024), |
| 5763 | BLOCK_SIZE(1)); |
| 5764 | |
| 5765 | static Sys_var_mybool Sys_userstat( |
| 5766 | "userstat" , |
| 5767 | "Enables statistics gathering for USER_STATISTICS, CLIENT_STATISTICS, " |
| 5768 | "INDEX_STATISTICS and TABLE_STATISTICS tables in the INFORMATION_SCHEMA" , |
| 5769 | GLOBAL_VAR(opt_userstat_running), |
| 5770 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5771 | |
| 5772 | static Sys_var_mybool Sys_binlog_annotate_row_events( |
| 5773 | "binlog_annotate_row_events" , |
| 5774 | "Tells the master to annotate RBR events with the statement that " |
| 5775 | "caused these events" , |
| 5776 | SESSION_VAR(binlog_annotate_row_events), CMD_LINE(OPT_ARG), |
| 5777 | DEFAULT(TRUE)); |
| 5778 | |
| 5779 | #ifdef HAVE_REPLICATION |
| 5780 | static Sys_var_mybool Sys_replicate_annotate_row_events( |
| 5781 | "replicate_annotate_row_events" , |
| 5782 | "Tells the slave to write annotate rows events received from the master " |
| 5783 | "to its own binary log. Ignored if log_slave_updates is not set" , |
| 5784 | READ_ONLY GLOBAL_VAR(opt_replicate_annotate_row_events), |
| 5785 | CMD_LINE(OPT_ARG), DEFAULT(TRUE)); |
| 5786 | #endif |
| 5787 | |
| 5788 | static Sys_var_ulonglong Sys_join_buffer_space_limit( |
| 5789 | "join_buffer_space_limit" , |
| 5790 | "The limit of the space for all join buffers used by a query" , |
| 5791 | SESSION_VAR(join_buff_space_limit), CMD_LINE(REQUIRED_ARG), |
| 5792 | VALID_RANGE(2048, ULONGLONG_MAX), DEFAULT(16*128*1024), |
| 5793 | BLOCK_SIZE(2048)); |
| 5794 | |
| 5795 | static Sys_var_ulong Sys_progress_report_time( |
| 5796 | "progress_report_time" , |
| 5797 | "Seconds between sending progress reports to the client for " |
| 5798 | "time-consuming statements. Set to 0 to disable progress reporting." , |
| 5799 | SESSION_VAR(progress_report_time), CMD_LINE(REQUIRED_ARG), |
| 5800 | VALID_RANGE(0, UINT_MAX), DEFAULT(5), BLOCK_SIZE(1)); |
| 5801 | |
| 5802 | const char *use_stat_tables_modes[] = |
| 5803 | {"NEVER" , "COMPLEMENTARY" , "PREFERABLY" , 0}; |
| 5804 | static Sys_var_enum Sys_optimizer_use_stat_tables( |
| 5805 | "use_stat_tables" , |
| 5806 | "Specifies how to use system statistics tables" , |
| 5807 | SESSION_VAR(use_stat_tables), CMD_LINE(REQUIRED_ARG), |
| 5808 | use_stat_tables_modes, DEFAULT(0)); |
| 5809 | |
| 5810 | static Sys_var_ulong Sys_histogram_size( |
| 5811 | "histogram_size" , |
| 5812 | "Number of bytes used for a histogram. " |
| 5813 | "If set to 0, no histograms are created by ANALYZE." , |
| 5814 | SESSION_VAR(histogram_size), CMD_LINE(REQUIRED_ARG), |
| 5815 | VALID_RANGE(0, 255), DEFAULT(0), BLOCK_SIZE(1)); |
| 5816 | |
| 5817 | extern const char *histogram_types[]; |
| 5818 | static Sys_var_enum Sys_histogram_type( |
| 5819 | "histogram_type" , |
| 5820 | "Specifies type of the histograms created by ANALYZE. " |
| 5821 | "Possible values are: " |
| 5822 | "SINGLE_PREC_HB - single precision height-balanced, " |
| 5823 | "DOUBLE_PREC_HB - double precision height-balanced." , |
| 5824 | SESSION_VAR(histogram_type), CMD_LINE(REQUIRED_ARG), |
| 5825 | histogram_types, DEFAULT(0)); |
| 5826 | |
| 5827 | static Sys_var_mybool Sys_no_thread_alarm( |
| 5828 | "debug_no_thread_alarm" , |
| 5829 | "Disable system thread alarm calls. Disabling it may be useful " |
| 5830 | "in debugging or testing, never do it in production" , |
| 5831 | READ_ONLY GLOBAL_VAR(my_disable_thr_alarm), CMD_LINE(OPT_ARG), |
| 5832 | DEFAULT(FALSE)); |
| 5833 | |
| 5834 | static Sys_var_mybool ( |
| 5835 | "query_cache_strip_comments" , |
| 5836 | "Strip all comments from a query before storing it " |
| 5837 | "in the query cache" , |
| 5838 | SESSION_VAR(query_cache_strip_comments), CMD_LINE(OPT_ARG), |
| 5839 | DEFAULT(FALSE)); |
| 5840 | |
| 5841 | static ulonglong in_transaction(THD *thd) |
| 5842 | { |
| 5843 | return MY_TEST(thd->in_active_multi_stmt_transaction()); |
| 5844 | } |
| 5845 | static Sys_var_session_special Sys_in_transaction( |
| 5846 | "in_transaction" , "Whether there is an active transaction" , |
| 5847 | READ_ONLY sys_var::ONLY_SESSION, NO_CMD_LINE, |
| 5848 | VALID_RANGE(0, 1), BLOCK_SIZE(1), NO_MUTEX_GUARD, |
| 5849 | NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), ON_READ(in_transaction)); |
| 5850 | |
| 5851 | #ifndef DBUG_OFF |
| 5852 | static Sys_var_ulong Sys_debug_binlog_fsync_sleep( |
| 5853 | "debug_binlog_fsync_sleep" , |
| 5854 | "Extra sleep (in microseconds) to add to binlog fsync(), for debugging" , |
| 5855 | GLOBAL_VAR(opt_binlog_dbug_fsync_sleep), |
| 5856 | CMD_LINE(REQUIRED_ARG), |
| 5857 | VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); |
| 5858 | #endif |
| 5859 | |
| 5860 | static Sys_var_harows Sys_expensive_subquery_limit( |
| 5861 | "expensive_subquery_limit" , |
| 5862 | "The maximum number of rows a subquery may examine in order to be " |
| 5863 | "executed during optimization and used for constant optimization" , |
| 5864 | SESSION_VAR(expensive_subquery_limit), CMD_LINE(REQUIRED_ARG), |
| 5865 | VALID_RANGE(0, HA_POS_ERROR), DEFAULT(100), BLOCK_SIZE(1)); |
| 5866 | |
| 5867 | static Sys_var_mybool Sys_encrypt_tmp_disk_tables( |
| 5868 | "encrypt_tmp_disk_tables" , |
| 5869 | "Encrypt temporary on-disk tables (created as part of query execution)" , |
| 5870 | GLOBAL_VAR(encrypt_tmp_disk_tables), |
| 5871 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5872 | |
| 5873 | static Sys_var_mybool Sys_encrypt_tmp_files( |
| 5874 | "encrypt_tmp_files" , |
| 5875 | "Encrypt temporary files (created for filesort, binary log cache, etc)" , |
| 5876 | READ_ONLY GLOBAL_VAR(encrypt_tmp_files), |
| 5877 | CMD_LINE(OPT_ARG), DEFAULT(FALSE)); |
| 5878 | |
| 5879 | static Sys_var_mybool Sys_binlog_encryption( |
| 5880 | "encrypt_binlog" , "Encrypt binary logs (including relay logs)" , |
| 5881 | READ_ONLY GLOBAL_VAR(encrypt_binlog), CMD_LINE(OPT_ARG), |
| 5882 | DEFAULT(FALSE)); |
| 5883 | |
| 5884 | static const char *binlog_row_image_names[]= {"MINIMAL" , "NOBLOB" , "FULL" , NullS}; |
| 5885 | static Sys_var_enum Sys_binlog_row_image( |
| 5886 | "binlog_row_image" , |
| 5887 | "Controls whether rows should be logged in 'FULL', 'NOBLOB' or " |
| 5888 | "'MINIMAL' formats. 'FULL', means that all columns in the before " |
| 5889 | "and after image are logged. 'NOBLOB', means that mysqld avoids logging " |
| 5890 | "blob columns whenever possible (eg, blob column was not changed or " |
| 5891 | "is not part of primary key). 'MINIMAL', means that a PK equivalent (PK " |
| 5892 | "columns or full row if there is no PK in the table) is logged in the " |
| 5893 | "before image, and only changed columns are logged in the after image. " |
| 5894 | "(Default: FULL)." , |
| 5895 | SESSION_VAR(binlog_row_image), CMD_LINE(REQUIRED_ARG), |
| 5896 | binlog_row_image_names, DEFAULT(BINLOG_ROW_IMAGE_FULL)); |
| 5897 | |
| 5898 | static bool check_pseudo_slave_mode(sys_var *self, THD *thd, set_var *var) |
| 5899 | { |
| 5900 | longlong previous_val= thd->variables.pseudo_slave_mode; |
| 5901 | longlong val= (longlong) var->save_result.ulonglong_value; |
| 5902 | bool rli_fake= false; |
| 5903 | |
| 5904 | #ifndef EMBEDDED_LIBRARY |
| 5905 | rli_fake= thd->rli_fake ? true : false; |
| 5906 | #endif |
| 5907 | |
| 5908 | if (rli_fake) |
| 5909 | { |
| 5910 | if (!val) |
| 5911 | { |
| 5912 | #ifndef EMBEDDED_LIBRARY |
| 5913 | delete thd->rli_fake; |
| 5914 | thd->rli_fake= NULL; |
| 5915 | delete thd->rgi_fake; |
| 5916 | thd->rgi_fake= NULL; |
| 5917 | #endif |
| 5918 | } |
| 5919 | else if (previous_val && val) |
| 5920 | goto ineffective; |
| 5921 | else if (!previous_val && val) |
| 5922 | push_warning(thd, Sql_condition::WARN_LEVEL_WARN, |
| 5923 | ER_WRONG_VALUE_FOR_VAR, |
| 5924 | "'pseudo_slave_mode' is already ON." ); |
| 5925 | } |
| 5926 | else |
| 5927 | { |
| 5928 | if (!previous_val && !val) |
| 5929 | goto ineffective; |
| 5930 | else if (previous_val && !val) |
| 5931 | push_warning(thd, Sql_condition::WARN_LEVEL_WARN, |
| 5932 | ER_WRONG_VALUE_FOR_VAR, |
| 5933 | "Slave applier execution mode not active, " |
| 5934 | "statement ineffective." ); |
| 5935 | } |
| 5936 | goto end; |
| 5937 | |
| 5938 | ineffective: |
| 5939 | push_warning(thd, Sql_condition::WARN_LEVEL_WARN, |
| 5940 | ER_WRONG_VALUE_FOR_VAR, |
| 5941 | "'pseudo_slave_mode' change was ineffective." ); |
| 5942 | |
| 5943 | end: |
| 5944 | return FALSE; |
| 5945 | } |
| 5946 | static Sys_var_mybool Sys_pseudo_slave_mode( |
| 5947 | "pseudo_slave_mode" , |
| 5948 | "SET pseudo_slave_mode= 0,1 are commands that mysqlbinlog " |
| 5949 | "adds to beginning and end of binary log dumps. While zero " |
| 5950 | "value indeed disables, the actual enabling of the slave " |
| 5951 | "applier execution mode is done implicitly when a " |
| 5952 | "Format_description_event is sent through the session." , |
| 5953 | SESSION_ONLY(pseudo_slave_mode), NO_CMD_LINE, DEFAULT(FALSE), |
| 5954 | NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_pseudo_slave_mode)); |
| 5955 | |
| 5956 | static Sys_var_mybool Sys_mysql56_temporal_format( |
| 5957 | "mysql56_temporal_format" , |
| 5958 | "Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns." , |
| 5959 | GLOBAL_VAR(opt_mysql56_temporal_format), |
| 5960 | CMD_LINE(OPT_ARG), DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG); |
| 5961 | |
| 5962 | static Sys_var_mybool Sys_strict_password_validation( |
| 5963 | "strict_password_validation" , |
| 5964 | "When password validation plugins are enabled, reject passwords " |
| 5965 | "that cannot be validated (passwords specified as a hash)" , |
| 5966 | GLOBAL_VAR(strict_password_validation), |
| 5967 | CMD_LINE(OPT_ARG), DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG); |
| 5968 | |
| 5969 | #ifdef HAVE_MMAP |
| 5970 | static Sys_var_ulong Sys_log_tc_size( |
| 5971 | "log_tc_size" , |
| 5972 | "Size of transaction coordinator log." , |
| 5973 | READ_ONLY GLOBAL_VAR(opt_tc_log_size), |
| 5974 | CMD_LINE(REQUIRED_ARG), |
| 5975 | VALID_RANGE(my_getpagesize() * 3, ULONG_MAX), |
| 5976 | DEFAULT(my_getpagesize() * 6), |
| 5977 | BLOCK_SIZE(my_getpagesize())); |
| 5978 | #endif |
| 5979 | |
| 5980 | static Sys_var_ulonglong Sys_max_thread_mem( |
| 5981 | "max_session_mem_used" , "Amount of memory a single user session " |
| 5982 | "is allowed to allocate. This limits the value of the " |
| 5983 | "session variable MEM_USED" , SESSION_VAR(max_mem_used), |
| 5984 | CMD_LINE(REQUIRED_ARG), VALID_RANGE(8192, ULONGLONG_MAX), |
| 5985 | DEFAULT(LONGLONG_MAX), BLOCK_SIZE(1)); |
| 5986 | |
| 5987 | #ifndef EMBEDDED_LIBRARY |
| 5988 | |
| 5989 | static Sys_var_sesvartrack Sys_track_session_sys_vars( |
| 5990 | "session_track_system_variables" , |
| 5991 | "Track changes in registered system variables. " , |
| 5992 | CMD_LINE(REQUIRED_ARG), IN_SYSTEM_CHARSET, |
| 5993 | DEFAULT("autocommit,character_set_client,character_set_connection," |
| 5994 | "character_set_results,time_zone" ), |
| 5995 | NO_MUTEX_GUARD); |
| 5996 | |
| 5997 | static bool update_session_track_schema(sys_var *self, THD *thd, |
| 5998 | enum_var_type type) |
| 5999 | { |
| 6000 | DBUG_ENTER("update_session_track_schema" ); |
| 6001 | DBUG_RETURN(thd->session_tracker.get_tracker(CURRENT_SCHEMA_TRACKER)-> |
| 6002 | update(thd, NULL)); |
| 6003 | } |
| 6004 | |
| 6005 | static Sys_var_mybool Sys_session_track_schema( |
| 6006 | "session_track_schema" , |
| 6007 | "Track changes to the default schema." , |
| 6008 | SESSION_VAR(session_track_schema), |
| 6009 | CMD_LINE(OPT_ARG), DEFAULT(TRUE), |
| 6010 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 6011 | ON_CHECK(0), |
| 6012 | ON_UPDATE(update_session_track_schema)); |
| 6013 | |
| 6014 | |
| 6015 | static bool update_session_track_tx_info(sys_var *self, THD *thd, |
| 6016 | enum_var_type type) |
| 6017 | { |
| 6018 | DBUG_ENTER("update_session_track_tx_info" ); |
| 6019 | DBUG_RETURN(thd->session_tracker.get_tracker(TRANSACTION_INFO_TRACKER)-> |
| 6020 | update(thd, NULL)); |
| 6021 | } |
| 6022 | |
| 6023 | static const char *session_track_transaction_info_names[]= |
| 6024 | { "OFF" , "STATE" , "CHARACTERISTICS" , NullS }; |
| 6025 | |
| 6026 | static Sys_var_enum Sys_session_track_transaction_info( |
| 6027 | "session_track_transaction_info" , |
| 6028 | "Track changes to the transaction attributes. OFF to disable; " |
| 6029 | "STATE to track just transaction state (Is there an active transaction? " |
| 6030 | "Does it have any data? etc.); CHARACTERISTICS to track transaction " |
| 6031 | "state and report all statements needed to start a transaction with" |
| 6032 | "the same characteristics (isolation level, read only/read write," |
| 6033 | "snapshot - but not any work done / data modified within the " |
| 6034 | "transaction)." , |
| 6035 | SESSION_VAR(session_track_transaction_info), |
| 6036 | CMD_LINE(REQUIRED_ARG), session_track_transaction_info_names, |
| 6037 | DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), |
| 6038 | ON_UPDATE(update_session_track_tx_info)); |
| 6039 | |
| 6040 | |
| 6041 | static bool update_session_track_state_change(sys_var *self, THD *thd, |
| 6042 | enum_var_type type) |
| 6043 | { |
| 6044 | DBUG_ENTER("update_session_track_state_change" ); |
| 6045 | DBUG_RETURN(thd->session_tracker.get_tracker(SESSION_STATE_CHANGE_TRACKER)-> |
| 6046 | update(thd, NULL)); |
| 6047 | } |
| 6048 | |
| 6049 | static Sys_var_mybool Sys_session_track_state_change( |
| 6050 | "session_track_state_change" , |
| 6051 | "Track changes to the session state." , |
| 6052 | SESSION_VAR(session_track_state_change), |
| 6053 | CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
| 6054 | NO_MUTEX_GUARD, NOT_IN_BINLOG, |
| 6055 | ON_CHECK(0), |
| 6056 | ON_UPDATE(update_session_track_state_change)); |
| 6057 | |
| 6058 | #endif //EMBEDDED_LIBRARY |
| 6059 | |
| 6060 | #ifndef DBUG_OFF |
| 6061 | static Sys_var_uint Sys_in_subquery_conversion_threshold( |
| 6062 | "in_predicate_conversion_threshold" , |
| 6063 | "The minimum number of scalar elements in the value list of " |
| 6064 | "IN predicate that triggers its conversion to IN subquery" , |
| 6065 | SESSION_VAR(in_subquery_conversion_threshold), CMD_LINE(OPT_ARG), |
| 6066 | VALID_RANGE(0, UINT_MAX), DEFAULT(IN_SUBQUERY_CONVERSION_THRESHOLD), BLOCK_SIZE(1)); |
| 6067 | #endif |
| 6068 | |
| 6069 | static Sys_var_enum Sys_secure_timestamp( |
| 6070 | "secure_timestamp" , "Restricts direct setting of a session " |
| 6071 | "timestamp. Possible levels are: YES - timestamp cannot deviate from " |
| 6072 | "the system clock, REPLICATION - replication thread can adjust " |
| 6073 | "timestamp to match the master's, SUPER - a user with this " |
| 6074 | "privilege and a replication thread can adjust timestamp, NO - " |
| 6075 | "historical behavior, anyone can modify session timestamp" , |
| 6076 | READ_ONLY GLOBAL_VAR(opt_secure_timestamp), CMD_LINE(REQUIRED_ARG), |
| 6077 | secure_timestamp_levels, DEFAULT(SECTIME_NO)); |
| 6078 | |