179
179
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
180
180
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
182
static plugin::TransactionApplier *replication_logger= NULL;
184
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
185
innobase_log_buffer_size,
186
innobase_force_recovery, innobase_open_files;
187
static long innobase_additional_mem_pool_size= 8*1024*1024L;
188
static ulong innobase_commit_concurrency = 0;
189
static ulong innobase_read_io_threads;
190
static ulong innobase_write_io_threads;
191
static int64_t innobase_buffer_pool_instances = 1;
194
* @TODO: Turn this into size_t as soon as we have a Variable<size_t>
196
static int64_t innobase_buffer_pool_size= 128*1024*1024;
197
static int64_t innobase_log_file_size;
182
static ReplicationLog *replication_logger= NULL;
183
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
184
static open_files_constraint innobase_open_files;
185
typedef constrained_check<uint32_t, 10, 1> mirrored_log_groups_constraint;
186
static mirrored_log_groups_constraint innobase_mirrored_log_groups;
187
typedef constrained_check<uint32_t, 100, 2> log_files_in_group_constraint;
188
static log_files_in_group_constraint innobase_log_files_in_group;
189
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
190
force_recovery_constraint innobase_force_recovery;
191
typedef constrained_check<size_t, SIZE_MAX, 256*1024, 1024> log_buffer_constraint;
192
static log_buffer_constraint innobase_log_buffer_size;
193
typedef constrained_check<size_t, SIZE_MAX, 512*1024, 1024> additional_mem_pool_constraint;
194
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
195
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
196
static autoextend_constraint innodb_auto_extend_increment;
197
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
198
static buffer_pool_constraint innobase_buffer_pool_size;
199
typedef constrained_check<uint32_t, MAX_BUFFER_POOLS, 1> buffer_pool_instances_constraint;
200
static buffer_pool_instances_constraint innobase_buffer_pool_instances;
201
typedef constrained_check<uint32_t, UINT32_MAX, 100> io_capacity_constraint;
202
static io_capacity_constraint innodb_io_capacity;
203
typedef constrained_check<uint32_t, 5000, 1> purge_batch_constraint;
204
static purge_batch_constraint innodb_purge_batch_size;
205
typedef constrained_check<uint32_t, 1, 0> purge_threads_constraint;
206
static purge_threads_constraint innodb_n_purge_threads;
207
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
208
static trinary_constraint innodb_flush_log_at_trx_commit;
209
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
210
static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
211
static uint64_constraint innodb_max_purge_lag;
212
static uint64_nonzero_constraint innodb_stats_sample_pages;
213
typedef constrained_check<uint32_t, 64, 1> io_threads_constraint;
214
static io_threads_constraint innobase_read_io_threads;
215
static io_threads_constraint innobase_write_io_threads;
217
typedef constrained_check<uint32_t, 1000, 0> concurrency_constraint;
218
static concurrency_constraint innobase_commit_concurrency;
219
static concurrency_constraint innobase_thread_concurrency;
220
static uint32_nonzero_constraint innodb_concurrency_tickets;
222
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
223
static log_file_constraint innobase_log_file_size;
225
static uint64_constraint innodb_replication_delay;
199
227
/** Percentage of the buffer pool to reserve for 'old' blocks.
200
228
Connected to buf_LRU_old_ratio. */
201
static uint innobase_old_blocks_pct;
229
typedef constrained_check<uint32_t, 95, 5> old_blocks_constraint;
230
static old_blocks_constraint innobase_old_blocks_pct;
232
static uint32_constraint innodb_sync_spin_loops;
233
static uint32_constraint innodb_spin_wait_delay;
234
static uint32_constraint innodb_thread_sleep_delay;
236
typedef constrained_check<uint32_t, 64, 0> read_ahead_threshold_constraint;
237
static read_ahead_threshold_constraint innodb_read_ahead_threshold;
203
239
/* The default values for the following char* start-up parameters
204
240
are determined in innobase_init below: */
1824
1841
value= value - (value % align_val);
1844
static void auto_extend_update(Session *, sql_var_t)
1846
srv_auto_extend_increment= innodb_auto_extend_increment.get();
1849
static void io_capacity_update(Session *, sql_var_t)
1851
srv_io_capacity= innodb_io_capacity.get();
1854
static void purge_batch_update(Session *, sql_var_t)
1856
srv_purge_batch_size= innodb_purge_batch_size.get();
1859
static void purge_threads_update(Session *, sql_var_t)
1861
srv_n_purge_threads= innodb_n_purge_threads.get();
1864
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
1866
if (btr_search_enabled)
1868
btr_search_enable();
1870
btr_search_disable();
1874
static void innodb_old_blocks_pct_update(Session *, sql_var_t)
1876
innobase_old_blocks_pct= buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(), TRUE);
1879
static void innodb_thread_concurrency_update(Session *, sql_var_t)
1881
srv_thread_concurrency= innobase_thread_concurrency.get();
1884
static void innodb_sync_spin_loops_update(Session *, sql_var_t)
1886
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1889
static void innodb_spin_wait_delay_update(Session *, sql_var_t)
1891
srv_spin_wait_delay= innodb_spin_wait_delay.get();
1894
static void innodb_thread_sleep_delay_update(Session *, sql_var_t)
1896
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1899
static void innodb_read_ahead_threshold_update(Session *, sql_var_t)
1901
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1905
static int innodb_commit_concurrency_validate(Session *session, set_var *var)
1907
uint32_t new_value= var->save_result.uint32_t_value;
1909
if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
1910
(innobase_commit_concurrency.get() != 0 && new_value == 0))
1912
push_warning_printf(session,
1913
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1915
_("Once InnoDB is running, innodb_commit_concurrency "
1916
"must not change between zero and nonzero."));
1922
/*************************************************************//**
1923
Check if it is a valid file format. This function is registered as
1924
a callback with MySQL.
1925
@return 0 for valid file format */
1928
innodb_file_format_name_validate(
1929
/*=============================*/
1930
Session* , /*!< in: thread handle */
1933
const char *file_format_input = var->value->str_value.ptr();
1934
if (file_format_input == NULL)
1937
if (file_format_input != NULL) {
1940
format_id = innobase_file_format_name_lookup(
1943
if (format_id <= DICT_TF_FORMAT_MAX) {
1944
innobase_file_format_name =
1945
trx_sys_file_format_id_to_name(format_id);
1954
/*************************************************************//**
1955
Check if it is a valid value of innodb_change_buffering. This function is
1956
registered as a callback with MySQL.
1957
@return 0 for valid innodb_change_buffering */
1960
innodb_change_buffering_validate(
1961
/*=============================*/
1962
Session* , /*!< in: thread handle */
1965
const char *change_buffering_input = var->value->str_value.ptr();
1967
if (change_buffering_input == NULL)
1973
use < UT_ARR_SIZE(innobase_change_buffering_values);
1975
if (!innobase_strcasecmp(change_buffering_input,
1976
innobase_change_buffering_values[use]))
1978
ibuf_use= static_cast<ibuf_use_t>(use);
1987
/*************************************************************//**
1988
Check if valid argument to innodb_file_format_max. This function
1989
is registered as a callback with MySQL.
1990
@return 0 for valid file format */
1993
innodb_file_format_max_validate(
1994
/*==============================*/
1995
Session* session, /*!< in: thread handle */
1998
const char *file_format_input = var->value->str_value.ptr();
1999
if (file_format_input == NULL)
2002
if (file_format_input != NULL) {
2003
int format_id = innobase_file_format_validate_and_set(file_format_input);
2005
if (format_id > DICT_TF_FORMAT_MAX) {
2006
/* DEFAULT is "on", which is invalid at runtime. */
2010
if (format_id >= 0) {
2011
innobase_file_format_max=
2012
trx_sys_file_format_id_to_name((uint)format_id);
2014
/* Update the max format id in the system tablespace. */
2015
char name_buff[100];
2016
strcpy(name_buff, innobase_file_format_max.c_str());
2017
if (trx_sys_file_format_max_set(format_id, (const char **)&name_buff))
2019
errmsg_printf(ERRMSG_LVL_WARN,
2020
" [Info] InnoDB: the file format in the system "
2021
"tablespace is now set to %s.\n", name_buff);
2022
innobase_file_format_max= name_buff;
2027
push_warning_printf(session,
2028
DRIZZLE_ERROR::WARN_LEVEL_WARN,
2030
"InnoDB: invalid innodb_file_format_max "
2031
"value; can be any format up to %s "
2032
"or equivalent id of %d",
2033
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
2034
DICT_TF_FORMAT_MAX);
1827
2042
/*********************************************************************//**
1828
2043
Opens an InnoDB database.
1829
2044
@return 0 on success, error code on failure */
1865
2090
innobase_data_home_dir= getDataHome().file_string();
1868
if (vm.count("fast-shutdown"))
1870
if (innobase_fast_shutdown > 2)
1872
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
1877
if (vm.count("file-format-max"))
1879
innobase_file_format_max= const_cast<char *>(vm["file-format-max"].as<string>().c_str());
1882
if (vm.count("file-format-check"))
1884
innobase_file_format_check= vm["file-format-check"].as<bool>();
1887
if (vm.count("flush-log-at-trx-commit"))
1889
if (srv_flush_log_at_trx_commit > 2)
1891
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
1897
#ifdef UNIV_LOG_ARCHIVE
1898
if (vm.count("log-arch-dir"))
1900
innobase_log_arch_dir= vm["log-arch-dir"].as<string>());
1903
#endif /* UNIV_LOG_ARCHIVE */
1905
if (vm.count("max-dirty-pages-pct"))
1907
if (srv_max_buf_pool_modified_pct > 99)
1909
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
1914
if (vm.count("stats-sample-pages"))
1916
if (srv_stats_sample_pages < 8)
1918
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
1923
if (vm.count("additional-mem-pool-size"))
1925
align_value(innobase_additional_mem_pool_size);
1927
if (innobase_additional_mem_pool_size < 512*1024L)
1929
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
1935
if (vm.count("autoextend-increment"))
1937
if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
1939
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
1944
if (vm.count("buffer-pool-size"))
1946
align_value(innobase_buffer_pool_size, 1024*1024);
1947
if (innobase_buffer_pool_size < 5*1024*1024)
1949
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
1955
if (vm.count("buffer-pool-instances"))
1957
if (innobase_buffer_pool_instances > MAX_BUFFER_POOLS)
1959
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-instances\n"));
1965
if (vm.count("commit-concurrency"))
1967
if (srv_replication_delay > 1000)
1969
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
1974
if (vm.count("concurrency-tickets"))
1976
if (srv_n_free_tickets_to_enter < 1)
1978
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
1983
if (vm.count("read-io-threads"))
1985
if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
1987
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
1992
if (vm.count("write-io-threads"))
1994
if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
1996
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
2001
if (vm.count("force-recovery"))
2003
if (innobase_force_recovery > 6)
2005
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
2010
if (vm.count("log-buffer-size"))
2012
align_value(innobase_log_buffer_size);
2013
if (innobase_log_buffer_size < 256*1024L)
2015
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2020
if (vm.count("log-file-size"))
2022
align_value(innobase_log_file_size, 1024*1024);
2023
if (innobase_log_file_size < 1*1024*1024L)
2025
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2030
if (vm.count("log-files-in-group"))
2032
if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
2034
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
2039
if (vm.count("mirrored-log-groups"))
2041
if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
2043
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
2048
if (vm.count("open-files"))
2050
if (innobase_open_files < 10)
2052
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
2057
if (vm.count("thread-concurrency"))
2059
if (srv_thread_concurrency > 1000)
2061
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
2066
2094
if (vm.count("data-file-path"))
2068
2096
innobase_data_file_path= vm["data-file-path"].as<string>();
2071
if (vm.count("read-ahead-threshold"))
2073
if (srv_read_ahead_threshold > 64)
2075
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
2082
2100
innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2451
2407
context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2452
2408
context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2454
#ifdef UNIV_LOG_ARCHIVE
2455
context.registerVariable(new sys_var_bool_ptr_readonly("log_archive", &innobase_log_archive));
2456
#endif /* UNIV_LOG_ARCHIVE */
2457
2410
context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2458
2411
context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
2459
context.registerVariable(new sys_var_constrained_value<uint32_t>("lock-wait-timeout", lock_wait_timeout));
2412
context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
2414
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
2415
context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
2416
innodb_auto_extend_increment,
2417
auto_extend_update));
2418
context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
2420
io_capacity_update));
2421
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
2422
innodb_purge_batch_size,
2423
purge_batch_update));
2424
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
2425
innodb_n_purge_threads,
2426
purge_threads_update));
2427
context.registerVariable(new sys_var_constrained_value<uint16_t>("fast_shutdown", innobase_fast_shutdown));
2428
context.registerVariable(new sys_var_std_string("file_format",
2429
innobase_file_format_name,
2430
innodb_file_format_name_validate));
2431
context.registerVariable(new sys_var_std_string("change_buffering",
2432
innobase_change_buffering,
2433
innodb_change_buffering_validate));
2434
context.registerVariable(new sys_var_std_string("file_format_max",
2435
innobase_file_format_max,
2436
innodb_file_format_max_validate));
2437
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
2438
context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
2439
context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit",
2440
innodb_flush_log_at_trx_commit));
2441
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
2442
innodb_max_dirty_pages_pct));
2443
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
2444
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
2445
context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
2447
context.registerVariable(new sys_var_constrained_value<uint32_t>("commit_concurrency",
2448
innobase_commit_concurrency,
2449
innodb_commit_concurrency_validate));
2450
context.registerVariable(new sys_var_constrained_value<uint32_t>("concurrency_tickets",
2451
innodb_concurrency_tickets));
2452
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_io_threads", innobase_read_io_threads));
2453
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_io_threads", innobase_write_io_threads));
2454
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("replication_delay", innodb_replication_delay));
2455
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
2456
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("log_buffer_size", innobase_log_buffer_size));
2457
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("log_files_in_group", innobase_log_files_in_group));
2458
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("mirrored_log_groups", innobase_mirrored_log_groups));
2459
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", innobase_open_files));
2460
context.registerVariable(new sys_var_constrained_value<uint32_t>("old_blocks_pct",
2461
innobase_old_blocks_pct,
2462
innodb_old_blocks_pct_update));
2463
context.registerVariable(new sys_var_uint32_t_ptr("old_blocks_time", &buf_LRU_old_threshold_ms));
2464
context.registerVariable(new sys_var_constrained_value<uint32_t>("sync_spin_loops", innodb_sync_spin_loops, innodb_sync_spin_loops_update));
2465
context.registerVariable(new sys_var_constrained_value<uint32_t>("spin_wait_delay", innodb_spin_wait_delay, innodb_spin_wait_delay_update));
2466
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_sleep_delay", innodb_thread_sleep_delay, innodb_thread_sleep_delay_update));
2467
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_concurrency",
2468
innobase_thread_concurrency,
2469
innodb_thread_concurrency_update));
2470
context.registerVariable(new sys_var_constrained_value<uint32_t>("read_ahead_threshold",
2471
innodb_read_ahead_threshold,
2472
innodb_read_ahead_threshold_update));
2461
2473
/* Get the current high water mark format. */
2462
innobase_file_format_max = (char*) trx_sys_file_format_max_get();
2474
innobase_file_format_max = trx_sys_file_format_max_get();
2463
2475
btr_search_fully_disabled = (!btr_search_enabled);
9179
/*************************************************************//**
9180
Check if it is a valid file format. This function is registered as
9181
a callback with MySQL.
9182
@return 0 for valid file format */
9185
innodb_file_format_name_validate(
9186
/*=============================*/
9187
Session* , /*!< in: thread handle */
9188
drizzle_sys_var* , /*!< in: pointer to system
9190
void* save, /*!< out: immediate result
9191
for update function */
9192
drizzle_value* value) /*!< in: incoming string */
9194
const char* file_format_input;
9195
char buff[STRING_BUFFER_USUAL_SIZE];
9196
int len = sizeof(buff);
9199
ut_a(value != NULL);
9201
file_format_input = value->val_str(value, buff, &len);
9203
if (file_format_input != NULL) {
9206
format_id = innobase_file_format_name_lookup(
9209
if (format_id <= DICT_TF_FORMAT_MAX) {
9210
/* Save a pointer to the name in the
9211
'file_format_name_map' constant array. */
9212
*static_cast<const char**>(save) =
9213
trx_sys_file_format_id_to_name(format_id);
9219
*static_cast<const char**>(save) = NULL;
9223
/****************************************************************//**
9224
Update the system variable innodb_file_format using the "saved"
9225
value. This function is registered as a callback with MySQL. */
9228
innodb_file_format_name_update(
9229
/*===========================*/
9230
Session* , /*!< in: thread handle */
9231
drizzle_sys_var* , /*!< in: pointer to
9233
void* var_ptr, /*!< out: where the
9234
formal string goes */
9235
const void* save) /*!< in: immediate result
9236
from check function */
9238
const char* format_name;
9240
ut_a(var_ptr != NULL);
9243
format_name = *static_cast<const char*const*>(save);
9248
format_id = innobase_file_format_name_lookup(format_name);
9250
if (format_id <= DICT_TF_FORMAT_MAX) {
9251
srv_file_format = format_id;
9255
*static_cast<const char**>(var_ptr)
9256
= trx_sys_file_format_id_to_name(srv_file_format);
9259
/*************************************************************//**
9260
Check if valid argument to innodb_file_format_max. This function
9261
is registered as a callback with MySQL.
9262
@return 0 for valid file format */
9265
innodb_file_format_max_validate(
9266
/*==============================*/
9267
Session* session, /*!< in: thread handle */
9268
drizzle_sys_var* , /*!< in: pointer to system
9270
void* save, /*!< out: immediate result
9271
for update function */
9272
drizzle_value* value) /*!< in: incoming string */
9274
const char* file_format_input;
9275
char buff[STRING_BUFFER_USUAL_SIZE];
9276
int len = sizeof(buff);
9280
ut_a(value != NULL);
9282
file_format_input = value->val_str(value, buff, &len);
9284
if (file_format_input != NULL) {
9285
format_id = innobase_file_format_validate_and_set(file_format_input);
9287
if (format_id >= 0) {
9288
/* Save a pointer to the name in the
9289
'file_format_name_map' constant array. */
9290
*static_cast<const char**>(save) =
9291
trx_sys_file_format_id_to_name((uint)format_id);
9296
push_warning_printf(session,
9297
DRIZZLE_ERROR::WARN_LEVEL_WARN,
9299
"InnoDB: invalid innodb_file_format_max "
9300
"value; can be any format up to %s "
9301
"or equivalent id of %d",
9302
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
9303
DICT_TF_FORMAT_MAX);
9307
*static_cast<const char**>(save) = NULL;
9311
/****************************************************************//**
9312
Update the system variable innodb_file_format_max using the "saved"
9313
value. This function is registered as a callback with MySQL. */
9316
innodb_file_format_max_update(
9317
/*============================*/
9318
Session* session, /*!< in: thread handle */
9319
drizzle_sys_var* , /*!< in: pointer to
9321
void* var_ptr, /*!< out: where the
9322
formal string goes */
9323
const void* save) /*!< in: immediate result
9324
from check function */
9326
const char* format_name_in;
9327
const char** format_name_out;
9331
ut_a(var_ptr != NULL);
9333
format_name_in = *static_cast<const char*const*>(save);
9335
if (!format_name_in) {
9340
format_id = innobase_file_format_name_lookup(format_name_in);
9342
if (format_id > DICT_TF_FORMAT_MAX) {
9343
/* DEFAULT is "on", which is invalid at runtime. */
9344
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
9346
"Ignoring SET innodb_file_format=%s",
9351
format_name_out = static_cast<const char**>(var_ptr);
9353
/* Update the max format id in the system tablespace. */
9354
if (trx_sys_file_format_max_set(format_id, format_name_out)) {
9355
ut_print_timestamp(stderr);
9357
" [Info] InnoDB: the file format in the system "
9358
"tablespace is now set to %s.\n", *format_name_out);
9362
/****************************************************************//**
9363
Update the system variable innodb_adaptive_hash_index using the "saved"
9364
value. This function is registered as a callback with MySQL. */
9367
innodb_adaptive_hash_index_update(
9368
/*==============================*/
9369
Session* , /*!< in: thread handle */
9370
drizzle_sys_var* , /*!< in: pointer to
9372
void* , /*!< out: where the
9373
formal string goes */
9374
const void* save) /*!< in: immediate result
9375
from check function */
9377
if (*(bool*) save) {
9378
btr_search_enable();
9380
btr_search_disable();
9384
/****************************************************************//**
9385
Update the system variable innodb_old_blocks_pct using the "saved"
9386
value. This function is registered as a callback with MySQL. */
9389
innodb_old_blocks_pct_update(
9390
/*=========================*/
9391
Session* , /*!< in: thread handle */
9392
drizzle_sys_var* , /*!< in: pointer to
9394
void* ,/*!< out: where the
9395
formal string goes */
9396
const void* save) /*!< in: immediate result
9397
from check function */
9399
innobase_old_blocks_pct = buf_LRU_old_ratio_update(
9400
*static_cast<const uint*>(save), TRUE);
9403
/*************************************************************//**
9404
Check if it is a valid value of innodb_change_buffering. This function is
9405
registered as a callback with MySQL.
9406
@return 0 for valid innodb_change_buffering */
9409
innodb_change_buffering_validate(
9410
/*=============================*/
9411
Session* , /*!< in: thread handle */
9412
drizzle_sys_var* , /*!< in: pointer to system
9414
void* save, /*!< out: immediate result
9415
for update function */
9416
drizzle_value* value) /*!< in: incoming string */
9418
const char* change_buffering_input;
9419
char buff[STRING_BUFFER_USUAL_SIZE];
9420
int len = sizeof(buff);
9423
ut_a(value != NULL);
9425
change_buffering_input = value->val_str(value, buff, &len);
9427
if (change_buffering_input != NULL) {
9430
for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
9432
if (!innobase_strcasecmp(
9433
change_buffering_input,
9434
innobase_change_buffering_values[use])) {
9435
*(ibuf_use_t*) save = (ibuf_use_t) use;
9444
/****************************************************************//**
9445
Update the system variable innodb_change_buffering using the "saved"
9446
value. This function is registered as a callback with MySQL. */
9449
innodb_change_buffering_update(
9450
/*===========================*/
9451
Session* , /*!< in: thread handle */
9452
drizzle_sys_var* , /*!< in: pointer to
9454
void* var_ptr, /*!< out: where the
9455
formal string goes */
9456
const void* save) /*!< in: immediate result
9457
from check function */
9459
ut_a(var_ptr != NULL);
9461
ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
9463
ibuf_use = *(const ibuf_use_t*) save;
9465
*(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
9468
/* plugin options */
9470
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
9471
PLUGIN_VAR_RQCMDARG,
9472
"Number of IOPs the server can do. Tunes the background IO rate",
9473
NULL, NULL, 200, 100, ~0L, 0);
9475
static DRIZZLE_SYSVAR_ULONG(purge_batch_size, srv_purge_batch_size,
9476
PLUGIN_VAR_OPCMDARG,
9477
"Number of UNDO logs to purge in one batch from the history list. "
9480
20, /* Default setting */
9481
1, /* Minimum value */
9482
5000, 0); /* Maximum value */
9484
static DRIZZLE_SYSVAR_ULONG(purge_threads, srv_n_purge_threads,
9485
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
9486
"Purge threads can be either 0 or 1. Default is 0.",
9488
0, /* Default setting */
9489
0, /* Minimum value */
9490
1, 0); /* Maximum value */
9492
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
9493
PLUGIN_VAR_OPCMDARG,
9494
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
9495
"values are 0, 1 (faster)"
9496
" or 2 (fastest - crash-like)"
9498
NULL, NULL, 1, 0, 2, 0);
9500
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
9501
PLUGIN_VAR_RQCMDARG,
9502
"File format to use for new tables in .ibd files.",
9503
innodb_file_format_name_validate,
9504
innodb_file_format_name_update, "Barracuda");
9506
/* "innobase_file_format_check" decides whether we would continue
9507
booting the server if the file format stamped on the system
9508
table space exceeds the maximum file format supported
9509
by the server. Can be set during server startup at command
9510
line or configure file, and a read only variable after
9513
/* If a new file format is introduced, the file format
9514
name needs to be updated accordingly. Please refer to
9515
file_format_name_map[] defined in trx0sys.c for the next
9516
file format name. */
9517
static DRIZZLE_SYSVAR_STR(file_format_max, innobase_file_format_max,
9518
PLUGIN_VAR_OPCMDARG,
9519
"The highest file format in the tablespace.",
9520
innodb_file_format_max_validate,
9521
innodb_file_format_max_update,
9524
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
9525
PLUGIN_VAR_OPCMDARG,
9526
"Set to 0 (write and flush once per second),"
9527
" 1 (write and flush at each commit)"
9528
" or 2 (write at commit, flush once per second).",
9529
NULL, NULL, 1, 0, 2, 0);
9531
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
9532
PLUGIN_VAR_RQCMDARG,
9533
"Percentage of dirty pages allowed in bufferpool.",
9534
NULL, NULL, 75, 0, 99, 0);
9536
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
9537
PLUGIN_VAR_RQCMDARG,
9538
"Desired maximum length of the purge queue (0 = no limit)",
9539
NULL, NULL, 0, 0, ~0L, 0);
9541
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
9542
PLUGIN_VAR_RQCMDARG,
9543
"The number of index pages to sample when calculating statistics (default 8)",
9544
NULL, NULL, 8, 1, ~0ULL, 0);
9546
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
9547
PLUGIN_VAR_OPCMDARG,
9548
"Enable InnoDB adaptive hash index (enabled by default).",
9549
NULL, innodb_adaptive_hash_index_update, TRUE);
9551
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
9552
PLUGIN_VAR_RQCMDARG,
9553
"Replication thread delay (ms) on the slave server if "
9554
"innodb_thread_concurrency is reached (0 by default)",
9555
NULL, NULL, 0, 0, ~0UL, 0);
9557
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
9558
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9559
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
9560
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
9562
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
9563
PLUGIN_VAR_RQCMDARG,
9564
"Data file autoextend increment in megabytes",
9565
NULL, NULL, 8L, 1L, 1000L, 0);
9567
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
9568
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9569
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
9570
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
9572
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_instances, innobase_buffer_pool_instances,
9573
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9574
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability",
9575
NULL, NULL, 1L, 1L, MAX_BUFFER_POOLS, 1L);
9577
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
9578
PLUGIN_VAR_RQCMDARG,
9579
"Helps in performance tuning in heavily concurrent environments.",
9580
innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
9582
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
9583
PLUGIN_VAR_RQCMDARG,
9584
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
9585
NULL, NULL, 500L, 1L, ~0L, 0);
9587
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
9588
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9589
"Number of background read I/O threads in InnoDB.",
9590
NULL, NULL, 4, 1, 64, 0);
9592
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
9593
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9594
"Number of background write I/O threads in InnoDB.",
9595
NULL, NULL, 4, 1, 64, 0);
9597
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
9598
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9599
"Helps to save your data in case the disk image of the database becomes corrupt.",
9600
NULL, NULL, 0, 0, 6, 0);
9602
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
9603
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9604
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
9605
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
9607
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
9608
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9609
"Size of each log file in a log group.",
9610
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
9612
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
9613
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9614
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
9615
NULL, NULL, 2, 2, 100, 0);
9617
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
9618
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9619
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
9620
NULL, NULL, 1, 1, 10, 0);
9622
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
9623
PLUGIN_VAR_RQCMDARG,
9624
"Percentage of the buffer pool to reserve for 'old' blocks.",
9625
NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
9627
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
9628
PLUGIN_VAR_RQCMDARG,
9629
"Move blocks to the 'new' end of the buffer pool if the first access"
9630
" was at least this many milliseconds ago."
9631
" The timeout is disabled if 0 (the default).",
9632
NULL, NULL, 0, 0, UINT32_MAX, 0);
9634
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
9635
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9636
"How many files at the maximum InnoDB keeps open at the same time.",
9637
NULL, NULL, 300L, 10L, LONG_MAX, 0);
9639
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
9640
PLUGIN_VAR_RQCMDARG,
9641
"Count of spin-loop rounds in InnoDB mutexes (30 by default)",
9642
NULL, NULL, 30L, 0L, ~0L, 0);
9644
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
9645
PLUGIN_VAR_OPCMDARG,
9646
"Maximum delay between polling for a spin lock (6 by default)",
9647
NULL, NULL, 6L, 0L, ~0L, 0);
9649
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
9650
PLUGIN_VAR_RQCMDARG,
9651
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
9652
NULL, NULL, 0, 0, 1000, 0);
9654
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
9655
PLUGIN_VAR_RQCMDARG,
9656
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
9657
NULL, NULL, 10000L, 0L, ~0L, 0);
9659
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
9660
PLUGIN_VAR_RQCMDARG,
9661
"Buffer changes to reduce random access: "
9662
"OFF, ON, inserting, deleting, changing or purging..",
9663
innodb_change_buffering_validate,
9664
innodb_change_buffering_update, "all");
9666
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
9667
PLUGIN_VAR_RQCMDARG,
9668
"Number of pages that must be accessed sequentially for InnoDB to "
9669
"trigger a readahead.",
9670
NULL, NULL, 56, 0, 64, 0);
9672
9211
static void init_options(drizzled::module::option_context &context)
9734
9265
context("disable-stats-on-metadata",
9735
9266
"Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9736
9267
context("stats-sample-pages",
9737
po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9268
po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9738
9269
"The number of index pages to sample when calculating statistics (default 8)");
9739
9270
context("disable-adaptive-hash-index",
9740
9271
"Enable InnoDB adaptive hash index (enabled by default)");
9741
9272
context("replication-delay",
9742
po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9273
po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
9743
9274
"Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9744
9275
context("additional-mem-pool-size",
9745
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9276
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9746
9277
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9747
9278
context("autoextend-increment",
9748
po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9279
po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
9749
9280
"Data file autoextend increment in megabytes");
9750
9281
context("buffer-pool-size",
9751
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9282
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9752
9283
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9753
9284
context("buffer-pool-instances",
9754
po::value<int64_t>(&innobase_buffer_pool_instances)->default_value(1),
9285
po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9755
9286
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9757
9288
context("commit-concurrency",
9758
po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9289
po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
9759
9290
"Helps in performance tuning in heavily concurrent environments.");
9760
9291
context("concurrency-tickets",
9761
po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9292
po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
9762
9293
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9763
9294
context("read-io-threads",
9764
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9295
po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
9765
9296
"Number of background read I/O threads in InnoDB.");
9766
9297
context("write-io-threads",
9767
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9298
po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
9768
9299
"Number of background write I/O threads in InnoDB.");
9769
9300
context("force-recovery",
9770
po::value<long>(&innobase_force_recovery)->default_value(0),
9301
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
9771
9302
"Helps to save your data in case the disk image of the database becomes corrupt.");
9772
9303
context("log-buffer-size",
9773
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9304
po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9774
9305
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9775
9306
context("log-file-size",
9776
po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9307
po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9777
9308
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9778
9309
context("log-files-in-group",
9779
po::value<long>(&innobase_log_files_in_group)->default_value(2),
9310
po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
9780
9311
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9781
9312
context("mirrored-log-groups",
9782
po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9313
po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
9783
9314
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9784
9315
context("open-files",
9785
po::value<long>(&innobase_open_files)->default_value(300L),
9316
po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
9786
9317
"How many files at the maximum InnoDB keeps open at the same time.");
9787
9318
context("sync-spin-loops",
9788
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9319
po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
9789
9320
"Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9790
9321
context("spin-wait-delay",
9791
po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9322
po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
9792
9323
"Maximum delay between polling for a spin lock (6 by default)");
9793
9324
context("thread-concurrency",
9794
po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9325
po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
9795
9326
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9796
9327
context("thread-sleep-delay",
9797
po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9328
po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
9798
9329
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9799
9330
context("data-file-path",
9800
9331
po::value<string>(),