179
179
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
180
180
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
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;
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;
227
199
/** Percentage of the buffer pool to reserve for 'old' blocks.
228
200
Connected to buf_LRU_old_ratio. */
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;
201
static uint innobase_old_blocks_pct;
239
203
/* The default values for the following char* start-up parameters
240
204
are determined in innobase_init below: */
1839
1824
value= value - (value % align_val);
1842
static void auto_extend_update(Session *, sql_var_t)
1844
srv_auto_extend_increment= innodb_auto_extend_increment.get();
1847
static void io_capacity_update(Session *, sql_var_t)
1849
srv_io_capacity= innodb_io_capacity.get();
1852
static void purge_batch_update(Session *, sql_var_t)
1854
srv_purge_batch_size= innodb_purge_batch_size.get();
1857
static void purge_threads_update(Session *, sql_var_t)
1859
srv_n_purge_threads= innodb_n_purge_threads.get();
1862
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
1864
if (btr_search_enabled)
1866
btr_search_enable();
1868
btr_search_disable();
1872
static void innodb_old_blocks_pct_update(Session *, sql_var_t)
1874
innobase_old_blocks_pct= buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(), TRUE);
1877
static void innodb_thread_concurrency_update(Session *, sql_var_t)
1879
srv_thread_concurrency= innobase_thread_concurrency.get();
1882
static void innodb_sync_spin_loops_update(Session *, sql_var_t)
1884
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1887
static void innodb_spin_wait_delay_update(Session *, sql_var_t)
1889
srv_spin_wait_delay= innodb_spin_wait_delay.get();
1892
static void innodb_thread_sleep_delay_update(Session *, sql_var_t)
1894
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1897
static void innodb_read_ahead_threshold_update(Session *, sql_var_t)
1899
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1903
static int innodb_commit_concurrency_validate(Session *session, set_var *var)
1905
uint32_t new_value= var->save_result.uint32_t_value;
1907
if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
1908
(innobase_commit_concurrency.get() != 0 && new_value == 0))
1910
push_warning_printf(session,
1911
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1913
_("Once InnoDB is running, innodb_commit_concurrency "
1914
"must not change between zero and nonzero."));
1920
/*************************************************************//**
1921
Check if it is a valid file format. This function is registered as
1922
a callback with MySQL.
1923
@return 0 for valid file format */
1926
innodb_file_format_name_validate(
1927
/*=============================*/
1928
Session* , /*!< in: thread handle */
1931
const char *file_format_input = var->value->str_value.ptr();
1932
if (file_format_input == NULL)
1935
if (file_format_input != NULL) {
1938
format_id = innobase_file_format_name_lookup(
1941
if (format_id <= DICT_TF_FORMAT_MAX) {
1942
innobase_file_format_name =
1943
trx_sys_file_format_id_to_name(format_id);
1952
/*************************************************************//**
1953
Check if it is a valid value of innodb_change_buffering. This function is
1954
registered as a callback with MySQL.
1955
@return 0 for valid innodb_change_buffering */
1958
innodb_change_buffering_validate(
1959
/*=============================*/
1960
Session* , /*!< in: thread handle */
1963
const char *change_buffering_input = var->value->str_value.ptr();
1965
if (change_buffering_input == NULL)
1971
use < UT_ARR_SIZE(innobase_change_buffering_values);
1973
if (!innobase_strcasecmp(change_buffering_input,
1974
innobase_change_buffering_values[use]))
1976
ibuf_use= static_cast<ibuf_use_t>(use);
1985
/*************************************************************//**
1986
Check if valid argument to innodb_file_format_max. This function
1987
is registered as a callback with MySQL.
1988
@return 0 for valid file format */
1991
innodb_file_format_max_validate(
1992
/*==============================*/
1993
Session* session, /*!< in: thread handle */
1996
const char *file_format_input = var->value->str_value.ptr();
1997
if (file_format_input == NULL)
2000
if (file_format_input != NULL) {
2001
int format_id = innobase_file_format_validate_and_set(file_format_input);
2003
if (format_id > DICT_TF_FORMAT_MAX) {
2004
/* DEFAULT is "on", which is invalid at runtime. */
2008
if (format_id >= 0) {
2009
innobase_file_format_max=
2010
trx_sys_file_format_id_to_name((uint)format_id);
2012
/* Update the max format id in the system tablespace. */
2013
char name_buff[100];
2014
strcpy(name_buff, innobase_file_format_max.c_str());
2015
if (trx_sys_file_format_max_set(format_id, (const char **)&name_buff))
2017
errmsg_printf(ERRMSG_LVL_WARN,
2018
" [Info] InnoDB: the file format in the system "
2019
"tablespace is now set to %s.\n", name_buff);
2020
innobase_file_format_max= name_buff;
2025
push_warning_printf(session,
2026
DRIZZLE_ERROR::WARN_LEVEL_WARN,
2028
"InnoDB: invalid innodb_file_format_max "
2029
"value; can be any format up to %s "
2030
"or equivalent id of %d",
2031
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
2032
DICT_TF_FORMAT_MAX);
2040
1827
/*********************************************************************//**
2041
1828
Opens an InnoDB database.
2042
1829
@return 0 on success, error code on failure */
2088
1865
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"));
2092
2066
if (vm.count("data-file-path"))
2094
2068
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"));
2098
2082
innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2405
2451
context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2406
2452
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 */
2408
2457
context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2409
2458
context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
2410
context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
2412
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
2413
context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
2414
innodb_auto_extend_increment,
2415
auto_extend_update));
2416
context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
2418
io_capacity_update));
2419
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
2420
innodb_purge_batch_size,
2421
purge_batch_update));
2422
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
2423
innodb_n_purge_threads,
2424
purge_threads_update));
2425
context.registerVariable(new sys_var_constrained_value<uint16_t>("fast_shutdown", innobase_fast_shutdown));
2426
context.registerVariable(new sys_var_std_string("file_format",
2427
innobase_file_format_name,
2428
innodb_file_format_name_validate));
2429
context.registerVariable(new sys_var_std_string("change_buffering",
2430
innobase_change_buffering,
2431
innodb_change_buffering_validate));
2432
context.registerVariable(new sys_var_std_string("file_format_max",
2433
innobase_file_format_max,
2434
innodb_file_format_max_validate));
2435
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
2436
context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
2437
context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit",
2438
innodb_flush_log_at_trx_commit));
2439
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
2440
innodb_max_dirty_pages_pct));
2441
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
2442
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
2443
context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
2445
context.registerVariable(new sys_var_constrained_value<uint32_t>("commit_concurrency",
2446
innobase_commit_concurrency,
2447
innodb_commit_concurrency_validate));
2448
context.registerVariable(new sys_var_constrained_value<uint32_t>("concurrency_tickets",
2449
innodb_concurrency_tickets));
2450
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_io_threads", innobase_read_io_threads));
2451
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_io_threads", innobase_write_io_threads));
2452
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("replication_delay", innodb_replication_delay));
2453
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
2454
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("log_buffer_size", innobase_log_buffer_size));
2455
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("log_files_in_group", innobase_log_files_in_group));
2456
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("mirrored_log_groups", innobase_mirrored_log_groups));
2457
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", innobase_open_files));
2458
context.registerVariable(new sys_var_constrained_value<uint32_t>("old_blocks_pct",
2459
innobase_old_blocks_pct,
2460
innodb_old_blocks_pct_update));
2461
context.registerVariable(new sys_var_uint32_t_ptr("old_blocks_time", &buf_LRU_old_threshold_ms));
2462
context.registerVariable(new sys_var_constrained_value<uint32_t>("sync_spin_loops", innodb_sync_spin_loops, innodb_sync_spin_loops_update));
2463
context.registerVariable(new sys_var_constrained_value<uint32_t>("spin_wait_delay", innodb_spin_wait_delay, innodb_spin_wait_delay_update));
2464
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_sleep_delay", innodb_thread_sleep_delay, innodb_thread_sleep_delay_update));
2465
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_concurrency",
2466
innobase_thread_concurrency,
2467
innodb_thread_concurrency_update));
2468
context.registerVariable(new sys_var_constrained_value<uint32_t>("read_ahead_threshold",
2469
innodb_read_ahead_threshold,
2470
innodb_read_ahead_threshold_update));
2459
context.registerVariable(new sys_var_constrained_value<uint32_t>("lock-wait-timeout", lock_wait_timeout));
2471
2461
/* Get the current high water mark format. */
2472
innobase_file_format_max = trx_sys_file_format_max_get();
2462
innobase_file_format_max = (char*) trx_sys_file_format_max_get();
2473
2463
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);
9209
9672
static void init_options(drizzled::module::option_context &context)
9263
9734
context("disable-stats-on-metadata",
9264
9735
"Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9265
9736
context("stats-sample-pages",
9266
po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9737
po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9267
9738
"The number of index pages to sample when calculating statistics (default 8)");
9268
9739
context("disable-adaptive-hash-index",
9269
9740
"Enable InnoDB adaptive hash index (enabled by default)");
9270
9741
context("replication-delay",
9271
po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
9742
po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9272
9743
"Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9273
9744
context("additional-mem-pool-size",
9274
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9745
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9275
9746
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9276
9747
context("autoextend-increment",
9277
po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
9748
po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9278
9749
"Data file autoextend increment in megabytes");
9279
9750
context("buffer-pool-size",
9280
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9751
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9281
9752
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9282
9753
context("buffer-pool-instances",
9283
po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9754
po::value<int64_t>(&innobase_buffer_pool_instances)->default_value(1),
9284
9755
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9286
9757
context("commit-concurrency",
9287
po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
9758
po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9288
9759
"Helps in performance tuning in heavily concurrent environments.");
9289
9760
context("concurrency-tickets",
9290
po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
9761
po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9291
9762
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9292
9763
context("read-io-threads",
9293
po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
9764
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9294
9765
"Number of background read I/O threads in InnoDB.");
9295
9766
context("write-io-threads",
9296
po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
9767
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9297
9768
"Number of background write I/O threads in InnoDB.");
9298
9769
context("force-recovery",
9299
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
9770
po::value<long>(&innobase_force_recovery)->default_value(0),
9300
9771
"Helps to save your data in case the disk image of the database becomes corrupt.");
9301
9772
context("log-buffer-size",
9302
po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9773
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9303
9774
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9304
9775
context("log-file-size",
9305
po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9776
po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9306
9777
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9307
9778
context("log-files-in-group",
9308
po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
9779
po::value<long>(&innobase_log_files_in_group)->default_value(2),
9309
9780
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9310
9781
context("mirrored-log-groups",
9311
po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
9782
po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9312
9783
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9313
9784
context("open-files",
9314
po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
9785
po::value<long>(&innobase_open_files)->default_value(300L),
9315
9786
"How many files at the maximum InnoDB keeps open at the same time.");
9316
9787
context("sync-spin-loops",
9317
po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
9788
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9318
9789
"Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9319
9790
context("spin-wait-delay",
9320
po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
9791
po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9321
9792
"Maximum delay between polling for a spin lock (6 by default)");
9322
9793
context("thread-concurrency",
9323
po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
9794
po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9324
9795
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9325
9796
context("thread-sleep-delay",
9326
po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
9797
po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9327
9798
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9328
9799
context("data-file-path",
9329
9800
po::value<string>(),