180
160
#endif /* MYSQL_DYNAMIC_PLUGIN && __WIN__ */
182
162
static plugin::XaStorageEngine* innodb_engine_ptr= NULL;
183
static plugin::TableFunction* status_table_function_ptr= NULL;
184
static plugin::TableFunction* cmp_tool= NULL;
185
static plugin::TableFunction* cmp_reset_tool= NULL;
186
static plugin::TableFunction* cmp_mem_tool= NULL;
187
static plugin::TableFunction* cmp_mem_reset_tool= NULL;
188
static plugin::TableFunction* innodb_trx_tool= NULL;
189
static plugin::TableFunction* innodb_locks_tool= NULL;
190
static plugin::TableFunction* innodb_lock_waits_tool= NULL;
192
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
193
innobase_log_buffer_size,
194
innobase_force_recovery, innobase_open_files;
195
static long innobase_additional_mem_pool_size= 8*1024*1024L;
196
static ulong innobase_commit_concurrency = 0;
197
static ulong innobase_read_io_threads;
198
static ulong innobase_write_io_threads;
201
* @TODO: Turn this into size_t as soon as we have a Variable<size_t>
203
static int64_t innobase_buffer_pool_size= 128*1024*1024;
204
static int64_t innobase_log_file_size;
164
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
165
static open_files_constraint innobase_open_files;
166
typedef constrained_check<uint32_t, 10, 1> mirrored_log_groups_constraint;
167
static mirrored_log_groups_constraint innobase_mirrored_log_groups;
168
typedef constrained_check<uint32_t, 100, 2> log_files_in_group_constraint;
169
static log_files_in_group_constraint innobase_log_files_in_group;
170
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
171
force_recovery_constraint innobase_force_recovery;
172
typedef constrained_check<size_t, SIZE_MAX, 256*1024, 1024> log_buffer_constraint;
173
static log_buffer_constraint innobase_log_buffer_size;
174
typedef constrained_check<size_t, SIZE_MAX, 512*1024, 1024> additional_mem_pool_constraint;
175
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
176
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
177
static autoextend_constraint innodb_auto_extend_increment;
178
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
179
static buffer_pool_constraint innobase_buffer_pool_size;
180
typedef constrained_check<uint32_t, MAX_BUFFER_POOLS, 1> buffer_pool_instances_constraint;
181
static buffer_pool_instances_constraint innobase_buffer_pool_instances;
182
typedef constrained_check<uint32_t, UINT32_MAX, 100> io_capacity_constraint;
183
static io_capacity_constraint innodb_io_capacity;
184
typedef constrained_check<uint32_t, 5000, 1> purge_batch_constraint;
185
static purge_batch_constraint innodb_purge_batch_size;
186
typedef constrained_check<uint32_t, 1, 0> purge_threads_constraint;
187
static purge_threads_constraint innodb_n_purge_threads;
188
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
189
static trinary_constraint innodb_flush_log_at_trx_commit;
190
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
191
static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
192
static uint64_constraint innodb_max_purge_lag;
193
static uint64_nonzero_constraint innodb_stats_sample_pages;
194
typedef constrained_check<uint32_t, 64, 1> io_threads_constraint;
195
static io_threads_constraint innobase_read_io_threads;
196
static io_threads_constraint innobase_write_io_threads;
198
typedef constrained_check<uint32_t, 1000, 0> concurrency_constraint;
199
static concurrency_constraint innobase_commit_concurrency;
200
static concurrency_constraint innobase_thread_concurrency;
201
static uint32_nonzero_constraint innodb_concurrency_tickets;
203
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
204
static log_file_constraint innobase_log_file_size;
206
static uint64_constraint innodb_replication_delay;
206
208
/** Percentage of the buffer pool to reserve for 'old' blocks.
207
209
Connected to buf_LRU_old_ratio. */
208
static uint innobase_old_blocks_pct;
210
typedef constrained_check<uint32_t, 95, 5> old_blocks_constraint;
211
static old_blocks_constraint innobase_old_blocks_pct;
213
static uint32_constraint innodb_sync_spin_loops;
214
static uint32_constraint innodb_spin_wait_delay;
215
static uint32_constraint innodb_thread_sleep_delay;
217
typedef constrained_check<uint32_t, 64, 0> read_ahead_threshold_constraint;
218
static read_ahead_threshold_constraint innodb_read_ahead_threshold;
210
220
/* The default values for the following char* start-up parameters
211
221
are determined in innobase_init below: */
213
static char* innobase_data_home_dir = NULL;
214
static char* innobase_data_file_path = NULL;
215
static char* innobase_log_group_home_dir = NULL;
216
static char* innobase_file_format_name = NULL;
217
static char* innobase_change_buffering = NULL;
219
/* Note: This variable can be set to on/off and any of the supported
220
file formats in the configuration file, but can only be set to any
221
of the supported file formats during runtime. */
222
static char* innobase_file_format_check = NULL;
224
static char* innobase_file_flush_method = NULL;
223
std::string innobase_data_home_dir;
224
std::string innobase_data_file_path;
225
std::string innobase_log_group_home_dir;
226
static string innobase_file_format_name;
227
static string innobase_change_buffering;
229
/* The highest file format being used in the database. The value can be
230
set by user, however, it will be adjusted to the newer file format if
231
a table of such format is created/opened. */
232
static string innobase_file_format_max;
226
234
/* Below we have boolean-valued start-up parameters, and their default
229
static ulong innobase_fast_shutdown = 1;
230
#ifdef UNIV_LOG_ARCHIVE
231
static my_bool innobase_log_archive = FALSE;
232
static char* innobase_log_arch_dir = NULL;
233
#endif /* UNIV_LOG_ARCHIVE */
237
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
238
static trinary_constraint innobase_fast_shutdown;
240
/* "innobase_file_format_check" decides whether we would continue
241
booting the server if the file format stamped on the system
242
table space exceeds the maximum file format supported
243
by the server. Can be set during server startup at command
244
line or configure file, and a read only variable after
247
/* If a new file format is introduced, the file format
248
name needs to be updated accordingly. Please refer to
249
file_format_name_map[] defined in trx0sys.c for the next
252
static my_bool innobase_file_format_check = TRUE;
234
253
static my_bool innobase_use_doublewrite = TRUE;
235
254
static my_bool innobase_use_checksums = TRUE;
236
255
static my_bool innobase_rollback_on_timeout = FALSE;
237
256
static my_bool innobase_create_status_file = FALSE;
257
static bool innobase_use_replication_log;
258
static bool support_xa;
259
static bool strict_mode;
260
typedef constrained_check<uint32_t, 1024*1024*1024, 1> lock_wait_constraint;
261
static lock_wait_constraint lock_wait_timeout;
239
263
static char* internal_innobase_data_file_path = NULL;
241
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
243
265
/* The following counter is used to convey information to InnoDB
244
266
about server activity: in selects it is not sensible to call
245
267
srv_active_wake_master_thread after each fetch or search, we only do
1827
1806
value= value - (value % align_val);
1809
static void auto_extend_update(Session *, sql_var_t)
1811
srv_auto_extend_increment= innodb_auto_extend_increment.get();
1814
static void io_capacity_update(Session *, sql_var_t)
1816
srv_io_capacity= innodb_io_capacity.get();
1819
static void purge_batch_update(Session *, sql_var_t)
1821
srv_purge_batch_size= innodb_purge_batch_size.get();
1824
static void purge_threads_update(Session *, sql_var_t)
1826
srv_n_purge_threads= innodb_n_purge_threads.get();
1829
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
1831
if (btr_search_enabled)
1833
btr_search_enable();
1835
btr_search_disable();
1839
static void innodb_old_blocks_pct_update(Session *, sql_var_t)
1841
innobase_old_blocks_pct= buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(), TRUE);
1844
static void innodb_thread_concurrency_update(Session *, sql_var_t)
1846
srv_thread_concurrency= innobase_thread_concurrency.get();
1849
static void innodb_sync_spin_loops_update(Session *, sql_var_t)
1851
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1854
static void innodb_spin_wait_delay_update(Session *, sql_var_t)
1856
srv_spin_wait_delay= innodb_spin_wait_delay.get();
1859
static void innodb_thread_sleep_delay_update(Session *, sql_var_t)
1861
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1864
static void innodb_read_ahead_threshold_update(Session *, sql_var_t)
1866
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1870
static int innodb_commit_concurrency_validate(Session *session, set_var *var)
1872
uint64_t new_value= var->getInteger();
1874
if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
1875
(innobase_commit_concurrency.get() != 0 && new_value == 0))
1877
push_warning_printf(session,
1878
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1880
_("Once InnoDB is running, innodb_commit_concurrency "
1881
"must not change between zero and nonzero."));
1887
/*************************************************************//**
1888
Check if it is a valid file format. This function is registered as
1889
a callback with MySQL.
1890
@return 0 for valid file format */
1893
innodb_file_format_name_validate(
1894
/*=============================*/
1895
Session* , /*!< in: thread handle */
1898
const char *file_format_input = var->value->str_value.ptr();
1899
if (file_format_input == NULL)
1902
if (file_format_input != NULL) {
1905
format_id = innobase_file_format_name_lookup(
1908
if (format_id <= DICT_TF_FORMAT_MAX) {
1909
innobase_file_format_name =
1910
trx_sys_file_format_id_to_name(format_id);
1919
/*************************************************************//**
1920
Check if it is a valid value of innodb_change_buffering. This function is
1921
registered as a callback with MySQL.
1922
@return 0 for valid innodb_change_buffering */
1925
innodb_change_buffering_validate(
1926
/*=============================*/
1927
Session* , /*!< in: thread handle */
1930
const char *change_buffering_input = var->value->str_value.ptr();
1932
if (change_buffering_input == NULL)
1938
use < UT_ARR_SIZE(innobase_change_buffering_values);
1940
if (!innobase_strcasecmp(change_buffering_input,
1941
innobase_change_buffering_values[use]))
1943
ibuf_use= static_cast<ibuf_use_t>(use);
1952
/*************************************************************//**
1953
Check if valid argument to innodb_file_format_max. This function
1954
is registered as a callback with MySQL.
1955
@return 0 for valid file format */
1958
innodb_file_format_max_validate(
1959
/*==============================*/
1960
Session* session, /*!< in: thread handle */
1963
const char *file_format_input = var->value->str_value.ptr();
1964
if (file_format_input == NULL)
1967
if (file_format_input != NULL) {
1968
int format_id = innobase_file_format_validate_and_set(file_format_input);
1970
if (format_id > DICT_TF_FORMAT_MAX) {
1971
/* DEFAULT is "on", which is invalid at runtime. */
1975
if (format_id >= 0) {
1976
innobase_file_format_max.assign(
1977
trx_sys_file_format_id_to_name((uint)format_id));
1979
/* Update the max format id in the system tablespace. */
1980
const char *name_buff;
1982
if (trx_sys_file_format_max_set(format_id, &name_buff))
1984
errmsg_printf(error::WARN,
1985
" [Info] InnoDB: the file format in the system "
1986
"tablespace is now set to %s.\n", name_buff);
1987
innobase_file_format_max= name_buff;
1992
push_warning_printf(session,
1993
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1995
"InnoDB: invalid innodb_file_format_max "
1996
"value; can be any format up to %s "
1997
"or equivalent id of %d",
1998
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
1999
DICT_TF_FORMAT_MAX);
1830
2007
/*********************************************************************//**
1831
2008
Opens an InnoDB database.
1832
2009
@return 0 on success, error code on failure */
1842
2019
InnobaseEngine *actuall_engine_ptr;
1843
2020
const module::option_map &vm= context.getOptions();
2022
srv_auto_extend_increment= innodb_auto_extend_increment.get();
2023
srv_io_capacity= innodb_io_capacity.get();
2024
srv_purge_batch_size= innodb_purge_batch_size.get();
2025
srv_n_purge_threads= innodb_n_purge_threads.get();
2026
srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
2027
srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
2028
srv_max_purge_lag= innodb_max_purge_lag.get();
2029
srv_stats_sample_pages= innodb_stats_sample_pages.get();
2030
srv_n_free_tickets_to_enter= innodb_concurrency_tickets.get();
2031
srv_replication_delay= innodb_replication_delay.get();
2032
srv_thread_concurrency= innobase_thread_concurrency.get();
2033
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
2034
srv_spin_wait_delay= innodb_spin_wait_delay.get();
2035
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
2036
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1845
2038
/* Inverted Booleans */
1847
2040
innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
1848
2041
innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
1849
2042
srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
1850
2043
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
1851
(SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
1852
(SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
1854
if (vm.count("io-capacity"))
1856
if (srv_io_capacity < 100)
1858
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
2044
srv_use_native_aio= (vm.count("disable-native-aio")) ? false : true;
2045
support_xa= (vm.count("disable-xa")) ? false : true;
2046
btr_search_enabled= (vm.count("disable-adaptive-hash-index")) ? false : true;
2049
/* Hafta do this here because we need to late-bind the default value */
1863
2050
if (vm.count("data-home-dir"))
1865
innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
1869
innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
1872
if (vm.count("fast-shutdown"))
1874
if (innobase_fast_shutdown > 2)
1876
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
1881
if (vm.count("file-format-check"))
1883
innobase_file_format_check= const_cast<char *>(vm["file-format-check"].as<string>().c_str());
1886
if (vm.count("flush-log-at-trx-commit"))
1888
if (srv_flush_log_at_trx_commit > 2)
1890
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
1895
if (vm.count("flush-method"))
1897
innobase_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
1901
innobase_file_flush_method= NULL;
1904
#ifdef UNIV_LOG_ARCHIVE
1905
if (vm.count("log-arch-dir"))
1907
innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
1912
innobase_log_arch_dir= NULL;
1914
#endif /* UNIV_LOG_ARCHIVE */
1916
if (vm.count("max-dirty-pages-pct"))
1918
if (srv_max_buf_pool_modified_pct > 99)
1920
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
1925
if (vm.count("stats-sample-pages"))
1927
if (srv_stats_sample_pages < 8)
1929
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
1934
if (vm.count("additional-mem-pool-size"))
1936
align_value(innobase_additional_mem_pool_size);
1938
if (innobase_additional_mem_pool_size < 512*1024L)
1940
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
1946
if (vm.count("autoextend-increment"))
1948
if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
1950
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
1955
if (vm.count("buffer-pool-size"))
1957
align_value(innobase_buffer_pool_size, 1024*1024);
1958
if (innobase_buffer_pool_size < 5*1024*1024)
1960
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
1966
if (vm.count("commit-concurrency"))
1968
if (srv_replication_delay > 1000)
1970
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
1975
if (vm.count("concurrency-tickets"))
1977
if (srv_n_free_tickets_to_enter < 1)
1979
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
1984
if (vm.count("read-io-threads"))
1986
if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
1988
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
1993
if (vm.count("write-io-threads"))
1995
if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
1997
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
2002
if (vm.count("force-recovery"))
2004
if (innobase_force_recovery > 6)
2006
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
2011
if (vm.count("log-buffer-size"))
2013
align_value(innobase_log_buffer_size);
2014
if (innobase_log_buffer_size < 256*1024L)
2016
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2021
if (vm.count("log-file-size"))
2023
align_value(innobase_log_file_size, 1024*1024);
2024
if (innobase_log_file_size < 1*1024*1024L)
2026
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2031
if (vm.count("log-files-in-group"))
2033
if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
2035
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
2040
if (vm.count("mirrored-log-groups"))
2042
if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
2044
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
2049
if (vm.count("open-files"))
2051
if (innobase_open_files < 10)
2053
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
2058
if (vm.count("thread-concurrency"))
2060
if (srv_thread_concurrency > 1000)
2062
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
2052
innobase_data_home_dir= vm["data-home-dir"].as<string>();
2056
innobase_data_home_dir= getDataHome().file_string();
2067
2060
if (vm.count("data-file-path"))
2069
innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
2073
innobase_data_file_path= NULL;
2076
if (vm.count("version"))
2078
innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
2081
if (vm.count("read-ahead-threshold"))
2083
if (srv_read_ahead_threshold > 64)
2085
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
2090
if (vm.count("strict-mode"))
2092
(SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
2095
if (vm.count("lock-wait-timeout"))
2097
if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
2099
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
2103
(SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
2062
innobase_data_file_path= vm["data-file-path"].as<string>();
2106
2066
innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2351
2269
err = innobase_start_or_create_for_mysql();
2271
if (err != DB_SUCCESS)
2273
goto mem_free_and_error;
2276
err = dict_create_sys_replication_log();
2353
2278
if (err != DB_SUCCESS) {
2354
2279
goto mem_free_and_error;
2283
innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(),
2357
2286
innobase_open_tables = hash_create(200);
2358
pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
2359
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
2360
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
2361
pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
2362
pthread_mutex_init(&analyze_mutex, MY_MUTEX_INIT_FAST);
2363
pthread_cond_init(&commit_cond, NULL);
2364
2287
innodb_inited= 1;
2366
2289
actuall_engine_ptr->dropTemporarySchema();
2368
status_table_function_ptr= new InnodbStatusTool;
2291
context.add(new InnodbStatusTool);
2370
2293
context.add(innodb_engine_ptr);
2372
context.add(status_table_function_ptr);
2374
cmp_tool= new(std::nothrow)CmpTool(false);
2375
context.add(cmp_tool);
2377
cmp_reset_tool= new(std::nothrow)CmpTool(true);
2378
context.add(cmp_reset_tool);
2380
cmp_mem_tool= new(std::nothrow)CmpmemTool(false);
2381
context.add(cmp_mem_tool);
2383
cmp_mem_reset_tool= new(std::nothrow)CmpmemTool(true);
2384
context.add(cmp_mem_reset_tool);
2386
innodb_trx_tool= new(std::nothrow)InnodbTrxTool("INNODB_TRX");
2387
context.add(innodb_trx_tool);
2389
innodb_locks_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCKS");
2390
context.add(innodb_locks_tool);
2392
innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
2393
context.add(innodb_lock_waits_tool);
2295
context.add(new(std::nothrow)CmpTool(false));
2297
context.add(new(std::nothrow)CmpTool(true));
2299
context.add(new(std::nothrow)CmpmemTool(false));
2301
context.add(new(std::nothrow)CmpmemTool(true));
2303
context.add(new(std::nothrow)InnodbTrxTool("INNODB_TRX"));
2305
context.add(new(std::nothrow)InnodbTrxTool("INNODB_LOCKS"));
2307
context.add(new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS"));
2309
context.add(new(std::nothrow)InnodbSysTablesTool());
2311
context.add(new(std::nothrow)InnodbSysTableStatsTool());
2313
context.add(new(std::nothrow)InnodbSysIndexesTool());
2315
context.add(new(std::nothrow)InnodbSysColumnsTool());
2317
context.add(new(std::nothrow)InnodbSysFieldsTool());
2319
context.add(new(std::nothrow)InnodbSysForeignTool());
2321
context.add(new(std::nothrow)InnodbSysForeignColsTool());
2395
2323
context.add(new(std::nothrow)InnodbInternalTables());
2324
context.add(new(std::nothrow)InnodbReplicationTable());
2326
if (innobase_use_replication_log)
2328
ReplicationLog *replication_logger= new(std::nothrow)ReplicationLog();
2329
context.add(replication_logger);
2330
ReplicationLog::setup(replication_logger);
2333
context.registerVariable(new sys_var_const_string_val("data-home-dir", innobase_data_home_dir));
2334
context.registerVariable(new sys_var_const_string_val("flush-method",
2335
vm.count("flush-method") ? vm["flush-method"].as<string>() : ""));
2336
context.registerVariable(new sys_var_const_string_val("log-group-home-dir", innobase_log_group_home_dir));
2337
context.registerVariable(new sys_var_const_string_val("data-file-path", innobase_data_file_path));
2338
context.registerVariable(new sys_var_const_string_val("version", vm["version"].as<string>()));
2341
context.registerVariable(new sys_var_bool_ptr_readonly("replication_log", &innobase_use_replication_log));
2342
context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
2343
context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
2344
context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
2345
context.registerVariable(new sys_var_bool_ptr_readonly("file-format-check", &innobase_file_format_check));
2346
context.registerVariable(new sys_var_bool_ptr("adaptive-flushing", &srv_adaptive_flushing));
2347
context.registerVariable(new sys_var_bool_ptr("status-file", &innobase_create_status_file));
2348
context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2349
context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2351
context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2352
context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
2353
context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
2355
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
2356
context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
2357
innodb_auto_extend_increment,
2358
auto_extend_update));
2359
context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
2361
io_capacity_update));
2362
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
2363
innodb_purge_batch_size,
2364
purge_batch_update));
2365
context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
2366
innodb_n_purge_threads,
2367
purge_threads_update));
2368
context.registerVariable(new sys_var_constrained_value<uint32_t>("fast_shutdown", innobase_fast_shutdown));
2369
context.registerVariable(new sys_var_std_string("file_format",
2370
innobase_file_format_name,
2371
innodb_file_format_name_validate));
2372
context.registerVariable(new sys_var_std_string("change_buffering",
2373
innobase_change_buffering,
2374
innodb_change_buffering_validate));
2375
context.registerVariable(new sys_var_std_string("file_format_max",
2376
innobase_file_format_max,
2377
innodb_file_format_max_validate));
2378
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
2379
context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
2380
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("flush_log_at_trx_commit",
2381
innodb_flush_log_at_trx_commit));
2382
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
2383
innodb_max_dirty_pages_pct));
2384
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
2385
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
2386
context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
2388
context.registerVariable(new sys_var_constrained_value<uint32_t>("commit_concurrency",
2389
innobase_commit_concurrency,
2390
innodb_commit_concurrency_validate));
2391
context.registerVariable(new sys_var_constrained_value<uint32_t>("concurrency_tickets",
2392
innodb_concurrency_tickets));
2393
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_io_threads", innobase_read_io_threads));
2394
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_io_threads", innobase_write_io_threads));
2395
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("replication_delay", innodb_replication_delay));
2396
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
2397
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("log_buffer_size", innobase_log_buffer_size));
2398
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("log_files_in_group", innobase_log_files_in_group));
2399
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("mirrored_log_groups", innobase_mirrored_log_groups));
2400
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", innobase_open_files));
2401
context.registerVariable(new sys_var_constrained_value<uint32_t>("old_blocks_pct",
2402
innobase_old_blocks_pct,
2403
innodb_old_blocks_pct_update));
2404
context.registerVariable(new sys_var_uint32_t_ptr("old_blocks_time", &buf_LRU_old_threshold_ms));
2405
context.registerVariable(new sys_var_constrained_value<uint32_t>("sync_spin_loops", innodb_sync_spin_loops, innodb_sync_spin_loops_update));
2406
context.registerVariable(new sys_var_constrained_value<uint32_t>("spin_wait_delay", innodb_spin_wait_delay, innodb_spin_wait_delay_update));
2407
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_sleep_delay", innodb_thread_sleep_delay, innodb_thread_sleep_delay_update));
2408
context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_concurrency",
2409
innobase_thread_concurrency,
2410
innodb_thread_concurrency_update));
2411
context.registerVariable(new sys_var_constrained_value<uint32_t>("read_ahead_threshold",
2412
innodb_read_ahead_threshold,
2413
innodb_read_ahead_threshold_update));
2397
2414
/* Get the current high water mark format. */
2398
innobase_file_format_check = (char*) trx_sys_file_format_max_get();
2415
innobase_file_format_max = trx_sys_file_format_max_get();
2416
btr_search_fully_disabled = (!btr_search_enabled);
2866
/*****************************************************************//**
2867
Normalizes a table name string. A normalized name consists of the
2868
database name catenated to '/' and table name. An example:
2869
test/mytable. On Windows normalization puts both the database name and the
2870
table name always to lower case. */
2873
normalize_table_name(
2874
/*=================*/
2875
char* norm_name, /*!< out: normalized name as a
2876
null-terminated string */
2877
const char* name) /*!< in: table name string */
2879
const char* name_ptr;
2883
/* Scan name from the end */
2885
ptr = strchr(name, '\0')-1;
2887
while (ptr >= name && *ptr != '\\' && *ptr != '/') {
2897
while (ptr >= name && *ptr != '\\' && *ptr != '/') {
2903
memcpy(norm_name, db_ptr, strlen(name) + 1 - (db_ptr - name));
2905
norm_name[name_ptr - db_ptr - 1] = '/';
2908
innobase_casedn_str(norm_name);
2879
/********************************************************************//**
2880
Get the upper limit of the MySQL integral and floating-point type.
2881
@return maximum allowed value for the field */
2884
innobase_get_int_col_max_value(
2885
/*===========================*/
2886
const Field* field) /*!< in: MySQL field */
2888
uint64_t max_value = 0;
2890
switch(field->key_type()) {
2892
case HA_KEYTYPE_BINARY:
2893
max_value = 0xFFULL;
2896
case HA_KEYTYPE_ULONG_INT:
2897
max_value = 0xFFFFFFFFULL;
2899
case HA_KEYTYPE_LONG_INT:
2900
max_value = 0x7FFFFFFFULL;
2903
case HA_KEYTYPE_ULONGLONG:
2904
max_value = 0xFFFFFFFFFFFFFFFFULL;
2906
case HA_KEYTYPE_LONGLONG:
2907
max_value = 0x7FFFFFFFFFFFFFFFULL;
2909
case HA_KEYTYPE_DOUBLE:
2910
/* We use the maximum as per IEEE754-2008 standard, 2^53 */
2911
max_value = 0x20000000000000ULL;
2920
/*******************************************************************//**
2921
This function checks whether the index column information
2922
is consistent between KEY info from mysql and that from innodb index.
2923
@return TRUE if all column types match. */
2926
innobase_match_index_columns(
2927
/*=========================*/
2928
const KeyInfo* key_info, /*!< in: Index info
2930
const dict_index_t* index_info) /*!< in: Index info
2933
const KeyPartInfo* key_part;
2934
const KeyPartInfo* key_end;
2935
const dict_field_t* innodb_idx_fld;
2936
const dict_field_t* innodb_idx_fld_end;
2938
/* Check whether user defined index column count matches */
2939
if (key_info->key_parts != index_info->n_user_defined_cols) {
2943
key_part = key_info->key_part;
2944
key_end = key_part + key_info->key_parts;
2945
innodb_idx_fld = index_info->fields;
2946
innodb_idx_fld_end = index_info->fields + index_info->n_fields;
2948
/* Check each index column's datatype. We do not check
2949
column name because there exists case that index
2950
column name got modified in mysql but such change does not
2951
propagate to InnoDB.
2952
One hidden assumption here is that the index column sequences
2953
are matched up between those in mysql and Innodb. */
2954
for (; key_part != key_end; ++key_part) {
2957
ulint mtype = innodb_idx_fld->col->mtype;
2959
/* Need to translate to InnoDB column type before
2961
col_type = get_innobase_type_from_mysql_type(&is_unsigned,
2964
/* Ignore Innodb specific system columns. */
2965
while (mtype == DATA_SYS) {
2968
if (innodb_idx_fld >= innodb_idx_fld_end) {
2973
if (col_type != mtype) {
2974
/* Column Type mismatches */
2984
/*******************************************************************//**
2985
This function builds a translation table in INNOBASE_SHARE
2986
structure for fast index location with mysql array number from its
2987
table->key_info structure. This also provides the necessary translation
2988
between the key order in mysql key_info and Innodb ib_table->indexes if
2989
they are not fully matched with each other.
2990
Note we do not have any mutex protecting the translation table
2991
building based on the assumption that there is no concurrent
2992
index creation/drop and DMLs that requires index lookup. All table
2993
handle will be closed before the index creation/drop.
2994
@return TRUE if index translation table built successfully */
2997
innobase_build_index_translation(
2998
/*=============================*/
2999
const Table* table, /*!< in: table in MySQL data
3001
dict_table_t* ib_table, /*!< in: table in Innodb data
3003
INNOBASE_SHARE* share) /*!< in/out: share structure
3004
where index translation table
3005
will be constructed in. */
3007
ulint mysql_num_index;
3009
dict_index_t** index_mapping;
3012
mutex_enter(&dict_sys->mutex);
3014
mysql_num_index = table->getShare()->keys;
3015
ib_num_index = UT_LIST_GET_LEN(ib_table->indexes);
3017
index_mapping = share->idx_trans_tbl.index_mapping;
3019
/* If there exists inconsistency between MySQL and InnoDB dictionary
3020
(metadata) information, the number of index defined in MySQL
3021
could exceed that in InnoDB, do not build index translation
3022
table in such case */
3023
if (UNIV_UNLIKELY(ib_num_index < mysql_num_index)) {
3028
/* If index entry count is non-zero, nothing has
3029
changed since last update, directly return TRUE */
3030
if (share->idx_trans_tbl.index_count) {
3031
/* Index entry count should still match mysql_num_index */
3032
ut_a(share->idx_trans_tbl.index_count == mysql_num_index);
3036
/* The number of index increased, rebuild the mapping table */
3037
if (mysql_num_index > share->idx_trans_tbl.array_size) {
3038
index_mapping = (dict_index_t**) realloc(index_mapping,
3040
sizeof(*index_mapping));
3042
if (!index_mapping) {
3043
/* Report an error if index_mapping continues to be
3044
NULL and mysql_num_index is a non-zero value */
3045
errmsg_printf(error::ERROR, "InnoDB: fail to allocate memory for "
3046
"index translation table. Number of Index:%lu, array size:%lu",
3048
share->idx_trans_tbl.array_size);
3053
share->idx_trans_tbl.array_size = mysql_num_index;
3056
/* For each index in the mysql key_info array, fetch its
3057
corresponding InnoDB index pointer into index_mapping
3059
for (ulint count = 0; count < mysql_num_index; count++) {
3061
/* Fetch index pointers into index_mapping according to mysql
3063
index_mapping[count] = dict_table_get_index_on_name(
3064
ib_table, table->key_info[count].name);
3066
if (!index_mapping[count]) {
3067
errmsg_printf(error::ERROR, "Cannot find index %s in InnoDB index dictionary.",
3068
table->key_info[count].name);
3073
/* Double check fetched index has the same
3074
column info as those in mysql key_info. */
3075
if (!innobase_match_index_columns(&table->key_info[count], index_mapping[count])) {
3076
errmsg_printf(error::ERROR, "Found index %s whose column info does not match that of MySQL.",
3077
table->key_info[count].name);
3083
/* Successfully built the translation table */
3084
share->idx_trans_tbl.index_count = mysql_num_index;
3088
/* Build translation table failed. */
3089
free(index_mapping);
3091
share->idx_trans_tbl.array_size = 0;
3092
share->idx_trans_tbl.index_count = 0;
3093
index_mapping = NULL;
3096
share->idx_trans_tbl.index_mapping = index_mapping;
3098
mutex_exit(&dict_sys->mutex);
3103
/*******************************************************************//**
3104
This function uses index translation table to quickly locate the
3105
requested index structure.
3106
Note we do not have mutex protection for the index translatoin table
3107
access, it is based on the assumption that there is no concurrent
3108
translation table rebuild (fter create/drop index) and DMLs that
3109
require index lookup.
3110
@return dict_index_t structure for requested index. NULL if
3111
fail to locate the index structure. */
3114
innobase_index_lookup(
3115
/*==================*/
3116
INNOBASE_SHARE* share, /*!< in: share structure for index
3117
translation table. */
3118
uint keynr) /*!< in: index number for the requested
3121
if (!share->idx_trans_tbl.index_mapping
3122
|| keynr >= share->idx_trans_tbl.index_count) {
3126
return(share->idx_trans_tbl.index_mapping[keynr]);
2912
3129
/********************************************************************//**
2913
3130
Set the autoinc column max value. This should only be called once from
2914
ha_innobase::open(). Therefore there's no need for a covering lock.
2915
@return DB_SUCCESS or error code */
3131
ha_innobase::open(). Therefore there's no need for a covering lock. */
2918
3134
ha_innobase::innobase_initialize_autoinc()
2919
3135
/*======================================*/
2921
dict_index_t* index;
2922
3137
uint64_t auto_inc;
2923
const char* col_name;
2926
col_name = getTable()->found_next_number_field->field_name;
2927
index = innobase_get_index(getTable()->getShare()->next_number_index);
2929
/* Execute SELECT MAX(col_name) FROM TABLE; */
2930
error = row_search_max_autoinc(index, col_name, &auto_inc);
2935
/* At the this stage we don't know the increment
2936
or the offset, so use default inrement of 1. */
2940
case DB_RECORD_NOT_FOUND:
3138
const Field* field = getTable()->found_next_number_field;
3140
if (field != NULL) {
3141
auto_inc = innobase_get_int_col_max_value(field);
3143
/* We have no idea what's been passed in to us as the
3144
autoinc column. We set it to the 0, effectively disabling
3145
updates to the table. */
2941
3148
ut_print_timestamp(stderr);
2942
fprintf(stderr, " InnoDB: MySQL and InnoDB data "
2943
"dictionaries are out of sync.\n"
2944
"InnoDB: Unable to find the AUTOINC column %s in the "
2945
"InnoDB table %s.\n"
2946
"InnoDB: We set the next AUTOINC column value to the "
2947
"maximum possible value,\n"
2948
"InnoDB: in effect disabling the AUTOINC next value "
2950
"InnoDB: You can either set the next AUTOINC value "
2951
"explicitly using ALTER TABLE\n"
2952
"InnoDB: or fix the data dictionary by recreating "
2954
col_name, index->table->name);
2956
auto_inc = 0xFFFFFFFFFFFFFFFFULL;
3149
errmsg_printf(error::ERROR, "InnoDB: Unable to determine the AUTOINC column name");
3152
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
3153
/* If the recovery level is set so high that writes
3154
are disabled we force the AUTOINC counter to 0
3155
value effectively disabling writes to the table.
3156
Secondly, we avoid reading the table in case the read
3157
results in failure due to a corrupted table/index.
3159
We will not return an error to the client, so that the
3160
tables can be dumped with minimal hassle. If an error
3161
were returned in this case, the first attempt to read
3162
the table would fail and subsequent SELECTs would succeed. */
3164
} else if (field == NULL) {
3165
/* This is a far more serious error, best to avoid
3166
opening the table and return failure. */
3167
my_error(ER_AUTOINC_READ_FAILED, MYF(0));
3169
dict_index_t* index;
3170
const char* col_name;
3171
uint64_t read_auto_inc;
3174
update_session(getTable()->in_use);
3175
col_name = field->field_name;
3177
ut_a(prebuilt->trx == session_to_trx(user_session));
3179
index = innobase_get_index(getTable()->getShare()->next_number_index);
3181
/* Execute SELECT MAX(col_name) FROM TABLE; */
3182
err = row_search_max_autoinc(index, col_name, &read_auto_inc);
3186
uint64_t col_max_value;
3188
col_max_value = innobase_get_int_col_max_value(field);
3190
/* At the this stage we do not know the increment
3191
nor the offset, so use a default increment of 1. */
3193
auto_inc = innobase_next_autoinc(read_auto_inc, 1, 1, col_max_value);
3197
case DB_RECORD_NOT_FOUND:
3198
ut_print_timestamp(stderr);
3199
errmsg_printf(error::ERROR, "InnoDB: MySQL and InnoDB data dictionaries are out of sync.\n"
3200
"InnoDB: Unable to find the AUTOINC column %s in the InnoDB table %s.\n"
3201
"InnoDB: We set the next AUTOINC column value to 0,\n"
3202
"InnoDB: in effect disabling the AUTOINC next value generation.\n"
3203
"InnoDB: You can either set the next AUTOINC value explicitly using ALTER TABLE\n"
3204
"InnoDB: or fix the data dictionary by recreating the table.\n",
3205
col_name, index->table->name);
3207
/* This will disable the AUTOINC generation. */
3210
/* We want the open to succeed, so that the user can
3211
take corrective action. ie. reads should succeed but
3212
updates should fail. */
3216
/* row_search_max_autoinc() should only return
3217
one of DB_SUCCESS or DB_RECORD_NOT_FOUND. */
2963
3222
dict_table_autoinc_initialize(prebuilt->table, auto_inc);
2968
3225
/*****************************************************************//**
3086
3369
of length ref_length! */
3088
3371
if (!row_table_got_default_clust_index(ib_table)) {
3089
if (primary_key >= MAX_KEY) {
3090
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has a primary key in InnoDB data "
3091
"dictionary, but not in MySQL!", identifier.getTableName().c_str());
3094
3373
prebuilt->clust_index_was_generated = FALSE;
3096
/* MySQL allocates the buffer for ref. key_info->key_length
3097
includes space for all key columns + one byte for each column
3098
that may be NULL. ref_length must be as exact as possible to
3099
save space, because all row reference buffers are allocated
3100
based on ref_length. */
3102
ref_length = getTable()->key_info[primary_key].key_length;
3375
if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) {
3376
errmsg_printf(error::ERROR, "Table %s has a primary key in "
3377
"InnoDB data dictionary, but not "
3378
"in MySQL!", identifier.getTableName().c_str());
3380
/* This mismatch could cause further problems
3381
if not attended, bring this to the user's attention
3382
by printing a warning in addition to log a message
3384
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3386
"InnoDB: Table %s has a "
3387
"primary key in InnoDB data "
3388
"dictionary, but not in "
3389
"MySQL!", identifier.getTableName().c_str());
3391
/* If primary_key >= MAX_KEY, its (primary_key)
3392
value could be out of bound if continue to index
3393
into key_info[] array. Find InnoDB primary index,
3394
and assign its key_length to ref_length.
3395
In addition, since MySQL indexes are sorted starting
3396
with primary index, unique index etc., initialize
3397
ref_length to the first index key length in
3398
case we fail to find InnoDB cluster index.
3400
Please note, this will not resolve the primary
3401
index mismatch problem, other side effects are
3402
possible if users continue to use the table.
3403
However, we allow this table to be opened so
3404
that user can adopt necessary measures for the
3405
mismatch while still being accessible to the table
3407
ref_length = getTable()->key_info[0].key_length;
3409
/* Find correspoinding cluster index
3410
key length in MySQL's key_info[] array */
3411
for (ulint i = 0; i < getTable()->getShare()->keys; i++) {
3412
dict_index_t* index;
3413
index = innobase_get_index(i);
3414
if (dict_index_is_clust(index)) {
3416
getTable()->key_info[i].key_length;
3420
/* MySQL allocates the buffer for ref.
3421
key_info->key_length includes space for all key
3422
columns + one byte for each column that may be
3423
NULL. ref_length must be as exact as possible to
3424
save space, because all row reference buffers are
3425
allocated based on ref_length. */
3427
ref_length = getTable()->key_info[primary_key].key_length;
3104
3430
if (primary_key != MAX_KEY) {
3105
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has no primary key in InnoDB data "
3106
"dictionary, but has one in MySQL! If you "
3107
"created the table with a MySQL version < "
3108
"3.23.54 and did not define a primary key, "
3109
"but defined a unique key with all non-NULL "
3110
"columns, then MySQL internally treats that "
3111
"key as the primary key. You can fix this "
3112
"error by dump + DROP + CREATE + reimport "
3113
"of the table.", identifier.getTableName().c_str());
3431
errmsg_printf(error::ERROR,
3432
"Table %s has no primary key in InnoDB data "
3433
"dictionary, but has one in MySQL! If you "
3434
"created the table with a MySQL version < "
3435
"3.23.54 and did not define a primary key, "
3436
"but defined a unique key with all non-NULL "
3437
"columns, then MySQL internally treats that "
3438
"key as the primary key. You can fix this "
3439
"error by dump + DROP + CREATE + reimport "
3440
"of the table.", identifier.getTableName().c_str());
3442
/* This mismatch could cause further problems
3443
if not attended, bring this to the user attention
3444
by printing a warning in addition to log a message
3446
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3448
"InnoDB: Table %s has no "
3449
"primary key in InnoDB data "
3450
"dictionary, but has one in "
3451
"MySQL!", identifier.getTableName().c_str());
3116
3454
prebuilt->clust_index_was_generated = TRUE;
8403
9093
/************************************************************//**
8404
Validate the file format check value, is it one of "on" or "off",
8405
as a side effect it sets the srv_check_file_format_at_startup variable.
8406
@return true if config value one of "on" or "off" */
8409
innobase_file_format_check_on_off(
8410
/*==============================*/
8411
const char* format_check) /*!< in: parameter value */
8415
if (!innobase_strcasecmp(format_check, "off")) {
8417
/* Set the value to disable checking. */
8418
srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
8420
} else if (!innobase_strcasecmp(format_check, "on")) {
8422
/* Set the value to the lowest supported format. */
8423
srv_check_file_format_at_startup = DICT_TF_FORMAT_51;
8431
/************************************************************//**
8432
9094
Validate the file format check config parameters, as a side effect it
8433
sets the srv_check_file_format_at_startup variable.
9095
sets the srv_max_file_format_at_startup variable.
8434
9096
@return the format_id if valid config value, otherwise, return -1 */
8437
9099
innobase_file_format_validate_and_set(
8438
9100
/*================================*/
8439
const char* format_check) /*!< in: parameter value */
9101
const char* format_max) /*!< in: parameter value */
8441
9103
uint format_id;
8443
format_id = innobase_file_format_name_lookup(format_check);
9105
format_id = innobase_file_format_name_lookup(format_max);
8445
9107
if (format_id < DICT_TF_FORMAT_MAX + 1) {
8446
srv_check_file_format_at_startup = format_id;
9108
srv_max_file_format_at_startup = format_id;
8447
9109
return((int) format_id);
8453
/*************************************************************//**
8454
Check if it is a valid file format. This function is registered as
8455
a callback with MySQL.
8456
@return 0 for valid file format */
8459
innodb_file_format_name_validate(
8460
/*=============================*/
8461
Session* , /*!< in: thread handle */
8462
drizzle_sys_var* , /*!< in: pointer to system
8464
void* save, /*!< out: immediate result
8465
for update function */
8466
drizzle_value* value) /*!< in: incoming string */
8468
const char* file_format_input;
8469
char buff[STRING_BUFFER_USUAL_SIZE];
8470
int len = sizeof(buff);
8473
ut_a(value != NULL);
8475
file_format_input = value->val_str(value, buff, &len);
8477
if (file_format_input != NULL) {
8480
format_id = innobase_file_format_name_lookup(
8483
if (format_id <= DICT_TF_FORMAT_MAX) {
8484
/* Save a pointer to the name in the
8485
'file_format_name_map' constant array. */
8486
*static_cast<const char**>(save) =
8487
trx_sys_file_format_id_to_name(format_id);
8493
*static_cast<const char**>(save) = NULL;
8497
/****************************************************************//**
8498
Update the system variable innodb_file_format using the "saved"
8499
value. This function is registered as a callback with MySQL. */
8502
innodb_file_format_name_update(
8503
/*===========================*/
8504
Session* , /*!< in: thread handle */
8505
drizzle_sys_var* , /*!< in: pointer to
8507
void* var_ptr, /*!< out: where the
8508
formal string goes */
8509
const void* save) /*!< in: immediate result
8510
from check function */
8512
const char* format_name;
8514
ut_a(var_ptr != NULL);
8517
format_name = *static_cast<const char*const*>(save);
8522
format_id = innobase_file_format_name_lookup(format_name);
8524
if (format_id <= DICT_TF_FORMAT_MAX) {
8525
srv_file_format = format_id;
8529
*static_cast<const char**>(var_ptr)
8530
= trx_sys_file_format_id_to_name(srv_file_format);
8533
/*************************************************************//**
8534
Check if valid argument to innodb_file_format_check. This
8535
function is registered as a callback with MySQL.
8536
@return 0 for valid file format */
8539
innodb_file_format_check_validate(
8540
/*==============================*/
8541
Session* session, /*!< in: thread handle */
8542
drizzle_sys_var* , /*!< in: pointer to system
8544
void* save, /*!< out: immediate result
8545
for update function */
8546
drizzle_value* value) /*!< in: incoming string */
8548
const char* file_format_input;
8549
char buff[STRING_BUFFER_USUAL_SIZE];
8550
int len = sizeof(buff);
8554
ut_a(value != NULL);
8556
file_format_input = value->val_str(value, buff, &len);
8558
if (file_format_input != NULL) {
8560
/* Check if user set on/off, we want to print a suitable
8561
message if they did so. */
8563
if (innobase_file_format_check_on_off(file_format_input)) {
8564
push_warning_printf(session,
8565
DRIZZLE_ERROR::WARN_LEVEL_WARN,
8567
"InnoDB: invalid innodb_file_format_check "
8568
"value; on/off can only be set at startup or "
8569
"in the configuration file");
8571
format_id = innobase_file_format_validate_and_set(file_format_input);
8572
if (format_id >= 0) {
8573
/* Save a pointer to the name in the
8574
'file_format_name_map' constant array. */
8575
*static_cast<const char**>(save) =
8576
trx_sys_file_format_id_to_name(
8582
push_warning_printf(session,
8583
DRIZZLE_ERROR::WARN_LEVEL_WARN,
8585
"InnoDB: invalid innodb_file_format_check "
8586
"value; can be any format up to %s "
8587
"or its equivalent numeric id",
8588
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
8593
*static_cast<const char**>(save) = NULL;
8597
/****************************************************************//**
8598
Update the system variable innodb_file_format_check using the "saved"
8599
value. This function is registered as a callback with MySQL. */
8602
innodb_file_format_check_update(
8603
/*============================*/
8604
Session* session, /*!< in: thread handle */
8605
drizzle_sys_var* , /*!< in: pointer to
8607
void* var_ptr, /*!< out: where the
8608
formal string goes */
8609
const void* save) /*!< in: immediate result
8610
from check function */
8612
const char* format_name_in;
8613
const char** format_name_out;
8617
ut_a(var_ptr != NULL);
8619
format_name_in = *static_cast<const char*const*>(save);
8621
if (!format_name_in) {
8626
format_id = innobase_file_format_name_lookup(format_name_in);
8628
if (format_id > DICT_TF_FORMAT_MAX) {
8629
/* DEFAULT is "on", which is invalid at runtime. */
8630
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
8632
"Ignoring SET innodb_file_format=%s",
8637
format_name_out = static_cast<const char**>(var_ptr);
8639
/* Update the max format id in the system tablespace. */
8640
if (trx_sys_file_format_max_set(format_id, format_name_out)) {
8641
ut_print_timestamp(stderr);
8643
" [Info] InnoDB: the file format in the system "
8644
"tablespace is now set to %s.\n", *format_name_out);
8648
/****************************************************************//**
8649
Update the system variable innodb_adaptive_hash_index using the "saved"
8650
value. This function is registered as a callback with MySQL. */
8653
innodb_adaptive_hash_index_update(
8654
/*==============================*/
8655
Session* , /*!< in: thread handle */
8656
drizzle_sys_var* , /*!< in: pointer to
8658
void* , /*!< out: where the
8659
formal string goes */
8660
const void* save) /*!< in: immediate result
8661
from check function */
8663
if (*(bool*) save) {
8664
btr_search_enable();
8666
btr_search_disable();
8670
/****************************************************************//**
8671
Update the system variable innodb_old_blocks_pct using the "saved"
8672
value. This function is registered as a callback with MySQL. */
8675
innodb_old_blocks_pct_update(
8676
/*=========================*/
8677
Session* , /*!< in: thread handle */
8678
drizzle_sys_var* , /*!< in: pointer to
8680
void* ,/*!< out: where the
8681
formal string goes */
8682
const void* save) /*!< in: immediate result
8683
from check function */
8685
innobase_old_blocks_pct = buf_LRU_old_ratio_update(
8686
*static_cast<const uint*>(save), TRUE);
8689
/*************************************************************//**
8690
Check if it is a valid value of innodb_change_buffering. This function is
8691
registered as a callback with MySQL.
8692
@return 0 for valid innodb_change_buffering */
8695
innodb_change_buffering_validate(
8696
/*=============================*/
8697
Session* , /*!< in: thread handle */
8698
drizzle_sys_var* , /*!< in: pointer to system
8700
void* save, /*!< out: immediate result
8701
for update function */
8702
drizzle_value* value) /*!< in: incoming string */
8704
const char* change_buffering_input;
8705
char buff[STRING_BUFFER_USUAL_SIZE];
8706
int len = sizeof(buff);
8709
ut_a(value != NULL);
8711
change_buffering_input = value->val_str(value, buff, &len);
8713
if (change_buffering_input != NULL) {
8716
for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
8718
if (!innobase_strcasecmp(
8719
change_buffering_input,
8720
innobase_change_buffering_values[use])) {
8721
*(ibuf_use_t*) save = (ibuf_use_t) use;
8730
/****************************************************************//**
8731
Update the system variable innodb_change_buffering using the "saved"
8732
value. This function is registered as a callback with MySQL. */
8735
innodb_change_buffering_update(
8736
/*===========================*/
8737
Session* , /*!< in: thread handle */
8738
drizzle_sys_var* , /*!< in: pointer to
8740
void* var_ptr, /*!< out: where the
8741
formal string goes */
8742
const void* save) /*!< in: immediate result
8743
from check function */
8745
ut_a(var_ptr != NULL);
8747
ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
8749
ibuf_use = *(const ibuf_use_t*) save;
8751
*(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
8754
/* plugin options */
8755
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
8756
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8757
"Enable InnoDB checksums validation (enabled by default). ",
8760
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
8761
PLUGIN_VAR_READONLY,
8762
"The common part for InnoDB table spaces.",
8765
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
8766
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8767
"Enable InnoDB doublewrite buffer (enabled by default). ",
8770
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
8771
PLUGIN_VAR_RQCMDARG,
8772
"Number of IOPs the server can do. Tunes the background IO rate",
8773
NULL, NULL, 200, 100, ~0L, 0);
8775
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
8776
PLUGIN_VAR_OPCMDARG,
8777
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
8778
"values are 0, 1 (faster)"
8779
" or 2 (fastest - crash-like)"
8781
NULL, NULL, 1, 0, 2, 0);
8783
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
8784
PLUGIN_VAR_NOCMDARG,
8785
"Stores each InnoDB table to an .ibd file in the database dir.",
8788
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
8789
PLUGIN_VAR_RQCMDARG,
8790
"File format to use for new tables in .ibd files.",
8791
innodb_file_format_name_validate,
8792
innodb_file_format_name_update, "Antelope");
8794
/* If a new file format is introduced, the file format
8795
name needs to be updated accordingly. Please refer to
8796
file_format_name_map[] defined in trx0sys.c for the next
8797
file format name. */
8798
static DRIZZLE_SYSVAR_STR(file_format_check, innobase_file_format_check,
8799
PLUGIN_VAR_OPCMDARG,
8800
"The highest file format in the tablespace.",
8801
innodb_file_format_check_validate,
8802
innodb_file_format_check_update,
8805
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
8806
PLUGIN_VAR_OPCMDARG,
8807
"Set to 0 (write and flush once per second),"
8808
" 1 (write and flush at each commit)"
8809
" or 2 (write at commit, flush once per second).",
8810
NULL, NULL, 1, 0, 2, 0);
8812
static DRIZZLE_SYSVAR_STR(flush_method, innobase_file_flush_method,
8813
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8814
"With which method to flush data.", NULL, NULL, NULL);
8816
#ifdef UNIV_LOG_ARCHIVE
8817
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
8818
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8819
"Where full logs should be archived.", NULL, NULL, NULL);
8821
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
8822
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
8823
"Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
8824
#endif /* UNIV_LOG_ARCHIVE */
8826
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
8827
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8828
"Path to InnoDB log files.", NULL, NULL, NULL);
8830
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
8831
PLUGIN_VAR_RQCMDARG,
8832
"Percentage of dirty pages allowed in bufferpool.",
8833
NULL, NULL, 75, 0, 99, 0);
8835
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
8836
PLUGIN_VAR_NOCMDARG,
8837
"Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
8840
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
8841
PLUGIN_VAR_RQCMDARG,
8842
"Desired maximum length of the purge queue (0 = no limit)",
8843
NULL, NULL, 0, 0, ~0L, 0);
8845
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
8846
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
8847
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
8850
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
8851
PLUGIN_VAR_RQCMDARG,
8852
"The number of index pages to sample when calculating statistics (default 8)",
8853
NULL, NULL, 8, 1, ~0ULL, 0);
8855
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
8856
PLUGIN_VAR_OPCMDARG,
8857
"Enable InnoDB adaptive hash index (enabled by default).",
8858
NULL, innodb_adaptive_hash_index_update, TRUE);
8860
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
8861
PLUGIN_VAR_RQCMDARG,
8862
"Replication thread delay (ms) on the slave server if "
8863
"innodb_thread_concurrency is reached (0 by default)",
8864
NULL, NULL, 0, 0, ~0UL, 0);
8866
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
8867
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8868
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
8869
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
8871
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
8872
PLUGIN_VAR_RQCMDARG,
8873
"Data file autoextend increment in megabytes",
8874
NULL, NULL, 8L, 1L, 1000L, 0);
8876
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
8877
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8878
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
8879
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
8881
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
8882
PLUGIN_VAR_RQCMDARG,
8883
"Helps in performance tuning in heavily concurrent environments.",
8884
innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
8886
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
8887
PLUGIN_VAR_RQCMDARG,
8888
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
8889
NULL, NULL, 500L, 1L, ~0L, 0);
8891
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
8892
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8893
"Number of background read I/O threads in InnoDB.",
8894
NULL, NULL, 4, 1, 64, 0);
8896
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
8897
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8898
"Number of background write I/O threads in InnoDB.",
8899
NULL, NULL, 4, 1, 64, 0);
8901
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
8902
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8903
"Helps to save your data in case the disk image of the database becomes corrupt.",
8904
NULL, NULL, 0, 0, 6, 0);
8906
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
8907
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8908
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
8909
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
8911
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
8912
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8913
"Size of each log file in a log group.",
8914
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
8916
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
8917
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8918
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
8919
NULL, NULL, 2, 2, 100, 0);
8921
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
8922
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8923
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
8924
NULL, NULL, 1, 1, 10, 0);
8926
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
8927
PLUGIN_VAR_RQCMDARG,
8928
"Percentage of the buffer pool to reserve for 'old' blocks.",
8929
NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
8931
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
8932
PLUGIN_VAR_RQCMDARG,
8933
"Move blocks to the 'new' end of the buffer pool if the first access"
8934
" was at least this many milliseconds ago."
8935
" The timeout is disabled if 0 (the default).",
8936
NULL, NULL, 0, 0, UINT32_MAX, 0);
8938
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
8939
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8940
"How many files at the maximum InnoDB keeps open at the same time.",
8941
NULL, NULL, 300L, 10L, LONG_MAX, 0);
8943
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
8944
PLUGIN_VAR_RQCMDARG,
8945
"Count of spin-loop rounds in InnoDB mutexes (30 by default)",
8946
NULL, NULL, 30L, 0L, ~0L, 0);
8948
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
8949
PLUGIN_VAR_OPCMDARG,
8950
"Maximum delay between polling for a spin lock (6 by default)",
8951
NULL, NULL, 6L, 0L, ~0L, 0);
8953
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
8954
PLUGIN_VAR_RQCMDARG,
8955
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
8956
NULL, NULL, 0, 0, 1000, 0);
8958
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
8959
PLUGIN_VAR_RQCMDARG,
8960
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
8961
NULL, NULL, 10000L, 0L, ~0L, 0);
8963
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
8964
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8965
"Path to individual files and their sizes.",
8968
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
8969
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
8970
"InnoDB version", NULL, NULL, INNODB_VERSION_STR);
8972
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
8973
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8974
"Use OS memory allocator instead of InnoDB's internal memory allocator",
8977
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
8978
PLUGIN_VAR_RQCMDARG,
8979
"Buffer changes to reduce random access: "
8980
"OFF, ON, inserting, deleting, changing, or purging.",
8981
innodb_change_buffering_validate,
8982
innodb_change_buffering_update, NULL);
8984
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
8985
PLUGIN_VAR_RQCMDARG,
8986
"Number of pages that must be accessed sequentially for InnoDB to"
8987
"trigger a readahead.",
8988
NULL, NULL, 56, 0, 64, 0);
8990
9117
static void init_options(drizzled::module::option_context &context)
9042
9171
context("disable-stats-on-metadata",
9043
9172
"Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9044
9173
context("stats-sample-pages",
9045
po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9174
po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9046
9175
"The number of index pages to sample when calculating statistics (default 8)");
9047
9176
context("disable-adaptive-hash-index",
9048
9177
"Enable InnoDB adaptive hash index (enabled by default)");
9049
9178
context("replication-delay",
9050
po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9179
po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
9051
9180
"Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9052
9181
context("additional-mem-pool-size",
9053
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9182
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9054
9183
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9055
9184
context("autoextend-increment",
9056
po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9185
po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(64L),
9057
9186
"Data file autoextend increment in megabytes");
9058
9187
context("buffer-pool-size",
9059
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9188
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9060
9189
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9190
context("buffer-pool-instances",
9191
po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9192
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9061
9194
context("commit-concurrency",
9062
po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9195
po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
9063
9196
"Helps in performance tuning in heavily concurrent environments.");
9064
9197
context("concurrency-tickets",
9065
po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9198
po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
9066
9199
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9067
9200
context("read-io-threads",
9068
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9201
po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
9069
9202
"Number of background read I/O threads in InnoDB.");
9070
9203
context("write-io-threads",
9071
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9204
po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
9072
9205
"Number of background write I/O threads in InnoDB.");
9073
9206
context("force-recovery",
9074
po::value<long>(&innobase_force_recovery)->default_value(0),
9207
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
9075
9208
"Helps to save your data in case the disk image of the database becomes corrupt.");
9076
9209
context("log-buffer-size",
9077
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9210
po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9078
9211
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9079
9212
context("log-file-size",
9080
po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9213
po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9081
9214
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9082
9215
context("log-files-in-group",
9083
po::value<long>(&innobase_log_files_in_group)->default_value(2),
9216
po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
9084
9217
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9085
9218
context("mirrored-log-groups",
9086
po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9219
po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
9087
9220
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9088
9221
context("open-files",
9089
po::value<long>(&innobase_open_files)->default_value(300L),
9222
po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
9090
9223
"How many files at the maximum InnoDB keeps open at the same time.");
9091
9224
context("sync-spin-loops",
9092
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9225
po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
9093
9226
"Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9094
9227
context("spin-wait-delay",
9095
po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9228
po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
9096
9229
"Maximum delay between polling for a spin lock (6 by default)");
9097
9230
context("thread-concurrency",
9098
po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9231
po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
9099
9232
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9100
9233
context("thread-sleep-delay",
9101
po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9234
po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
9102
9235
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9103
9236
context("data-file-path",
9104
9237
po::value<string>(),
9108
9241
"InnoDB version");
9109
9242
context("use-internal-malloc",
9110
9243
"Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9244
context("disable-native-aio",
9245
_("Do not use Native AIO library for IO, even if available"));
9111
9246
context("change-buffering",
9112
po::value<string>(),
9247
po::value<string>(&innobase_change_buffering),
9113
9248
"Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9114
9249
context("read-ahead-threshold",
9115
po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9250
po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
9116
9251
"Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9117
9252
context("disable-xa",
9118
9253
"Disable InnoDB support for the XA two-phase commit");
9119
9254
context("disable-table-locks",
9120
9255
"Disable InnoDB locking in LOCK TABLES");
9121
9256
context("strict-mode",
9122
po::value<bool>()->default_value(false)->zero_tokens(),
9257
po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
9123
9258
"Use strict mode when evaluating create options.");
9259
context("replication-log",
9260
po::value<bool>(&innobase_use_replication_log)->default_value(false),
9261
_("Enable internal replication log."));
9124
9262
context("lock-wait-timeout",
9125
po::value<unsigned long>()->default_value(50),
9126
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9263
po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9264
_("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9265
context("old-blocks-pct",
9266
po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9267
_("Percentage of the buffer pool to reserve for 'old' blocks."));
9268
context("old-blocks-time",
9269
po::value<uint32_t>(&buf_LRU_old_threshold_ms)->default_value(0),
9270
_("ove blocks to the 'new' end of the buffer pool if the first access"
9271
" was at least this many milliseconds ago."
9272
" The timeout is disabled if 0 (the default)."));
9129
static drizzle_sys_var* innobase_system_variables[]= {
9130
DRIZZLE_SYSVAR(additional_mem_pool_size),
9131
DRIZZLE_SYSVAR(autoextend_increment),
9132
DRIZZLE_SYSVAR(buffer_pool_size),
9133
DRIZZLE_SYSVAR(checksums),
9134
DRIZZLE_SYSVAR(commit_concurrency),
9135
DRIZZLE_SYSVAR(concurrency_tickets),
9136
DRIZZLE_SYSVAR(data_file_path),
9137
DRIZZLE_SYSVAR(data_home_dir),
9138
DRIZZLE_SYSVAR(doublewrite),
9139
DRIZZLE_SYSVAR(fast_shutdown),
9140
DRIZZLE_SYSVAR(read_io_threads),
9141
DRIZZLE_SYSVAR(write_io_threads),
9142
DRIZZLE_SYSVAR(file_per_table),
9143
DRIZZLE_SYSVAR(file_format),
9144
DRIZZLE_SYSVAR(file_format_check),
9145
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
9146
DRIZZLE_SYSVAR(flush_method),
9147
DRIZZLE_SYSVAR(force_recovery),
9148
DRIZZLE_SYSVAR(lock_wait_timeout),
9149
#ifdef UNIV_LOG_ARCHIVE
9150
DRIZZLE_SYSVAR(log_arch_dir),
9151
DRIZZLE_SYSVAR(log_archive),
9152
#endif /* UNIV_LOG_ARCHIVE */
9153
DRIZZLE_SYSVAR(log_buffer_size),
9154
DRIZZLE_SYSVAR(log_file_size),
9155
DRIZZLE_SYSVAR(log_files_in_group),
9156
DRIZZLE_SYSVAR(log_group_home_dir),
9157
DRIZZLE_SYSVAR(max_dirty_pages_pct),
9158
DRIZZLE_SYSVAR(max_purge_lag),
9159
DRIZZLE_SYSVAR(adaptive_flushing),
9160
DRIZZLE_SYSVAR(mirrored_log_groups),
9161
DRIZZLE_SYSVAR(old_blocks_pct),
9162
DRIZZLE_SYSVAR(old_blocks_time),
9163
DRIZZLE_SYSVAR(open_files),
9164
DRIZZLE_SYSVAR(stats_sample_pages),
9165
DRIZZLE_SYSVAR(adaptive_hash_index),
9166
DRIZZLE_SYSVAR(replication_delay),
9167
DRIZZLE_SYSVAR(status_file),
9168
DRIZZLE_SYSVAR(strict_mode),
9169
DRIZZLE_SYSVAR(support_xa),
9170
DRIZZLE_SYSVAR(sync_spin_loops),
9171
DRIZZLE_SYSVAR(spin_wait_delay),
9172
DRIZZLE_SYSVAR(table_locks),
9173
DRIZZLE_SYSVAR(thread_concurrency),
9174
DRIZZLE_SYSVAR(thread_sleep_delay),
9175
DRIZZLE_SYSVAR(version),
9176
DRIZZLE_SYSVAR(use_sys_malloc),
9177
DRIZZLE_SYSVAR(change_buffering),
9178
DRIZZLE_SYSVAR(read_ahead_threshold),
9179
DRIZZLE_SYSVAR(io_capacity),
9183
9277
DRIZZLE_DECLARE_PLUGIN