160
180
#endif /* MYSQL_DYNAMIC_PLUGIN && __WIN__ */
162
182
static plugin::XaStorageEngine* innodb_engine_ptr= NULL;
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;
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;
208
206
/** Percentage of the buffer pool to reserve for 'old' blocks.
209
207
Connected to buf_LRU_old_ratio. */
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;
208
static uint innobase_old_blocks_pct;
220
210
/* The default values for the following char* start-up parameters
221
211
are determined in innobase_init below: */
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;
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;
234
226
/* Below we have boolean-valued start-up parameters, and their default
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;
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 */
253
234
static my_bool innobase_use_doublewrite = TRUE;
254
235
static my_bool innobase_use_checksums = TRUE;
255
236
static my_bool innobase_rollback_on_timeout = FALSE;
256
237
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;
263
239
static char* internal_innobase_data_file_path = NULL;
241
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
265
243
/* The following counter is used to convey information to InnoDB
266
244
about server activity: in selects it is not sensible to call
267
245
srv_active_wake_master_thread after each fetch or search, we only do
1806
1825
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);
2007
1828
/*********************************************************************//**
2008
1829
Opens an InnoDB database.
2009
1830
@return 0 on success, error code on failure */
2019
1840
InnobaseEngine *actuall_engine_ptr;
2020
1841
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();
2038
1843
/* Inverted Booleans */
2040
1845
innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
2041
1846
innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
2042
1847
srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
2043
1848
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
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 */
1849
(SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
1850
(SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
1852
if (vm.count("io-capacity"))
1854
if (srv_io_capacity < 100)
1856
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
2050
1861
if (vm.count("data-home-dir"))
2052
innobase_data_home_dir= vm["data-home-dir"].as<string>();
2056
innobase_data_home_dir= getDataHome().file_string();
1863
innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
1867
innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
1870
if (vm.count("fast-shutdown"))
1872
if (innobase_fast_shutdown > 2)
1874
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
1879
if (vm.count("file-format-check"))
1881
innobase_file_format_check= const_cast<char *>(vm["file-format-check"].as<string>().c_str());
1884
if (vm.count("flush-log-at-trx-commit"))
1886
if (srv_flush_log_at_trx_commit > 2)
1888
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
1893
if (vm.count("flush-method"))
1895
innobase_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
1899
innobase_file_flush_method= NULL;
1902
#ifdef UNIV_LOG_ARCHIVE
1903
if (vm.count("log-arch-dir"))
1905
innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
1910
innobase_log_arch_dir= NULL;
1912
#endif /* UNIV_LOG_ARCHIVE */
1914
if (vm.count("max-dirty-pages-pct"))
1916
if (srv_max_buf_pool_modified_pct > 99)
1918
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
1923
if (vm.count("stats-sample-pages"))
1925
if (srv_stats_sample_pages < 8)
1927
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
1932
if (vm.count("additional-mem-pool-size"))
1934
align_value(innobase_additional_mem_pool_size);
1936
if (innobase_additional_mem_pool_size < 512*1024L)
1938
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
1944
if (vm.count("autoextend-increment"))
1946
if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
1948
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
1953
if (vm.count("buffer-pool-size"))
1955
align_value(innobase_buffer_pool_size, 1024*1024);
1956
if (innobase_buffer_pool_size < 5*1024*1024)
1958
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
1964
if (vm.count("commit-concurrency"))
1966
if (srv_replication_delay > 1000)
1968
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
1973
if (vm.count("concurrency-tickets"))
1975
if (srv_n_free_tickets_to_enter < 1)
1977
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
1982
if (vm.count("read-io-threads"))
1984
if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
1986
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
1991
if (vm.count("write-io-threads"))
1993
if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
1995
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
2000
if (vm.count("force-recovery"))
2002
if (innobase_force_recovery > 6)
2004
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
2009
if (vm.count("log-buffer-size"))
2011
align_value(innobase_log_buffer_size);
2012
if (innobase_log_buffer_size < 256*1024L)
2014
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2019
if (vm.count("log-file-size"))
2021
align_value(innobase_log_file_size, 1024*1024);
2022
if (innobase_log_file_size < 1*1024*1024L)
2024
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2029
if (vm.count("log-files-in-group"))
2031
if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
2033
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
2038
if (vm.count("mirrored-log-groups"))
2040
if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
2042
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
2047
if (vm.count("open-files"))
2049
if (innobase_open_files < 10)
2051
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
2056
if (vm.count("thread-concurrency"))
2058
if (srv_thread_concurrency > 1000)
2060
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
2060
2065
if (vm.count("data-file-path"))
2062
innobase_data_file_path= vm["data-file-path"].as<string>();
2067
innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
2071
innobase_data_file_path= NULL;
2074
if (vm.count("version"))
2076
innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
2079
if (vm.count("read-ahead-threshold"))
2081
if (srv_read_ahead_threshold > 64)
2083
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
2088
if (vm.count("strict-mode"))
2090
(SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
2093
if (vm.count("lock-wait-timeout"))
2095
if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
2097
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
2101
(SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
2066
2104
innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2269
2349
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();
2278
2351
if (err != DB_SUCCESS) {
2279
2352
goto mem_free_and_error;
2283
innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(),
2286
2355
innobase_open_tables = hash_create(200);
2356
pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
2357
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
2358
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
2359
pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
2360
pthread_mutex_init(&analyze_mutex, MY_MUTEX_INIT_FAST);
2361
pthread_cond_init(&commit_cond, NULL);
2287
2362
innodb_inited= 1;
2289
2364
actuall_engine_ptr->dropTemporarySchema();
2291
context.add(new InnodbStatusTool);
2366
status_table_function_ptr= new InnodbStatusTool;
2293
2368
context.add(innodb_engine_ptr);
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());
2370
context.add(status_table_function_ptr);
2372
cmp_tool= new(std::nothrow)CmpTool(false);
2373
context.add(cmp_tool);
2375
cmp_reset_tool= new(std::nothrow)CmpTool(true);
2376
context.add(cmp_reset_tool);
2378
cmp_mem_tool= new(std::nothrow)CmpmemTool(false);
2379
context.add(cmp_mem_tool);
2381
cmp_mem_reset_tool= new(std::nothrow)CmpmemTool(true);
2382
context.add(cmp_mem_reset_tool);
2384
innodb_trx_tool= new(std::nothrow)InnodbTrxTool("INNODB_TRX");
2385
context.add(innodb_trx_tool);
2387
innodb_locks_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCKS");
2388
context.add(innodb_locks_tool);
2390
innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
2391
context.add(innodb_lock_waits_tool);
2323
2393
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));
2414
2395
/* Get the current high water mark format. */
2415
innobase_file_format_max = trx_sys_file_format_max_get();
2416
btr_search_fully_disabled = (!btr_search_enabled);
2396
innobase_file_format_check = (char*) trx_sys_file_format_max_get();
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]);
2840
/*****************************************************************//**
2841
Normalizes a table name string. A normalized name consists of the
2842
database name catenated to '/' and table name. An example:
2843
test/mytable. On Windows normalization puts both the database name and the
2844
table name always to lower case. */
2847
normalize_table_name(
2848
/*=================*/
2849
char* norm_name, /*!< out: normalized name as a
2850
null-terminated string */
2851
const char* name) /*!< in: table name string */
2853
const char* name_ptr;
2857
/* Scan name from the end */
2859
ptr = strchr(name, '\0')-1;
2861
while (ptr >= name && *ptr != '\\' && *ptr != '/') {
2871
while (ptr >= name && *ptr != '\\' && *ptr != '/') {
2877
memcpy(norm_name, db_ptr, strlen(name) + 1 - (db_ptr - name));
2879
norm_name[name_ptr - db_ptr - 1] = '/';
2882
innobase_casedn_str(norm_name);
3129
2886
/********************************************************************//**
3130
2887
Set the autoinc column max value. This should only be called once from
3131
ha_innobase::open(). Therefore there's no need for a covering lock. */
2888
ha_innobase::open(). Therefore there's no need for a covering lock.
2889
@return DB_SUCCESS or error code */
3134
2892
ha_innobase::innobase_initialize_autoinc()
3135
2893
/*======================================*/
2895
dict_index_t* index;
3137
2896
uint64_t auto_inc;
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. */
2897
const char* col_name;
2900
col_name = table->found_next_number_field->field_name;
2901
index = innobase_get_index(table->getShare()->next_number_index);
2903
/* Execute SELECT MAX(col_name) FROM TABLE; */
2904
error = row_search_max_autoinc(index, col_name, &auto_inc);
2909
/* At the this stage we don't know the increment
2910
or the offset, so use default inrement of 1. */
2914
case DB_RECORD_NOT_FOUND:
3148
2915
ut_print_timestamp(stderr);
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. */
2916
fprintf(stderr, " InnoDB: MySQL and InnoDB data "
2917
"dictionaries are out of sync.\n"
2918
"InnoDB: Unable to find the AUTOINC column %s in the "
2919
"InnoDB table %s.\n"
2920
"InnoDB: We set the next AUTOINC column value to the "
2921
"maximum possible value,\n"
2922
"InnoDB: in effect disabling the AUTOINC next value "
2924
"InnoDB: You can either set the next AUTOINC value "
2925
"explicitly using ALTER TABLE\n"
2926
"InnoDB: or fix the data dictionary by recreating "
2928
col_name, index->table->name);
2930
auto_inc = 0xFFFFFFFFFFFFFFFFULL;
3222
2937
dict_table_autoinc_initialize(prebuilt->table, auto_inc);
3225
2942
/*****************************************************************//**
3369
3060
of length ref_length! */
3371
3062
if (!row_table_got_default_clust_index(ib_table)) {
3063
if (primary_key >= MAX_KEY) {
3064
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has a primary key in InnoDB data "
3065
"dictionary, but not in MySQL!", identifier.getTableName().c_str());
3373
3068
prebuilt->clust_index_was_generated = FALSE;
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;
3070
/* MySQL allocates the buffer for ref. key_info->key_length
3071
includes space for all key columns + one byte for each column
3072
that may be NULL. ref_length must be as exact as possible to
3073
save space, because all row reference buffers are allocated
3074
based on ref_length. */
3076
ref_length = table->key_info[primary_key].key_length;
3430
3078
if (primary_key != MAX_KEY) {
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());
3079
errmsg_printf(ERRMSG_LVL_ERROR, "Table %s has no primary key in InnoDB data "
3080
"dictionary, but has one in MySQL! If you "
3081
"created the table with a MySQL version < "
3082
"3.23.54 and did not define a primary key, "
3083
"but defined a unique key with all non-NULL "
3084
"columns, then MySQL internally treats that "
3085
"key as the primary key. You can fix this "
3086
"error by dump + DROP + CREATE + reimport "
3087
"of the table.", identifier.getTableName().c_str());
3454
3090
prebuilt->clust_index_was_generated = TRUE;
7363
6819
/* Build the template; we will use a dummy template
7364
6820
in index scans done in checking */
7366
build_template(prebuilt, NULL, getTable(), ROW_MYSQL_WHOLE_ROW);
6822
build_template(prebuilt, NULL, table, ROW_MYSQL_WHOLE_ROW);
7369
if (prebuilt->table->ibd_file_missing) {
7370
errmsg_printf(error::ERROR, "InnoDB: Error:\n"
7371
"InnoDB: MySQL is trying to use a table handle"
7372
" but the .ibd file for\n"
7373
"InnoDB: table %s does not exist.\n"
7374
"InnoDB: Have you deleted the .ibd file"
7375
" from the database directory under\n"
7376
"InnoDB: the MySQL datadir, or have you"
7377
" used DISCARD TABLESPACE?\n"
7378
"InnoDB: Please refer to\n"
7379
"InnoDB: " REFMAN "innodb-troubleshooting.html\n"
7380
"InnoDB: how you can resolve the problem.\n",
7381
prebuilt->table->name);
6825
ret = row_check_table_for_mysql(prebuilt);
6829
return(HA_ADMIN_OK);
6830
case DB_INTERRUPTED:
6831
my_error(ER_QUERY_INTERRUPTED, MYF(0));
7382
6834
return(HA_ADMIN_CORRUPT);
7385
prebuilt->trx->op_info = "checking table";
7387
old_isolation_level = prebuilt->trx->isolation_level;
7389
/* We must run the index record counts at an isolation level
7390
>= READ COMMITTED, because a dirty read can see a wrong number
7391
of records in some index; to play safe, we use always
7392
REPEATABLE READ here */
7394
prebuilt->trx->isolation_level = TRX_ISO_REPEATABLE_READ;
7396
/* Enlarge the fatal lock wait timeout during CHECK TABLE. */
7397
mutex_enter(&kernel_mutex);
7398
srv_fatal_semaphore_wait_threshold += 7200; /* 2 hours */
7399
mutex_exit(&kernel_mutex);
7401
for (index = dict_table_get_first_index(prebuilt->table);
7403
index = dict_table_get_next_index(index)) {
7405
fputs("Validating index ", stderr);
7406
ut_print_name(stderr, trx, FALSE, index->name);
7410
if (!btr_validate_index(index, prebuilt->trx)) {
7412
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7414
"InnoDB: The B-tree of"
7415
" index '%-.200s' is corrupted.",
7420
/* Instead of invoking change_active_index(), set up
7421
a dummy template for non-locking reads, disabling
7422
access to the clustered index. */
7423
prebuilt->index = index;
7425
prebuilt->index_usable = row_merge_is_index_usable(
7426
prebuilt->trx, prebuilt->index);
7428
if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
7429
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7430
HA_ERR_TABLE_DEF_CHANGED,
7431
"InnoDB: Insufficient history for"
7437
prebuilt->sql_stat_start = TRUE;
7438
prebuilt->template_type = ROW_MYSQL_DUMMY_TEMPLATE;
7439
prebuilt->n_template = 0;
7440
prebuilt->need_to_access_clustered = FALSE;
7442
dtuple_set_n_fields(prebuilt->search_tuple, 0);
7444
prebuilt->select_lock_type = LOCK_NONE;
7446
if (!row_check_index_for_mysql(prebuilt, index, &n_rows)) {
7447
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7449
"InnoDB: The B-tree of"
7450
" index '%-.200s' is corrupted.",
7455
if (user_session->getKilled()) {
7460
fprintf(stderr, "%lu entries in index %s\n", n_rows,
7464
if (index == dict_table_get_first_index(prebuilt->table)) {
7465
n_rows_in_table = n_rows;
7466
} else if (n_rows != n_rows_in_table) {
7467
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7469
"InnoDB: Index '%-.200s'"
7470
" contains %lu entries,"
7474
(ulong) n_rows_in_table);
7479
/* Restore the original isolation level */
7480
prebuilt->trx->isolation_level = old_isolation_level;
7482
/* We validate also the whole adaptive hash index for all tables
7483
at every CHECK TABLE */
7485
if (!btr_search_validate()) {
7486
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
7488
"InnoDB: The adaptive hash index is corrupted.");
7492
/* Restore the fatal lock wait timeout after CHECK TABLE. */
7493
mutex_enter(&kernel_mutex);
7494
srv_fatal_semaphore_wait_threshold -= 7200; /* 2 hours */
7495
mutex_exit(&kernel_mutex);
7497
prebuilt->trx->op_info = "";
7498
if (user_session->getKilled()) {
7499
my_error(ER_QUERY_INTERRUPTED, MYF(0));
7502
return(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
7505
6838
/*************************************************************//**
9103
8367
/************************************************************//**
8368
Validate the file format check value, is it one of "on" or "off",
8369
as a side effect it sets the srv_check_file_format_at_startup variable.
8370
@return true if config value one of "on" or "off" */
8373
innobase_file_format_check_on_off(
8374
/*==============================*/
8375
const char* format_check) /*!< in: parameter value */
8379
if (!innobase_strcasecmp(format_check, "off")) {
8381
/* Set the value to disable checking. */
8382
srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
8384
} else if (!innobase_strcasecmp(format_check, "on")) {
8386
/* Set the value to the lowest supported format. */
8387
srv_check_file_format_at_startup = DICT_TF_FORMAT_51;
8395
/************************************************************//**
9104
8396
Validate the file format check config parameters, as a side effect it
9105
sets the srv_max_file_format_at_startup variable.
8397
sets the srv_check_file_format_at_startup variable.
9106
8398
@return the format_id if valid config value, otherwise, return -1 */
9109
8401
innobase_file_format_validate_and_set(
9110
8402
/*================================*/
9111
const char* format_max) /*!< in: parameter value */
8403
const char* format_check) /*!< in: parameter value */
9113
8405
uint format_id;
9115
format_id = innobase_file_format_name_lookup(format_max);
8407
format_id = innobase_file_format_name_lookup(format_check);
9117
8409
if (format_id < DICT_TF_FORMAT_MAX + 1) {
9118
srv_max_file_format_at_startup = format_id;
8410
srv_check_file_format_at_startup = format_id;
9119
8411
return((int) format_id);
8417
/*************************************************************//**
8418
Check if it is a valid file format. This function is registered as
8419
a callback with MySQL.
8420
@return 0 for valid file format */
8423
innodb_file_format_name_validate(
8424
/*=============================*/
8425
Session* , /*!< in: thread handle */
8426
drizzle_sys_var* , /*!< in: pointer to system
8428
void* save, /*!< out: immediate result
8429
for update function */
8430
drizzle_value* value) /*!< in: incoming string */
8432
const char* file_format_input;
8433
char buff[STRING_BUFFER_USUAL_SIZE];
8434
int len = sizeof(buff);
8437
ut_a(value != NULL);
8439
file_format_input = value->val_str(value, buff, &len);
8441
if (file_format_input != NULL) {
8444
format_id = innobase_file_format_name_lookup(
8447
if (format_id <= DICT_TF_FORMAT_MAX) {
8448
/* Save a pointer to the name in the
8449
'file_format_name_map' constant array. */
8450
*static_cast<const char**>(save) =
8451
trx_sys_file_format_id_to_name(format_id);
8457
*static_cast<const char**>(save) = NULL;
8461
/****************************************************************//**
8462
Update the system variable innodb_file_format using the "saved"
8463
value. This function is registered as a callback with MySQL. */
8466
innodb_file_format_name_update(
8467
/*===========================*/
8468
Session* , /*!< in: thread handle */
8469
drizzle_sys_var* , /*!< in: pointer to
8471
void* var_ptr, /*!< out: where the
8472
formal string goes */
8473
const void* save) /*!< in: immediate result
8474
from check function */
8476
const char* format_name;
8478
ut_a(var_ptr != NULL);
8481
format_name = *static_cast<const char*const*>(save);
8486
format_id = innobase_file_format_name_lookup(format_name);
8488
if (format_id <= DICT_TF_FORMAT_MAX) {
8489
srv_file_format = format_id;
8493
*static_cast<const char**>(var_ptr)
8494
= trx_sys_file_format_id_to_name(srv_file_format);
8497
/*************************************************************//**
8498
Check if valid argument to innodb_file_format_check. This
8499
function is registered as a callback with MySQL.
8500
@return 0 for valid file format */
8503
innodb_file_format_check_validate(
8504
/*==============================*/
8505
Session* session, /*!< in: thread handle */
8506
drizzle_sys_var* , /*!< in: pointer to system
8508
void* save, /*!< out: immediate result
8509
for update function */
8510
drizzle_value* value) /*!< in: incoming string */
8512
const char* file_format_input;
8513
char buff[STRING_BUFFER_USUAL_SIZE];
8514
int len = sizeof(buff);
8518
ut_a(value != NULL);
8520
file_format_input = value->val_str(value, buff, &len);
8522
if (file_format_input != NULL) {
8524
/* Check if user set on/off, we want to print a suitable
8525
message if they did so. */
8527
if (innobase_file_format_check_on_off(file_format_input)) {
8528
push_warning_printf(session,
8529
DRIZZLE_ERROR::WARN_LEVEL_WARN,
8531
"InnoDB: invalid innodb_file_format_check "
8532
"value; on/off can only be set at startup or "
8533
"in the configuration file");
8535
format_id = innobase_file_format_validate_and_set(file_format_input);
8536
if (format_id >= 0) {
8537
/* Save a pointer to the name in the
8538
'file_format_name_map' constant array. */
8539
*static_cast<const char**>(save) =
8540
trx_sys_file_format_id_to_name(
8546
push_warning_printf(session,
8547
DRIZZLE_ERROR::WARN_LEVEL_WARN,
8549
"InnoDB: invalid innodb_file_format_check "
8550
"value; can be any format up to %s "
8551
"or its equivalent numeric id",
8552
trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
8557
*static_cast<const char**>(save) = NULL;
8561
/****************************************************************//**
8562
Update the system variable innodb_file_format_check using the "saved"
8563
value. This function is registered as a callback with MySQL. */
8566
innodb_file_format_check_update(
8567
/*============================*/
8568
Session* session, /*!< in: thread handle */
8569
drizzle_sys_var* , /*!< in: pointer to
8571
void* var_ptr, /*!< out: where the
8572
formal string goes */
8573
const void* save) /*!< in: immediate result
8574
from check function */
8576
const char* format_name_in;
8577
const char** format_name_out;
8581
ut_a(var_ptr != NULL);
8583
format_name_in = *static_cast<const char*const*>(save);
8585
if (!format_name_in) {
8590
format_id = innobase_file_format_name_lookup(format_name_in);
8592
if (format_id > DICT_TF_FORMAT_MAX) {
8593
/* DEFAULT is "on", which is invalid at runtime. */
8594
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
8596
"Ignoring SET innodb_file_format=%s",
8601
format_name_out = static_cast<const char**>(var_ptr);
8603
/* Update the max format id in the system tablespace. */
8604
if (trx_sys_file_format_max_set(format_id, format_name_out)) {
8605
ut_print_timestamp(stderr);
8607
" [Info] InnoDB: the file format in the system "
8608
"tablespace is now set to %s.\n", *format_name_out);
8612
/****************************************************************//**
8613
Update the system variable innodb_adaptive_hash_index using the "saved"
8614
value. This function is registered as a callback with MySQL. */
8617
innodb_adaptive_hash_index_update(
8618
/*==============================*/
8619
Session* , /*!< in: thread handle */
8620
drizzle_sys_var* , /*!< in: pointer to
8622
void* , /*!< out: where the
8623
formal string goes */
8624
const void* save) /*!< in: immediate result
8625
from check function */
8627
if (*(bool*) save) {
8628
btr_search_enable();
8630
btr_search_disable();
8634
/****************************************************************//**
8635
Update the system variable innodb_old_blocks_pct using the "saved"
8636
value. This function is registered as a callback with MySQL. */
8639
innodb_old_blocks_pct_update(
8640
/*=========================*/
8641
Session* , /*!< in: thread handle */
8642
drizzle_sys_var* , /*!< in: pointer to
8644
void* ,/*!< out: where the
8645
formal string goes */
8646
const void* save) /*!< in: immediate result
8647
from check function */
8649
innobase_old_blocks_pct = buf_LRU_old_ratio_update(
8650
*static_cast<const uint*>(save), TRUE);
8653
/*************************************************************//**
8654
Check if it is a valid value of innodb_change_buffering. This function is
8655
registered as a callback with MySQL.
8656
@return 0 for valid innodb_change_buffering */
8659
innodb_change_buffering_validate(
8660
/*=============================*/
8661
Session* , /*!< in: thread handle */
8662
drizzle_sys_var* , /*!< in: pointer to system
8664
void* save, /*!< out: immediate result
8665
for update function */
8666
drizzle_value* value) /*!< in: incoming string */
8668
const char* change_buffering_input;
8669
char buff[STRING_BUFFER_USUAL_SIZE];
8670
int len = sizeof(buff);
8673
ut_a(value != NULL);
8675
change_buffering_input = value->val_str(value, buff, &len);
8677
if (change_buffering_input != NULL) {
8680
for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
8682
if (!innobase_strcasecmp(
8683
change_buffering_input,
8684
innobase_change_buffering_values[use])) {
8685
*(ibuf_use_t*) save = (ibuf_use_t) use;
8694
/****************************************************************//**
8695
Update the system variable innodb_change_buffering using the "saved"
8696
value. This function is registered as a callback with MySQL. */
8699
innodb_change_buffering_update(
8700
/*===========================*/
8701
Session* , /*!< in: thread handle */
8702
drizzle_sys_var* , /*!< in: pointer to
8704
void* var_ptr, /*!< out: where the
8705
formal string goes */
8706
const void* save) /*!< in: immediate result
8707
from check function */
8709
ut_a(var_ptr != NULL);
8711
ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
8713
ibuf_use = *(const ibuf_use_t*) save;
8715
*(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
8718
/* plugin options */
8719
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
8720
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8721
"Enable InnoDB checksums validation (enabled by default). ",
8724
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
8725
PLUGIN_VAR_READONLY,
8726
"The common part for InnoDB table spaces.",
8729
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
8730
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8731
"Enable InnoDB doublewrite buffer (enabled by default). ",
8734
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
8735
PLUGIN_VAR_RQCMDARG,
8736
"Number of IOPs the server can do. Tunes the background IO rate",
8737
NULL, NULL, 200, 100, ~0L, 0);
8739
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
8740
PLUGIN_VAR_OPCMDARG,
8741
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
8742
"values are 0, 1 (faster)"
8743
" or 2 (fastest - crash-like)"
8745
NULL, NULL, 1, 0, 2, 0);
8747
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
8748
PLUGIN_VAR_NOCMDARG,
8749
"Stores each InnoDB table to an .ibd file in the database dir.",
8752
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
8753
PLUGIN_VAR_RQCMDARG,
8754
"File format to use for new tables in .ibd files.",
8755
innodb_file_format_name_validate,
8756
innodb_file_format_name_update, "Antelope");
8758
/* If a new file format is introduced, the file format
8759
name needs to be updated accordingly. Please refer to
8760
file_format_name_map[] defined in trx0sys.c for the next
8761
file format name. */
8762
static DRIZZLE_SYSVAR_STR(file_format_check, innobase_file_format_check,
8763
PLUGIN_VAR_OPCMDARG,
8764
"The highest file format in the tablespace.",
8765
innodb_file_format_check_validate,
8766
innodb_file_format_check_update,
8769
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
8770
PLUGIN_VAR_OPCMDARG,
8771
"Set to 0 (write and flush once per second),"
8772
" 1 (write and flush at each commit)"
8773
" or 2 (write at commit, flush once per second).",
8774
NULL, NULL, 1, 0, 2, 0);
8776
static DRIZZLE_SYSVAR_STR(flush_method, innobase_file_flush_method,
8777
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8778
"With which method to flush data.", NULL, NULL, NULL);
8780
#ifdef UNIV_LOG_ARCHIVE
8781
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
8782
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8783
"Where full logs should be archived.", NULL, NULL, NULL);
8785
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
8786
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
8787
"Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
8788
#endif /* UNIV_LOG_ARCHIVE */
8790
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
8791
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8792
"Path to InnoDB log files.", NULL, NULL, NULL);
8794
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
8795
PLUGIN_VAR_RQCMDARG,
8796
"Percentage of dirty pages allowed in bufferpool.",
8797
NULL, NULL, 75, 0, 99, 0);
8799
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
8800
PLUGIN_VAR_NOCMDARG,
8801
"Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
8804
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
8805
PLUGIN_VAR_RQCMDARG,
8806
"Desired maximum length of the purge queue (0 = no limit)",
8807
NULL, NULL, 0, 0, ~0L, 0);
8809
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
8810
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
8811
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
8814
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
8815
PLUGIN_VAR_RQCMDARG,
8816
"The number of index pages to sample when calculating statistics (default 8)",
8817
NULL, NULL, 8, 1, ~0ULL, 0);
8819
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
8820
PLUGIN_VAR_OPCMDARG,
8821
"Enable InnoDB adaptive hash index (enabled by default).",
8822
NULL, innodb_adaptive_hash_index_update, TRUE);
8824
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
8825
PLUGIN_VAR_RQCMDARG,
8826
"Replication thread delay (ms) on the slave server if "
8827
"innodb_thread_concurrency is reached (0 by default)",
8828
NULL, NULL, 0, 0, ~0UL, 0);
8830
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
8831
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8832
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
8833
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
8835
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
8836
PLUGIN_VAR_RQCMDARG,
8837
"Data file autoextend increment in megabytes",
8838
NULL, NULL, 8L, 1L, 1000L, 0);
8840
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
8841
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8842
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
8843
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
8845
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
8846
PLUGIN_VAR_RQCMDARG,
8847
"Helps in performance tuning in heavily concurrent environments.",
8848
innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
8850
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
8851
PLUGIN_VAR_RQCMDARG,
8852
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
8853
NULL, NULL, 500L, 1L, ~0L, 0);
8855
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
8856
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8857
"Number of background read I/O threads in InnoDB.",
8858
NULL, NULL, 4, 1, 64, 0);
8860
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
8861
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8862
"Number of background write I/O threads in InnoDB.",
8863
NULL, NULL, 4, 1, 64, 0);
8865
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
8866
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8867
"Helps to save your data in case the disk image of the database becomes corrupt.",
8868
NULL, NULL, 0, 0, 6, 0);
8870
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
8871
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8872
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
8873
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
8875
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
8876
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8877
"Size of each log file in a log group.",
8878
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
8880
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
8881
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8882
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
8883
NULL, NULL, 2, 2, 100, 0);
8885
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
8886
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8887
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
8888
NULL, NULL, 1, 1, 10, 0);
8890
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
8891
PLUGIN_VAR_RQCMDARG,
8892
"Percentage of the buffer pool to reserve for 'old' blocks.",
8893
NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
8895
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
8896
PLUGIN_VAR_RQCMDARG,
8897
"Move blocks to the 'new' end of the buffer pool if the first access"
8898
" was at least this many milliseconds ago."
8899
" The timeout is disabled if 0 (the default).",
8900
NULL, NULL, 0, 0, UINT32_MAX, 0);
8902
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
8903
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8904
"How many files at the maximum InnoDB keeps open at the same time.",
8905
NULL, NULL, 300L, 10L, LONG_MAX, 0);
8907
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
8908
PLUGIN_VAR_RQCMDARG,
8909
"Count of spin-loop rounds in InnoDB mutexes (30 by default)",
8910
NULL, NULL, 30L, 0L, ~0L, 0);
8912
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
8913
PLUGIN_VAR_OPCMDARG,
8914
"Maximum delay between polling for a spin lock (6 by default)",
8915
NULL, NULL, 6L, 0L, ~0L, 0);
8917
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
8918
PLUGIN_VAR_RQCMDARG,
8919
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
8920
NULL, NULL, 0, 0, 1000, 0);
8922
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
8923
PLUGIN_VAR_RQCMDARG,
8924
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
8925
NULL, NULL, 10000L, 0L, ~0L, 0);
8927
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
8928
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
8929
"Path to individual files and their sizes.",
8932
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
8933
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
8934
"InnoDB version", NULL, NULL, INNODB_VERSION_STR);
8936
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
8937
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
8938
"Use OS memory allocator instead of InnoDB's internal memory allocator",
8941
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
8942
PLUGIN_VAR_RQCMDARG,
8943
"Buffer changes to reduce random access: "
8944
"OFF, ON, inserting, deleting, changing, or purging.",
8945
innodb_change_buffering_validate,
8946
innodb_change_buffering_update, NULL);
8948
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
8949
PLUGIN_VAR_RQCMDARG,
8950
"Number of pages that must be accessed sequentially for InnoDB to"
8951
"trigger a readahead.",
8952
NULL, NULL, 56, 0, 64, 0);
9127
8954
static void init_options(drizzled::module::option_context &context)
9181
9006
context("disable-stats-on-metadata",
9182
9007
"Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9183
9008
context("stats-sample-pages",
9184
po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9009
po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9185
9010
"The number of index pages to sample when calculating statistics (default 8)");
9186
9011
context("disable-adaptive-hash-index",
9187
9012
"Enable InnoDB adaptive hash index (enabled by default)");
9188
9013
context("replication-delay",
9189
po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
9014
po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9190
9015
"Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9191
9016
context("additional-mem-pool-size",
9192
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9017
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9193
9018
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9194
9019
context("autoextend-increment",
9195
po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(64L),
9020
po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9196
9021
"Data file autoextend increment in megabytes");
9197
9022
context("buffer-pool-size",
9198
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9023
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9199
9024
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9200
context("buffer-pool-instances",
9201
po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9202
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9204
9025
context("commit-concurrency",
9205
po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
9026
po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9206
9027
"Helps in performance tuning in heavily concurrent environments.");
9207
9028
context("concurrency-tickets",
9208
po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
9029
po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9209
9030
"Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9210
9031
context("read-io-threads",
9211
po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
9032
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9212
9033
"Number of background read I/O threads in InnoDB.");
9213
9034
context("write-io-threads",
9214
po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
9035
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9215
9036
"Number of background write I/O threads in InnoDB.");
9216
9037
context("force-recovery",
9217
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
9038
po::value<long>(&innobase_force_recovery)->default_value(0),
9218
9039
"Helps to save your data in case the disk image of the database becomes corrupt.");
9219
9040
context("log-buffer-size",
9220
po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9041
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9221
9042
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9222
9043
context("log-file-size",
9223
po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9044
po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9224
9045
"The size of the buffer which InnoDB uses to write log to the log files on disk.");
9225
9046
context("log-files-in-group",
9226
po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
9047
po::value<long>(&innobase_log_files_in_group)->default_value(2),
9227
9048
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9228
9049
context("mirrored-log-groups",
9229
po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
9050
po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9230
9051
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9231
9052
context("open-files",
9232
po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
9053
po::value<long>(&innobase_open_files)->default_value(300L),
9233
9054
"How many files at the maximum InnoDB keeps open at the same time.");
9234
9055
context("sync-spin-loops",
9235
po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
9056
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9236
9057
"Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9237
9058
context("spin-wait-delay",
9238
po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
9059
po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9239
9060
"Maximum delay between polling for a spin lock (6 by default)");
9240
9061
context("thread-concurrency",
9241
po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
9062
po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9242
9063
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9243
9064
context("thread-sleep-delay",
9244
po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
9065
po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9245
9066
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9246
9067
context("data-file-path",
9247
9068
po::value<string>(),
9251
9072
"InnoDB version");
9252
9073
context("use-internal-malloc",
9253
9074
"Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9254
context("disable-native-aio",
9255
_("Do not use Native AIO library for IO, even if available"));
9256
9075
context("change-buffering",
9257
po::value<string>(&innobase_change_buffering),
9076
po::value<string>(),
9258
9077
"Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9259
9078
context("read-ahead-threshold",
9260
po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
9079
po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9261
9080
"Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9262
9081
context("disable-xa",
9263
9082
"Disable InnoDB support for the XA two-phase commit");
9264
9083
context("disable-table-locks",
9265
9084
"Disable InnoDB locking in LOCK TABLES");
9266
9085
context("strict-mode",
9267
po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
9086
po::value<bool>()->default_value(false)->zero_tokens(),
9268
9087
"Use strict mode when evaluating create options.");
9269
context("replication-log",
9270
po::value<bool>(&innobase_use_replication_log)->default_value(false),
9271
_("Enable internal replication log."));
9272
9088
context("lock-wait-timeout",
9273
po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9274
_("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9275
context("old-blocks-pct",
9276
po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9277
_("Percentage of the buffer pool to reserve for 'old' blocks."));
9278
context("old-blocks-time",
9279
po::value<uint32_t>(&buf_LRU_old_threshold_ms)->default_value(0),
9280
_("ove blocks to the 'new' end of the buffer pool if the first access"
9281
" was at least this many milliseconds ago."
9282
" The timeout is disabled if 0 (the default)."));
9089
po::value<unsigned long>()->default_value(50),
9090
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9093
static drizzle_sys_var* innobase_system_variables[]= {
9094
DRIZZLE_SYSVAR(additional_mem_pool_size),
9095
DRIZZLE_SYSVAR(autoextend_increment),
9096
DRIZZLE_SYSVAR(buffer_pool_size),
9097
DRIZZLE_SYSVAR(checksums),
9098
DRIZZLE_SYSVAR(commit_concurrency),
9099
DRIZZLE_SYSVAR(concurrency_tickets),
9100
DRIZZLE_SYSVAR(data_file_path),
9101
DRIZZLE_SYSVAR(data_home_dir),
9102
DRIZZLE_SYSVAR(doublewrite),
9103
DRIZZLE_SYSVAR(fast_shutdown),
9104
DRIZZLE_SYSVAR(read_io_threads),
9105
DRIZZLE_SYSVAR(write_io_threads),
9106
DRIZZLE_SYSVAR(file_per_table),
9107
DRIZZLE_SYSVAR(file_format),
9108
DRIZZLE_SYSVAR(file_format_check),
9109
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
9110
DRIZZLE_SYSVAR(flush_method),
9111
DRIZZLE_SYSVAR(force_recovery),
9112
DRIZZLE_SYSVAR(lock_wait_timeout),
9113
#ifdef UNIV_LOG_ARCHIVE
9114
DRIZZLE_SYSVAR(log_arch_dir),
9115
DRIZZLE_SYSVAR(log_archive),
9116
#endif /* UNIV_LOG_ARCHIVE */
9117
DRIZZLE_SYSVAR(log_buffer_size),
9118
DRIZZLE_SYSVAR(log_file_size),
9119
DRIZZLE_SYSVAR(log_files_in_group),
9120
DRIZZLE_SYSVAR(log_group_home_dir),
9121
DRIZZLE_SYSVAR(max_dirty_pages_pct),
9122
DRIZZLE_SYSVAR(max_purge_lag),
9123
DRIZZLE_SYSVAR(adaptive_flushing),
9124
DRIZZLE_SYSVAR(mirrored_log_groups),
9125
DRIZZLE_SYSVAR(old_blocks_pct),
9126
DRIZZLE_SYSVAR(old_blocks_time),
9127
DRIZZLE_SYSVAR(open_files),
9128
DRIZZLE_SYSVAR(stats_sample_pages),
9129
DRIZZLE_SYSVAR(adaptive_hash_index),
9130
DRIZZLE_SYSVAR(replication_delay),
9131
DRIZZLE_SYSVAR(status_file),
9132
DRIZZLE_SYSVAR(strict_mode),
9133
DRIZZLE_SYSVAR(support_xa),
9134
DRIZZLE_SYSVAR(sync_spin_loops),
9135
DRIZZLE_SYSVAR(spin_wait_delay),
9136
DRIZZLE_SYSVAR(table_locks),
9137
DRIZZLE_SYSVAR(thread_concurrency),
9138
DRIZZLE_SYSVAR(thread_sleep_delay),
9139
DRIZZLE_SYSVAR(version),
9140
DRIZZLE_SYSVAR(use_sys_malloc),
9141
DRIZZLE_SYSVAR(change_buffering),
9142
DRIZZLE_SYSVAR(read_ahead_threshold),
9143
DRIZZLE_SYSVAR(io_capacity),
9287
9147
DRIZZLE_DECLARE_PLUGIN