170
186
static plugin::TableFunction* innodb_trx_tool= NULL;
171
187
static plugin::TableFunction* innodb_locks_tool= NULL;
172
188
static plugin::TableFunction* innodb_lock_waits_tool= NULL;
173
static plugin::TableFunction* innodb_sys_tables_tool= NULL;
174
static plugin::TableFunction* innodb_sys_tablestats_tool= NULL;
176
static plugin::TableFunction* innodb_sys_indexes_tool= NULL;
177
static plugin::TableFunction* innodb_sys_columns_tool= NULL;
178
static plugin::TableFunction* innodb_sys_fields_tool= NULL;
179
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
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;
227
/** Percentage of the buffer pool to reserve for 'old' blocks.
228
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;
190
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
191
innobase_log_buffer_size,
192
innobase_force_recovery, innobase_open_files;
193
static long innobase_additional_mem_pool_size= 8*1024*1024L;
194
static ulong innobase_commit_concurrency = 0;
195
static ulong innobase_read_io_threads;
196
static ulong innobase_write_io_threads;
199
* @TODO: Turn this into size_t as soon as we have a Variable<size_t>
201
static int64_t innobase_buffer_pool_size= 128*1024*1024;
202
static int64_t innobase_log_file_size;
239
204
/* The default values for the following char* start-up parameters
240
205
are determined in innobase_init below: */
242
std::string innobase_data_home_dir;
243
std::string innobase_data_file_path;
244
std::string innobase_log_group_home_dir;
245
static string innobase_file_format_name;
246
static string innobase_change_buffering;
248
/* The highest file format being used in the database. The value can be
249
set by user, however, it will be adjusted to the newer file format if
250
a table of such format is created/opened. */
251
static string innobase_file_format_max;
207
static char* innobase_data_home_dir = NULL;
208
static char* innobase_data_file_path = NULL;
209
static char* innobase_log_group_home_dir = NULL;
210
static char* innobase_file_format_name = NULL;
211
static char* innobase_change_buffering = NULL;
213
/* Note: This variable can be set to on/off and any of the supported
214
file formats in the configuration file, but can only be set to any
215
of the supported file formats during runtime. */
216
static char* innobase_file_format_check = NULL;
218
/* The following has a misleading name: starting from 4.0.5, this also
220
static char* innobase_unix_file_flush_method = NULL;
253
222
/* Below we have boolean-valued start-up parameters, and their default
256
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
257
static trinary_constraint innobase_fast_shutdown;
259
/* "innobase_file_format_check" decides whether we would continue
260
booting the server if the file format stamped on the system
261
table space exceeds the maximum file format supported
262
by the server. Can be set during server startup at command
263
line or configure file, and a read only variable after
266
/* If a new file format is introduced, the file format
267
name needs to be updated accordingly. Please refer to
268
file_format_name_map[] defined in trx0sys.c for the next
271
static my_bool innobase_file_format_check = TRUE;
225
static ulong innobase_fast_shutdown = 1;
226
#ifdef UNIV_LOG_ARCHIVE
227
static my_bool innobase_log_archive = FALSE;
228
static char* innobase_log_arch_dir = NULL;
229
#endif /* UNIV_LOG_ARCHIVE */
272
230
static my_bool innobase_use_doublewrite = TRUE;
273
231
static my_bool innobase_use_checksums = TRUE;
274
232
static my_bool innobase_rollback_on_timeout = FALSE;
275
233
static my_bool innobase_create_status_file = FALSE;
276
static bool innobase_use_replication_log;
277
static bool support_xa;
278
static bool strict_mode;
279
typedef constrained_check<uint32_t, 1024*1024*1024, 1> lock_wait_constraint;
280
static lock_wait_constraint lock_wait_timeout;
234
static my_bool innobase_stats_on_metadata = TRUE;
282
236
static char* internal_innobase_data_file_path = NULL;
238
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
284
240
/* The following counter is used to convey information to InnoDB
285
241
about server activity: in selects it is not sensible to call
286
242
srv_active_wake_master_thread after each fetch or search, we only do
1839
1802
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
1805
/*********************************************************************//**
2041
1806
Opens an InnoDB database.
2042
1807
@return 0 on success, error code on failure */
2052
1817
InnobaseEngine *actuall_engine_ptr;
2053
1818
const module::option_map &vm= context.getOptions();
2055
srv_auto_extend_increment= innodb_auto_extend_increment.get();
2056
srv_io_capacity= innodb_io_capacity.get();
2057
srv_purge_batch_size= innodb_purge_batch_size.get();
2058
srv_n_purge_threads= innodb_n_purge_threads.get();
2059
srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
2060
srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
2061
srv_max_purge_lag= innodb_max_purge_lag.get();
2062
srv_stats_sample_pages= innodb_stats_sample_pages.get();
2063
srv_n_free_tickets_to_enter= innodb_concurrency_tickets.get();
2064
srv_replication_delay= innodb_replication_delay.get();
2065
srv_thread_concurrency= innobase_thread_concurrency.get();
2066
srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
2067
srv_spin_wait_delay= innodb_spin_wait_delay.get();
2068
srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
2069
srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
2071
1820
/* Inverted Booleans */
2073
1822
innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
2074
1823
innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
2075
1824
srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
1825
innobase_stats_on_metadata= (vm.count("disable-stats-on-metadata")) ? false : true;
2076
1826
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2077
support_xa= (vm.count("disable-xa")) ? false : true;
2078
btr_search_enabled= (vm.count("disable-adaptive-hash-index")) ? false : true;
2081
/* Hafta do this here because we need to late-bind the default value */
1827
(SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
1828
(SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
1830
if (vm.count("io-capacity"))
1832
if (srv_io_capacity < 100)
1834
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
2082
1839
if (vm.count("data-home-dir"))
2084
innobase_data_home_dir= vm["data-home-dir"].as<string>();
2088
innobase_data_home_dir= getDataHome().file_string();
1841
innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
1845
innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
1848
if (vm.count("fast-shutdown"))
1850
if (innobase_fast_shutdown > 2)
1852
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
1857
if (vm.count("file-format-check"))
1859
innobase_file_format_check= const_cast<char *>(vm["file-format-check"].as<string>().c_str());
1862
if (vm.count("flush-log-at-trx-commit"))
1864
if (srv_flush_log_at_trx_commit > 2)
1866
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
1871
if (vm.count("flush-method"))
1873
innobase_unix_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
1877
innobase_unix_file_flush_method= NULL;
1880
#ifdef UNIV_LOG_ARCHIVE
1881
if (vm.count("log-arch-dir"))
1883
innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
1888
innobase_log_arch_dir= NULL;
1890
#endif /* UNIV_LOG_ARCHIVE */
1892
if (vm.count("max-dirty-pages-pct"))
1894
if (srv_max_buf_pool_modified_pct > 99)
1896
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
1901
if (vm.count("stats-sample-pages"))
1903
if (srv_stats_sample_pages < 8)
1905
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
1910
if (vm.count("additional-mem-pool-size"))
1912
align_value(innobase_additional_mem_pool_size);
1914
if (innobase_additional_mem_pool_size < 512*1024L)
1916
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
1922
if (vm.count("autoextend-increment"))
1924
if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
1926
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
1931
if (vm.count("buffer-pool-size"))
1933
align_value(innobase_buffer_pool_size, 1024*1024);
1934
if (innobase_buffer_pool_size < 5*1024*1024)
1936
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
1942
if (vm.count("commit-concurrency"))
1944
if (srv_replication_delay > 1000)
1946
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
1951
if (vm.count("concurrency-tickets"))
1953
if (srv_n_free_tickets_to_enter < 1)
1955
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
1960
if (vm.count("read-io-threads"))
1962
if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
1964
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
1969
if (vm.count("write-io-threads"))
1971
if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
1973
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
1978
if (vm.count("force-recovery"))
1980
if (innobase_force_recovery > 6)
1982
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
1987
if (vm.count("log-buffer-size"))
1989
align_value(innobase_log_buffer_size);
1990
if (innobase_log_buffer_size < 256*1024L)
1992
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
1997
if (vm.count("log-file-size"))
1999
align_value(innobase_log_file_size, 1024*1024);
2000
if (innobase_log_file_size < 1*1024*1024L)
2002
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2007
if (vm.count("log-files-in-group"))
2009
if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
2011
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
2016
if (vm.count("mirrored-log-groups"))
2018
if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
2020
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
2025
if (vm.count("open-files"))
2027
if (innobase_open_files < 10)
2029
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
2034
if (vm.count("thread-concurrency"))
2036
if (srv_thread_concurrency > 1000)
2038
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
2092
2043
if (vm.count("data-file-path"))
2094
innobase_data_file_path= vm["data-file-path"].as<string>();
2045
innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
2049
innobase_data_file_path= NULL;
2052
if (vm.count("version"))
2054
innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
2057
if (vm.count("read-ahead-threshold"))
2059
if (srv_read_ahead_threshold > 64)
2061
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
2066
if (vm.count("strict-mode"))
2068
(SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
2071
if (vm.count("lock-wait-timeout"))
2073
if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
2075
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
2079
(SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
2098
2082
innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2356
2366
innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
2357
2367
context.add(innodb_lock_waits_tool);
2359
innodb_sys_tables_tool= new(std::nothrow)InnodbSysTablesTool();
2360
context.add(innodb_sys_tables_tool);
2362
innodb_sys_tablestats_tool= new(std::nothrow)InnodbSysTableStatsTool();
2363
context.add(innodb_sys_tablestats_tool);
2365
innodb_sys_indexes_tool= new(std::nothrow)InnodbSysIndexesTool();
2366
context.add(innodb_sys_indexes_tool);
2368
innodb_sys_columns_tool= new(std::nothrow)InnodbSysColumnsTool();
2369
context.add(innodb_sys_columns_tool);
2371
innodb_sys_fields_tool= new(std::nothrow)InnodbSysFieldsTool();
2372
context.add(innodb_sys_fields_tool);
2374
innodb_sys_foreign_tool= new(std::nothrow)InnodbSysForeignTool();
2375
context.add(innodb_sys_foreign_tool);
2377
innodb_sys_foreign_cols_tool= new(std::nothrow)InnodbSysForeignColsTool();
2378
context.add(innodb_sys_foreign_cols_tool);
2380
2369
context.add(new(std::nothrow)InnodbInternalTables());
2381
context.add(new(std::nothrow)InnodbReplicationTable());
2383
if (innobase_use_replication_log)
2385
replication_logger= new(std::nothrow)ReplicationLog();
2386
context.add(replication_logger);
2387
ReplicationLog::setup(replication_logger);
2390
context.registerVariable(new sys_var_const_string_val("data-home-dir", innobase_data_home_dir));
2391
context.registerVariable(new sys_var_const_string_val("flush-method",
2392
vm.count("flush-method") ? vm["flush-method"].as<string>() : ""));
2393
context.registerVariable(new sys_var_const_string_val("log-group-home-dir", innobase_log_group_home_dir));
2394
context.registerVariable(new sys_var_const_string_val("data-file-path", innobase_data_file_path));
2395
context.registerVariable(new sys_var_const_string_val("version", vm["version"].as<string>()));
2398
context.registerVariable(new sys_var_bool_ptr_readonly("replication_log", &innobase_use_replication_log));
2399
context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
2400
context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
2401
context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
2402
context.registerVariable(new sys_var_bool_ptr_readonly("file-format-check", &innobase_file_format_check));
2403
context.registerVariable(new sys_var_bool_ptr("adaptive-flushing", &srv_adaptive_flushing));
2404
context.registerVariable(new sys_var_bool_ptr("status-file", &innobase_create_status_file));
2405
context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2406
context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2408
context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2409
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));
2471
2371
/* Get the current high water mark format. */
2472
innobase_file_format_max = trx_sys_file_format_max_get();
2473
btr_search_fully_disabled = (!btr_search_enabled);
2372
innobase_file_format_check = (char*) trx_sys_file_format_max_get();
2987
2860
/********************************************************************//**
2988
Get the upper limit of the MySQL integral and floating-point type.
2989
@return maximum allowed value for the field */
2992
innobase_get_int_col_max_value(
2993
/*===========================*/
2994
const Field* field) /*!< in: MySQL field */
2996
uint64_t max_value = 0;
2998
switch(field->key_type()) {
3000
case HA_KEYTYPE_BINARY:
3001
max_value = 0xFFULL;
3004
case HA_KEYTYPE_ULONG_INT:
3005
max_value = 0xFFFFFFFFULL;
3007
case HA_KEYTYPE_LONG_INT:
3008
max_value = 0x7FFFFFFFULL;
3011
case HA_KEYTYPE_ULONGLONG:
3012
max_value = 0xFFFFFFFFFFFFFFFFULL;
3014
case HA_KEYTYPE_LONGLONG:
3015
max_value = 0x7FFFFFFFFFFFFFFFULL;
3017
case HA_KEYTYPE_DOUBLE:
3018
/* We use the maximum as per IEEE754-2008 standard, 2^53 */
3019
max_value = 0x20000000000000ULL;
3028
/*******************************************************************//**
3029
This function checks whether the index column information
3030
is consistent between KEY info from mysql and that from innodb index.
3031
@return TRUE if all column types match. */
3034
innobase_match_index_columns(
3035
/*=========================*/
3036
const KeyInfo* key_info, /*!< in: Index info
3038
const dict_index_t* index_info) /*!< in: Index info
3041
const KeyPartInfo* key_part;
3042
const KeyPartInfo* key_end;
3043
const dict_field_t* innodb_idx_fld;
3044
const dict_field_t* innodb_idx_fld_end;
3046
/* Check whether user defined index column count matches */
3047
if (key_info->key_parts != index_info->n_user_defined_cols) {
3051
key_part = key_info->key_part;
3052
key_end = key_part + key_info->key_parts;
3053
innodb_idx_fld = index_info->fields;
3054
innodb_idx_fld_end = index_info->fields + index_info->n_fields;
3056
/* Check each index column's datatype. We do not check
3057
column name because there exists case that index
3058
column name got modified in mysql but such change does not
3059
propagate to InnoDB.
3060
One hidden assumption here is that the index column sequences
3061
are matched up between those in mysql and Innodb. */
3062
for (; key_part != key_end; ++key_part) {
3065
ulint mtype = innodb_idx_fld->col->mtype;
3067
/* Need to translate to InnoDB column type before
3069
col_type = get_innobase_type_from_mysql_type(&is_unsigned,
3072
/* Ignore Innodb specific system columns. */
3073
while (mtype == DATA_SYS) {
3076
if (innodb_idx_fld >= innodb_idx_fld_end) {
3081
if (col_type != mtype) {
3082
/* Column Type mismatches */
3092
/*******************************************************************//**
3093
This function builds a translation table in INNOBASE_SHARE
3094
structure for fast index location with mysql array number from its
3095
table->key_info structure. This also provides the necessary translation
3096
between the key order in mysql key_info and Innodb ib_table->indexes if
3097
they are not fully matched with each other.
3098
Note we do not have any mutex protecting the translation table
3099
building based on the assumption that there is no concurrent
3100
index creation/drop and DMLs that requires index lookup. All table
3101
handle will be closed before the index creation/drop.
3102
@return TRUE if index translation table built successfully */
3105
innobase_build_index_translation(
3106
/*=============================*/
3107
const Table* table, /*!< in: table in MySQL data
3109
dict_table_t* ib_table, /*!< in: table in Innodb data
3111
INNOBASE_SHARE* share) /*!< in/out: share structure
3112
where index translation table
3113
will be constructed in. */
3115
ulint mysql_num_index;
3117
dict_index_t** index_mapping;
3120
mutex_enter(&dict_sys->mutex);
3122
mysql_num_index = table->getShare()->keys;
3123
ib_num_index = UT_LIST_GET_LEN(ib_table->indexes);
3125
index_mapping = share->idx_trans_tbl.index_mapping;
3127
/* If there exists inconsistency between MySQL and InnoDB dictionary
3128
(metadata) information, the number of index defined in MySQL
3129
could exceed that in InnoDB, do not build index translation
3130
table in such case */
3131
if (UNIV_UNLIKELY(ib_num_index < mysql_num_index)) {
3136
/* If index entry count is non-zero, nothing has
3137
changed since last update, directly return TRUE */
3138
if (share->idx_trans_tbl.index_count) {
3139
/* Index entry count should still match mysql_num_index */
3140
ut_a(share->idx_trans_tbl.index_count == mysql_num_index);
3144
/* The number of index increased, rebuild the mapping table */
3145
if (mysql_num_index > share->idx_trans_tbl.array_size) {
3146
index_mapping = (dict_index_t**) realloc(index_mapping,
3148
sizeof(*index_mapping));
3150
if (!index_mapping) {
3151
/* Report an error if index_mapping continues to be
3152
NULL and mysql_num_index is a non-zero value */
3153
errmsg_printf(ERRMSG_LVL_ERROR,
3154
"InnoDB: fail to allocate memory for "
3155
"index translation table. Number of "
3156
"Index:%lu, array size:%lu",
3158
share->idx_trans_tbl.array_size);
3163
share->idx_trans_tbl.array_size = mysql_num_index;
3166
/* For each index in the mysql key_info array, fetch its
3167
corresponding InnoDB index pointer into index_mapping
3169
for (ulint count = 0; count < mysql_num_index; count++) {
3171
/* Fetch index pointers into index_mapping according to mysql
3173
index_mapping[count] = dict_table_get_index_on_name(
3174
ib_table, table->key_info[count].name);
3176
if (!index_mapping[count]) {
3177
errmsg_printf(ERRMSG_LVL_ERROR, "Cannot find index %s in InnoDB "
3178
"index dictionary.",
3179
table->key_info[count].name);
3184
/* Double check fetched index has the same
3185
column info as those in mysql key_info. */
3186
if (!innobase_match_index_columns(&table->key_info[count],
3187
index_mapping[count])) {
3188
errmsg_printf(ERRMSG_LVL_ERROR, "Found index %s whose column info "
3189
"does not match that of MySQL.",
3190
table->key_info[count].name);
3196
/* Successfully built the translation table */
3197
share->idx_trans_tbl.index_count = mysql_num_index;
3201
/* Build translation table failed. */
3202
free(index_mapping);
3204
share->idx_trans_tbl.array_size = 0;
3205
share->idx_trans_tbl.index_count = 0;
3206
index_mapping = NULL;
3209
share->idx_trans_tbl.index_mapping = index_mapping;
3211
mutex_exit(&dict_sys->mutex);
3216
/*******************************************************************//**
3217
This function uses index translation table to quickly locate the
3218
requested index structure.
3219
Note we do not have mutex protection for the index translatoin table
3220
access, it is based on the assumption that there is no concurrent
3221
translation table rebuild (fter create/drop index) and DMLs that
3222
require index lookup.
3223
@return dict_index_t structure for requested index. NULL if
3224
fail to locate the index structure. */
3227
innobase_index_lookup(
3228
/*==================*/
3229
INNOBASE_SHARE* share, /*!< in: share structure for index
3230
translation table. */
3231
uint keynr) /*!< in: index number for the requested
3234
if (!share->idx_trans_tbl.index_mapping
3235
|| keynr >= share->idx_trans_tbl.index_count) {
3239
return(share->idx_trans_tbl.index_mapping[keynr]);
3242
/********************************************************************//**
3243
2861
Set the autoinc column max value. This should only be called once from
3244
ha_innobase::open(). Therefore there's no need for a covering lock. */
2862
ha_innobase::open(). Therefore there's no need for a covering lock.
2863
@return DB_SUCCESS or error code */
3247
2866
ha_innobase::innobase_initialize_autoinc()
3248
2867
/*======================================*/
2869
dict_index_t* index;
3250
2870
uint64_t auto_inc;
3251
const Field* field = getTable()->found_next_number_field;
3253
if (field != NULL) {
3254
auto_inc = innobase_get_int_col_max_value(field);
3256
/* We have no idea what's been passed in to us as the
3257
autoinc column. We set it to the 0, effectively disabling
3258
updates to the table. */
2871
const char* col_name;
2874
col_name = table->found_next_number_field->field_name;
2875
index = innobase_get_index(table->getShare()->next_number_index);
2877
/* Execute SELECT MAX(col_name) FROM TABLE; */
2878
error = row_search_max_autoinc(index, col_name, &auto_inc);
2883
/* At the this stage we don't know the increment
2884
or the offset, so use default inrement of 1. */
2888
case DB_RECORD_NOT_FOUND:
3261
2889
ut_print_timestamp(stderr);
3262
fprintf(stderr, " InnoDB: Unable to determine the AUTOINC "
3266
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
3267
/* If the recovery level is set so high that writes
3268
are disabled we force the AUTOINC counter to 0
3269
value effectively disabling writes to the table.
3270
Secondly, we avoid reading the table in case the read
3271
results in failure due to a corrupted table/index.
3273
We will not return an error to the client, so that the
3274
tables can be dumped with minimal hassle. If an error
3275
were returned in this case, the first attempt to read
3276
the table would fail and subsequent SELECTs would succeed. */
3278
} else if (field == NULL) {
3279
/* This is a far more serious error, best to avoid
3280
opening the table and return failure. */
3281
my_error(ER_AUTOINC_READ_FAILED, MYF(0));
3283
dict_index_t* index;
3284
const char* col_name;
3285
uint64_t read_auto_inc;
3288
update_session(getTable()->in_use);
3289
col_name = field->field_name;
3291
ut_a(prebuilt->trx == session_to_trx(user_session));
3293
index = innobase_get_index(getTable()->getShare()->next_number_index);
3295
/* Execute SELECT MAX(col_name) FROM TABLE; */
3296
err = row_search_max_autoinc(index, col_name, &read_auto_inc);
3300
uint64_t col_max_value;
3302
col_max_value = innobase_get_int_col_max_value(field);
3304
/* At the this stage we do not know the increment
3305
nor the offset, so use a default increment of 1. */
3307
auto_inc = innobase_next_autoinc(read_auto_inc, 1, 1, col_max_value);
3311
case DB_RECORD_NOT_FOUND:
3312
ut_print_timestamp(stderr);
3313
fprintf(stderr, " InnoDB: MySQL and InnoDB data "
3314
"dictionaries are out of sync.\n"
3315
"InnoDB: Unable to find the AUTOINC column "
3316
"%s in the InnoDB table %s.\n"
3317
"InnoDB: We set the next AUTOINC column "
3319
"InnoDB: in effect disabling the AUTOINC "
3320
"next value generation.\n"
3321
"InnoDB: You can either set the next "
3322
"AUTOINC value explicitly using ALTER TABLE\n"
3323
"InnoDB: or fix the data dictionary by "
3324
"recreating the table.\n",
3325
col_name, index->table->name);
3327
/* This will disable the AUTOINC generation. */
3330
/* We want the open to succeed, so that the user can
3331
take corrective action. ie. reads should succeed but
3332
updates should fail. */
3336
/* row_search_max_autoinc() should only return
3337
one of DB_SUCCESS or DB_RECORD_NOT_FOUND. */
2890
fprintf(stderr, " InnoDB: MySQL and InnoDB data "
2891
"dictionaries are out of sync.\n"
2892
"InnoDB: Unable to find the AUTOINC column %s in the "
2893
"InnoDB table %s.\n"
2894
"InnoDB: We set the next AUTOINC column value to the "
2895
"maximum possible value,\n"
2896
"InnoDB: in effect disabling the AUTOINC next value "
2898
"InnoDB: You can either set the next AUTOINC value "
2899
"explicitly using ALTER TABLE\n"
2900
"InnoDB: or fix the data dictionary by recreating "
2902
col_name, index->table->name);
2904
auto_inc = 0xFFFFFFFFFFFFFFFFULL;
3342
2911
dict_table_autoinc_initialize(prebuilt->table, auto_inc);
3345
2916
/*****************************************************************//**
3468
3034
of length ref_length! */
3470
3036
if (!row_table_got_default_clust_index(ib_table)) {
3037
if (primary_key >= MAX_KEY) {
3038
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has a primary key in InnoDB data "
3039
"dictionary, but not in MySQL!", identifier.getTableName().c_str());
3472
3042
prebuilt->clust_index_was_generated = FALSE;
3474
if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) {
3475
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has a primary key in "
3476
"InnoDB data dictionary, but not "
3477
"in MySQL!", identifier.getTableName().c_str());
3479
/* This mismatch could cause further problems
3480
if not attended, bring this to the user's attention
3481
by printing a warning in addition to log a message
3483
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3485
"InnoDB: Table %s has a "
3486
"primary key in InnoDB data "
3487
"dictionary, but not in "
3488
"MySQL!", identifier.getTableName().c_str());
3490
/* If primary_key >= MAX_KEY, its (primary_key)
3491
value could be out of bound if continue to index
3492
into key_info[] array. Find InnoDB primary index,
3493
and assign its key_length to ref_length.
3494
In addition, since MySQL indexes are sorted starting
3495
with primary index, unique index etc., initialize
3496
ref_length to the first index key length in
3497
case we fail to find InnoDB cluster index.
3499
Please note, this will not resolve the primary
3500
index mismatch problem, other side effects are
3501
possible if users continue to use the table.
3502
However, we allow this table to be opened so
3503
that user can adopt necessary measures for the
3504
mismatch while still being accessible to the table
3506
ref_length = getTable()->key_info[0].key_length;
3508
/* Find correspoinding cluster index
3509
key length in MySQL's key_info[] array */
3510
for (ulint i = 0; i < getTable()->getShare()->keys; i++) {
3511
dict_index_t* index;
3512
index = innobase_get_index(i);
3513
if (dict_index_is_clust(index)) {
3515
getTable()->key_info[i].key_length;
3519
/* MySQL allocates the buffer for ref.
3520
key_info->key_length includes space for all key
3521
columns + one byte for each column that may be
3522
NULL. ref_length must be as exact as possible to
3523
save space, because all row reference buffers are
3524
allocated based on ref_length. */
3526
ref_length = getTable()->key_info[primary_key].key_length;
3044
/* MySQL allocates the buffer for ref. key_info->key_length
3045
includes space for all key columns + one byte for each column
3046
that may be NULL. ref_length must be as exact as possible to
3047
save space, because all row reference buffers are allocated
3048
based on ref_length. */
3050
ref_length = table->key_info[primary_key].key_length;
3529
3052
if (primary_key != MAX_KEY) {
3530
errmsg_printf(ERRMSG_LVL_ERROR,
3531
"Table %s has no primary key in InnoDB data "
3532
"dictionary, but has one in MySQL! If you "
3533
"created the table with a MySQL version < "
3534
"3.23.54 and did not define a primary key, "
3535
"but defined a unique key with all non-NULL "
3536
"columns, then MySQL internally treats that "
3537
"key as the primary key. You can fix this "
3538
"error by dump + DROP + CREATE + reimport "
3539
"of the table.", identifier.getTableName().c_str());
3541
/* This mismatch could cause further problems
3542
if not attended, bring this to the user attention
3543
by printing a warning in addition to log a message
3545
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
3547
"InnoDB: Table %s has no "
3548
"primary key in InnoDB data "
3549
"dictionary, but has one in "
3550
"MySQL!", identifier.getTableName().c_str());
3053
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has no primary key in InnoDB data "
3054
"dictionary, but has one in MySQL! If you "
3055
"created the table with a MySQL version < "
3056
"3.23.54 and did not define a primary key, "
3057
"but defined a unique key with all non-NULL "
3058
"columns, then MySQL internally treats that "
3059
"key as the primary key. You can fix this "
3060
"error by dump + DROP + CREATE + reimport "
3061
"of the table.", identifier.getTableName().c_str());
3553
3064
prebuilt->clust_index_was_generated = TRUE;
7439
6724
/* Build the template; we will use a dummy template
7440
6725
in index scans done in checking */
7442
build_template(prebuilt, NULL, getTable(), ROW_MYSQL_WHOLE_ROW);
7445
if (prebuilt->table->ibd_file_missing) {
7446
errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: Error:\n"
7447
"InnoDB: MySQL is trying to use a table handle"
7448
" but the .ibd file for\n"
7449
"InnoDB: table %s does not exist.\n"
7450
"InnoDB: Have you deleted the .ibd file"
7451
" from the database directory under\n"
7452
"InnoDB: the MySQL datadir, or have you"
7453
" used DISCARD TABLESPACE?\n"
7454
"InnoDB: Please refer to\n"
7455
"InnoDB: " REFMAN "innodb-troubleshooting.html\n"
7456
"InnoDB: how you can resolve the problem.\n",
7457
prebuilt->table->name);
7458
return(HA_ADMIN_CORRUPT);
7461
prebuilt->trx->op_info = "checking table";
7463
old_isolation_level = prebuilt->trx->isolation_level;
7465
/* We must run the index record counts at an isolation level
7466
>= READ COMMITTED, because a dirty read can see a wrong number
7467
of records in some index; to play safe, we use always
7468
REPEATABLE READ here */
7470
prebuilt->trx->isolation_level = TRX_ISO_REPEATABLE_READ;
7472
/* Enlarge the fatal lock wait timeout during CHECK TABLE. */
7473
mutex_enter(&kernel_mutex);
7474
srv_fatal_semaphore_wait_threshold += 7200; /* 2 hours */
7475
mutex_exit(&kernel_mutex);
7477
for (index = dict_table_get_first_index(prebuilt->table);
7479
index = dict_table_get_next_index(index)) {
7481
fputs("Validating index ", stderr);
7482
ut_print_name(stderr, trx, FALSE, index->name);
7486
if (!btr_validate_index(index, prebuilt->trx)) {
7488
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7490
"InnoDB: The B-tree of"
7491
" index '%-.200s' is corrupted.",
7496
/* Instead of invoking change_active_index(), set up
7497
a dummy template for non-locking reads, disabling
7498
access to the clustered index. */
7499
prebuilt->index = index;
7501
prebuilt->index_usable = row_merge_is_index_usable(
7502
prebuilt->trx, prebuilt->index);
7504
if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
7505
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7506
HA_ERR_TABLE_DEF_CHANGED,
7507
"InnoDB: Insufficient history for"
7513
prebuilt->sql_stat_start = TRUE;
7514
prebuilt->template_type = ROW_MYSQL_DUMMY_TEMPLATE;
7515
prebuilt->n_template = 0;
7516
prebuilt->need_to_access_clustered = FALSE;
7518
dtuple_set_n_fields(prebuilt->search_tuple, 0);
7520
prebuilt->select_lock_type = LOCK_NONE;
7522
if (!row_check_index_for_mysql(prebuilt, index, &n_rows)) {
7523
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7525
"InnoDB: The B-tree of"
7526
" index '%-.200s' is corrupted.",
7531
if (user_session->getKilled()) {
7536
fprintf(stderr, "%lu entries in index %s\n", n_rows,
7540
if (index == dict_table_get_first_index(prebuilt->table)) {
7541
n_rows_in_table = n_rows;
7542
} else if (n_rows != n_rows_in_table) {
7543
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7545
"InnoDB: Index '%-.200s'"
7546
" contains %lu entries,"
7550
(ulong) n_rows_in_table);
7555
/* Restore the original isolation level */
7556
prebuilt->trx->isolation_level = old_isolation_level;
7558
/* We validate also the whole adaptive hash index for all tables
7559
at every CHECK TABLE */
7561
if (!btr_search_validate()) {
7562
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7564
"InnoDB: The adaptive hash index is corrupted.");
7568
/* Restore the fatal lock wait timeout after CHECK TABLE. */
7569
mutex_enter(&kernel_mutex);
7570
srv_fatal_semaphore_wait_threshold -= 7200; /* 2 hours */
7571
mutex_exit(&kernel_mutex);
7573
prebuilt->trx->op_info = "";
7574
if (user_session->getKilled()) {
7575
my_error(ER_QUERY_INTERRUPTED, MYF(0));
7578
return(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
6727
build_template(prebuilt, NULL, table, ROW_MYSQL_WHOLE_ROW);
6730
ret = row_check_table_for_mysql(prebuilt);
6732
if (ret == DB_SUCCESS) {
6733
return(HA_ADMIN_OK);
6736
return(HA_ADMIN_CORRUPT);
7581
6739
/*************************************************************//**
8258
7408
#endif /* UNIV_DEBUG */
8262
buf1len = snprintf(buf1, sizeof buf1,
8264
block_mutex->cfile_name,
8265
(ulong) block_mutex->cline);
8266
buf2len = snprintf(buf2, sizeof buf2,
8268
(ulong) block_mutex_oswait_count);
8270
if (stat_print(session, innobase_engine_name,
8271
strlen(innobase_engine_name), buf1, buf1len,
8273
mutex_exit(&mutex_list_mutex);
7411
mutex = UT_LIST_GET_NEXT(list, mutex);
8278
7414
mutex_exit(&mutex_list_mutex);
8280
7416
mutex_enter(&rw_lock_list_mutex);
8282
for (lock = UT_LIST_GET_FIRST(rw_lock_list); lock != NULL;
8283
lock = UT_LIST_GET_NEXT(list, lock)) {
8284
if (lock->count_os_wait == 0) {
8288
if (buf_pool_is_block_lock(lock)) {
8290
block_lock_oswait_count += lock->count_os_wait;
8294
buf1len = snprintf(buf1, sizeof buf1, "%s:%lu",
8295
lock->cfile_name, (ulong) lock->cline);
8296
buf2len = snprintf(buf2, sizeof buf2, "os_waits=%lu",
8297
(ulong) lock->count_os_wait);
8299
if (stat_print(session, innobase_engine_name,
8300
strlen(innobase_engine_name), buf1, buf1len,
8302
mutex_exit(&rw_lock_list_mutex);
8308
buf1len = snprintf(buf1, sizeof buf1,
8310
block_lock->cfile_name,
8311
(ulong) block_lock->cline);
8312
buf2len = snprintf(buf2, sizeof buf2,
8314
(ulong) block_lock_oswait_count);
8316
if (stat_print(session, innobase_engine_name,
8317
strlen(innobase_engine_name), buf1, buf1len,
8319
mutex_exit(&rw_lock_list_mutex);
7418
lock = UT_LIST_GET_FIRST(rw_lock_list);
7420
while (lock != NULL) {
7421
if (lock->count_os_wait
7422
&& !buf_pool_is_block_lock(lock)) {
7423
buf1len= snprintf(buf1, sizeof(buf1), "%s:%lu",
7424
lock->cfile_name, (unsigned long) lock->cline);
7425
buf2len= snprintf(buf2, sizeof(buf2),
7426
"os_waits=%lu", lock->count_os_wait);
7428
if (stat_print(session, innobase_engine_name,
7429
engine_name_len, buf1, buf1len,
7431
mutex_exit(&rw_lock_list_mutex);
7435
lock = UT_LIST_GET_NEXT(list, lock);
8324
7438
mutex_exit(&rw_lock_list_mutex);
8326
7440
#ifdef UNIV_DEBUG
8327
buf2len = snprintf(buf2, sizeof buf2,
8328
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
8329
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
8330
(ulong) rw_lock_count,
8331
(ulong) rw_lock_count_spin_loop,
8332
(ulong) rw_lock_count_spin_rounds,
8333
(ulong) rw_lock_count_os_wait,
8334
(ulong) rw_lock_count_os_yield,
8335
(ulong) (rw_lock_wait_time / 1000));
7441
buf2len= my_snprintf(buf2, sizeof(buf2),
7442
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
7443
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
7444
rw_lock_count, rw_lock_count_spin_loop,
7445
rw_lock_count_spin_rounds,
7446
rw_lock_count_os_wait, rw_lock_count_os_yield,
7447
(ulong) (rw_lock_wait_time/1000));
8337
7449
if (stat_print(session, innobase_engine_name, engine_name_len,
8338
7450
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
9185
8265
/************************************************************//**
8266
Validate the file format check value, is it one of "on" or "off",
8267
as a side effect it sets the srv_check_file_format_at_startup variable.
8268
@return true if config value one of "on" or "off" */
8271
innobase_file_format_check_on_off(
8272
/*==============================*/
8273
const char* format_check) /*!< in: parameter value */
8277
if (!innobase_strcasecmp(format_check, "off")) {
8279
/* Set the value to disable checking. */
8280
srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
8282
} else if (!innobase_strcasecmp(format_check, "on")) {
8284
/* Set the value to the lowest supported format. */
8285
srv_check_file_format_at_startup = DICT_TF_FORMAT_51;
8293
/************************************************************//**
9186
8294
Validate the file format check config parameters, as a side effect it
9187
sets the srv_max_file_format_at_startup variable.
9188
@return the format_id if valid config value, otherwise, return -1 */
8295
sets the srv_check_file_format_at_startup variable.
8296
@return true if valid config value */
9191
innobase_file_format_validate_and_set(
8299
innobase_file_format_check_validate(
9192
8300
/*================================*/
9193
const char* format_max) /*!< in: parameter value */
8301
const char* format_check) /*!< in: parameter value */
9195
8303
uint format_id;
9197
format_id = innobase_file_format_name_lookup(format_max);
8306
format_id = innobase_file_format_name_lookup(format_check);
9199
8308
if (format_id < DICT_TF_FORMAT_MAX + 1) {
9200
srv_max_file_format_at_startup = format_id;
9201
return((int) format_id);
8309
srv_check_file_format_at_startup = format_id;
8317
/*************************************************************//**
8318
Check if it is a valid file format. This function is registered as
8319
a callback with MySQL.
8320
@return 0 for valid file format */
8323
innodb_file_format_name_validate(
8324
/*=============================*/
8325
Session* , /*!< in: thread handle */
8326
drizzle_sys_var* , /*!< in: pointer to system
8328
void* save, /*!< out: immediate result
8329
for update function */
8330
drizzle_value* value) /*!< in: incoming string */
8332
const char* file_format_input;
8333
char buff[STRING_BUFFER_USUAL_SIZE];
8334
int len = sizeof(buff);
8337
ut_a(value != NULL);
8339
file_format_input = value->val_str(value, buff, &len);
8341
if (file_format_input != NULL) {
8344
format_id = innobase_file_format_name_lookup(
8347
if (format_id <= DICT_TF_FORMAT_MAX) {
8349
*static_cast<const char**>(save) = file_format_input;
8354
*static_cast<const char**>(save) = NULL;
8358
/****************************************************************//**
8359
Update the system variable innodb_file_format using the "saved"
8360
value. This function is registered as a callback with MySQL. */
8363
innodb_file_format_name_update(
8364
/*===========================*/
8365
Session* , /*!< in: thread handle */
8366
drizzle_sys_var* , /*!< in: pointer to
8368
void* var_ptr, /*!< out: where the
8369
formal string goes */
8370
const void* save) /*!< in: immediate result
8371
from check function */
8373
const char* format_name;
8375
ut_a(var_ptr != NULL);
8378
format_name = *static_cast<const char*const*>(save);
8383
format_id = innobase_file_format_name_lookup(format_name);
8385
if (format_id <= DICT_TF_FORMAT_MAX) {
8386
srv_file_format = format_id;
8390
*static_cast<const char**>(var_ptr)
8391
= trx_sys_file_format_id_to_name(srv_file_format);
8394
/*************************************************************//**
8395
Check if valid argument to innodb_file_format_check. This
8396
function is registered as a callback with MySQL.
8397
@return 0 for valid file format */
8400
innodb_file_format_check_validate(
8401
/*==============================*/
8402
Session* , /*!< in: thread handle */
8403
drizzle_sys_var* , /*!< in: pointer to system
8405
void* save, /*!< out: immediate result
8406
for update function */
8407
drizzle_value* value) /*!< in: incoming string */
8409
const char* file_format_input;
8410
char buff[STRING_BUFFER_USUAL_SIZE];
8411
int len = sizeof(buff);
8414
ut_a(value != NULL);
8416
file_format_input = value->val_str(value, buff, &len);
8418
if (file_format_input != NULL) {
8420
/* Check if user set on/off, we want to print a suitable
8421
message if they did so. */
8423
if (innobase_file_format_check_on_off(file_format_input)) {
8424
errmsg_printf(ERRMSG_LVL_WARN,
8425
"InnoDB: invalid innodb_file_format_check "
8426
"value; on/off can only be set at startup or "
8427
"in the configuration file");
8428
} else if (innobase_file_format_check_validate(
8429
file_format_input)) {
8431
*static_cast<const char**>(save) = file_format_input;
8436
errmsg_printf(ERRMSG_LVL_WARN,
8437
"InnoDB: invalid innodb_file_format_check "
8438
"value; can be any format up to %s "
8439
"or its equivalent numeric id",
8440
trx_sys_file_format_id_to_name(
8441
DICT_TF_FORMAT_MAX));
8445
*static_cast<const char**>(save) = NULL;
8449
/****************************************************************//**
8450
Update the system variable innodb_file_format_check using the "saved"
8451
value. This function is registered as a callback with MySQL. */
8454
innodb_file_format_check_update(
8455
/*============================*/
8456
Session* session, /*!< in: thread handle */
8457
drizzle_sys_var* , /*!< in: pointer to
8459
void* var_ptr, /*!< out: where the
8460
formal string goes */
8461
const void* save) /*!< in: immediate result
8462
from check function */
8464
const char* format_name_in;
8465
const char** format_name_out;
8469
ut_a(var_ptr != NULL);
8471
format_name_in = *static_cast<const char*const*>(save);
8473
if (!format_name_in) {
8478
format_id = innobase_file_format_name_lookup(format_name_in);
8480
if (format_id > DICT_TF_FORMAT_MAX) {
8481
/* DEFAULT is "on", which is invalid at runtime. */
8482
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
8484
"Ignoring SET innodb_file_format=%s",
8489
format_name_out = static_cast<const char**>(var_ptr);
8491
/* Update the max format id in the system tablespace. */
8492
if (trx_sys_file_format_max_set(format_id, format_name_out)) {
8493
ut_print_timestamp(stderr);
8495
" [Info] InnoDB: the file format in the system "
8496
"tablespace is now set to %s.\n", *format_name_out);
8500
/****************************************************************//**
8501
Update the system variable innodb_adaptive_hash_index using the "saved"
8502
value. This function is registered as a callback with MySQL. */
8505
innodb_adaptive_hash_index_update(
8506
/*==============================*/
8507
Session* , /*!< in: thread handle */
8508
drizzle_sys_var* , /*!< in: pointer to
8510
void* , /*!< out: where the
8511
formal string goes */
8512
const void* save) /*!< in: immediate result
8513
from check function */
8515
if (*(bool*) save) {
8516
btr_search_enable();
8518
btr_search_disable();
8522
/*************************************************************//**
8523
Check if it is a valid value of innodb_change_buffering. This function is
8524
registered as a callback with MySQL.
8525
@return 0 for valid innodb_change_buffering */
8528
innodb_change_buffering_validate(
8529
/*=============================*/
8530
Session* , /*!< in: thread handle */
8531
drizzle_sys_var* , /*!< in: pointer to system
8533
void* save, /*!< out: immediate result
8534
for update function */
8535
drizzle_value* value) /*!< in: incoming string */
8537
const char* change_buffering_input;
8538
char buff[STRING_BUFFER_USUAL_SIZE];
8539
int len = sizeof(buff);
8542
ut_a(value != NULL);
8544
change_buffering_input = value->val_str(value, buff, &len);
8546
if (change_buffering_input != NULL) {
8549
for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
8551
if (!innobase_strcasecmp(
8552
change_buffering_input,
8553
innobase_change_buffering_values[use])) {
8554
*(ibuf_use_t*) save = (ibuf_use_t) use;
8563
/****************************************************************//**
8564
Update the system variable innodb_change_buffering using the "saved"
8565
value. This function is registered as a callback with MySQL. */
8568
innodb_change_buffering_update(
8569
/*===========================*/
8570
Session* , /*!< in: thread handle */
8571
drizzle_sys_var* , /*!< in: pointer to
8573
void* var_ptr, /*!< out: where the
8574
formal string goes */
8575
const void* save) /*!< in: immediate result
8576
from check function */
8578
ut_a(var_ptr != NULL);
8580
ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
8582
ibuf_use = *(const ibuf_use_t*) save;
8584
*(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
8587
/* plugin options */
8588
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
8589
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8590
"Enable InnoDB checksums validation (enabled by default). ",
8593
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
8594
PLUGIN_VAR_READONLY,
8595
"The common part for InnoDB table spaces.",
8598
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
8599
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8600
"Enable InnoDB doublewrite buffer (enabled by default). ",
8603
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
8604
PLUGIN_VAR_RQCMDARG,
8605
"Number of IOPs the server can do. Tunes the background IO rate",
8606
NULL, NULL, 200, 100, ~0L, 0);
8608
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
8609
PLUGIN_VAR_OPCMDARG,
8610
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
8611
"values are 0, 1 (faster)"
8612
" or 2 (fastest - crash-like)"
8614
NULL, NULL, 1, 0, 2, 0);
8616
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
8617
PLUGIN_VAR_NOCMDARG,
8618
"Stores each InnoDB table to an .ibd file in the database dir.",
8621
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
8622
PLUGIN_VAR_RQCMDARG,
8623
"File format to use for new tables in .ibd files.",
8624
innodb_file_format_name_validate,
8625
innodb_file_format_name_update, "Antelope");
8627
static DRIZZLE_SYSVAR_STR(file_format_check, innobase_file_format_check,
8628
PLUGIN_VAR_OPCMDARG,
8629
"The highest file format in the tablespace.",
8630
innodb_file_format_check_validate,
8631
innodb_file_format_check_update,
8634
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
8635
PLUGIN_VAR_OPCMDARG,
8636
"Set to 0 (write and flush once per second),"
8637
" 1 (write and flush at each commit)"
8638
" or 2 (write at commit, flush once per second).",
8639
NULL, NULL, 1, 0, 2, 0);
8641
static DRIZZLE_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
8642
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8643
"With which method to flush data.", NULL, NULL, NULL);
8645
#ifdef UNIV_LOG_ARCHIVE
8646
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
8647
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8648
"Where full logs should be archived.", NULL, NULL, NULL);
8650
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
8651
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
8652
"Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
8653
#endif /* UNIV_LOG_ARCHIVE */
8655
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
8656
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8657
"Path to InnoDB log files.", NULL, NULL, NULL);
8659
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
8660
PLUGIN_VAR_RQCMDARG,
8661
"Percentage of dirty pages allowed in bufferpool.",
8662
NULL, NULL, 75, 0, 99, 0);
8664
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
8665
PLUGIN_VAR_NOCMDARG,
8666
"Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
8669
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
8670
PLUGIN_VAR_RQCMDARG,
8671
"Desired maximum length of the purge queue (0 = no limit)",
8672
NULL, NULL, 0, 0, ~0L, 0);
8674
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
8675
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
8676
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
8679
static DRIZZLE_SYSVAR_BOOL(stats_on_metadata, innobase_stats_on_metadata,
8680
PLUGIN_VAR_OPCMDARG,
8681
"Enable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)",
8684
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
8685
PLUGIN_VAR_RQCMDARG,
8686
"The number of index pages to sample when calculating statistics (default 8)",
8687
NULL, NULL, 8, 1, ~0ULL, 0);
8689
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
8690
PLUGIN_VAR_OPCMDARG,
8691
"Enable InnoDB adaptive hash index (enabled by default).",
8692
NULL, innodb_adaptive_hash_index_update, TRUE);
8694
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
8695
PLUGIN_VAR_RQCMDARG,
8696
"Replication thread delay (ms) on the slave server if "
8697
"innodb_thread_concurrency is reached (0 by default)",
8698
NULL, NULL, 0, 0, ~0UL, 0);
8700
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
8701
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8702
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
8703
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
8705
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
8706
PLUGIN_VAR_RQCMDARG,
8707
"Data file autoextend increment in megabytes",
8708
NULL, NULL, 8L, 1L, 1000L, 0);
8710
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
8711
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8712
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
8713
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
8715
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
8716
PLUGIN_VAR_RQCMDARG,
8717
"Helps in performance tuning in heavily concurrent environments.",
8718
innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
8720
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
8721
PLUGIN_VAR_RQCMDARG,
8722
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
8723
NULL, NULL, 500L, 1L, ~0L, 0);
8725
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
8726
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8727
"Number of background read I/O threads in InnoDB.",
8728
NULL, NULL, 4, 1, 64, 0);
8730
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
8731
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8732
"Number of background write I/O threads in InnoDB.",
8733
NULL, NULL, 4, 1, 64, 0);
8735
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
8736
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8737
"Helps to save your data in case the disk image of the database becomes corrupt.",
8738
NULL, NULL, 0, 0, 6, 0);
8740
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
8741
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8742
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
8743
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
8745
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
8746
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8747
"Size of each log file in a log group.",
8748
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
8750
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
8751
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8752
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
8753
NULL, NULL, 2, 2, 100, 0);
8755
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
8756
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8757
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
8758
NULL, NULL, 1, 1, 10, 0);
8760
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
8761
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8762
"How many files at the maximum InnoDB keeps open at the same time.",
8763
NULL, NULL, 300L, 10L, LONG_MAX, 0);
8765
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
8766
PLUGIN_VAR_RQCMDARG,
8767
"Count of spin-loop rounds in InnoDB mutexes (30 by default)",
8768
NULL, NULL, 30L, 0L, ~0L, 0);
8770
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
8771
PLUGIN_VAR_OPCMDARG,
8772
"Maximum delay between polling for a spin lock (6 by default)",
8773
NULL, NULL, 6L, 0L, ~0L, 0);
8775
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
8776
PLUGIN_VAR_RQCMDARG,
8777
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
8778
NULL, NULL, 0, 0, 1000, 0);
8780
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
8781
PLUGIN_VAR_RQCMDARG,
8782
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
8783
NULL, NULL, 10000L, 0L, ~0L, 0);
8785
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
8786
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8787
"Path to individual files and their sizes.",
8790
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
8791
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
8792
"InnoDB version", NULL, NULL, INNODB_VERSION_STR);
8794
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
8795
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8796
"Use OS memory allocator instead of InnoDB's internal memory allocator",
8799
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
8800
PLUGIN_VAR_RQCMDARG,
8801
"Buffer changes to reduce random access: "
8802
"OFF, ON, inserting, deleting, changing, or purging.",
8803
innodb_change_buffering_validate,
8804
innodb_change_buffering_update, NULL);
8806
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
8807
PLUGIN_VAR_RQCMDARG,
8808
"Number of pages that must be accessed sequentially for InnoDB to"
8809
"trigger a readahead.",
8810
NULL, NULL, 56, 0, 64, 0);
9209
8812
static void init_options(drizzled::module::option_context &context)
9263
8864
context("disable-stats-on-metadata",
9264
8865
"Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9265
8866
context("stats-sample-pages",
9266
po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
8867
po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9267
8868
"The number of index pages to sample when calculating statistics (default 8)");
9268
8869
context("disable-adaptive-hash-index",
9269
8870
"Enable InnoDB adaptive hash index (enabled by default)");
9270
8871
context("replication-delay",
9271
po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
8872
po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9272
8873
"Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9273
8874
context("additional-mem-pool-size",
9274
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
8875
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9275
8876
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9276
8877
context("autoextend-increment",
9277
po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
8878
po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9278
8879
"Data file autoextend increment in megabytes");
9279
8880
context("buffer-pool-size",
9280
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
8881
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9281
8882
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9282
context("buffer-pool-instances",
9283
po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9284
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9286
8883
context("commit-concurrency",
9287
po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
8884
po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9288
8885
"Helps in performance tuning in heavily concurrent environments.");
9289
8886
context("concurrency-tickets",
9290
po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
8887
po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9291
8888
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9292
8889
context("read-io-threads",
9293
po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
8890
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9294
8891
"Number of background read I/O threads in InnoDB.");
9295
8892
context("write-io-threads",
9296
po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
8893
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9297
8894
"Number of background write I/O threads in InnoDB.");
9298
8895
context("force-recovery",
9299
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
8896
po::value<long>(&innobase_force_recovery)->default_value(0),
9300
8897
"Helps to save your data in case the disk image of the database becomes corrupt.");
9301
8898
context("log-buffer-size",
9302
po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
8899
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9303
8900
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9304
8901
context("log-file-size",
9305
po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
8902
po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9306
8903
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9307
8904
context("log-files-in-group",
9308
po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
8905
po::value<long>(&innobase_log_files_in_group)->default_value(2),
9309
8906
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9310
8907
context("mirrored-log-groups",
9311
po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
8908
po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9312
8909
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9313
8910
context("open-files",
9314
po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
8911
po::value<long>(&innobase_open_files)->default_value(300L),
9315
8912
"How many files at the maximum InnoDB keeps open at the same time.");
9316
8913
context("sync-spin-loops",
9317
po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
8914
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9318
8915
"Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9319
8916
context("spin-wait-delay",
9320
po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
8917
po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9321
8918
"Maximum delay between polling for a spin lock (6 by default)");
9322
8919
context("thread-concurrency",
9323
po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
8920
po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9324
8921
"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
8922
context("thread-sleep-delay",
9326
po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
8923
po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9327
8924
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9328
8925
context("data-file-path",
9329
8926
po::value<string>(),
9334
8931
context("use-internal-malloc",
9335
8932
"Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9336
8933
context("change-buffering",
9337
po::value<string>(&innobase_change_buffering),
8934
po::value<string>(),
9338
8935
"Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9339
8936
context("read-ahead-threshold",
9340
po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
8937
po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9341
8938
"Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9342
8939
context("disable-xa",
9343
8940
"Disable InnoDB support for the XA two-phase commit");
9344
8941
context("disable-table-locks",
9345
8942
"Disable InnoDB locking in LOCK TABLES");
9346
8943
context("strict-mode",
9347
po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
8944
po::value<bool>()->default_value(false)->zero_tokens(),
9348
8945
"Use strict mode when evaluating create options.");
9349
context("replication-log",
9350
po::value<bool>(&innobase_use_replication_log)->default_value(false),
9351
_("Enable internal replication log."));
9352
8946
context("lock-wait-timeout",
9353
po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9354
_("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9355
context("old-blocks-pct",
9356
po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9357
_("Percentage of the buffer pool to reserve for 'old' blocks."));
9358
context("old-blocks-time",
9359
po::value<uint32_t>(&buf_LRU_old_threshold_ms)->default_value(0),
9360
_("ove blocks to the 'new' end of the buffer pool if the first access"
9361
" was at least this many milliseconds ago."
9362
" The timeout is disabled if 0 (the default)."));
8947
po::value<unsigned long>()->default_value(50),
8948
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
8951
static drizzle_sys_var* innobase_system_variables[]= {
8952
DRIZZLE_SYSVAR(additional_mem_pool_size),
8953
DRIZZLE_SYSVAR(autoextend_increment),
8954
DRIZZLE_SYSVAR(buffer_pool_size),
8955
DRIZZLE_SYSVAR(checksums),
8956
DRIZZLE_SYSVAR(commit_concurrency),
8957
DRIZZLE_SYSVAR(concurrency_tickets),
8958
DRIZZLE_SYSVAR(data_file_path),
8959
DRIZZLE_SYSVAR(data_home_dir),
8960
DRIZZLE_SYSVAR(doublewrite),
8961
DRIZZLE_SYSVAR(fast_shutdown),
8962
DRIZZLE_SYSVAR(read_io_threads),
8963
DRIZZLE_SYSVAR(write_io_threads),
8964
DRIZZLE_SYSVAR(file_per_table),
8965
DRIZZLE_SYSVAR(file_format),
8966
DRIZZLE_SYSVAR(file_format_check),
8967
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
8968
DRIZZLE_SYSVAR(flush_method),
8969
DRIZZLE_SYSVAR(force_recovery),
8970
DRIZZLE_SYSVAR(lock_wait_timeout),
8971
#ifdef UNIV_LOG_ARCHIVE
8972
DRIZZLE_SYSVAR(log_arch_dir),
8973
DRIZZLE_SYSVAR(log_archive),
8974
#endif /* UNIV_LOG_ARCHIVE */
8975
DRIZZLE_SYSVAR(log_buffer_size),
8976
DRIZZLE_SYSVAR(log_file_size),
8977
DRIZZLE_SYSVAR(log_files_in_group),
8978
DRIZZLE_SYSVAR(log_group_home_dir),
8979
DRIZZLE_SYSVAR(max_dirty_pages_pct),
8980
DRIZZLE_SYSVAR(max_purge_lag),
8981
DRIZZLE_SYSVAR(adaptive_flushing),
8982
DRIZZLE_SYSVAR(mirrored_log_groups),
8983
DRIZZLE_SYSVAR(open_files),
8984
DRIZZLE_SYSVAR(stats_on_metadata),
8985
DRIZZLE_SYSVAR(stats_sample_pages),
8986
DRIZZLE_SYSVAR(adaptive_hash_index),
8987
DRIZZLE_SYSVAR(replication_delay),
8988
DRIZZLE_SYSVAR(status_file),
8989
DRIZZLE_SYSVAR(strict_mode),
8990
DRIZZLE_SYSVAR(support_xa),
8991
DRIZZLE_SYSVAR(sync_spin_loops),
8992
DRIZZLE_SYSVAR(spin_wait_delay),
8993
DRIZZLE_SYSVAR(table_locks),
8994
DRIZZLE_SYSVAR(thread_concurrency),
8995
DRIZZLE_SYSVAR(thread_sleep_delay),
8996
DRIZZLE_SYSVAR(version),
8997
DRIZZLE_SYSVAR(use_sys_malloc),
8998
DRIZZLE_SYSVAR(change_buffering),
8999
DRIZZLE_SYSVAR(read_ahead_threshold),
9000
DRIZZLE_SYSVAR(io_capacity),
9367
9004
DRIZZLE_DECLARE_PLUGIN