35 #include <sql_table.h>   
   41 #include <mysys_err.h> 
   42 #include <mysql/innodb_priv.h> 
   98 enum_tx_isolation thd_get_trx_isolation(
const THD* thd);
 
  100 #include "ha_innodb.h" 
  103 # ifndef MYSQL_PLUGIN_IMPORT 
  104 #  define MYSQL_PLUGIN_IMPORT  
  110 static ulong commit_threads = 0;
 
  113 static bool innodb_inited = 0;
 
  115 #define INSIDE_HA_INNOBASE_CC 
  117 #define EQ_CURRENT_THD(thd) ((thd) == current_thd) 
  121 static const long AUTOINC_OLD_STYLE_LOCKING = 0;
 
  122 static const long AUTOINC_NEW_STYLE_LOCKING = 1;
 
  123 static const long AUTOINC_NO_LOCKING = 2;
 
  125 static long innobase_mirrored_log_groups;
 
  126 static long innobase_log_buffer_size;
 
  127 static long innobase_additional_mem_pool_size;
 
  128 static long innobase_file_io_threads;
 
  129 static long innobase_open_files;
 
  130 static long innobase_autoinc_lock_mode;
 
  131 static ulong innobase_commit_concurrency = 0;
 
  132 static ulong innobase_read_io_threads;
 
  133 static ulong innobase_write_io_threads;
 
  134 static long innobase_buffer_pool_instances = 1;
 
  136 static long long innobase_buffer_pool_size, innobase_log_file_size;
 
  140 static uint innobase_old_blocks_pct;
 
  149 static char*    innobase_data_home_dir                  = NULL;
 
  150 static char*    innobase_data_file_path                 = NULL;
 
  151 static char*    innobase_file_format_name               = NULL;
 
  152 static char*    innobase_change_buffering               = NULL;
 
  153 static char*    innobase_enable_monitor_counter         = NULL;
 
  154 static char*    innobase_disable_monitor_counter        = NULL;
 
  155 static char*    innobase_reset_monitor_counter          = NULL;
 
  156 static char*    innobase_reset_all_monitor_counter      = NULL;
 
  161 static char*    innobase_file_format_max                = NULL;
 
  163 static char*    innobase_file_flush_method              = NULL;
 
  167 static char*    innobase_server_stopword_table          = NULL;
 
  172 static ulong    innobase_fast_shutdown                  = 1;
 
  173 static my_bool  innobase_file_format_check              = TRUE;
 
  174 #ifdef UNIV_LOG_ARCHIVE 
  175 static my_bool  innobase_log_archive                    = FALSE;
 
  176 static char*    innobase_log_arch_dir                   = NULL;
 
  178 static my_bool  innobase_use_doublewrite                = TRUE;
 
  179 static my_bool  innobase_use_checksums                  = TRUE;
 
  180 static my_bool  innobase_locks_unsafe_for_binlog        = FALSE;
 
  181 static my_bool  innobase_rollback_on_timeout            = FALSE;
 
  182 static my_bool  innobase_create_status_file             = FALSE;
 
  183 static my_bool  innobase_stats_on_metadata              = TRUE;
 
  184 static my_bool  innobase_large_prefix                   = FALSE;
 
  185 static my_bool  innodb_optimize_fulltext_only           = FALSE;
 
  187 static char*    internal_innobase_data_file_path        = NULL;
 
  189 static char*    innodb_version_str = (
char*) INNODB_VERSION_STR;
 
  191 static char*    fts_server_stopword_table               = NULL;
 
  196 static const char* innodb_stats_method_names[] = {
 
  205 static TYPELIB innodb_stats_method_typelib = {
 
  206         array_elements(innodb_stats_method_names) - 1,
 
  207         "innodb_stats_method_typelib",
 
  208         innodb_stats_method_names,
 
  213 static const char* innodb_checksum_algorithm_names[] = {
 
  225 static TYPELIB innodb_checksum_algorithm_typelib = {
 
  226         array_elements(innodb_checksum_algorithm_names) - 1,
 
  227         "innodb_checksum_algorithm_typelib",
 
  228         innodb_checksum_algorithm_names,
 
  237 #define INNOBASE_WAKE_INTERVAL  32 
  238 static ulong    innobase_active_counter = 0;
 
  243 static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = {
 
  254 const struct _ft_vft ft_vft_result = {NULL,
 
  255                                       innobase_fts_find_ranking,
 
  256                                       innobase_fts_close_ranking,
 
  257                                       innobase_fts_retrieve_ranking,
 
  260 const struct _ft_vft_ext ft_vft_ext_result = {innobase_fts_get_version,
 
  262                                               innobase_fts_retrieve_docid,
 
  263                                               innobase_fts_count_matches};
 
  265 #ifdef HAVE_PSI_INTERFACE 
  268 static mysql_pfs_key_t  innobase_share_mutex_key;
 
  269 static mysql_pfs_key_t  commit_cond_mutex_key;
 
  270 static mysql_pfs_key_t  commit_cond_key;
 
  272 static PSI_mutex_info   all_pthread_mutexes[] = {
 
  273         {&commit_cond_mutex_key, 
"commit_cond_mutex", 0},
 
  274         {&innobase_share_mutex_key, 
"innobase_share_mutex", 0}
 
  277 static PSI_cond_info    all_innodb_conds[] = {
 
  278         {&commit_cond_key, 
"commit_cond", 0}
 
  281 # ifdef UNIV_PFS_MUTEX 
  285 static PSI_mutex_info all_innodb_mutexes[] = {
 
  286         {&autoinc_mutex_key, 
"autoinc_mutex", 0},
 
  287 #  ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK 
  288         {&buffer_block_mutex_key, 
"buffer_block_mutex", 0},
 
  290         {&buf_pool_mutex_key, 
"buf_pool_mutex", 0},
 
  291         {&buf_pool_zip_mutex_key, 
"buf_pool_zip_mutex", 0},
 
  292         {&cache_last_read_mutex_key, 
"cache_last_read_mutex", 0},
 
  293         {&dict_foreign_err_mutex_key, 
"dict_foreign_err_mutex", 0},
 
  294         {&dict_sys_mutex_key, 
"dict_sys_mutex", 0},
 
  295         {&file_format_max_mutex_key, 
"file_format_max_mutex", 0},
 
  296         {&fil_system_mutex_key, 
"fil_system_mutex", 0},
 
  297         {&flush_list_mutex_key, 
"flush_list_mutex", 0},
 
  298         {&fts_bg_threads_mutex_key, 
"fts_bg_threads_mutex", 0},
 
  299         {&fts_delete_mutex_key, 
"fts_delete_mutex", 0},
 
  300         {&fts_optimize_mutex_key, 
"fts_optimize_mutex", 0},
 
  301         {&fts_doc_id_mutex_key, 
"fts_doc_id_mutex", 0},
 
  302         {&log_flush_order_mutex_key, 
"log_flush_order_mutex", 0},
 
  303         {&hash_table_mutex_key, 
"hash_table_mutex", 0},
 
  304         {&ibuf_bitmap_mutex_key, 
"ibuf_bitmap_mutex", 0},
 
  305         {&ibuf_mutex_key, 
"ibuf_mutex", 0},
 
  306         {&ibuf_pessimistic_insert_mutex_key,
 
  307                  "ibuf_pessimistic_insert_mutex", 0},
 
  308 #  ifndef HAVE_ATOMIC_BUILTINS 
  309         {&server_mutex_key, 
"server_mutex", 0},
 
  311         {&log_sys_mutex_key, 
"log_sys_mutex", 0},
 
  312 #  ifdef UNIV_MEM_DEBUG 
  313         {&mem_hash_mutex_key, 
"mem_hash_mutex", 0},
 
  315         {&mem_pool_mutex_key, 
"mem_pool_mutex", 0},
 
  316         {&mutex_list_mutex_key, 
"mutex_list_mutex", 0},
 
  317         {&page_zip_stat_per_index_mutex_key, 
"page_zip_stat_per_index_mutex", 0},
 
  318         {&purge_sys_bh_mutex_key, 
"purge_sys_bh_mutex", 0},
 
  319         {&recv_sys_mutex_key, 
"recv_sys_mutex", 0},
 
  320         {&recv_writer_mutex_key, 
"recv_writer_mutex", 0},
 
  321         {&rseg_mutex_key, 
"rseg_mutex", 0},
 
  322 #  ifdef UNIV_SYNC_DEBUG 
  323         {&rw_lock_debug_mutex_key, 
"rw_lock_debug_mutex", 0},
 
  325         {&rw_lock_list_mutex_key, 
"rw_lock_list_mutex", 0},
 
  326         {&rw_lock_mutex_key, 
"rw_lock_mutex", 0},
 
  327         {&srv_dict_tmpfile_mutex_key, 
"srv_dict_tmpfile_mutex", 0},
 
  328         {&srv_innodb_monitor_mutex_key, 
"srv_innodb_monitor_mutex", 0},
 
  329         {&srv_misc_tmpfile_mutex_key, 
"srv_misc_tmpfile_mutex", 0},
 
  330         {&srv_monitor_file_mutex_key, 
"srv_monitor_file_mutex", 0},
 
  331 #  ifdef UNIV_SYNC_DEBUG 
  332         {&sync_thread_mutex_key, 
"sync_thread_mutex", 0},
 
  334         {&buf_dblwr_mutex_key, 
"buf_dblwr_mutex", 0},
 
  335         {&trx_undo_mutex_key, 
"trx_undo_mutex", 0},
 
  336         {&srv_sys_mutex_key, 
"srv_sys_mutex", 0},
 
  337         {&lock_sys_mutex_key, 
"lock_mutex", 0},
 
  338         {&lock_sys_wait_mutex_key, 
"lock_wait_mutex", 0},
 
  339         {&trx_mutex_key, 
"trx_mutex", 0},
 
  340         {&srv_sys_tasks_mutex_key, 
"srv_threads_mutex", 0},
 
  342 #  ifndef PFS_SKIP_EVENT_MUTEX 
  343         {&event_os_mutex_key, 
"event_os_mutex", 0},
 
  345         {&os_mutex_key, 
"os_mutex", 0},
 
  346 #ifndef HAVE_ATOMIC_BUILTINS 
  347         {&srv_conc_mutex_key, 
"srv_conc_mutex", 0},
 
  349 #ifndef HAVE_ATOMIC_BUILTINS_64 
  352         {&ut_list_mutex_key, 
"ut_list_mutex", 0},
 
  353         {&trx_sys_mutex_key, 
"trx_sys_mutex", 0},
 
  354         {&zip_pad_mutex_key, 
"zip_pad_mutex", 0},
 
  358 # ifdef UNIV_PFS_RWLOCK 
  362 static PSI_rwlock_info all_innodb_rwlocks[] = {
 
  363 #  ifdef UNIV_LOG_ARCHIVE 
  364         {&archive_lock_key, 
"archive_lock", 0},
 
  366         {&btr_search_latch_key, 
"btr_search_latch", 0},
 
  367 #  ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK 
  368         {&buf_block_lock_key, 
"buf_block_lock", 0},
 
  370 #  ifdef UNIV_SYNC_DEBUG 
  371         {&buf_block_debug_latch_key, 
"buf_block_debug_latch", 0},
 
  373         {&dict_operation_lock_key, 
"dict_operation_lock", 0},
 
  374         {&fil_space_latch_key, 
"fil_space_latch", 0},
 
  375         {&checkpoint_lock_key, 
"checkpoint_lock", 0},
 
  376         {&fts_cache_rw_lock_key, 
"fts_cache_rw_lock", 0},
 
  377         {&fts_cache_init_rw_lock_key, 
"fts_cache_init_rw_lock", 0},
 
  378         {&trx_i_s_cache_lock_key, 
"trx_i_s_cache_lock", 0},
 
  379         {&trx_purge_latch_key, 
"trx_purge_latch", 0},
 
  380         {&index_tree_rw_lock_key, 
"index_tree_rw_lock", 0},
 
  381         {&index_online_log_key, 
"index_online_log", 0},
 
  382         {&dict_table_stats_latch_key, 
"dict_table_stats", 0},
 
  383         {&hash_table_rw_lock_key, 
"hash_table_locks", 0}
 
  387 # ifdef UNIV_PFS_THREAD 
  391 static PSI_thread_info  all_innodb_threads[] = {
 
  392         {&trx_rollback_clean_thread_key, 
"trx_rollback_clean_thread", 0},
 
  393         {&io_handler_thread_key, 
"io_handler_thread", 0},
 
  394         {&srv_lock_timeout_thread_key, 
"srv_lock_timeout_thread", 0},
 
  395         {&srv_error_monitor_thread_key, 
"srv_error_monitor_thread", 0},
 
  396         {&srv_monitor_thread_key, 
"srv_monitor_thread", 0},
 
  397         {&srv_master_thread_key, 
"srv_master_thread", 0},
 
  398         {&srv_purge_thread_key, 
"srv_purge_thread", 0},
 
  399         {&buf_page_cleaner_thread_key, 
"page_cleaner_thread", 0},
 
  400         {&recv_writer_thread_key, 
"recv_writer_thread", 0}
 
  407 static PSI_file_info    all_innodb_files[] = {
 
  408         {&innodb_file_data_key, 
"innodb_data_file", 0},
 
  409         {&innodb_file_log_key, 
"innodb_log_file", 0},
 
  410         {&innodb_file_temp_key, 
"innodb_temp_file", 0}
 
  417 #define normalize_table_name(norm_name, name)           \ 
  418         normalize_table_name_low(norm_name, name, TRUE) 
  420 #define normalize_table_name(norm_name, name)           \ 
  421         normalize_table_name_low(norm_name, name, FALSE) 
  493 innodb_stopword_table_validate(
 
  511 innobase_map_isolation_level(
 
  513         enum_tx_isolation       iso);   
 
  515 static const char innobase_hton_name[]= 
"InnoDB";
 
  517 static MYSQL_THDVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG,
 
  518   "Enable InnoDB support for the XA two-phase commit",
 
  522 static MYSQL_THDVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
 
  523   "Enable InnoDB locking in LOCK TABLES",
 
  527 static MYSQL_THDVAR_BOOL(strict_mode, PLUGIN_VAR_OPCMDARG,
 
  528   "Use strict mode when evaluating create options.",
 
  531 static MYSQL_THDVAR_BOOL(ft_enable_stopword, PLUGIN_VAR_OPCMDARG,
 
  532   "Create FTS index with stopword.",
 
  536 static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
 
  537   "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
 
  538   NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
 
  540 static MYSQL_THDVAR_STR(ft_user_stopword_table,
 
  541   PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_MEMALLOC,
 
  542   "User supplied stopword table name, effective in the session level.",
 
  543   innodb_stopword_table_validate, NULL, NULL);
 
  545 static SHOW_VAR innodb_status_variables[]= {
 
  546   {
"buffer_pool_dump_status",
 
  548   {
"buffer_pool_load_status",
 
  550   {
"buffer_pool_pages_data",
 
  552   {
"buffer_pool_bytes_data",
 
  554   {
"buffer_pool_pages_dirty",
 
  556   {
"buffer_pool_bytes_dirty",
 
  558   {
"buffer_pool_pages_flushed",
 
  560   {
"buffer_pool_pages_free",
 
  563   {
"buffer_pool_pages_latched",
 
  564   (
char*) &
export_vars.innodb_buffer_pool_pages_latched,  SHOW_LONG},
 
  566   {
"buffer_pool_pages_misc",
 
  568   {
"buffer_pool_pages_total",
 
  570   {
"buffer_pool_read_ahead_rnd",
 
  572   {
"buffer_pool_read_ahead",
 
  574   {
"buffer_pool_read_ahead_evicted",
 
  576   {
"buffer_pool_read_requests",
 
  578   {
"buffer_pool_reads",
 
  580   {
"buffer_pool_wait_free",
 
  582   {
"buffer_pool_write_requests",
 
  586   {
"data_pending_fsyncs",
 
  588   {
"data_pending_reads",
 
  590   {
"data_pending_writes",
 
  600   {
"dblwr_pages_written",
 
  604   {
"have_atomic_builtins",
 
  608   {
"log_write_requests",
 
  614   {
"os_log_pending_fsyncs",
 
  616   {
"os_log_pending_writes",
 
  628   {
"row_lock_current_waits",
 
  632   {
"row_lock_time_avg",
 
  634   {
"row_lock_time_max",
 
  648   {
"truncated_status_writes",
 
  650   {
"available_undo_logs",
 
  654   (
char*) &
export_vars.innodb_purge_trx_id_age,           SHOW_LONG},
 
  655   {
"purge_view_trx_id_age",
 
  656   (
char*) &
export_vars.innodb_purge_view_trx_id_age,      SHOW_LONG},
 
  658   {NullS, NullS, SHOW_LONG}
 
  683 innobase_close_connection(
 
  727 innobase_rollback_to_savepoint(
 
  754 innobase_release_savepoint(
 
  766 innobase_create_handler(
 
  783 innobase_commit_concurrency_init_default();
 
  793 innobase_undo_logs_init_default_max();
 
  801 innobase_file_format_name_lookup(
 
  803         const char*     format_name);   
 
  811 innobase_file_format_validate_and_set(
 
  813         const char*     format_max);    
 
  845 innobase_commit_by_xid(
 
  856 innobase_rollback_by_xid(
 
  869 innobase_create_cursor_view(
 
  880 innobase_set_cursor_view(
 
  892 innobase_close_cursor_view(
 
  902 innobase_drop_database(
 
  917         ha_panic_function       
type);
 
  927 innobase_start_trx_and_assign_read_view(
 
  954         stat_print_fn*  stat_print);
 
  960 innobase_show_status(
 
  965         stat_print_fn*          stat_print,
 
  966         enum ha_stat_type       stat_type);
 
  983 innodb_enable_monitor_at_startup(
 
  994 normalize_table_name_low(
 
  999         ibool           set_lower_case); 
 
 1007 innobase_commit_concurrency_validate(
 
 1017         ulong           commit_concurrency;
 
 1019         DBUG_ENTER(
"innobase_commit_concurrency_validate");
 
 1021         if (value->val_int(value, &intbuf)) {
 
 1026         *
reinterpret_cast<ulong*
>(save) = commit_concurrency
 
 1027                 = static_cast<ulong>(intbuf);
 
 1031         DBUG_RETURN(!(!commit_concurrency == !innobase_commit_concurrency));
 
 1038 innobase_create_handler(
 
 1061         DBUG_ENTER(
"innodb_page_size_validate");
 
 1063         for (n = UNIV_PAGE_SIZE_SHIFT_MIN;
 
 1064              n <= UNIV_PAGE_SIZE_SHIFT_MAX;
 
 1066                 if (page_size == (ulong) (1 << n)) {
 
 1087         return((ibool) thd_slave_thread(thd));
 
 1095 enum durability_properties
 
 1100         return(thd_get_durability_property(thd));
 
 1112         return(thd != 0 && thd_tx_is_read_only(thd));
 
 1126                && !thd_test_options(
 
 1128                        OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)
 
 1137 innobase_srv_conc_enter_innodb(
 
 1155                                 srv_replication_delay * 1000);
 
 1168 innobase_srv_conc_exit_innodb(
 
 1172 #ifdef UNIV_SYNC_DEBUG 
 1188 innobase_srv_conc_force_exit_innodb(
 
 1192 #ifdef UNIV_SYNC_DEBUG 
 1210         return(glob_hostname);
 
 1225         return((ibool) thd_non_transactional_update(thd));
 
 1237         return(thd_sql_command(thd) == SQLCOM_SELECT);
 
 1251         return(THDVAR(thd, support_xa));
 
 1266         return(THDVAR(thd, lock_wait_timeout));
 
 1279                 thd_storage_lock_wait(thd, value);
 
 1286 __attribute__((warn_unused_result, nonnull))
 
 1293         return(*(
trx_t**) thd_ha_data(thd, innodb_hton_ptr));
 
 1303 innobase_release_temporary_latches(
 
 1308         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 1310         if (!innodb_inited) {
 
 1315         trx_t*  trx = thd_to_trx(thd);
 
 1331 innobase_active_small(
void)
 
 1334         innobase_active_counter++;
 
 1348 convert_error_code_to_mysql(
 
 1358         case DB_INTERRUPTED:
 
 1359                 my_error(ER_QUERY_INTERRUPTED, MYF(0));
 
 1364                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
 1365                                     HA_ERR_ROW_IS_REFERENCED,
 
 1366                                     "InnoDB: Cannot delete/update " 
 1367                                     "rows with cascading foreign key " 
 1368                                     "constraints that exceed max " 
 1369                                     "depth of %d. Please " 
 1370                                     "drop extra constraints and try " 
 1379         case DB_DUPLICATE_KEY:
 
 1386                 return(HA_ERR_FOUND_DUPP_KEY);
 
 1389                 return(HA_ERR_TABLE_READONLY);
 
 1392                 return(HA_ERR_FOREIGN_DUPLICATE_KEY);
 
 1395                 return(HA_ERR_TABLE_DEF_CHANGED);
 
 1397         case DB_RECORD_NOT_FOUND:
 
 1398                 return(HA_ERR_NO_ACTIVE_RECORD);
 
 1406                         thd_mark_transaction_to_rollback(thd, TRUE);
 
 1409                 return(HA_ERR_LOCK_DEADLOCK);
 
 1417                         thd_mark_transaction_to_rollback(
 
 1421                 return(HA_ERR_LOCK_WAIT_TIMEOUT);
 
 1424                 return(HA_ERR_NO_REFERENCED_ROW);
 
 1427                 return(HA_ERR_ROW_IS_REFERENCED);
 
 1432                 return(HA_ERR_CANNOT_ADD_FOREIGN);
 
 1436                 return(HA_ERR_ROW_IS_REFERENCED); 
 
 1441                 return(HA_ERR_CRASHED);
 
 1443         case DB_OUT_OF_FILE_SPACE:
 
 1444                 return(HA_ERR_RECORD_FILE_FULL);
 
 1446         case DB_TABLE_IN_FK_CHECK:
 
 1447                 return(HA_ERR_TABLE_IN_FK_CHECK);
 
 1449         case DB_TABLE_IS_BEING_USED:
 
 1450                 return(HA_ERR_WRONG_COMMAND);
 
 1453         case DB_TABLE_NOT_FOUND:
 
 1454                 return(HA_ERR_NO_SUCH_TABLE);
 
 1456         case DB_TABLESPACE_NOT_FOUND:
 
 1457                 return(HA_ERR_NO_SUCH_TABLE);
 
 1463                 my_printf_error(ER_TOO_BIG_ROWSIZE,
 
 1464                         "Row size too large (> %lu). Changing some columns " 
 1465                         "to TEXT or BLOB %smay help. In current row " 
 1466                         "format, BLOB prefix of %d bytes is stored inline.",
 
 1470                         prefix ? 
"or using ROW_FORMAT=DYNAMIC " 
 1471                         "or ROW_FORMAT=COMPRESSED ": 
"",
 
 1473                 return(HA_ERR_TO_BIG_ROW);
 
 1477                 my_error(ER_INDEX_COLUMN_TOO_LONG, MYF(0),
 
 1478                          DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(flags));
 
 1479                 return(HA_ERR_INDEX_COL_TOO_LONG);
 
 1482                 return(HA_ERR_NO_SAVEPOINT);
 
 1490                         thd_mark_transaction_to_rollback(thd, TRUE);
 
 1493                 return(HA_ERR_LOCK_TABLE_FULL);
 
 1495         case DB_FTS_INVALID_DOCID:
 
 1496                 return(HA_FTS_INVALID_DOCID);
 
 1498                 return(HA_ERR_FTS_EXCEED_RESULT_CACHE_LIMIT);
 
 1500                 return(HA_ERR_TOO_MANY_CONCURRENT_TRXS);
 
 1502                 return(HA_ERR_UNSUPPORTED);
 
 1504                 return(HA_ERR_INDEX_CORRUPT);
 
 1506                 return(HA_ERR_UNDO_REC_TOO_BIG);
 
 1507         case DB_OUT_OF_MEMORY:
 
 1508                 return(HA_ERR_OUT_OF_MEM);
 
 1510                 return(HA_ERR_TABLESPACE_EXISTS);
 
 1512                 return(HA_ERR_INTERNAL_ERROR);
 
 1529         fputs(thd_security_context(thd, buffer, 
sizeof buffer,
 
 1543         return(my_get_err_msg(error_code));
 
 1557         ut_ad(cset <= MAX_CHAR_COLL_NUM);
 
 1561         cs = all_charsets[cset];
 
 1563                 *mbminlen = cs->mbminlen;
 
 1564                 *mbmaxlen = cs->mbmaxlen;
 
 1565                 ut_ad(*mbminlen < DATA_MBMAX);
 
 1566                 ut_ad(*mbmaxlen < DATA_MBMAX);
 
 1568                 THD*    thd = current_thd;
 
 1570                 if (thd && thd_sql_command(thd) == SQLCOM_DROP_TABLE) {
 
 1578                                         "Unknown collation #%lu.", cset);
 
 1585                 *mbminlen = *mbmaxlen = 0;
 
 1602         strconvert(cs, from, &my_charset_filename, to, (uint) len, &errors);
 
 1610 innobase_check_identifier_length(
 
 1615         int             well_formed_error = 0;
 
 1617         DBUG_ENTER(
"innobase_check_identifier_length");
 
 1619         uint res = cs->cset->well_formed_len(cs, 
id, 
id + strlen(
id),
 
 1621                                              &well_formed_error);
 
 1623         if (well_formed_error || res == NAME_CHAR_LEN) {
 
 1624                 my_error(ER_TOO_LONG_IDENT, MYF(0), 
id);
 
 1643         strconvert(cs, from, system_charset_info, to, (uint) len, &errors);
 
 1666         return(my_strcasecmp(system_charset_info, a, b));
 
 1680         return(wild_case_compare(system_charset_info, a, b));
 
 1690         const char*     path_name)      
 
 1692         const char*     
name = base_name(path_name);
 
 1694         return((name) ? name : 
"null");
 
 1705         my_casedn_str(system_charset_info, a);
 
 1717         return(thd_charset(mysql_thd));
 
 1732         stmt = thd_query_string(thd);
 
 1733         *length = stmt->length;
 
 1747         return(table_def_size);
 
 1761         return(lower_case_table_names);
 
 1776                 "innobase_tmpfile_creation_failure",
 
 1780         fd = mysql_tmpfile(
"ib");
 
 1798                         HANDLE hFile = my_get_osfhandle(fd);
 
 1800                         BOOL bOK = DuplicateHandle(
 
 1801                                         GetCurrentProcess(),
 
 1802                                         hFile, GetCurrentProcess(),
 
 1803                                         &hDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
 
 1805                                 fd2 = _open_osfhandle((intptr_t) hDup, 0);
 
 1807                                 my_osmaperr(GetLastError());
 
 1815                         char errbuf[MYSYS_STRERROR_SIZE];
 
 1816                         DBUG_PRINT(
"error",(
"Got error %d on dup",fd2));
 
 1818                         my_error(EE_OUT_OF_FILERESOURCES,
 
 1819                                  MYF(ME_BELL+ME_WAITTANG),
 
 1821                                  my_strerror(errbuf, 
sizeof(errbuf), my_errno));
 
 1823                 my_close(fd, MYF(MY_WME));
 
 1846         return(copy_and_convert(
 
 1847                         (
char*) to, (uint32) to_length, to_cs,
 
 1848                         (
const char*) from, (uint32) from_length, from_cs,
 
 1880         data_cs = all_charsets[charset_coll];
 
 1883                                                system_charset_info,
 
 1884                                                data, data_len, data_cs,
 
 1916         ulonglong       max_value)      
 
 1918         ulonglong       next_value;
 
 1919         ulonglong       
block = need * step;
 
 1924         ut_a(max_value > 0);
 
 1928         if (offset > block) {
 
 1937         if (block >= max_value
 
 1938             || offset > max_value
 
 1939             || current >= max_value
 
 1940             || max_value - offset <= offset) {
 
 1942                 next_value = max_value;
 
 1944                 ut_a(max_value > current);
 
 1946                 ulonglong       free = max_value - current;
 
 1948                 if (free < offset || free - offset <= block) {
 
 1949                         next_value = max_value;
 
 1955         if (next_value == 0) {
 
 1958                 if (current > offset) {
 
 1959                         next = (current - 
offset) / step;
 
 1961                         next = (offset - current) / step;
 
 1964                 ut_a(max_value > next);
 
 1965                 next_value = next * step;
 
 1967                 ut_a(next_value >= next);
 
 1968                 ut_a(max_value > next_value);
 
 1971                 if (max_value - next_value >= block) {
 
 1973                         next_value += 
block;
 
 1975                         if (max_value - next_value >= offset) {
 
 1978                                 next_value = max_value;
 
 1981                         next_value = max_value;
 
 1985         ut_a(next_value != 0);
 
 1986         ut_a(next_value <= max_value);
 
 2000         DBUG_ENTER(
"innobase_trx_init");
 
 2001         DBUG_ASSERT(EQ_CURRENT_THD(thd));
 
 2024         DBUG_ENTER(
"innobase_trx_allocate");
 
 2025         DBUG_ASSERT(thd != NULL);
 
 2026         DBUG_ASSERT(EQ_CURRENT_THD(thd));
 
 2032         innobase_trx_init(thd, trx);
 
 2048         trx_t*& trx = thd_to_trx(thd);
 
 2050         ut_ad(EQ_CURRENT_THD(thd));
 
 2054         } 
else if (UNIV_UNLIKELY(trx->magic_n != TRX_MAGIC_N)) {
 
 2059         innobase_trx_init(thd, trx);
 
 2069 trx_is_registered_for_2pc(
 
 2073         return(trx->is_registered == 1);
 
 2080 trx_register_for_2pc(
 
 2084         trx->is_registered = 1;
 
 2085         ut_ad(trx->owns_prepare_mutex == 0);
 
 2092 trx_deregister_from_2pc(
 
 2096         trx->is_registered = 0;
 
 2097         trx->owns_prepare_mutex = 0;
 
 2110         return(trx->
state != TRX_STATE_NOT_STARTED);
 
 2133                 ps_on = create_info->table_options
 
 2134                         & HA_OPTION_STATS_PERSISTENT;
 
 2135                 ps_off = create_info->table_options
 
 2136                         & HA_OPTION_NO_STATS_PERSISTENT;
 
 2143                 create_info->stats_auto_recalc == HA_STATS_AUTO_RECALC_ON,
 
 2144                 create_info->stats_auto_recalc == HA_STATS_AUTO_RECALC_OFF);
 
 2169                 ps_on = table_share->db_create_options
 
 2170                         & HA_OPTION_STATS_PERSISTENT;
 
 2171                 ps_off = table_share->db_create_options
 
 2172                         & HA_OPTION_NO_STATS_PERSISTENT;
 
 2179                 table_share->stats_auto_recalc == HA_STATS_AUTO_RECALC_ON,
 
 2180                 table_share->stats_auto_recalc == HA_STATS_AUTO_RECALC_OFF);
 
 2193         int_table_flags(HA_REC_NOT_IN_SEQ |
 
 2195                   HA_CAN_INDEX_BLOBS |
 
 2196                   HA_CAN_SQL_HANDLER |
 
 2197                   HA_PRIMARY_KEY_REQUIRED_FOR_POSITION |
 
 2198                   HA_PRIMARY_KEY_IN_READ_INDEX |
 
 2199                   HA_BINLOG_ROW_CAPABLE |
 
 2200                   HA_CAN_GEOMETRY | HA_PARTIAL_COLUMN_READ |
 
 2201                   HA_TABLE_SCAN_ON_INDEX | HA_CAN_FULLTEXT |
 
 2202                   HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT),
 
 2221 ha_innobase::update_thd(
 
 2227         DBUG_ENTER(
"ha_innobase::update_thd");
 
 2228         DBUG_PRINT(
"ha_innobase::update_thd", (
"user_thd: %p -> %p",
 
 2234         trx = check_trx_exists(thd);
 
 2236         if (prebuilt->
trx != trx) {
 
 2251 ha_innobase::update_thd()
 
 2254         THD*    thd = ha_thd();
 
 2256         ut_ad(EQ_CURRENT_THD(thd));
 
 2269 innobase_register_trx(
 
 2277         if (!trx_is_registered_for_2pc(trx)
 
 2278             && thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
 2283         trx_register_for_2pc(trx);
 
 2354 innobase_query_caching_of_table_permitted(
 
 2364         ibool   is_autocommit;
 
 2366         char    norm_name[1000];
 
 2368         ut_a(full_name_len < 999);
 
 2370         trx = check_trx_exists(thd);
 
 2376                 return((my_bool)FALSE);
 
 2380                 sql_print_error(
"The calling thread is holding the adaptive " 
 2381                                 "search, latch though calling " 
 2382                                 "innobase_query_caching_of_table_permitted.");
 
 2388         innobase_srv_conc_force_exit_innodb(trx);
 
 2390         if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
 2392                 is_autocommit = TRUE;
 
 2394                 is_autocommit = FALSE;
 
 2417                 return((my_bool)TRUE);
 
 2423         innobase_register_trx(innodb_hton_ptr, thd, trx);
 
 2429                 return((my_bool)TRUE);
 
 2434         return((my_bool)FALSE);
 
 2445         const char*     full_name,      
 
 2450         ulint           full_name_len)  
 
 2458 #ifdef HAVE_QUERY_CACHE 
 2459         mysql_query_cache_invalidate4(trx->
mysql_thd,
 
 2461                                       (uint32) full_name_len,
 
 2472 innobase_convert_identifier(
 
 2494                 memcpy(nz, 
id, idlen);
 
 2498                 idlen = explain_filename(thd, nz, nz2, 
sizeof nz2,
 
 2499                                          EXPLAIN_PARTITIONS_AS_COMMENT);
 
 2504         if (UNIV_UNLIKELY(!thd)) {
 
 2507                 q = get_quote_char_for_identifier(thd, s, (
int) idlen);
 
 2512                 if (UNIV_UNLIKELY(idlen > buflen)) {
 
 2515                 memcpy(buf, s, idlen);
 
 2516                 return(buf + idlen);
 
 2527         for (; idlen; idlen--) {
 
 2529                 if (UNIV_UNLIKELY(c == q)) {
 
 2530                         if (UNIV_UNLIKELY(buflen < 3)) {
 
 2538                         if (UNIV_UNLIKELY(buflen < 2)) {
 
 2568         const char*     bufend  = buf + buflen;
 
 2571                 const char*     slash = (
const char*) memchr(
id, 
'/', idlen);
 
 2578                 s = innobase_convert_identifier(s, bufend - s, 
id, slash - 
id,
 
 2580                 if (UNIV_LIKELY(s < bufend)) {
 
 2582                         s = innobase_convert_identifier(s, bufend - s,
 
 2589                 const char temp_index_suffix[]= 
"--temporary--";
 
 2591                 s = innobase_convert_identifier(buf, buflen, 
id + 1, idlen - 1,
 
 2593                 if (s - buf + (
sizeof temp_index_suffix - 1) < buflen) {
 
 2594                         memcpy(s, temp_index_suffix,
 
 2595                                sizeof temp_index_suffix - 1);
 
 2596                         s += 
sizeof temp_index_suffix - 1;
 
 2600                 s = innobase_convert_identifier(buf, buflen, 
id, idlen,
 
 2618         ibool           is_index_name) 
 
 2623                                        NULL, !is_index_name);
 
 2625         ut_ad((ulint) (bufend - buf) < buflen);
 
 2627         buf[bufend - 
buf] = 
'\0';
 
 2664         return(THDVAR(thd, strict_mode));
 
 2672 ha_innobase::reset_template(
void)
 
 2707         update_thd(ha_thd());
 
 2714         innobase_srv_conc_force_exit_innodb(prebuilt->
trx);
 
 2718         trx_start_if_not_started_xa(prebuilt->
trx);
 
 2724         innobase_register_trx(ht, user_thd, prebuilt->
trx);
 
 2757         static char     current_dir[3];         
 
 2762         ulong           num_pll_degree;
 
 2764         DBUG_ENTER(
"innobase_init");
 
 2766         innodb_hton_ptr = innobase_hton;
 
 2768         innobase_hton->state = SHOW_OPTION_YES;
 
 2769         innobase_hton->db_type= DB_TYPE_INNODB;
 
 2771         innobase_hton->close_connection = innobase_close_connection;
 
 2772         innobase_hton->savepoint_set = innobase_savepoint;
 
 2773         innobase_hton->savepoint_rollback = innobase_rollback_to_savepoint;
 
 2774         innobase_hton->savepoint_release = innobase_release_savepoint;
 
 2775         innobase_hton->commit = innobase_commit;
 
 2776         innobase_hton->rollback = innobase_rollback;
 
 2777         innobase_hton->prepare = innobase_xa_prepare;
 
 2778         innobase_hton->recover = innobase_xa_recover;
 
 2779         innobase_hton->commit_by_xid = innobase_commit_by_xid;
 
 2780         innobase_hton->rollback_by_xid = innobase_rollback_by_xid;
 
 2781         innobase_hton->create_cursor_read_view = innobase_create_cursor_view;
 
 2782         innobase_hton->set_cursor_read_view = innobase_set_cursor_view;
 
 2783         innobase_hton->close_cursor_read_view = innobase_close_cursor_view;
 
 2784         innobase_hton->create = innobase_create_handler;
 
 2785         innobase_hton->drop_database = innobase_drop_database;
 
 2786         innobase_hton->panic = innobase_end;
 
 2788         innobase_hton->start_consistent_snapshot =
 
 2789                 innobase_start_trx_and_assign_read_view;
 
 2791         innobase_hton->flush_logs = innobase_flush_logs;
 
 2792         innobase_hton->show_status = innobase_show_status;
 
 2793         innobase_hton->flags = HTON_SUPPORTS_EXTENDED_KEYS;
 
 2795         innobase_hton->release_temporary_latches =
 
 2796                 innobase_release_temporary_latches;
 
 2800         ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
 
 2803         static const char       test_filename[] = 
"-@";
 
 2804         char                    test_tablename[
sizeof test_filename
 
 2806         if ((
sizeof(test_tablename)) - 1
 
 2807                         != filename_to_tablename(test_filename,
 
 2809                                                  sizeof(test_tablename), 
true)
 
 2810                         || strncmp(test_tablename,
 
 2813                         || strcmp(test_tablename
 
 2817                 sql_print_error(
"tablename encoding has been changed");
 
 2824         if (
sizeof(ulint) == 4) {
 
 2825                 if (innobase_buffer_pool_size > UINT_MAX32) {
 
 2827                                 "innobase_buffer_pool_size can't be over 4GB" 
 2828                                 " on 32-bit systems");
 
 2842         if (mysqld_embedded) {
 
 2843                 default_path = mysql_real_data_home;
 
 2847                 current_dir[0] = FN_CURLIB;
 
 2848                 current_dir[1] = FN_LIBCHAR;
 
 2850                 default_path = current_dir;
 
 2862         srv_data_home = (innobase_data_home_dir ? innobase_data_home_dir :
 
 2869         if (!innobase_data_file_path) {
 
 2870                 innobase_data_file_path = (
char*) 
"ibdata1:12M:autoextend";
 
 2876         internal_innobase_data_file_path = my_strdup(innobase_data_file_path,
 
 2880                 internal_innobase_data_file_path);
 
 2883                         "InnoDB: syntax error in innodb_data_file_path");
 
 2886                 my_free(internal_innobase_data_file_path);
 
 2894         if (!srv_log_group_home_dir) {
 
 2895                 srv_log_group_home_dir = default_path;
 
 2898 #ifdef UNIV_LOG_ARCHIVE 
 2903         innobase_log_arch_dir = innobase_log_group_home_dir;
 
 2905         srv_arch_dir = innobase_log_arch_dir;
 
 2910         if (strchr(srv_log_group_home_dir, 
';')) {
 
 2911                 sql_print_error(
"syntax error in innodb_log_group_home_dir");
 
 2912                 goto mem_free_and_error;
 
 2915         if (innobase_mirrored_log_groups == 1) {
 
 2917                         "innodb_mirrored_log_groups is an unimplemented " 
 2918                         "feature and the variable will be completely " 
 2919                         "removed in a future version.");
 
 2922         if (innobase_mirrored_log_groups > 1) {
 
 2924                 "innodb_mirrored_log_groups is an unimplemented feature and " 
 2925                 "the variable will be completely removed in a future version. " 
 2926                 "Using values other than 1 is not supported.");
 
 2927                 goto mem_free_and_error;
 
 2930         if (innobase_mirrored_log_groups == 0) {
 
 2934                 innobase_mirrored_log_groups = 1;
 
 2938         if (innobase_file_format_name != NULL) {
 
 2940                 format_id = innobase_file_format_name_lookup(
 
 2941                         innobase_file_format_name);
 
 2943                 if (format_id > UNIV_FORMAT_MAX) {
 
 2945                         sql_print_error(
"InnoDB: wrong innodb_file_format.");
 
 2947                         goto mem_free_and_error;
 
 2962         innobase_file_format_name =
 
 2966         if (!innobase_file_format_check) {
 
 2980         if (innobase_file_format_validate_and_set(
 
 2981                         innobase_file_format_max) < 0) {
 
 2983                 sql_print_error(
"InnoDB: invalid " 
 2984                                 "innodb_file_format_max value: " 
 2985                                 "should be any value up to %s or its " 
 2986                                 "equivalent numeric id",
 
 2990                 goto mem_free_and_error;
 
 2994         if (innobase_server_stopword_table) {
 
 2995                 fts_server_stopword_table =
 
 2996                         my_strdup(innobase_server_stopword_table,  MYF(0));
 
 2999         if (innobase_change_buffering) {
 
 3003                      use < UT_ARR_SIZE(innobase_change_buffering_values);
 
 3006                                     innobase_change_buffering,
 
 3007                                     innobase_change_buffering_values[use])) {
 
 3009                                 goto innobase_change_buffering_inited_ok;
 
 3013                 sql_print_error(
"InnoDB: invalid value " 
 3014                                 "innodb_change_buffering=%s",
 
 3015                                 innobase_change_buffering);
 
 3016                 goto mem_free_and_error;
 
 3019 innobase_change_buffering_inited_ok:
 
 3020         ut_a((ulint) 
ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
 
 3021         innobase_change_buffering = (
char*)
 
 3022                 innobase_change_buffering_values[
ibuf_use];
 
 3025         if (srv_max_buf_pool_modified_pct < srv_max_dirty_pages_pct_lwm) {
 
 3026                 sql_print_warning(
"InnoDB: innodb_max_dirty_pages_pct_lwm" 
 3027                                   " cannot be set higher than" 
 3028                                   " innodb_max_dirty_pages_pct.\n" 
 3030                                   " innodb_max_dirty_pages_pct_lwm to %lu\n",
 
 3031                                   srv_max_buf_pool_modified_pct);
 
 3033                 srv_max_dirty_pages_pct_lwm = srv_max_buf_pool_modified_pct;
 
 3036         if (srv_max_io_capacity == SRV_MAX_IO_CAPACITY_DUMMY_DEFAULT) {
 
 3038                 if (srv_io_capacity >= SRV_MAX_IO_CAPACITY_LIMIT / 2) {
 
 3040                         srv_max_io_capacity = SRV_MAX_IO_CAPACITY_LIMIT;
 
 3044                         srv_max_io_capacity =
 
 3045                                 ut_max(2 * srv_io_capacity, 2000);
 
 3048         } 
else if (srv_max_io_capacity < srv_io_capacity) {
 
 3049                 sql_print_warning(
"InnoDB: innodb_io_capacity" 
 3050                                   " cannot be set higher than" 
 3051                                   " innodb_io_capacity_max.\n" 
 3053                                   " innodb_io_capacity to %lu\n",
 
 3054                                   srv_max_io_capacity);
 
 3056                 srv_io_capacity = srv_max_io_capacity;
 
 3061                 sql_print_error(
"InnoDB: innodb_buffer_pool_filename" 
 3062                         " cannot have colon (:) in the file name.");
 
 3063                 goto mem_free_and_error;
 
 3068         srv_file_flush_method_str = innobase_file_flush_method;
 
 3070         srv_log_file_size = (ib_uint64_t) innobase_log_file_size;
 
 3072 #ifdef UNIV_LOG_ARCHIVE 
 3073         srv_log_archive_on = (ulint) innobase_log_archive;
 
 3080         if (!srv_page_size_shift) {
 
 3081                 sql_print_error(
"InnoDB: Invalid page size=%lu.\n",
 
 3083                 goto mem_free_and_error;
 
 3085         if (UNIV_PAGE_SIZE_DEF != srv_page_size) {
 
 3088                         " InnoDB: innodb-page-size has been changed" 
 3089                         " from the default value %d to %lu.\n",
 
 3090                         UNIV_PAGE_SIZE_DEF, srv_page_size);
 
 3093         srv_log_buffer_size = (ulint) innobase_log_buffer_size;
 
 3095         if (innobase_buffer_pool_instances == 0) {
 
 3096                 innobase_buffer_pool_instances = 8;
 
 3098 #if defined(__WIN__) && !defined(_WIN64) 
 3099                 if (innobase_buffer_pool_size > 1331 * 1024 * 1024) {
 
 3100                         innobase_buffer_pool_instances
 
 3102                                         (
long) (innobase_buffer_pool_size
 
 3103                                         / (128 * 1024 * 1024)));
 
 3108         srv_buf_pool_instances = (ulint) innobase_buffer_pool_instances;
 
 3110         srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
 
 3112         if (innobase_additional_mem_pool_size
 
 3117                         " InnoDB: Warning: Using " 
 3118                         "innodb_additional_mem_pool_size is DEPRECATED. " 
 3119                         "This option may be removed in future releases, " 
 3120                         "together with the option innodb_use_sys_malloc " 
 3121                         "and with the InnoDB's internal memory " 
 3125         if (!srv_use_sys_malloc ) {
 
 3128                         " InnoDB: Warning: Setting " 
 3129                         "innodb_use_sys_malloc to FALSE is DEPRECATED. " 
 3130                         "This option may be removed in future releases, " 
 3131                         "together with the InnoDB's internal memory " 
 3135         srv_n_file_io_threads = (ulint) innobase_file_io_threads;
 
 3136         srv_n_read_io_threads = (ulint) innobase_read_io_threads;
 
 3137         srv_n_write_io_threads = (ulint) innobase_write_io_threads;
 
 3139         srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
 
 3141         if (!innobase_use_checksums) {
 
 3144                         " InnoDB: Warning: Setting " 
 3145                         "innodb_checksums to OFF is DEPRECATED. " 
 3146                         "This option may be removed in future releases. " 
 3147                         "You should set innodb_checksum_algorithm=NONE " 
 3152 #ifdef HAVE_LARGE_PAGES 
 3153         if ((os_use_large_pages = (ibool) my_use_large_pages)) {
 
 3154                 os_large_page_size = (ulint) opt_large_page_size;
 
 3161         if (innobase_locks_unsafe_for_binlog) {
 
 3164                         " InnoDB: Warning: Using " 
 3165                         "innodb_locks_unsafe_for_binlog is DEPRECATED. " 
 3166                         "This option may be removed in future releases. " 
 3167                         "Please use READ COMMITTED transaction isolation " 
 3168                         "level instead, see " REFMAN 
"set-transaction.html.\n");
 
 3171         if (innobase_open_files < 10) {
 
 3172                 innobase_open_files = 300;
 
 3174                         innobase_open_files = table_cache_size;
 
 3177         srv_max_n_open_files = (ulint) innobase_open_files;
 
 3178         srv_innodb_status = (ibool) innobase_create_status_file;
 
 3180         srv_print_verbose_log = mysqld_embedded ? 0 : 1;
 
 3183         for (num_pll_degree = 1;
 
 3185              num_pll_degree <<= 1) {
 
 3190         fts_sort_pll_degree = num_pll_degree;
 
 3195         data_mysql_default_charset_coll = (ulint) default_charset_info->number;
 
 3197         ut_a(DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL ==
 
 3198                                         my_charset_latin1.number);
 
 3199         ut_a(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number);
 
 3206         ut_a(0 == strcmp(my_charset_latin1.name, 
"latin1_swedish_ci"));
 
 3209         innobase_commit_concurrency_init_default();
 
 3211 #ifdef HAVE_PSI_INTERFACE 
 3215         count = array_elements(all_pthread_mutexes);
 
 3218 # ifdef UNIV_PFS_MUTEX 
 3219         count = array_elements(all_innodb_mutexes);
 
 3223 # ifdef UNIV_PFS_RWLOCK 
 3224         count = array_elements(all_innodb_rwlocks);
 
 3228 # ifdef UNIV_PFS_THREAD 
 3229         count = array_elements(all_innodb_threads);
 
 3234         count = array_elements(all_innodb_files);
 
 3238         count = array_elements(all_innodb_conds);
 
 3250         if (err != DB_SUCCESS) {
 
 3251                 goto mem_free_and_error;
 
 3255         innobase_undo_logs_init_default_max();
 
 3258                 innobase_old_blocks_pct, TRUE);
 
 3262         innobase_open_tables = hash_create(200);
 
 3264                          &innobase_share_mutex,
 
 3265                          MY_MUTEX_INIT_FAST);
 
 3267                          &commit_cond_m, MY_MUTEX_INIT_FAST);
 
 3270 #ifdef MYSQL_DYNAMIC_PLUGIN 
 3271         if (innobase_hton != p) {
 
 3272                 innobase_hton = 
reinterpret_cast<handlerton*
>(p);
 
 3273                 *innobase_hton = *innodb_hton_ptr;
 
 3288         if (innobase_enable_monitor_counter) {
 
 3289                 innodb_enable_monitor_at_startup(
 
 3290                         innobase_enable_monitor_counter);
 
 3309         ha_panic_function       
type __attribute__((unused)))
 
 3314         DBUG_ENTER(
"innobase_end");
 
 3315         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3317         if (innodb_inited) {
 
 3323                 innobase_open_tables = NULL;
 
 3328                 my_free(internal_innobase_data_file_path);
 
 3343 innobase_flush_logs(
 
 3349         DBUG_ENTER(
"innobase_flush_logs");
 
 3350         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3356         DBUG_RETURN(result);
 
 3363 innobase_commit_low(
 
 3367         if (trx_is_started(trx)) {
 
 3381 innobase_start_trx_and_assign_read_view(
 
 3389         DBUG_ENTER(
"innobase_start_trx_and_assign_read_view");
 
 3390         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3394         trx = check_trx_exists(thd);
 
 3403         innobase_srv_conc_force_exit_innodb(trx);
 
 3407         trx_start_if_not_started_xa(trx);
 
 3413                 thd_get_trx_isolation(thd));
 
 3418                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
 3420                                     "InnoDB: WITH CONSISTENT SNAPSHOT " 
 3421                                     "was ignored because this phrase " 
 3422                                     "can only be used with " 
 3423                                     "REPEATABLE READ isolation level.");
 
 3428         innobase_register_trx(hton, current_thd, trx);
 
 3451         DBUG_ENTER(
"innobase_commit");
 
 3452         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3453         DBUG_PRINT(
"trans", (
"ending transaction"));
 
 3455         trx = check_trx_exists(thd);
 
 3469         if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
 
 3471                 sql_print_error(
"Transaction not registered for MySQL 2PC, " 
 3472                                 "but transaction is active");
 
 3476             || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
 
 3483                 if (innobase_commit_concurrency > 0) {
 
 3487                         if (commit_threads > innobase_commit_concurrency) {
 
 3511                 unsigned long long pos;
 
 3516                 trx->flush_log_later = TRUE;
 
 3517                 innobase_commit_low(trx);
 
 3518                 trx->flush_log_later = FALSE;
 
 3520                 if (innobase_commit_concurrency > 0) {
 
 3527                 trx_deregister_from_2pc(trx);
 
 3550         trx->fts_next_doc_id = 0;
 
 3552         innobase_srv_conc_force_exit_innodb(trx);
 
 3579         DBUG_ENTER(
"innobase_rollback");
 
 3580         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3581         DBUG_PRINT(
"trans", (
"aborting transaction"));
 
 3583         trx = check_trx_exists(thd);
 
 3591         innobase_srv_conc_force_exit_innodb(trx);
 
 3602         trx->fts_next_doc_id = 0;
 
 3605             || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
 3608                 trx_deregister_from_2pc(trx);
 
 3613         DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));
 
 3621 innobase_rollback_trx(
 
 3627         DBUG_ENTER(
"innobase_rollback_trx");
 
 3628         DBUG_PRINT(
"trans", (
"aborting transaction"));
 
 3636         innobase_srv_conc_force_exit_innodb(trx);
 
 3648         DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));
 
 3657 innobase_rollback_to_savepoint(
 
 3665         ib_int64_t      mysql_binlog_cache_pos;
 
 3670         DBUG_ENTER(
"innobase_rollback_to_savepoint");
 
 3671         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3673         trx = check_trx_exists(thd);
 
 3681         innobase_srv_conc_force_exit_innodb(trx);
 
 3685         longlong2str((ulint) savepoint, name, 36);
 
 3688                 trx, name, &mysql_binlog_cache_pos);
 
 3690         if (error == DB_SUCCESS && trx->
fts_trx != NULL) {
 
 3694         DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));
 
 3703 innobase_release_savepoint(
 
 3715         DBUG_ENTER(
"innobase_release_savepoint");
 
 3716         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3718         trx = check_trx_exists(thd);
 
 3722         longlong2str((ulint) savepoint, name, 36);
 
 3726         if (error == DB_SUCCESS && trx->
fts_trx != NULL) {
 
 3730         DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));
 
 3747         DBUG_ENTER(
"innobase_savepoint");
 
 3748         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3754         trx = check_trx_exists(thd);
 
 3762         innobase_srv_conc_force_exit_innodb(trx);
 
 3765         DBUG_ASSERT(trx_is_registered_for_2pc(trx));
 
 3769         longlong2str((ulint) savepoint,name,36);
 
 3773         if (error == DB_SUCCESS && trx->
fts_trx != NULL) {
 
 3777         DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));
 
 3785 innobase_close_connection(
 
 3793         DBUG_ENTER(
"innobase_close_connection");
 
 3794         DBUG_ASSERT(hton == innodb_hton_ptr);
 
 3795         trx = thd_to_trx(thd);
 
 3799         if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
 
 3801                 sql_print_error(
"Transaction not registered for MySQL 2PC, " 
 3802                                 "but transaction is active");
 
 3805         if (trx_is_started(trx) && log_warnings) {
 
 3808                         "MySQL is closing a connection that has an active " 
 3809                         "InnoDB transaction.  "TRX_ID_FMT" row modifications " 
 3814         innobase_rollback_trx(trx);
 
 3831         trx_t*  trx = thd_to_trx(thd);
 
 3837         return(innobase_close_connection(innodb_hton_ptr, thd));
 
 3853         if (prebuilt && prebuilt->
table) {
 
 3856                 switch (dict_tf_get_rec_format(flags)) {
 
 3858                         return(ROW_TYPE_REDUNDANT);
 
 3860                         return(ROW_TYPE_COMPACT);
 
 3862                         return(ROW_TYPE_COMPRESSED);
 
 3864                         return(ROW_TYPE_DYNAMIC);
 
 3868         return(ROW_TYPE_NOT_USED);
 
 3877 handler::Table_flags
 
 3883         ulong 
const tx_isolation = thd_tx_isolation(ha_thd());
 
 3885         if (tx_isolation <= ISO_READ_COMMITTED) {
 
 3886                 return(int_table_flags);
 
 3889         return(int_table_flags | HA_BINLOG_STMT_CAPABLE);
 
 3894 static const char* ha_innobase_exts[] = {
 
 3908         return(innobase_hton_name);
 
 3922         if (index && index->
type & DICT_FTS) {
 
 3937         return(ha_innobase_exts);
 
 3951         return((table_share->key_info[key].algorithm == HA_KEY_ALG_FULLTEXT)
 
 3953                  : (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER
 
 3954                   | HA_READ_RANGE | HA_KEYREAD_ONLY
 
 3955                   | HA_DO_INDEX_COND_PUSHDOWN));
 
 3989         switch (UNIV_PAGE_SIZE) {
 
 4007         return(&key_map_full);
 
 4018         return(HA_CACHE_TBL_ASKTRANSACT);
 
 4039 normalize_table_name_low(
 
 4044         ibool           set_lower_case) 
 
 4056         ptr = strend(name) - 1;
 
 4059         while (ptr >= name && *ptr != 
'\\' && *ptr != 
'/') {
 
 4064         name_len = strlen(name_ptr);
 
 4067         while (ptr >= name && (*ptr == 
'\\' || *ptr == 
'/')) {
 
 4071         DBUG_ASSERT(ptr >= name);
 
 4076         while (ptr >= name && *ptr != 
'\\' && *ptr != 
'/') {
 
 4083         norm_len = db_len + name_len + 
sizeof "/";
 
 4084         ut_a(norm_len < FN_REFLEN - 1);
 
 4086         memcpy(norm_name, db_ptr, db_len);
 
 4088         norm_name[db_len] = 
'/';
 
 4091         memcpy(norm_name + db_len + 1, name_ptr, name_len + 1);
 
 4093         if (set_lower_case) {
 
 4098 #if !defined(DBUG_OFF) 
 4103 test_normalize_table_name_low()
 
 4106         char            norm_name[FN_REFLEN];
 
 4107         const char*     test_data[][2] = {
 
 4109                 {
"./mysqltest/t1", 
"mysqltest/t1"},
 
 4110                 {
"./test/#sql-842b_2", 
"test/#sql-842b_2"},
 
 4111                 {
"./test/#sql-85a3_10", 
"test/#sql-85a3_10"},
 
 4112                 {
"./test/#sql2-842b-2", 
"test/#sql2-842b-2"},
 
 4113                 {
"./test/bug29807", 
"test/bug29807"},
 
 4114                 {
"./test/foo", 
"test/foo"},
 
 4115                 {
"./test/innodb_bug52663", 
"test/innodb_bug52663"},
 
 4116                 {
"./test/t", 
"test/t"},
 
 4117                 {
"./test/t1", 
"test/t1"},
 
 4118                 {
"./test/t10", 
"test/t10"},
 
 4119                 {
"/a/b/db/table", 
"db/table"},
 
 4120                 {
"/a/b/db///////table", 
"db/table"},
 
 4121                 {
"/a/b////db///////table", 
"db/table"},
 
 4122                 {
"/var/tmp/mysqld.1/#sql842b_2_10", 
"mysqld.1/#sql842b_2_10"},
 
 4123                 {
"db/table", 
"db/table"},
 
 4127                 {
".\\mysqltest\\t1", 
"mysqltest/t1"},
 
 4128                 {
".\\test\\#sql-842b_2", 
"test/#sql-842b_2"},
 
 4129                 {
".\\test\\#sql-85a3_10", 
"test/#sql-85a3_10"},
 
 4130                 {
".\\test\\#sql2-842b-2", 
"test/#sql2-842b-2"},
 
 4131                 {
".\\test\\bug29807", 
"test/bug29807"},
 
 4132                 {
".\\test\\foo", 
"test/foo"},
 
 4133                 {
".\\test\\innodb_bug52663", 
"test/innodb_bug52663"},
 
 4134                 {
".\\test\\t", 
"test/t"},
 
 4135                 {
".\\test\\t1", 
"test/t1"},
 
 4136                 {
".\\test\\t10", 
"test/t10"},
 
 4137                 {
"C:\\a\\b\\db\\table", 
"db/table"},
 
 4138                 {
"C:\\a\\b\\db\\\\\\\\\\\\\\table", 
"db/table"},
 
 4139                 {
"C:\\a\\b\\\\\\\\db\\\\\\\\\\\\\\table", 
"db/table"},
 
 4140                 {
"C:\\var\\tmp\\mysqld.1\\#sql842b_2_10", 
"mysqld.1/#sql842b_2_10"},
 
 4141                 {
"db\\table", 
"db/table"},
 
 4142                 {
"ddd\\t", 
"ddd/t"},
 
 4143                 {
"d\\ttt", 
"d/ttt"},
 
 4147         for (
size_t i = 0; 
i < UT_ARR_SIZE(test_data); 
i++) {
 
 4148                 printf(
"test_normalize_table_name_low(): " 
 4149                        "testing \"%s\", expected \"%s\"... ",
 
 4150                        test_data[
i][0], test_data[i][1]);
 
 4152                 normalize_table_name_low(norm_name, test_data[
i][0], FALSE);
 
 4154                 if (strcmp(norm_name, test_data[
i][1]) == 0) {
 
 4157                         printf(
"got \"%s\"\n", norm_name);
 
 4167 test_ut_format_name()
 
 4170         char            buf[NAME_LEN * 3];
 
 4176                 const char*     expected;
 
 4178                 {
"test/t1",     TRUE,   
sizeof(
buf),    
"\"test\".\"t1\""},
 
 4179                 {
"test/t1",     TRUE,   12,             
"\"test\".\"t1\""},
 
 4180                 {
"test/t1",     TRUE,   11,             
"\"test\".\"t1"},
 
 4181                 {
"test/t1",     TRUE,   10,             
"\"test\".\"t"},
 
 4182                 {
"test/t1",     TRUE,   9,              
"\"test\".\""},
 
 4183                 {
"test/t1",     TRUE,   8,              
"\"test\"."},
 
 4184                 {
"test/t1",     TRUE,   7,              
"\"test\""},
 
 4185                 {
"test/t1",     TRUE,   6,              
"\"test"},
 
 4186                 {
"test/t1",     TRUE,   5,              
"\"tes"},
 
 4187                 {
"test/t1",     TRUE,   4,              
"\"te"},
 
 4188                 {
"test/t1",     TRUE,   3,              
"\"t"},
 
 4189                 {
"test/t1",     TRUE,   2,              
"\""},
 
 4190                 {
"test/t1",     TRUE,   1,              
""},
 
 4191                 {
"test/t1",     TRUE,   0,              
"BUF_NOT_CHANGED"},
 
 4192                 {
"table",       TRUE,   
sizeof(
buf),    
"\"table\""},
 
 4193                 {
"ta'le",       TRUE,   
sizeof(
buf),    
"\"ta'le\""},
 
 4194                 {
"ta\"le",      TRUE,   
sizeof(
buf),    
"\"ta\"\"le\""},
 
 4195                 {
"ta`le",       TRUE,   
sizeof(
buf),    
"\"ta`le\""},
 
 4196                 {
"index",       FALSE,  
sizeof(
buf),    
"\"index\""},
 
 4197                 {
"ind/ex",      FALSE,  
sizeof(
buf),    
"\"ind/ex\""},
 
 4200         for (
size_t i = 0; 
i < UT_ARR_SIZE(test_data); 
i++) {
 
 4202                 memcpy(buf, 
"BUF_NOT_CHANGED", strlen(
"BUF_NOT_CHANGED") + 1);
 
 4207                                      test_data[
i].is_table,
 
 4209                                      test_data[
i].buf_size);
 
 4213                 if (strcmp(buf, test_data[
i].expected) == 0) {
 
 4215                                 "ut_format_name(%s, %s, buf, %lu), " 
 4216                                 "expected %s, OK\n",
 
 4218                                 test_data[
i].is_table ? 
"TRUE" : 
"FALSE",
 
 4219                                 test_data[
i].buf_size,
 
 4220                                 test_data[
i].expected);
 
 4223                                 "ut_format_name(%s, %s, buf, %lu), " 
 4224                                 "expected %s, ERROR: got %s\n",
 
 4226                                 test_data[
i].is_table ? 
"TRUE" : 
"FALSE",
 
 4227                                 test_data[
i].buf_size,
 
 4228                                 test_data[
i].expected,
 
 4245         ulonglong       max_value = 0;
 
 4247         switch (field->key_type()) {
 
 4249         case HA_KEYTYPE_BINARY:
 
 4250                 max_value = 0xFFULL;
 
 4252         case HA_KEYTYPE_INT8:
 
 4253                 max_value = 0x7FULL;
 
 4256         case HA_KEYTYPE_USHORT_INT:
 
 4257                 max_value = 0xFFFFULL;
 
 4259         case HA_KEYTYPE_SHORT_INT:
 
 4260                 max_value = 0x7FFFULL;
 
 4263         case HA_KEYTYPE_UINT24:
 
 4264                 max_value = 0xFFFFFFULL;
 
 4266         case HA_KEYTYPE_INT24:
 
 4267                 max_value = 0x7FFFFFULL;
 
 4270         case HA_KEYTYPE_ULONG_INT:
 
 4271                 max_value = 0xFFFFFFFFULL;
 
 4273         case HA_KEYTYPE_LONG_INT:
 
 4274                 max_value = 0x7FFFFFFFULL;
 
 4277         case HA_KEYTYPE_ULONGLONG:
 
 4278                 max_value = 0xFFFFFFFFFFFFFFFFULL;
 
 4280         case HA_KEYTYPE_LONGLONG:
 
 4281                 max_value = 0x7FFFFFFFFFFFFFFFULL;
 
 4283         case HA_KEYTYPE_FLOAT:
 
 4285                 max_value = 0x1000000ULL;
 
 4287         case HA_KEYTYPE_DOUBLE:
 
 4289                 max_value = 0x20000000000000ULL;
 
 4304 innobase_match_index_columns(
 
 4306         const KEY*              key_info,       
 
 4316         DBUG_ENTER(
"innobase_match_index_columns");
 
 4324         key_part = key_info->key_part;
 
 4326         innodb_idx_fld = index_info->
fields;
 
 4335         for (; key_part != key_end; ++key_part) {
 
 4338                 ulint   mtype = innodb_idx_fld->
col->
mtype;
 
 4346                 while (mtype == DATA_SYS) {
 
 4349                         if (innodb_idx_fld >= innodb_idx_fld_end) {
 
 4354                 if (col_type != mtype) {
 
 4378 innobase_build_index_translation(
 
 4388         ulint           mysql_num_index;
 
 4393         DBUG_ENTER(
"innobase_build_index_translation");
 
 4397         mysql_num_index = table->s->keys;
 
 4406         if (UNIV_UNLIKELY(ib_num_index < mysql_num_index)) {
 
 4421                 index_mapping = (
dict_index_t**) my_realloc(index_mapping,
 
 4423                                                         sizeof(*index_mapping),
 
 4424                                                         MYF(MY_ALLOW_ZERO_PTR));
 
 4426                 if (!index_mapping) {
 
 4429                         sql_print_error(
"InnoDB: fail to allocate memory for " 
 4430                                         "index translation table. Number of " 
 4431                                         "Index:%lu, array size:%lu",
 
 4444         for (ulint count = 0; count < mysql_num_index; count++) {
 
 4449                         ib_table, table->key_info[count].
name);
 
 4451                 if (!index_mapping[count]) {
 
 4452                         sql_print_error(
"Cannot find index %s in InnoDB " 
 4453                                         "index dictionary.",
 
 4454                                         table->key_info[count].
name);
 
 4461                 if (!innobase_match_index_columns(&table->key_info[count],
 
 4462                                                   index_mapping[count])) {
 
 4463                         sql_print_error(
"Found index %s whose column info " 
 4464                                         "does not match that of MySQL.",
 
 4465                                         table->key_info[count].
name);
 
 4477                 my_free(index_mapping);
 
 4481                 index_mapping = NULL;
 
 4502 innobase_index_lookup(
 
 4522 ha_innobase::innobase_initialize_autoinc()
 
 4526         const Field*    field = table->found_next_number_field;
 
 4528         if (field != NULL) {
 
 4537                 fprintf(stderr, 
"  InnoDB: Unable to determine the AUTOINC " 
 4553         } 
else if (field == NULL) {
 
 4556                 my_error(ER_AUTOINC_READ_FAILED, MYF(0));
 
 4559                 const char*     col_name;
 
 4560                 ib_uint64_t     read_auto_inc;
 
 4563                 update_thd(ha_thd());
 
 4565                 ut_a(prebuilt->
trx == thd_to_trx(user_thd));
 
 4567                 col_name = field->field_name;
 
 4568                 index = innobase_get_index(table->s->next_number_index);
 
 4575                         ulonglong       col_max_value;
 
 4583                                 read_auto_inc, 1, 1, 0, col_max_value);
 
 4587                 case DB_RECORD_NOT_FOUND:
 
 4589                         fprintf(stderr, 
"  InnoDB: MySQL and InnoDB data " 
 4590                                 "dictionaries are out of sync.\n" 
 4591                                 "InnoDB: Unable to find the AUTOINC column " 
 4592                                 "%s in the InnoDB table %s.\n" 
 4593                                 "InnoDB: We set the next AUTOINC column " 
 4595                                 "InnoDB: in effect disabling the AUTOINC " 
 4596                                 "next value generation.\n" 
 4597                                 "InnoDB: You can either set the next " 
 4598                                 "AUTOINC value explicitly using ALTER TABLE\n" 
 4599                                 "InnoDB: or fix the data dictionary by " 
 4600                                 "recreating the table.\n",
 
 4631         uint                    test_if_locked) 
 
 4634         char                    norm_name[FN_REFLEN];
 
 4636         char*                   is_part = NULL;
 
 4637         ibool                   par_case_name_set = FALSE;
 
 4638         char                    par_case_name[FN_REFLEN];
 
 4641         DBUG_ENTER(
"ha_innobase::open");
 
 4652                 innobase_release_temporary_latches(ht, thd);
 
 4659         if (!(share=get_share(name))) {
 
 4671         is_part = strstr(norm_name, 
"#p#");
 
 4673         is_part = strstr(norm_name, 
"#P#");
 
 4690                     && (table->s->fields
 
 4693                         "table %s contains %lu user defined columns " 
 4694                         "in InnoDB, but %lu columns in MySQL. Please " 
 4695                         "check INFORMATION_SCHEMA.INNODB_SYS_COLUMNS and " 
 4696                         REFMAN 
"innodb-troubleshooting.html " 
 4697                         "for how to resolve it",
 
 4699                         (ulong) table->s->fields);
 
 4709         if (NULL == ib_table) {
 
 4730                                 if (!par_case_name_set) {
 
 4735                                         strcpy(par_case_name, norm_name);
 
 4742                                         normalize_table_name_low(
 
 4743                                                 par_case_name, name, FALSE);
 
 4745                                         par_case_name_set = TRUE;
 
 4749                                         par_case_name, FALSE, TRUE,
 
 4755                                 sql_print_warning(
"Partition table %s opened " 
 4756                                                   "after converting to lower " 
 4757                                                   "case. The table may have " 
 4758                                                   "been moved from a case " 
 4759                                                   "in-sensitive file system. " 
 4760                                                   "Please recreate table in " 
 4761                                                   "the current file system\n",
 
 4764                                 sql_print_warning(
"Partition table %s opened " 
 4765                                                   "after skipping the step to " 
 4766                                                   "lower case the table name. " 
 4767                                                   "The table may have been " 
 4768                                                   "moved from a case sensitive " 
 4769                                                   "file system. Please " 
 4770                                                   "recreate table in the " 
 4771                                                   "current file system\n",
 
 4779                         sql_print_error(
"Failed to open table %s.\n",
 
 4784                         "Cannot open table %s from the internal data " 
 4785                         "dictionary of InnoDB though the .frm file " 
 4786                         "for the table exists. See " 
 4787                         REFMAN 
"innodb-troubleshooting.html for how " 
 4788                         "you can resolve the problem.", norm_name);
 
 4793                 DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 
 4809                         IB_LOG_LEVEL_WARN, ER_TABLESPACE_DISCARDED,
 
 4810                         table->s->table_name.str);
 
 4817                 no_tablespace = 
false;
 
 4822                         thd, IB_LOG_LEVEL_WARN,
 
 4823                         ER_TABLESPACE_MISSING, norm_name);
 
 4828                 no_tablespace = 
true;
 
 4830                 no_tablespace = 
false;
 
 4833         if (!thd_tablespace_op(thd) && no_tablespace) {
 
 4839                 DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 
 4848         primary_key = table->s->primary_key;
 
 4849         key_used_on_scan = primary_key;
 
 4851         if (!innobase_build_index_translation(table, ib_table, share)) {
 
 4852                   sql_print_error(
"Build InnoDB index translation table for" 
 4853                                   " Table %s failed", name);
 
 4866                 if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) {
 
 4867                         sql_print_error(
"Table %s has a primary key in " 
 4868                                         "InnoDB data dictionary, but not " 
 4875                         push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
 4877                                             "InnoDB: Table %s has a " 
 4878                                             "primary key in InnoDB data " 
 4879                                             "dictionary, but not in " 
 4898                         if (!table->key_info) {
 
 4899                                 ut_ad(!table->s->keys);
 
 4907                         for (ulint 
i = 0; 
i < table->s->keys; 
i++) {
 
 4909                                 index = innobase_get_index(
i);
 
 4926                 if (primary_key != MAX_KEY) {
 
 4928                                 "Table %s has no primary key in InnoDB data " 
 4929                                 "dictionary, but has one in MySQL! If you " 
 4930                                 "created the table with a MySQL version < " 
 4931                                 "3.23.54 and did not define a primary key, " 
 4932                                 "but defined a unique key with all non-NULL " 
 4933                                 "columns, then MySQL internally treats that " 
 4934                                 "key as the primary key. You can fix this " 
 4935                                 "error by dump + DROP + CREATE + reimport " 
 4936                                 "of the table.", name);
 
 4942                         push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
 4944                                             "InnoDB: Table %s has no " 
 4945                                             "primary key in InnoDB data " 
 4946                                             "dictionary, but has one in " 
 4962                 if (key_used_on_scan != MAX_KEY) {
 
 4964                                 "Table %s key_used_on_scan is %lu even " 
 4965                                 "though there is no primary key inside " 
 4966                                 "InnoDB.", name, (ulong) key_used_on_scan);
 
 4971         stats.block_size = UNIV_PAGE_SIZE;
 
 4974         thr_lock_data_init(&share->
lock,&lock,(
void*) 0);
 
 4976         if (prebuilt->
table) {
 
 4981                         (
const char**) &innobase_file_format_max,
 
 4986         if (prebuilt->
table != NULL
 
 4988             && table->found_next_number_field != NULL) {
 
 4997                         innobase_initialize_autoinc();
 
 5003         info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
 
 5017         DBUG_ENTER(
"ha_innobase::clone");
 
 5022                 DBUG_ASSERT(new_handler->prebuilt != NULL);
 
 5028         DBUG_RETURN(new_handler);
 
 5033 ha_innobase::max_supported_key_part_length() const
 
 5038         return(innobase_large_prefix
 
 5040                 : REC_ANTELOPE_MAX_INDEX_COL_LEN - 1);
 
 5053         DBUG_ENTER(
"ha_innobase::close");
 
 5057                 innobase_release_temporary_latches(ht, thd);
 
 5062         if (upd_buf != NULL) {
 
 5063                 ut_ad(upd_buf_size != 0);
 
 5093         return((uint) (field->ptr - table->record[0]));
 
 5107         uint            charset_number, 
 
 5108         const unsigned char* a,         
 
 5109         unsigned int    a_length,       
 
 5111         const unsigned char* b,         
 
 5112         unsigned int    b_length)       
 
 5116         enum_field_types        mysql_tp;
 
 5119         DBUG_ASSERT(a_length != UNIV_SQL_NULL);
 
 5120         DBUG_ASSERT(b_length != UNIV_SQL_NULL);
 
 5122         mysql_tp = (enum_field_types) mysql_type;
 
 5126         case MYSQL_TYPE_BIT:
 
 5127         case MYSQL_TYPE_STRING:
 
 5128         case MYSQL_TYPE_VAR_STRING:
 
 5129         case MYSQL_TYPE_TINY_BLOB:
 
 5130         case MYSQL_TYPE_MEDIUM_BLOB:
 
 5131         case MYSQL_TYPE_BLOB:
 
 5132         case MYSQL_TYPE_LONG_BLOB:
 
 5133         case MYSQL_TYPE_VARCHAR:
 
 5139                 if (charset_number == default_charset_info->number) {
 
 5140                         charset = default_charset_info;
 
 5141                 } 
else if (charset_number == my_charset_latin1.number) {
 
 5142                         charset = &my_charset_latin1;
 
 5144                         charset = get_charset(charset_number, MYF(MY_WME));
 
 5146                         if (charset == NULL) {
 
 5147                           sql_print_error(
"InnoDB needs charset %lu for doing " 
 5148                                           "a comparison, but MySQL cannot " 
 5149                                           "find that charset.",
 
 5150                                           (ulong) charset_number);
 
 5160                 ret = charset->coll->strnncollsp(
 
 5161                         charset, a, a_length, b, b_length, 0);
 
 5165                 } 
else if (ret > 0) {
 
 5185         uint            charset_number) 
 
 5187         enum_field_types        mysql_tp;
 
 5190         mysql_tp = (enum_field_types) mysql_type;
 
 5194         case MYSQL_TYPE_BIT:
 
 5195         case MYSQL_TYPE_STRING:
 
 5196         case MYSQL_TYPE_VAR_STRING:
 
 5197         case MYSQL_TYPE_TINY_BLOB:
 
 5198         case MYSQL_TYPE_MEDIUM_BLOB:
 
 5199         case MYSQL_TYPE_BLOB:
 
 5200         case MYSQL_TYPE_LONG_BLOB:
 
 5201         case MYSQL_TYPE_VARCHAR:
 
 5207                 if (charset_number == default_charset_info->number) {
 
 5208                         charset = default_charset_info;
 
 5209                 } 
else if (charset_number == my_charset_latin1.number) {
 
 5210                         charset = &my_charset_latin1;
 
 5212                         charset = get_charset(charset_number, MYF(MY_WME));
 
 5214                         if (charset == NULL) {
 
 5215                           sql_print_error(
"InnoDB needs charset %lu for doing " 
 5216                                           "a comparison, but MySQL cannot " 
 5217                                           "find that charset.",
 
 5218                                           (ulong) charset_number);
 
 5241         uint            charset_number, 
 
 5242         const unsigned char* a,         
 
 5243         unsigned int    a_length,       
 
 5245         const unsigned char* b,         
 
 5246         unsigned int    b_length)       
 
 5254         result = ha_compare_text(charset, (uchar*) a, a_length,
 
 5255                                  (uchar*) b, b_length, 1, 0);
 
 5273         return(ha_compare_text(charset, s1->
f_str, s1->
f_len,
 
 5291         my_casedn_str(charset, (
char*) s2->
f_str);
 
 5293         newlen = strlen((
const char*) s2->
f_str);
 
 5295         return(ha_compare_text(charset, s1->
f_str, s1->
f_len,
 
 5296                                s2->
f_str, newlen, 0, 0));
 
 5312         if (!str || len == 0) {
 
 5316         my_strnxfrm(cs, (uchar*) mystr, 2, str, len);
 
 5321                 value = value / 256;
 
 5342         result = ha_compare_text(charset, s2->
f_str, s2->
f_len,
 
 5360         uchar*                  s1 = (uchar*) p1;
 
 5361         uchar*                  s2 = *(uchar**) p2;
 
 5363         return(ha_compare_text(charset, s1, strlen((
const char*) s1),
 
 5364                                s2, strlen((
const char*) s2), 0, 0));
 
 5378         if (cs->casedn_multiply == 1) {
 
 5379                 memcpy(dst, src, src_len);
 
 5381                 my_casedn_str(cs, dst);
 
 5383                 return(strlen(dst));
 
 5385                 return(cs->cset->casedn(cs, src, src_len, dst, dst_len));
 
 5389 #define true_word_char(c, ch) ((c) & (_MY_U | _MY_L | _MY_NMR) || (ch) == '_') 
 5391 #define misc_word_char(X)       0 
 5411         const uchar*    doc = start;
 
 5420                         return(doc - start);
 
 5425                 mbl = cs->cset->ctype(
 
 5426                         cs, &ctype, doc, (
const uchar*) end);
 
 5428                 if (true_word_char(ctype, *doc)) {
 
 5432                 doc += mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1);
 
 5438         token->
f_str = 
const_cast<byte*
>(doc);
 
 5444                 mbl = cs->cset->ctype(
 
 5445                         cs, &ctype, (uchar*) doc, (uchar*) end);
 
 5446                 if (true_word_char(ctype, *doc)) {
 
 5448                 } 
else if (!misc_word_char(*doc) || mwc) {
 
 5456                 doc += mbl > 0 ? mbl : (mbl < 0 ? -mbl : 1);
 
 5459         token->
f_len = (uint) (doc - token->
f_str) - mwc;
 
 5462         return(doc - start);
 
 5474         ulint*          unsigned_flag,  
 
 5481         const class Field* field = 
reinterpret_cast<const class Field*
>(f);
 
 5487         DBUG_ASSERT((ulint)MYSQL_TYPE_STRING < 256);
 
 5488         DBUG_ASSERT((ulint)MYSQL_TYPE_VAR_STRING < 256);
 
 5489         DBUG_ASSERT((ulint)MYSQL_TYPE_DOUBLE < 256);
 
 5490         DBUG_ASSERT((ulint)MYSQL_TYPE_FLOAT < 256);
 
 5491         DBUG_ASSERT((ulint)MYSQL_TYPE_DECIMAL < 256);
 
 5493         if (field->flags & UNSIGNED_FLAG) {
 
 5495                 *unsigned_flag = DATA_UNSIGNED;
 
 5500         if (field->real_type() == MYSQL_TYPE_ENUM
 
 5501                 || field->real_type() == MYSQL_TYPE_SET) {
 
 5507                 *unsigned_flag = DATA_UNSIGNED; 
 
 5514         switch (field->type()) {
 
 5517         case MYSQL_TYPE_VAR_STRING:     
 
 5518         case MYSQL_TYPE_VARCHAR:        
 
 5519                 if (field->binary()) {
 
 5520                         return(DATA_BINARY);
 
 5521                 } 
else if (strcmp(field->charset()->name,
 
 5522                                   "latin1_swedish_ci") == 0) {
 
 5523                         return(DATA_VARCHAR);
 
 5525                         return(DATA_VARMYSQL);
 
 5527         case MYSQL_TYPE_BIT:
 
 5528         case MYSQL_TYPE_STRING: 
if (field->binary()) {
 
 5530                         return(DATA_FIXBINARY);
 
 5531                 } 
else if (strcmp(field->charset()->name,
 
 5532                                   "latin1_swedish_ci") == 0) {
 
 5537         case MYSQL_TYPE_NEWDECIMAL:
 
 5538                 return(DATA_FIXBINARY);
 
 5539         case MYSQL_TYPE_LONG:
 
 5540         case MYSQL_TYPE_LONGLONG:
 
 5541         case MYSQL_TYPE_TINY:
 
 5542         case MYSQL_TYPE_SHORT:
 
 5543         case MYSQL_TYPE_INT24:
 
 5544         case MYSQL_TYPE_DATE:
 
 5545         case MYSQL_TYPE_YEAR:
 
 5546         case MYSQL_TYPE_NEWDATE:
 
 5548         case MYSQL_TYPE_TIME:
 
 5549         case MYSQL_TYPE_DATETIME:
 
 5550         case MYSQL_TYPE_TIMESTAMP:
 
 5551                 switch (field->real_type()) {
 
 5552                 case MYSQL_TYPE_TIME:
 
 5553                 case MYSQL_TYPE_DATETIME:
 
 5554                 case MYSQL_TYPE_TIMESTAMP:
 
 5557                         DBUG_ASSERT((ulint)MYSQL_TYPE_DECIMAL < 256);
 
 5558                 case MYSQL_TYPE_TIME2:
 
 5559                 case MYSQL_TYPE_DATETIME2:
 
 5560                 case MYSQL_TYPE_TIMESTAMP2:
 
 5561                         return(DATA_FIXBINARY);
 
 5563         case MYSQL_TYPE_FLOAT:
 
 5565         case MYSQL_TYPE_DOUBLE:
 
 5566                 return(DATA_DOUBLE);
 
 5567         case MYSQL_TYPE_DECIMAL:
 
 5568                 return(DATA_DECIMAL);
 
 5569         case MYSQL_TYPE_GEOMETRY:
 
 5570         case MYSQL_TYPE_TINY_BLOB:
 
 5571         case MYSQL_TYPE_MEDIUM_BLOB:
 
 5572         case MYSQL_TYPE_BLOB:
 
 5573         case MYSQL_TYPE_LONG_BLOB:
 
 5575         case MYSQL_TYPE_NULL:
 
 5592 innobase_write_to_2_little_endian(
 
 5597         ut_a(val < 256 * 256);
 
 5599         buf[0] = (byte)(val & 0xFF);
 
 5600         buf[1] = (byte)(val / 256);
 
 5609 innobase_read_from_2_little_endian(
 
 5613         return((uint) ((ulint)(buf[0]) + 256 * ((ulint)(buf[1]))));
 
 5621 ha_innobase::store_key_val_for_row(
 
 5629         KEY*            key_info        = table->key_info + keynr;
 
 5633         char*           buff_start      = buff;
 
 5634         enum_field_types mysql_type;
 
 5638         DBUG_ENTER(
"store_key_val_for_row");
 
 5665         memset(buff, 0, buff_len);
 
 5667         for (; key_part != end; key_part++) {
 
 5670                 if (key_part->null_bit) {
 
 5671                         if (record[key_part->null_offset]
 
 5672                                                 & key_part->null_bit) {
 
 5681                 field = key_part->field;
 
 5682                 mysql_type = field->type();
 
 5684                 if (mysql_type == MYSQL_TYPE_VARCHAR) {
 
 5694                         key_len = key_part->length;
 
 5697                                 buff += key_len + 2;
 
 5701                         cs = field->charset();
 
 5708                                 + (ulint) get_field_offset(table, field)),
 
 5716                         if (len > 0 && cs->mbmaxlen > 1) {
 
 5717                                 true_len = (ulint) cs->cset->well_formed_len(cs,
 
 5719                                                 (
const char*) data + len,
 
 5720                                                 (uint) (key_len / cs->mbmaxlen),
 
 5727                         if (true_len > key_len) {
 
 5737                         memcpy(buff, data, true_len);
 
 5747                 } 
else if (mysql_type == MYSQL_TYPE_TINY_BLOB
 
 5748                         || mysql_type == MYSQL_TYPE_MEDIUM_BLOB
 
 5749                         || mysql_type == MYSQL_TYPE_BLOB
 
 5750                         || mysql_type == MYSQL_TYPE_LONG_BLOB
 
 5753                         || mysql_type == MYSQL_TYPE_GEOMETRY) {
 
 5760                         const byte*     blob_data;
 
 5762                         ut_a(key_part->key_part_flag & HA_PART_KEY_SEG);
 
 5764                         key_len = key_part->length;
 
 5767                                 buff += key_len + 2;
 
 5772                         cs = field->charset();
 
 5776                                 + (ulint) get_field_offset(table, field)),
 
 5777                                         (ulint) field->pack_length());
 
 5779                         true_len = blob_len;
 
 5781                         ut_a(get_field_offset(table, field)
 
 5782                                 == key_part->offset);
 
 5787                         if (blob_len > 0 && cs->mbmaxlen > 1) {
 
 5788                                 true_len = (ulint) cs->cset->well_formed_len(cs,
 
 5789                                                 (
const char*) blob_data,
 
 5790                                                 (
const char*) blob_data
 
 5792                                                 (uint) (key_len / cs->mbmaxlen),
 
 5800                         if (true_len > key_len) {
 
 5807                         innobase_write_to_2_little_endian(
 
 5808                                         (byte*) buff, true_len);
 
 5811                         memcpy(buff, blob_data, true_len);
 
 5826                         const uchar*            src_start;
 
 5828                         enum_field_types        real_type;
 
 5830                         key_len = key_part->length;
 
 5838                         src_start = record + key_part->offset;
 
 5839                         real_type = field->real_type();
 
 5847                         if (real_type != MYSQL_TYPE_ENUM
 
 5848                                 && real_type != MYSQL_TYPE_SET
 
 5849                                 && ( mysql_type == MYSQL_TYPE_VAR_STRING
 
 5850                                         || mysql_type == MYSQL_TYPE_STRING)) {
 
 5852                                 cs = field->charset();
 
 5857                                 if (key_len > 0 && cs->mbmaxlen > 1) {
 
 5860                                                 cs->cset->well_formed_len(cs,
 
 5861                                                         (
const char*) src_start,
 
 5862                                                         (
const char*) src_start
 
 5870                         memcpy(buff, src_start, true_len);
 
 5875                         if (true_len < key_len) {
 
 5876                                 ulint   pad_len = key_len - true_len;
 
 5878                                 ut_a(!(pad_len % cs->mbminlen));
 
 5880                                 cs->cset->fill(cs, buff, pad_len,
 
 5887         ut_a(buff <= buff_start + buff_len);
 
 5889         DBUG_RETURN((uint)(buff - buff_start));
 
 5897 build_template_needs_field(
 
 5899         ibool           index_contains, 
 
 5902         ibool           read_just_key,  
 
 5908         ibool           fetch_all_in_key,
 
 5911         ibool           fetch_primary_key_cols,
 
 5918         const Field*    field   = table->field[
i];
 
 5922         if (!index_contains) {
 
 5923                 if (read_just_key) {
 
 5929         } 
else if (fetch_all_in_key) {
 
 5935         if (bitmap_is_set(table->read_set, i)
 
 5936             || bitmap_is_set(table->write_set, i)) {
 
 5942         if (fetch_primary_key_cols
 
 5969         return(index == prebuilt->
index 
 5979 build_template_field(
 
 5991         ut_ad(field == table->field[i]);
 
 5994         col = dict_table_get_nth_col(index->
table, i);
 
 5997         UNIV_MEM_INVALID(templ, 
sizeof *templ);
 
 6008         if (field->real_maybe_null()) {
 
 6010                         field->null_offset();
 
 6023         if (templ->
mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
 
 6044         if (templ->
type == DATA_BLOB) {
 
 6056 ha_innobase::build_template(
 
 6064         ibool           fetch_all_in_key        = FALSE;
 
 6065         ibool           fetch_primary_key_cols  = FALSE;
 
 6074         } 
else if (!whole_row) {
 
 6076                         == ROW_RETRIEVE_ALL_COLS) {
 
 6089                                 fetch_all_in_key = TRUE;
 
 6094                         == ROW_RETRIEVE_PRIMARY_KEY) {
 
 6102                         fetch_primary_key_cols = TRUE;
 
 6106         clust_index = dict_table_get_first_index(prebuilt->
table);
 
 6108         index = whole_row ? clust_index : prebuilt->
index;
 
 6119         n_fields = (ulint) table->s->fields; 
 
 6127                 ? ROW_MYSQL_WHOLE_ROW : ROW_MYSQL_REC_FIELDS;
 
 6139         if (active_index != MAX_KEY && active_index == pushed_idx_cond_keyno) {
 
 6141                 for (i = 0; i < n_fields; i++) {
 
 6142                         const ibool             index_contains
 
 6160                                     index, prebuilt, index_contains, i)) {
 
 6166                                         field = table->field[
i];
 
 6168                                         field = build_template_needs_field(
 
 6172                                                 fetch_primary_key_cols,
 
 6179                                 templ = build_template_field(
 
 6180                                         prebuilt, clust_index, index,
 
 6186                                 if (index == prebuilt->
index) {
 
 6192                                                         prebuilt->
index, i);
 
 6197                                               != ULINT_UNDEFINED);
 
 6212                                            != ULINT_UNDEFINED) {
 
 6222                                                 prebuilt->
index, i, TRUE);
 
 6224                                       != ULINT_UNDEFINED);
 
 6254                 for (i = 0; i < n_fields; i++) {
 
 6255                         const ibool             index_contains
 
 6259                                     index, prebuilt, index_contains, i)) {
 
 6264                                         field = table->field[
i];
 
 6266                                         field = build_template_needs_field(
 
 6270                                                 fetch_primary_key_cols,
 
 6277                                 build_template_field(prebuilt,
 
 6288                 for (i = 0; i < n_fields; i++) {
 
 6292                                 field = table->field[
i];
 
 6294                                 field = build_template_needs_field(
 
 6299                                         fetch_primary_key_cols,
 
 6306                         build_template_field(prebuilt, clust_index, index,
 
 6333 ha_innobase::innobase_lock_autoinc(
void)
 
 6340         switch (innobase_autoinc_lock_mode) {
 
 6341         case AUTOINC_NO_LOCKING:
 
 6346         case AUTOINC_NEW_STYLE_LOCKING:
 
 6351                 if (thd_sql_command(user_thd) == SQLCOM_INSERT
 
 6352                     || thd_sql_command(user_thd) == SQLCOM_REPLACE) {
 
 6369         case AUTOINC_OLD_STYLE_LOCKING:
 
 6372                 if (error == DB_SUCCESS) {
 
 6391 ha_innobase::innobase_reset_autoinc(
 
 6397         error = innobase_lock_autoinc();
 
 6399         if (error == DB_SUCCESS) {
 
 6415 ha_innobase::innobase_set_max_autoinc(
 
 6421         error = innobase_lock_autoinc();
 
 6423         if (error == DB_SUCCESS) {
 
 6444         int             error_result= 0;
 
 6445         ibool           auto_inc_used= FALSE;
 
 6447         trx_t*          trx = thd_to_trx(user_thd);
 
 6449         DBUG_ENTER(
"ha_innobase::write_row");
 
 6452                 ib_senderrf(ha_thd(), IB_LOG_LEVEL_WARN, ER_READ_ONLY_MODE);
 
 6453                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
 6454         } 
else if (prebuilt->
trx != trx) {
 
 6455                 sql_print_error(
"The transaction object for the table handle " 
 6456                                 "is at %p, but for the current thread it is at " 
 6458                                 (
const void*) prebuilt->
trx, (
const void*) trx);
 
 6460                 fputs(
"InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
 
 6461                 ut_print_buf(stderr, ((
const byte*) prebuilt) - 100, 200);
 
 6463                         "InnoDB: Dump of 200 bytes around ha_data: ",
 
 6468         } 
else if (!trx_is_started(trx)) {
 
 6472         ha_statistic_increment(&SSV::ha_write_count);
 
 6474         sql_command = thd_sql_command(user_thd);
 
 6476         if ((sql_command == SQLCOM_ALTER_TABLE
 
 6477              || sql_command == SQLCOM_OPTIMIZE
 
 6478              || sql_command == SQLCOM_CREATE_INDEX
 
 6479              || sql_command == SQLCOM_DROP_INDEX)
 
 6480             && num_write_row >= 10000) {
 
 6491                 enum lock_mode  
mode;
 
 6501                                 prebuilt->
trx, prebuilt->
table, &mode);
 
 6513                 } 
else if (src_table == prebuilt->
table) {
 
 6518                         innobase_commit(ht, user_thd, 1);
 
 6520                         trx_register_for_2pc(prebuilt->
trx);
 
 6534                         innobase_commit(ht, user_thd, 1);
 
 6536                         trx_register_for_2pc(prebuilt->
trx);
 
 6547         if (table->next_number_field && record == table->record[0]) {
 
 6553                 if ((error_result = update_auto_increment())) {
 
 6559                                 error_result = ER_AUTOINC_READ_FAILED;
 
 6561                                 my_error(ER_AUTOINC_READ_FAILED, MYF(0));
 
 6572                 auto_inc_used = TRUE;
 
 6581                 build_template(
true);
 
 6584         innobase_srv_conc_enter_innodb(prebuilt->
trx);
 
 6587         DEBUG_SYNC(user_thd, 
"ib_after_row_insert");
 
 6590         if (auto_inc_used) {
 
 6592                 ulonglong       col_max_value;
 
 6605                         table->next_number_field);
 
 6608                 auto_inc = table->next_number_field->val_int();
 
 6611                 case DB_DUPLICATE_KEY:
 
 6618                         switch (sql_command) {
 
 6622                                         goto set_max_autoinc;
 
 6626                         case SQLCOM_REPLACE:
 
 6627                         case SQLCOM_INSERT_SELECT:
 
 6628                         case SQLCOM_REPLACE_SELECT:
 
 6629                                 goto set_max_autoinc;
 
 6647                                 if (auto_inc <= col_max_value) {
 
 6651                                         ulonglong       increment;
 
 6659                                                 1, increment, offset,
 
 6662                                         err = innobase_set_max_autoinc(
 
 6665                                         if (err != DB_SUCCESS) {
 
 6676         innobase_srv_conc_exit_innodb(prebuilt->
trx);
 
 6682                         ER_TABLESPACE_DISCARDED,
 
 6683                         table->s->table_name.str);
 
 6686         error_result = convert_error_code_to_mysql(error,
 
 6690         if (error_result == HA_FTS_INVALID_DOCID) {
 
 6691                 my_error(HA_FTS_INVALID_DOCID, MYF(0));
 
 6695         innobase_active_small();
 
 6697         DBUG_RETURN(error_result);
 
 6706 calc_row_difference(
 
 6718         uchar*          original_upd_buff = upd_buff;
 
 6720         enum_field_types field_mysql_type;
 
 6725         const byte*     new_mysql_row_col;
 
 6731         ulint           n_changed = 0;
 
 6735         ibool           changes_fts_column = FALSE;
 
 6736         ibool           changes_fts_doc_col = FALSE;
 
 6737         trx_t*          trx = thd_to_trx(thd);
 
 6742         n_fields = table->s->fields;
 
 6743         clust_index = dict_table_get_first_index(prebuilt->
table);
 
 6746         buf = (byte*) upd_buff;
 
 6748         for (i = 0; i < n_fields; i++) {
 
 6749                 field = table->field[
i];
 
 6751                 o_ptr = (
const byte*) old_row + get_field_offset(table, field);
 
 6752                 n_ptr = (
const byte*) new_row + get_field_offset(table, field);
 
 6756                 new_mysql_row_col = n_ptr;
 
 6757                 col_pack_len = field->pack_length();
 
 6759                 o_len = col_pack_len;
 
 6760                 n_len = col_pack_len;
 
 6765                 field_mysql_type = field->type();
 
 6780                         if (field_mysql_type == MYSQL_TYPE_VARCHAR) {
 
 6801                 if (field_mysql_type == MYSQL_TYPE_LONGLONG
 
 6802                     && prebuilt->
table->fts
 
 6808                                 return(DB_FTS_INVALID_DOCID);
 
 6813                 if (field->real_maybe_null()) {
 
 6814                         if (field->is_null_in_record(old_row)) {
 
 6815                                 o_len = UNIV_SQL_NULL;
 
 6818                         if (field->is_null_in_record(new_row)) {
 
 6819                                 n_len = UNIV_SQL_NULL;
 
 6823                 if (o_len != n_len || (o_len != UNIV_SQL_NULL &&
 
 6824                                         0 != memcmp(o_ptr, n_ptr, o_len))) {
 
 6827                         ufield = uvect->
fields + n_changed;
 
 6828                         UNIV_MEM_INVALID(ufield, 
sizeof *ufield);
 
 6833                         if (n_len != UNIV_SQL_NULL) {
 
 6835                                                    dfield_get_type(&dfield));
 
 6852                                 &prebuilt->
table->
cols[i], clust_index);
 
 6864                         if (prebuilt->
table->fts != NULL) {
 
 6868                                 innodb_table = prebuilt->
table;
 
 6870                                 if (!changes_fts_column) {
 
 6872                                                 innodb_table, ufield);
 
 6874                                         if (offset != ULINT_UNDEFINED) {
 
 6875                                                 changes_fts_column = TRUE;
 
 6879                                 if (!changes_fts_doc_col) {
 
 6880                                         changes_fts_doc_col =
 
 6882                                                 innodb_table, ufield);
 
 6892         if (!prebuilt->
table->fts) {
 
 6893                         trx->fts_next_doc_id = 0;
 
 6894         } 
else if (changes_fts_column || changes_fts_doc_col) {
 
 6897                 ufield = uvect->
fields + n_changed;
 
 6899                 if (!DICT_TF2_FLAG_IS_SET(
 
 6906                         if (changes_fts_column && !changes_fts_doc_col) {
 
 6908                                 fprintf(stderr, 
" InnoDB: A new Doc ID" 
 6909                                         " must be supplied while updating" 
 6910                                         " FTS indexed columns.\n");
 
 6911                                 return(DB_FTS_INVALID_DOCID);
 
 6916                         if (doc_id < prebuilt->table->fts->cache->next_doc_id) {
 
 6918                                         "InnoDB: FTS Doc ID must be larger than" 
 6919                                         " "IB_ID_FMT
" for table",
 
 6923                                               TRUE, innodb_table->
name);
 
 6926                                 return(DB_FTS_INVALID_DOCID);
 
 6929                                    >= FTS_DOC_ID_MAX_STEP) {
 
 6931                                         "InnoDB: Doc ID "UINT64PF
" is too" 
 6932                                         " big. Its difference with largest" 
 6933                                         " Doc ID used "UINT64PF
" cannot" 
 6934                                         " exceed or equal to %d\n",
 
 6937                                         FTS_DOC_ID_MAX_STEP);
 
 6941                         trx->fts_next_doc_id = doc_id;
 
 6945                         ut_ad(!changes_fts_doc_col);
 
 6949                         trx->fts_next_doc_id = 0;
 
 6953                         innodb_table, ufield, &trx->fts_next_doc_id);
 
 6961                 trx->fts_next_doc_id = UINT64_UNDEFINED;
 
 6967         ut_a(buf <= (byte*) original_upd_buff + buff_len);
 
 6984         const uchar*    old_row,        
 
 6989         trx_t*          trx = thd_to_trx(user_thd);
 
 6991         DBUG_ENTER(
"ha_innobase::update_row");
 
 6996                 ib_senderrf(ha_thd(), IB_LOG_LEVEL_WARN, ER_READ_ONLY_MODE);
 
 6997                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
 6998         } 
else if (!trx_is_started(trx)) {
 
 7002         if (upd_buf == NULL) {
 
 7003                 ut_ad(upd_buf_size == 0);
 
 7010                 upd_buf_size = table->s->reclength + table->s->max_key_length
 
 7011                         + MAX_REF_PARTS * 3;
 
 7012                 upd_buf = (uchar*) my_malloc(upd_buf_size, MYF(MY_WME));
 
 7013                 if (upd_buf == NULL) {
 
 7015                         DBUG_RETURN(HA_ERR_OUT_OF_MEM);
 
 7019         ha_statistic_increment(&SSV::ha_update_count);
 
 7030         error = calc_row_difference(uvect, (uchar*) old_row, new_row, table,
 
 7031                                     upd_buf, upd_buf_size, prebuilt, user_thd);
 
 7033         if (error != DB_SUCCESS) {
 
 7038         prebuilt->
upd_node->is_delete = FALSE;
 
 7042         innobase_srv_conc_enter_innodb(trx);
 
 7054         if (error == DB_SUCCESS
 
 7055             && table->next_number_field
 
 7056             && new_row == table->record[0]
 
 7057             && thd_sql_command(user_thd) == SQLCOM_INSERT
 
 7061                 ulonglong       col_max_value;
 
 7063                 auto_inc = table->next_number_field->val_int();
 
 7068                         table->next_number_field);
 
 7070                 if (auto_inc <= col_max_value && auto_inc != 0) {
 
 7073                         ulonglong       increment;
 
 7079                                 auto_inc, 1, increment, offset, col_max_value);
 
 7081                         error = innobase_set_max_autoinc(auto_inc);
 
 7085         innobase_srv_conc_exit_innodb(trx);
 
 7088         int err = convert_error_code_to_mysql(error,
 
 7092         if (err == 0 && uvect->
n_fields == 0) {
 
 7098                 err = HA_ERR_RECORD_IS_THE_SAME;
 
 7099         } 
else if (err == HA_FTS_INVALID_DOCID) {
 
 7100                 my_error(HA_FTS_INVALID_DOCID, MYF(0));
 
 7106         innobase_active_small();
 
 7118         const uchar*    record) 
 
 7121         trx_t*          trx = thd_to_trx(user_thd);
 
 7123         DBUG_ENTER(
"ha_innobase::delete_row");
 
 7128                 ib_senderrf(ha_thd(), IB_LOG_LEVEL_WARN, ER_READ_ONLY_MODE);
 
 7129                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
 7130         } 
else if (!trx_is_started(trx)) {
 
 7134         ha_statistic_increment(&SSV::ha_delete_count);
 
 7142         prebuilt->
upd_node->is_delete = TRUE;
 
 7144         innobase_srv_conc_enter_innodb(trx);
 
 7148         innobase_srv_conc_exit_innodb(trx);
 
 7153         innobase_active_small();
 
 7155         DBUG_RETURN(convert_error_code_to_mysql(
 
 7168         DBUG_ENTER(
"ha_innobase::unlock_row");
 
 7184         case ROW_READ_WITH_LOCKS:
 
 7187                     > TRX_ISO_READ_COMMITTED) {
 
 7191         case ROW_READ_TRY_SEMI_CONSISTENT:
 
 7194         case ROW_READ_DID_SEMI_CONSISTENT:
 
 7208         return(prebuilt->
row_read_type == ROW_READ_DID_SEMI_CONSISTENT);
 
 7217         ut_a(prebuilt->
trx == thd_to_trx(ha_thd()));
 
 7243         DBUG_ENTER(
"index_init");
 
 7245         DBUG_RETURN(change_active_index(keynr));
 
 7257         DBUG_ENTER(
"index_end");
 
 7258         active_index = MAX_KEY;
 
 7259         in_range_check_pushed_down = FALSE;
 
 7260         ds_mrr.dsmrr_close();
 
 7269 convert_search_mode_to_innobase(
 
 7271         enum ha_rkey_function   find_flag)
 
 7273         switch (find_flag) {
 
 7274         case HA_READ_KEY_EXACT:
 
 7276                 return(PAGE_CUR_GE);
 
 7277         case HA_READ_KEY_OR_NEXT:
 
 7278                 return(PAGE_CUR_GE);
 
 7279         case HA_READ_KEY_OR_PREV:
 
 7280                 return(PAGE_CUR_LE);
 
 7281         case HA_READ_AFTER_KEY:
 
 7283         case HA_READ_BEFORE_KEY:
 
 7285         case HA_READ_PREFIX:
 
 7286                 return(PAGE_CUR_GE);
 
 7287         case HA_READ_PREFIX_LAST:
 
 7288                 return(PAGE_CUR_LE);
 
 7289         case HA_READ_PREFIX_LAST_OR_PREV:
 
 7290                 return(PAGE_CUR_LE);
 
 7304         case HA_READ_MBR_CONTAIN:
 
 7305         case HA_READ_MBR_INTERSECT:
 
 7306         case HA_READ_MBR_WITHIN:
 
 7307         case HA_READ_MBR_DISJOINT:
 
 7308         case HA_READ_MBR_EQUAL:
 
 7309                 return(PAGE_CUR_UNSUPP);
 
 7315         my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), 
"this functionality");
 
 7317         return(PAGE_CUR_UNSUPP);
 
 7379         const uchar*    key_ptr,        
 
 7389         enum ha_rkey_function find_flag)
 
 7393         ulint           match_mode      = 0;
 
 7397         DBUG_ENTER(
"index_read");
 
 7398         DEBUG_SYNC_C(
"ha_innobase_index_read_begin");
 
 7400         ut_a(prebuilt->
trx == thd_to_trx(user_thd));
 
 7401         ut_ad(key_len != 0 || find_flag != HA_READ_KEY_EXACT);
 
 7403         ha_statistic_increment(&SSV::ha_read_key_count);
 
 7405         index = prebuilt->
index;
 
 7409                 DBUG_RETURN(HA_ERR_CRASHED);
 
 7413                             ? HA_ERR_INDEX_CORRUPT
 
 7414                             : HA_ERR_TABLE_DEF_CHANGED);
 
 7417         if (index->
type & DICT_FTS) {
 
 7418                 DBUG_RETURN(HA_ERR_KEY_NOT_FOUND);
 
 7425                 build_template(
false);
 
 7434                         srch_key_val1, 
sizeof(srch_key_val1),
 
 7447         mode = convert_search_mode_to_innobase(find_flag);
 
 7451         if (find_flag == HA_READ_KEY_EXACT) {
 
 7455         } 
else if (find_flag == HA_READ_PREFIX
 
 7456                    || find_flag == HA_READ_PREFIX_LAST) {
 
 7461         last_match_mode = (uint) match_mode;
 
 7463         if (mode != PAGE_CUR_UNSUPP) {
 
 7465                 innobase_srv_conc_enter_innodb(prebuilt->
trx);
 
 7470                 innobase_srv_conc_exit_innodb(prebuilt->
trx);
 
 7482         case DB_RECORD_NOT_FOUND:
 
 7483                 error = HA_ERR_KEY_NOT_FOUND;
 
 7484                 table->status = STATUS_NOT_FOUND;
 
 7486         case DB_END_OF_INDEX:
 
 7487                 error = HA_ERR_KEY_NOT_FOUND;
 
 7488                 table->status = STATUS_NOT_FOUND;
 
 7494                         ER_TABLESPACE_DISCARDED,
 
 7495                         table->s->table_name.str);
 
 7497                 table->status = STATUS_NOT_FOUND;
 
 7498                 error = HA_ERR_NO_SUCH_TABLE;
 
 7500         case DB_TABLESPACE_NOT_FOUND:
 
 7504                         ER_TABLESPACE_MISSING, MYF(0),
 
 7505                         table->s->table_name.str);
 
 7507                 table->status = STATUS_NOT_FOUND;
 
 7508                 error = HA_ERR_NO_SUCH_TABLE;
 
 7511                 error = convert_error_code_to_mysql(
 
 7514                 table->status = STATUS_NOT_FOUND;
 
 7530         const uchar*    key_ptr,
 
 7535         return(
index_read(buf, key_ptr, key_len, HA_READ_PREFIX_LAST));
 
 7543 ha_innobase::innobase_get_index(
 
 7552         DBUG_ENTER(
"innobase_get_index");
 
 7554         if (keynr != MAX_KEY && table->s->keys > 0) {
 
 7555                 key = table->key_info + keynr;
 
 7557                 index = innobase_index_lookup(share, keynr);
 
 7566                                 sql_print_warning(
"InnoDB could not find " 
 7567                                                   "index %s key no %u for " 
 7568                                                   "table %s through its " 
 7569                                                   "index translation table",
 
 7570                                                   key ? key->
name : 
"NULL",
 
 7579                 index = dict_table_get_first_index(prebuilt->
table);
 
 7584                         "Innodb could not find key n:o %u with name %s " 
 7585                         "from dict cache for table %s",
 
 7586                         keynr, key ? key->
name : 
"NULL",
 
 7598 ha_innobase::change_active_index(
 
 7604         DBUG_ENTER(
"change_active_index");
 
 7606         ut_ad(user_thd == ha_thd());
 
 7607         ut_a(prebuilt->
trx == thd_to_trx(user_thd));
 
 7609         active_index = keynr;
 
 7611         prebuilt->
index = innobase_get_index(keynr);
 
 7613         if (UNIV_UNLIKELY(!prebuilt->
index)) {
 
 7614                 sql_print_warning(
"InnoDB: change_active_index(%u) failed",
 
 7625                         char index_name[MAX_FULL_NAME_LEN + 1];
 
 7629                                 index_name, 
sizeof index_name,
 
 7633                                 table_name, 
sizeof table_name,
 
 7636                         push_warning_printf(
 
 7637                                 user_thd, Sql_condition::WARN_LEVEL_WARN,
 
 7638                                 HA_ERR_INDEX_CORRUPT,
 
 7639                                 "InnoDB: Index %s for table %s is" 
 7640                                 " marked as corrupted",
 
 7641                                 index_name, table_name);
 
 7642                         DBUG_RETURN(HA_ERR_INDEX_CORRUPT);
 
 7644                         push_warning_printf(
 
 7645                                 user_thd, Sql_condition::WARN_LEVEL_WARN,
 
 7646                                 HA_ERR_TABLE_DEF_CHANGED,
 
 7647                                 "InnoDB: insufficient history for index %u",
 
 7653                 DBUG_RETURN(HA_ERR_TABLE_DEF_CHANGED);
 
 7669         build_template(
false);
 
 7690         enum ha_rkey_function find_flag)
 
 7692         if (change_active_index(keynr)) {
 
 7697         return(
index_read(buf, key, key_len, find_flag));
 
 7706 ha_innobase::general_fetch(
 
 7717         DBUG_ENTER(
"general_fetch");
 
 7719         ut_a(prebuilt->
trx == thd_to_trx(user_thd));
 
 7721         innobase_srv_conc_enter_innodb(prebuilt->
trx);
 
 7724                 (byte*) buf, 0, prebuilt, match_mode, direction);
 
 7726         innobase_srv_conc_exit_innodb(prebuilt->
trx);
 
 7734         case DB_RECORD_NOT_FOUND:
 
 7735                 error = HA_ERR_END_OF_FILE;
 
 7736                 table->status = STATUS_NOT_FOUND;
 
 7738         case DB_END_OF_INDEX:
 
 7739                 error = HA_ERR_END_OF_FILE;
 
 7740                 table->status = STATUS_NOT_FOUND;
 
 7746                         ER_TABLESPACE_DISCARDED,
 
 7747                         table->s->table_name.str);
 
 7749                 table->status = STATUS_NOT_FOUND;
 
 7750                 error = HA_ERR_NO_SUCH_TABLE;
 
 7752         case DB_TABLESPACE_NOT_FOUND:
 
 7756                         ER_TABLESPACE_MISSING,
 
 7757                         table->s->table_name.str);
 
 7759                 table->status = STATUS_NOT_FOUND;
 
 7760                 error = HA_ERR_NO_SUCH_TABLE;
 
 7763                 error = convert_error_code_to_mysql(
 
 7766                 table->status = STATUS_NOT_FOUND;
 
 7784         ha_statistic_increment(&SSV::ha_read_next_count);
 
 7800         ha_statistic_increment(&SSV::ha_read_next_count);
 
 7802         return(general_fetch(buf, 
ROW_SEL_NEXT, last_match_mode));
 
 7815         ha_statistic_increment(&SSV::ha_read_prev_count);
 
 7832         DBUG_ENTER(
"index_first");
 
 7833         ha_statistic_increment(&SSV::ha_read_first_count);
 
 7835         error = 
index_read(buf, NULL, 0, HA_READ_AFTER_KEY);
 
 7839         if (error == HA_ERR_KEY_NOT_FOUND) {
 
 7840                 error = HA_ERR_END_OF_FILE;
 
 7858         DBUG_ENTER(
"index_last");
 
 7859         ha_statistic_increment(&SSV::ha_read_last_count);
 
 7861         error = 
index_read(buf, NULL, 0, HA_READ_BEFORE_KEY);
 
 7865         if (error == HA_ERR_KEY_NOT_FOUND) {
 
 7866                 error = HA_ERR_END_OF_FILE;
 
 7887                 err = change_active_index(MAX_KEY);
 
 7889                 err = change_active_index(primary_key);
 
 7928         DBUG_ENTER(
"rnd_next");
 
 7929         ha_statistic_increment(&SSV::ha_read_rnd_next_count);
 
 7931         if (start_of_scan) {
 
 7934                 if (error == HA_ERR_KEY_NOT_FOUND) {
 
 7935                         error = HA_ERR_END_OF_FILE;
 
 7960         DBUG_ENTER(
"rnd_pos");
 
 7963         ha_statistic_increment(&SSV::ha_read_rnd_count);
 
 7965         ut_a(prebuilt->
trx == thd_to_trx(ha_thd()));
 
 7973                 DBUG_PRINT(
"error", (
"Got error: %d", error));
 
 7987         DBUG_ENTER(
"ft_init");
 
 7989         trx_t*  trx = check_trx_exists(ha_thd());
 
 7996         if (!trx_is_started(trx)) {
 
 8017         byte*                   
query = (byte*) key->ptr();
 
 8018         ulint                   query_len = key->length();
 
 8028                 fprintf(stderr, 
"keynr=%u, '%.*s'\n",
 
 8029                         keynr, (
int) key->length(), (byte*) key->ptr());
 
 8031                 if (flags & FT_BOOL) {
 
 8032                         fprintf(stderr, 
"BOOL search\n");
 
 8034                         fprintf(stderr, 
"NL search\n");
 
 8041         if (strcmp(char_set->csname, 
"utf32") == 0
 
 8042             || strcmp(char_set->csname, 
"utf16") == 0) {
 
 8044                         buf_tmp, 
sizeof(buf_tmp) - 1,
 
 8045                         &my_charset_utf8_general_ci,
 
 8049                 query = (byte*) buf_tmp;
 
 8050                 query_len = buf_tmp_used;
 
 8051                 query[query_len] = 0;
 
 8054         trx = prebuilt->
trx;
 
 8061         if (!trx_is_started(trx)) {
 
 8065         table = prebuilt->
table;
 
 8069                 my_error(ER_TABLE_HAS_NO_FT, MYF(0));
 
 8073         if (keynr == NO_SUCH_KEY) {
 
 8077                 index = innobase_get_index(keynr);
 
 8080         if (!index || index->
type != DICT_FTS) {
 
 8081                 my_error(ER_TABLE_HAS_NO_FT, MYF(0));
 
 8091         error = 
fts_query(trx, index, flags, query, query_len, &result);
 
 8093         if (error != DB_SUCCESS) {
 
 8094                 my_error(convert_error_code_to_mysql(error, 0, NULL),
 
 8103         fts_hdl->please = 
const_cast<_ft_vft*
>(&ft_vft_result);
 
 8104         fts_hdl->could_you = 
const_cast<_ft_vft_ext*
>(&ft_vft_ext_result);
 
 8105         fts_hdl->ft_prebuilt = prebuilt;
 
 8106         fts_hdl->ft_result = result;
 
 8121 innobase_fts_create_doc_id_key(
 
 8131         dfield_t*       dfield = dtuple_get_nth_field(tuple, 0);
 
 8140         dict_field_t*   field = dict_index_get_nth_field(index, 0);
 
 8148         *doc_id = temp_doc_id;
 
 8153         for (ulint i = 1; i < index->
n_fields; i++) {
 
 8154                 dfield = dtuple_get_nth_field(tuple, i);
 
 8172         ft_prebuilt = ((
NEW_FT_INFO*) ft_handler)->ft_prebuilt;
 
 8174         ut_a(ft_prebuilt == prebuilt);
 
 8178         if (result->
current == NULL) {
 
 8200         if (result->
current != NULL) {
 
 8224                 search_doc_id = ranking->
doc_id;
 
 8229                 innobase_fts_create_doc_id_key(tuple, index, &search_doc_id);
 
 8231                 innobase_srv_conc_enter_innodb(prebuilt->
trx);
 
 8236                 innobase_srv_conc_exit_innodb(prebuilt->
trx);
 
 8243                 case DB_RECORD_NOT_FOUND:
 
 8253                                 error = HA_ERR_END_OF_FILE;
 
 8254                                 table->status = STATUS_NOT_FOUND;
 
 8259                 case DB_END_OF_INDEX:
 
 8260                         error = HA_ERR_END_OF_FILE;
 
 8261                         table->status = STATUS_NOT_FOUND;
 
 8267                                 ER_TABLESPACE_DISCARDED,
 
 8268                                 table->s->table_name.str);
 
 8270                         table->status = STATUS_NOT_FOUND;
 
 8271                         error = HA_ERR_NO_SUCH_TABLE;
 
 8273                 case DB_TABLESPACE_NOT_FOUND:
 
 8277                                 ER_TABLESPACE_MISSING,
 
 8278                                 table->s->table_name.str);
 
 8280                         table->status = STATUS_NOT_FOUND;
 
 8281                         error = HA_ERR_NO_SUCH_TABLE;
 
 8284                         error = convert_error_code_to_mysql(
 
 8287                         table->status = STATUS_NOT_FOUND;
 
 8294         return(HA_ERR_END_OF_FILE);
 
 8301 ha_innobase::ft_end()
 
 8303         fprintf(stderr, 
"ft_end()\n");
 
 8320         const uchar*    record) 
 
 8324         ut_a(prebuilt->
trx == thd_to_trx(ha_thd()));
 
 8332                 len = DATA_ROW_ID_LEN;
 
 8334                 memcpy(ref, prebuilt->
row_id, len);
 
 8336                 len = store_key_val_for_row(primary_key, (
char*) ref,
 
 8344                 sql_print_error(
"Stored ref len is %lu, but table ref len is " 
 8351 #define IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS(table_name, thd) \ 
 8352         (row_is_magic_monitor_table(table_name) \ 
 8353          && check_global_access(thd, PROCESS_ACL)) 
 8361 create_table_check_doc_id_col(
 
 8371         for (ulint i = 0; i < form->s->fields; i++) {
 
 8375                 ulint           unsigned_type;
 
 8377                 field = form->field[
i];
 
 8382                 col_len = field->pack_length();
 
 8389                         if (col_type == DATA_INT
 
 8390                             && !field->real_maybe_null()
 
 8392                             && (strcmp(field->field_name,
 
 8396                                 push_warning_printf(
 
 8398                                         Sql_condition::WARN_LEVEL_WARN,
 
 8399                                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 8400                                         "InnoDB: FTS_DOC_ID column must be " 
 8401                                         "of BIGINT NOT NULL type, and named " 
 8402                                         "in all capitalized characters");
 
 8403                                 my_error(ER_WRONG_COLUMN_NAME, MYF(0),
 
 8405                                 *doc_id_col = ULINT_UNDEFINED;
 
 8417 static __attribute__((nonnull, warn_unused_result))
 
 8437         THD*            thd = trx->mysql_thd;
 
 8443         ulint           nulls_allowed;
 
 8444         ulint           unsigned_type;
 
 8446         ulint           long_true_varchar;
 
 8449         ulint           doc_id_col = 0;
 
 8450         ibool           has_doc_id_col = FALSE;
 
 8453         DBUG_ENTER(
"create_table_def");
 
 8454         DBUG_PRINT(
"enter", (
"table_name: %s", table_name));
 
 8456         DBUG_ASSERT(thd != NULL);
 
 8460         if (strlen(table_name) > MAX_FULL_NAME_LEN) {
 
 8461                 push_warning_printf(
 
 8462                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8464                         "InnoDB: Table Name or Database Name is too long");
 
 8466                 DBUG_RETURN(ER_TABLE_NAME);
 
 8471         if (strcmp(strchr(table_name, 
'/') + 1,
 
 8472                    "innodb_table_monitor") == 0) {
 
 8474                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8475                         HA_ERR_WRONG_COMMAND,
 
 8476                         DEPRECATED_MSG_INNODB_TABLE_MONITOR);
 
 8479         n_cols = form->s->fields;
 
 8482         if (create_table_check_doc_id_col(trx, form, &doc_id_col)){
 
 8485                 if (doc_id_col == ULINT_UNDEFINED) {
 
 8491                         has_doc_id_col = TRUE;
 
 8500                 if (!has_doc_id_col) {
 
 8509                         table->fts->
doc_col = doc_id_col;
 
 8517                 ut_a(strlen(temp_path));
 
 8523                 ut_a(strlen(remote_path));
 
 8530         for (i = 0; i < n_cols; i++) {
 
 8531                 Field*  field = form->field[
i];
 
 8537                         push_warning_printf(
 
 8538                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 8539                                 ER_CANT_CREATE_TABLE,
 
 8540                                 "Error creating table '%s' with " 
 8541                                 "column '%s'. Please check its " 
 8542                                 "column type and try to re-create " 
 8543                                 "the table with an appropriate " 
 8545                                 table->
name, field->field_name);
 
 8549                 nulls_allowed = field->real_maybe_null() ? 0 : DATA_NOT_NULL;
 
 8550                 binary_type = field->binary() ? DATA_BINARY_TYPE : 0;
 
 8556                         charset_no = (ulint) field->charset()->number;
 
 8558                         if (UNIV_UNLIKELY(charset_no > MAX_CHAR_COLL_NUM)) {
 
 8561                                 push_warning_printf(
 
 8562                                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8563                                         ER_CANT_CREATE_TABLE,
 
 8564                                         "In InnoDB, charset-collation codes" 
 8565                                         " must be below 256." 
 8566                                         " Unsupported code %lu.",
 
 8567                                         (ulong) charset_no);
 
 8569                                 DBUG_RETURN(ER_CANT_CREATE_TABLE);
 
 8575                 ut_a(field->type() <= MAX_CHAR_COLL_NUM);
 
 8576                 col_len = field->pack_length();
 
 8583                 long_true_varchar = 0;
 
 8585                 if (field->type() == MYSQL_TYPE_VARCHAR) {
 
 8589                                 long_true_varchar = DATA_LONG_TRUE_VARCHAR;
 
 8596                         my_error(ER_WRONG_COLUMN_NAME, MYF(0),
 
 8611                                 (ulint) field->type()
 
 8612                                 | nulls_allowed | unsigned_type
 
 8613                                 | binary_type | long_true_varchar,
 
 8619         if (flags2 & DICT_TF2_FTS && !has_doc_id_col) {
 
 8627         DBUG_EXECUTE_IF(
"ib_create_err_tablespace_exist",
 
 8631                 char display_name[FN_REFLEN];
 
 8632                 char* buf_end = innobase_convert_identifier(
 
 8633                         display_name, 
sizeof(display_name) - 1,
 
 8634                         table_name, strlen(table_name),
 
 8639                 my_error(err == DB_DUPLICATE_KEY
 
 8640                          ? ER_TABLE_EXISTS_ERROR
 
 8641                          : ER_TABLESPACE_EXISTS, MYF(0), display_name);
 
 8644         if (err == DB_SUCCESS && (flags2 & DICT_TF2_FTS)) {
 
 8649         DBUG_RETURN(convert_error_code_to_mysql(err, flags, thd));
 
 8662         const char*     table_name,     
 
 8669         ulint*          field_lengths;
 
 8671         DBUG_ENTER(
"create_index");
 
 8673         key = form->key_info + key_num;
 
 8678         if (key->
flags & HA_FULLTEXT) {
 
 8686                                 index, key_part->field->field_name, 0);
 
 8689                 DBUG_RETURN(convert_error_code_to_mysql(
 
 8698         if (key_num == form->s->primary_key) {
 
 8702         if (key->
flags & HA_NOSAME) {
 
 8706         field_lengths = (ulint*) my_malloc(
 
 8708                                 field_lengths, MYF(MY_FAE));
 
 8730                 Field*  field = NULL;
 
 8732                 for (ulint j = 0; j < form->s->fields; j++) {
 
 8734                         field = form->field[j];
 
 8738                                     key_part->field->field_name)) {
 
 8748                         &is_unsigned, key_part->field);
 
 8750                 if (DATA_BLOB == col_type
 
 8751                     || (key_part->length < field->pack_length()
 
 8752                         && field->type() != MYSQL_TYPE_VARCHAR)
 
 8753                     || (field->type() == MYSQL_TYPE_VARCHAR
 
 8754                         && key_part->length < field->pack_length()
 
 8759                                 prefix_len = key_part->length;
 
 8766                                         "MySQL is trying to create a column " 
 8767                                         "prefix index field, on an " 
 8768                                         "inappropriate data type. Table " 
 8769                                         "name %s, column name %s.",
 
 8771                                         key_part->field->field_name);
 
 8779                 field_lengths[
i] = key_part->length;
 
 8782                         index, key_part->field->field_name, prefix_len);
 
 8791         error = convert_error_code_to_mysql(
 
 8795         my_free(field_lengths);
 
 8805 create_clustered_index_when_no_primary(
 
 8809         const char*     table_name)     
 
 8817                                       innobase_index_reserve_name,
 
 8822         return(convert_error_code_to_mysql(error, flags, NULL));
 
 8830 get_row_format_name(
 
 8832         enum row_type   row_format)             
 
 8834         switch (row_format) {
 
 8835         case ROW_TYPE_COMPACT:
 
 8837         case ROW_TYPE_COMPRESSED:
 
 8838                 return(
"COMPRESSED");
 
 8839         case ROW_TYPE_DYNAMIC:
 
 8841         case ROW_TYPE_REDUNDANT:
 
 8842                 return(
"REDUNDANT");
 
 8843         case ROW_TYPE_DEFAULT:
 
 8845         case ROW_TYPE_FIXED:
 
 8848         case ROW_TYPE_NOT_USED:
 
 8855 #define CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace)\ 
 8856         if (!use_tablespace) {                                  \ 
 8857                 push_warning_printf(                            \ 
 8858                         thd, Sql_condition::WARN_LEVEL_WARN,    \ 
 8859                         ER_ILLEGAL_HA_CREATE_OPTION,            \ 
 8860                         "InnoDB: ROW_FORMAT=%s requires"        \ 
 8861                         " innodb_file_per_table.",              \ 
 8862                         get_row_format_name(row_format));       \ 
 8863                 ret = "ROW_FORMAT";                                     \ 
 8867 #define CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE                  \ 
 8868         if (srv_file_format < UNIV_FORMAT_B) {          \ 
 8869                 push_warning_printf(                            \ 
 8870                         thd, Sql_condition::WARN_LEVEL_WARN,    \ 
 8871                         ER_ILLEGAL_HA_CREATE_OPTION,            \ 
 8872                         "InnoDB: ROW_FORMAT=%s requires"        \ 
 8873                         " innodb_file_format > Antelope.",      \ 
 8874                         get_row_format_name(row_format));       \ 
 8875                 ret = "ROW_FORMAT";                             \ 
 8887 create_options_are_invalid(
 
 8893         bool            use_tablespace) 
 
 8895         ibool   kbs_specified   = FALSE;
 
 8896         const char*     ret     = NULL;
 
 8897         enum row_type   row_format      = form->s->row_type;
 
 8902         if (!(THDVAR(thd, strict_mode))) {
 
 8906         ut_ad(form != NULL);
 
 8907         ut_ad(create_info != NULL);
 
 8910         if (create_info->key_block_size) {
 
 8911                 kbs_specified = TRUE;
 
 8912                 switch (create_info->key_block_size) {
 
 8920                         if (!use_tablespace) {
 
 8922                                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8923                                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 8924                                         "InnoDB: KEY_BLOCK_SIZE requires" 
 8925                                         " innodb_file_per_table.");
 
 8926                                 ret = 
"KEY_BLOCK_SIZE";
 
 8930                                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8931                                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 8932                                         "InnoDB: KEY_BLOCK_SIZE requires" 
 8933                                         " innodb_file_format > Antelope.");
 
 8934                                 ret = 
"KEY_BLOCK_SIZE";
 
 8941                                 1 << (UNIV_PAGE_SSIZE_MAX - 1),
 
 8943                         if (create_info->key_block_size > kbs_max) {
 
 8944                                 push_warning_printf(
 
 8945                                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8946                                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 8947                                         "InnoDB: KEY_BLOCK_SIZE=%ld" 
 8948                                         " cannot be larger than %ld.",
 
 8949                                         create_info->key_block_size,
 
 8951                                 ret = 
"KEY_BLOCK_SIZE";
 
 8955                         push_warning_printf(
 
 8956                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 8957                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 8958                                 "InnoDB: invalid KEY_BLOCK_SIZE = %lu." 
 8959                                 " Valid values are [1, 2, 4, 8, 16]",
 
 8960                                 create_info->key_block_size);
 
 8961                         ret = 
"KEY_BLOCK_SIZE";
 
 8968         switch (row_format) {
 
 8969         case ROW_TYPE_COMPRESSED:
 
 8970                 CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace);
 
 8971                 CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE;
 
 8973         case ROW_TYPE_DYNAMIC:
 
 8974                 CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE(use_tablespace);
 
 8975                 CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE;
 
 8977         case ROW_TYPE_COMPACT:
 
 8978         case ROW_TYPE_REDUNDANT:
 
 8979                 if (kbs_specified) {
 
 8980                         push_warning_printf(
 
 8981                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 8982                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 8983                                 "InnoDB: cannot specify ROW_FORMAT = %s" 
 8984                                 " with KEY_BLOCK_SIZE.",
 
 8985                                 get_row_format_name(row_format));
 
 8986                         ret = 
"KEY_BLOCK_SIZE";
 
 8989         case ROW_TYPE_DEFAULT:
 
 8991         case ROW_TYPE_FIXED:
 
 8993         case ROW_TYPE_NOT_USED:
 
 8995                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 8996                         ER_ILLEGAL_HA_CREATE_OPTION,            \
 
 8997                         "InnoDB: invalid ROW_FORMAT specifier.");
 
 9003         if (create_info->data_file_name && !use_tablespace) {
 
 9005                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 9006                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 9007                         "InnoDB: DATA DIRECTORY requires" 
 9008                         " innodb_file_per_table.");
 
 9009                 ret = 
"DATA DIRECTORY";
 
 9013         if (create_info->data_file_name
 
 9014             && create_info->options & HA_LEX_CREATE_TMP_TABLE) {
 
 9016                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 9017                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 9018                         "InnoDB: DATA DIRECTORY cannot be used" 
 9019                         " for TEMPORARY tables.");
 
 9020                 ret = 
"DATA DIRECTORY";
 
 9024         if (create_info->index_file_name) {
 
 9025                 push_warning_printf(
 
 9026                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 9027                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 9028                         "InnoDB: INDEX DIRECTORY is not supported");
 
 9029                 ret = 
"INDEX DIRECTORY";
 
 9039 ha_innobase::update_create_info(
 
 9043         if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) {
 
 9044                 ha_innobase::info(HA_STATUS_AUTO);
 
 9045                 create_info->auto_increment_value = 
stats.auto_increment_value;
 
 9061 innobase_fts_load_stopword(
 
 9068                                  fts_server_stopword_table,
 
 9069                                  THDVAR(thd, ft_user_stopword_table),
 
 9070                                  THDVAR(thd, ft_enable_stopword), FALSE));
 
 9079 ha_innobase::parse_table_name(
 
 9091         THD*            thd = ha_thd();
 
 9093         DBUG_ENTER(
"ha_innobase::parse_table_name");
 
 9109             && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) {
 
 9111                 if ((name[1] == 
':')
 
 9112                     || (name[0] == 
'\\' && name[1] == 
'\\')) {
 
 9113                         sql_print_error(
"Cannot create table %s\n", name);
 
 9114                         DBUG_RETURN(HA_ERR_GENERIC);
 
 9120         temp_path[0] = 
'\0';
 
 9121         remote_path[0] = 
'\0';
 
 9127         if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
 
 9128                 strncpy(temp_path, name, FN_REFLEN - 1);
 
 9131         if (create_info->data_file_name) {
 
 9132                 bool ignore = 
false;
 
 9135                 if (!use_tablespace) {
 
 9137                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9138                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9139                                 "InnoDB: DATA DIRECTORY requires" 
 9140                                 " innodb_file_per_table.");
 
 9145                 if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
 
 9147                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9148                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9149                                 "InnoDB: DATA DIRECTORY cannot be" 
 9150                                 " used for TEMPORARY tables.");
 
 9155                         push_warning_printf(
 
 9156                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9157                                 WARN_OPTION_IGNORED,
 
 9158                                 ER_DEFAULT(WARN_OPTION_IGNORED),
 
 9161                         strncpy(remote_path, create_info->data_file_name,
 
 9166         if (create_info->index_file_name) {
 
 9167                 push_warning_printf(
 
 9168                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 9169                         WARN_OPTION_IGNORED,
 
 9170                         ER_DEFAULT(WARN_OPTION_IGNORED),
 
 9182 innobase_table_flags(
 
 9188         bool                    use_tablespace, 
 
 9193         DBUG_ENTER(
"innobase_table_flags");
 
 9195         const char*     fts_doc_id_index_bad = NULL;
 
 9196         bool            zip_allowed = 
true;
 
 9197         ulint           zip_ssize = 0;
 
 9198         enum row_type   row_format;
 
 9210         for (uint i = 0; i < form->s->keys; i++) {
 
 9211                 const KEY*      key = &form->key_info[
i];
 
 9213                 if (key->
flags & HA_FULLTEXT) {
 
 9218                         if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
 
 9220                                 my_error(ER_INNODB_NO_FT_TEMP_TABLE, MYF(0));
 
 9224                         if (key->
flags & HA_USES_PARSER) {
 
 9225                                 my_error(ER_INNODB_NO_FT_USES_PARSER, MYF(0));
 
 9229                         if (fts_doc_id_index_bad) {
 
 9239                 if (!(key->
flags & HA_NOSAME)
 
 9241                     || strcmp(key->key_part[0].field->field_name,
 
 9243                         fts_doc_id_index_bad = key->
name;
 
 9246                 if (fts_doc_id_index_bad && (*flags2 & DICT_TF2_FTS)) {
 
 9248                         my_error(ER_INNODB_FT_WRONG_DOCID_INDEX, MYF(0),
 
 9249                                  fts_doc_id_index_bad);
 
 9254         if (create_info->key_block_size) {
 
 9261                 for (zssize = kbsize = 1;
 
 9262                      zssize <= 
ut_min(UNIV_PAGE_SSIZE_MAX,
 
 9264                      zssize++, kbsize <<= 1) {
 
 9265                         if (kbsize == create_info->key_block_size) {
 
 9272                 if (!use_tablespace) {
 
 9274                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9275                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9276                                 "InnoDB: KEY_BLOCK_SIZE requires" 
 9277                                 " innodb_file_per_table.");
 
 9278                         zip_allowed = FALSE;
 
 9281                 if (file_format_allowed < UNIV_FORMAT_B) {
 
 9283                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9284                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9285                                 "InnoDB: KEY_BLOCK_SIZE requires" 
 9286                                 " innodb_file_format > Antelope.");
 
 9287                         zip_allowed = FALSE;
 
 9291                     || zssize > 
ut_min(UNIV_PAGE_SSIZE_MAX,
 
 9293                         push_warning_printf(
 
 9294                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9295                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9296                                 "InnoDB: ignoring KEY_BLOCK_SIZE=%lu.",
 
 9297                                 create_info->key_block_size);
 
 9301         row_format = form->s->row_type;
 
 9303         if (zip_ssize && zip_allowed) {
 
 9306                 if (row_format == ROW_TYPE_DEFAULT) {
 
 9307                         row_format = ROW_TYPE_COMPRESSED;
 
 9308                 } 
else if (row_format != ROW_TYPE_COMPRESSED) {
 
 9315                         push_warning_printf(
 
 9316                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9317                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9318                                 "InnoDB: ignoring KEY_BLOCK_SIZE=%lu" 
 9319                                 " unless ROW_FORMAT=COMPRESSED.",
 
 9320                                 create_info->key_block_size);
 
 9321                         zip_allowed = FALSE;
 
 9325                 if (row_format == ROW_TYPE_COMPRESSED && zip_allowed) {
 
 9329                         zip_ssize = 
ut_min(UNIV_PAGE_SSIZE_MAX,
 
 9335         switch (row_format) {
 
 9336         case ROW_TYPE_REDUNDANT:
 
 9340         case ROW_TYPE_COMPRESSED:
 
 9341         case ROW_TYPE_DYNAMIC:
 
 9342                 if (!use_tablespace) {
 
 9343                         push_warning_printf(
 
 9344                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9345                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9346                                 "InnoDB: ROW_FORMAT=%s requires" 
 9347                                 " innodb_file_per_table.",
 
 9348                                 get_row_format_name(row_format));
 
 9349                 } 
else if (file_format_allowed == UNIV_FORMAT_A) {
 
 9350                         push_warning_printf(
 
 9351                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9352                                 ER_ILLEGAL_HA_CREATE_OPTION,
 
 9353                                 "InnoDB: ROW_FORMAT=%s requires" 
 9354                                 " innodb_file_format > Antelope.",
 
 9355                                 get_row_format_name(row_format));
 
 9357                         innodb_row_format = (row_format == ROW_TYPE_DYNAMIC
 
 9362                 zip_allowed = FALSE;
 
 9364         case ROW_TYPE_NOT_USED:
 
 9365         case ROW_TYPE_FIXED:
 
 9368                         thd, Sql_condition::WARN_LEVEL_WARN,
 
 9369                         ER_ILLEGAL_HA_CREATE_OPTION,
 
 9370                         "InnoDB: assuming ROW_FORMAT=COMPACT.");
 
 9371         case ROW_TYPE_DEFAULT:
 
 9373                 row_format = ROW_TYPE_COMPACT;
 
 9374         case ROW_TYPE_COMPACT:
 
 9383         use_data_dir = use_tablespace
 
 9384                        && ((create_info->data_file_name != NULL)
 
 9385                        && !(create_info->options & HA_LEX_CREATE_TMP_TABLE));
 
 9387         dict_tf_set(flags, innodb_row_format, zip_ssize, use_data_dir);
 
 9389         if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
 
 9393         if (use_tablespace) {
 
 9405 ha_innobase::create(
 
 9419         char            norm_name[FN_REFLEN];   
 
 9420         char            temp_path[FN_REFLEN];   
 
 9421         char            remote_path[FN_REFLEN]; 
 
 9422         THD*            thd = ha_thd();
 
 9423         ib_int64_t      auto_inc_value;
 
 9441         DBUG_ENTER(
"ha_innobase::create");
 
 9443         DBUG_ASSERT(thd != NULL);
 
 9444         DBUG_ASSERT(create_info != NULL);
 
 9446         if (form->s->fields > REC_MAX_N_USER_FIELDS) {
 
 9447                 DBUG_RETURN(HA_ERR_TOO_MANY_FIELDS);
 
 9449                 DBUG_RETURN(HA_ERR_INNODB_READ_ONLY);
 
 9455         if (create_options_are_invalid(
 
 9456                         thd, form, create_info, use_tablespace)) {
 
 9457                 DBUG_RETURN(HA_WRONG_CREATE_OPTION);
 
 9460         if (!innobase_table_flags(form, create_info,
 
 9461                                   thd, use_tablespace,
 
 9466         error = parse_table_name(name, create_info, flags, flags2,
 
 9467                                  norm_name, temp_path, remote_path);
 
 9473         primary_key_no = (form->s->primary_key != MAX_KEY ?
 
 9474                           (int) form->s->primary_key :
 
 9479         ut_a(primary_key_no == -1 || primary_key_no == 0);
 
 9483         if (innobase_index_name_is_reserved(thd, form->key_info,
 
 9488         if (IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS(norm_name, thd)) {
 
 9489                 DBUG_RETURN(HA_ERR_GENERIC);
 
 9495         parent_trx = check_trx_exists(thd);
 
 9508         row_mysql_lock_data_dictionary(trx);
 
 9510         error = create_table_def(trx, form, norm_name, temp_path,
 
 9511                                  remote_path, flags, flags2);
 
 9518         if (form->s->keys == 0 || primary_key_no == -1) {
 
 9523                 error = create_clustered_index_when_no_primary(
 
 9524                         trx, flags, norm_name);
 
 9530         if (primary_key_no != -1) {
 
 9533                 if ((error = create_index(trx, form, flags, norm_name,
 
 9534                                           (uint) primary_key_no))) {
 
 9541         if (flags2 & DICT_TF2_FTS) {
 
 9542                 enum fts_doc_id_index_enum      
ret;
 
 9547                 ut_a(innobase_table);
 
 9550                 ret = innobase_fts_check_doc_id_index_in_def(
 
 9551                         form->s->keys, form->key_info);
 
 9554                 case FTS_INCORRECT_DOC_ID_INDEX:
 
 9555                         push_warning_printf(thd,
 
 9556                                             Sql_condition::WARN_LEVEL_WARN,
 
 9557                                             ER_WRONG_NAME_FOR_INDEX,
 
 9558                                             " InnoDB: Index name %s is reserved" 
 9559                                             " for the unique index on" 
 9560                                             " FTS_DOC_ID column for FTS" 
 9561                                             " Document ID indexing" 
 9562                                             " on table %s. Please check" 
 9563                                             " the index definition to" 
 9564                                             " make sure it is of correct" 
 9567                                             innobase_table->
name);
 
 9569                         if (innobase_table->fts) {
 
 9574                         my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0),
 
 9578                 case FTS_EXIST_DOC_ID_INDEX:
 
 9579                 case FTS_NOT_EXIST_DOC_ID_INDEX:
 
 9584                         trx, innobase_table, norm_name,
 
 9585                         (ret == FTS_EXIST_DOC_ID_INDEX));
 
 9587                 error = convert_error_code_to_mysql(err, 0, NULL);
 
 9596         for (i = 0; i < form->s->keys; i++) {
 
 9598                 if (i != static_cast<uint>(primary_key_no)) {
 
 9600                         if ((error = create_index(trx, form, flags,
 
 9609         if (flags2 & DICT_TF2_FTS) {
 
 9610                 fts_t*          fts = innobase_table->fts;
 
 9621                         trx, stmt, stmt_len, norm_name,
 
 9622                         create_info->options & HA_LEX_CREATE_TMP_TABLE);
 
 9627                         push_warning_printf(
 
 9628                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9629                                 HA_ERR_CANNOT_ADD_FOREIGN,
 
 9630                                 "Create table '%s' with foreign key constraint" 
 9631                                 " failed. There is no index in the referenced" 
 9632                                 " table where the referenced columns appear" 
 9633                                 " as the first columns.\n", norm_name);
 
 9637                         push_warning_printf(
 
 9638                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
 9639                                 HA_ERR_CANNOT_ADD_FOREIGN,
 
 9640                                 "Create table '%s' with foreign key constraint" 
 9641                                 " failed. There is no index in the referencing" 
 9642                                 " table where referencing columns appear" 
 9643                                 " as the first columns.\n", norm_name);
 
 9649                 error = convert_error_code_to_mysql(err, flags, NULL);
 
 9656         innobase_commit_low(trx);
 
 9669         DBUG_ASSERT(innobase_table != 0);
 
 9675         if (innobase_table) {
 
 9680                         (
const char**) &innobase_file_format_max,
 
 9685         if (flags2 & DICT_TF2_FTS) {
 
 9686                 if (!innobase_fts_load_stopword(innobase_table, NULL, thd)) {
 
 9711         if (((create_info->used_fields & HA_CREATE_USED_AUTO)
 
 9712             || thd_sql_command(thd) == SQLCOM_ALTER_TABLE
 
 9713             || thd_sql_command(thd) == SQLCOM_OPTIMIZE
 
 9714             || thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
 
 9715             && create_info->auto_increment_value > 0) {
 
 9717                 auto_inc_value = create_info->auto_increment_value;
 
 9750 ha_innobase::discard_or_import_tablespace(
 
 9757         DBUG_ENTER(
"ha_innobase::discard_or_import_tablespace");
 
 9760         ut_a(prebuilt->
trx->magic_n == TRX_MAGIC_N);
 
 9761         ut_a(prebuilt->
trx == thd_to_trx(ha_thd()));
 
 9764                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
 9767         dict_table = prebuilt->
table;
 
 9769         if (dict_table->
space == TRX_SYS_SPACE) {
 
 9773                         ER_TABLE_IN_SYSTEM_TABLESPACE,
 
 9774                         table->s->table_name.str);
 
 9776                 DBUG_RETURN(HA_ERR_TABLE_NEEDS_UPGRADE);
 
 9779         trx_start_if_not_started(prebuilt->
trx);
 
 9787                 prebuilt->
trx, dict_table, LOCK_X,
 
 9788                 discard ? 
"setting table lock for DISCARD TABLESPACE" 
 9789                         : 
"setting table lock for IMPORT TABLESPACE");
 
 9791         if (err != DB_SUCCESS) {
 
 9793         } 
else if (discard) {
 
 9803                                 IB_LOG_LEVEL_WARN, ER_TABLESPACE_MISSING,
 
 9804                                 table->s->table_name.str);
 
 9808                         dict_table->
name, prebuilt->
trx);
 
 9817                         ER_TABLESPACE_EXISTS, table->s->table_name.str);
 
 9819                 DBUG_RETURN(HA_ERR_TABLE_EXIST);
 
 9823                 if (err == DB_SUCCESS) {
 
 9825                         if (table->found_next_number_field) {
 
 9827                                 innobase_initialize_autoinc();
 
 9833                              | HA_STATUS_VARIABLE
 
 9841         DBUG_RETURN(convert_error_code_to_mysql(err, dict_table->
flags, NULL));
 
 9855         DBUG_ENTER(
"ha_innobase::truncate");
 
 9858                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
 9864         update_thd(ha_thd());
 
 9866         if (!trx_is_started(prebuilt->
trx)) {
 
 9876         case DB_TABLESPACE_NOT_FOUND:
 
 9880                         ER_TABLESPACE_DISCARDED : ER_TABLESPACE_MISSING),
 
 9881                         table->s->table_name.str);
 
 9882                 table->status = STATUS_NOT_FOUND;
 
 9883                 error = HA_ERR_NO_SUCH_TABLE;
 
 9887                 error = convert_error_code_to_mysql(
 
 9890                 table->status = STATUS_NOT_FOUND;
 
 9913         THD*    thd = ha_thd();
 
 9914         char    norm_name[FN_REFLEN];
 
 9916         DBUG_ENTER(
"ha_innobase::delete_table");
 
 9919                 "test_normalize_table_name_low",
 
 9920                 test_normalize_table_name_low();
 
 9923                 "test_ut_format_name",
 
 9924                 test_ut_format_name();
 
 9932                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
 9933         } 
else if (IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS(norm_name, thd)) {
 
 9934                 DBUG_RETURN(HA_ERR_GENERIC);
 
 9937         parent_trx = check_trx_exists(thd);
 
 9946         name_len = strlen(name);
 
 9948         ut_a(name_len < 1000);
 
 9961                 norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB);
 
 9964         if (err == DB_TABLE_NOT_FOUND
 
 9966                 char*   is_part = NULL;
 
 9968                 is_part = strstr(norm_name, 
"#p#");
 
 9970                 is_part = strstr(norm_name, 
"#P#");
 
 9974                         char    par_case_name[FN_REFLEN];
 
 9980                         strcpy(par_case_name, norm_name);
 
 9987                         normalize_table_name_low(
 
 9988                                 par_case_name, name, FALSE);
 
 9992                                 thd_sql_command(thd) == SQLCOM_DROP_DB);
 
10007         innobase_commit_low(trx);
 
10011         DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL));
 
10018 innobase_drop_database(
 
10030         THD*    thd             = current_thd;
 
10035         DBUG_ASSERT(hton == innodb_hton_ptr);
 
10043                 trx_t*  parent_trx = check_trx_exists(thd);
 
10052         ptr = strend(path) - 2;
 
10054         while (ptr >= path && *ptr != 
'\\' && *ptr != 
'/') {
 
10060         namebuf = (
char*) my_malloc((uint) len + 2, MYF(0));
 
10062         memcpy(namebuf, ptr, len);
 
10063         namebuf[len] = 
'/';
 
10064         namebuf[len + 1] = 
'\0';
 
10093         innobase_commit_low(trx);
 
10100 static __attribute__((nonnull, warn_unused_result))
 
10102 innobase_rename_table(
 
10109         char    norm_to[FN_REFLEN];
 
10110         char    norm_from[FN_REFLEN];
 
10112         DBUG_ENTER(
"innobase_rename_table");
 
10120         DEBUG_SYNC_C(
"innodb_rename_table_ready");
 
10122         trx_start_if_not_started(trx);
 
10127         row_mysql_lock_data_dictionary(trx);
 
10132         ut_a(trx->will_lock > 0);
 
10135                 norm_from, norm_to, trx, TRUE);
 
10137         if (error != DB_SUCCESS) {
 
10138                 if (error == DB_TABLE_NOT_FOUND
 
10140                         char*   is_part = NULL;
 
10142                         is_part = strstr(norm_from, 
"#p#");
 
10144                         is_part = strstr(norm_from, 
"#P#");
 
10148                                 char    par_case_name[FN_REFLEN];
 
10153                                 strcpy(par_case_name, norm_from);
 
10160                                 normalize_table_name_low(
 
10161                                         par_case_name, from, FALSE);
 
10163                                 trx_start_if_not_started(trx);
 
10165                                         par_case_name, norm_to, trx, TRUE);
 
10169                 if (error != DB_SUCCESS) {
 
10171                                 FILE* ef = dict_foreign_err_file;
 
10173                                 fputs(
"InnoDB: Renaming table ", ef);
 
10177                                 fputs(
" failed!\n", ef);
 
10181                         sql_print_warning(
"Rename partition table %s " 
10182                                           "succeeds after converting to lower " 
10183                                           "case. The table may have " 
10184                                           "been moved from a case " 
10185                                           "in-sensitive file system.\n",
 
10188                         sql_print_warning(
"Rename partition table %s " 
10189                                           "succeeds after skipping the step to " 
10190                                           "lower case the table name. " 
10191                                           "The table may have been " 
10192                                           "moved from a case sensitive " 
10207         DBUG_RETURN(error);
 
10223         THD*    thd             = ha_thd();
 
10225         DBUG_ENTER(
"ha_innobase::rename_table");
 
10228                 ib_senderrf(thd, IB_LOG_LEVEL_WARN, ER_READ_ONLY_MODE);
 
10229                 DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
10235         parent_trx = check_trx_exists(thd);
 
10248         error = innobase_rename_table(trx, from, to);
 
10250         DEBUG_SYNC(thd, 
"after_innobase_rename_table");
 
10257         innobase_commit_low(trx);
 
10260         if (error == DB_SUCCESS) {
 
10261                 char    norm_from[MAX_FULL_NAME_LEN];
 
10262                 char    norm_to[MAX_FULL_NAME_LEN];
 
10270                                               errstr, 
sizeof(errstr));
 
10272                 if (ret != DB_SUCCESS) {
 
10274                         fprintf(stderr, 
" InnoDB: %s\n", errstr);
 
10276                         push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
 
10277                                      ER_LOCK_WAIT_TIMEOUT, errstr);
 
10293         if (error == DB_DUPLICATE_KEY) {
 
10294                 my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to);
 
10299         DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));
 
10307 ha_innobase::records_in_range(
 
10324         DBUG_ENTER(
"records_in_range");
 
10326         ut_a(prebuilt->
trx == thd_to_trx(ha_thd()));
 
10328         prebuilt->
trx->
op_info = (
char*)
"estimating records in index range";
 
10335         active_index = keynr;
 
10337         key = table->key_info + active_index;
 
10339         index = innobase_get_index(keynr);
 
10344         if (UNIV_UNLIKELY(!index)) {
 
10345                 n_rows = HA_POS_ERROR;
 
10349                 n_rows = HA_ERR_INDEX_CORRUPT;
 
10353                 n_rows = HA_ERR_TABLE_DEF_CHANGED;
 
10368                                 srch_key_val1, 
sizeof(srch_key_val1),
 
10370                                 (byte*) (min_key ? min_key->key :
 
10372                                 (ulint) (min_key ? min_key->length : 0),
 
10374         DBUG_ASSERT(min_key
 
10380                                 srch_key_val2, 
sizeof(srch_key_val2),
 
10382                                 (byte*) (max_key ? max_key->key :
 
10384                                 (ulint) (max_key ? max_key->length : 0),
 
10386         DBUG_ASSERT(max_key
 
10390         mode1 = convert_search_mode_to_innobase(min_key ? min_key->flag :
 
10391                                                 HA_READ_KEY_EXACT);
 
10392         mode2 = convert_search_mode_to_innobase(max_key ? max_key->flag :
 
10393                                                 HA_READ_KEY_EXACT);
 
10395         if (mode1 != PAGE_CUR_UNSUPP && mode2 != PAGE_CUR_UNSUPP) {
 
10402                 n_rows = HA_POS_ERROR;
 
10421         DBUG_RETURN((ha_rows) n_rows);
 
10434         ulonglong               estimate;
 
10435         ulonglong               local_data_file_length;
 
10436         ulint                   stat_n_leaf_pages;
 
10438         DBUG_ENTER(
"estimate_rows_upper_bound");
 
10444         update_thd(ha_thd());
 
10446         prebuilt->
trx->
op_info = 
"calculating upper bound for table rows";
 
10453         index = dict_table_get_first_index(prebuilt->
table);
 
10457         ut_a(stat_n_leaf_pages > 0);
 
10459         local_data_file_length =
 
10460                 ((ulonglong) stat_n_leaf_pages) * UNIV_PAGE_SIZE;
 
10467         estimate = 2 * local_data_file_length
 
10472         DBUG_RETURN((ha_rows) estimate);
 
10482 ha_innobase::scan_time()
 
10497         update_thd(ha_thd());
 
10501         ulint   stat_clustered_index_size;
 
10515         return((
double) stat_clustered_index_size);
 
10530         ha_rows total_rows;
 
10531         double  time_for_scan;
 
10533         if (index != table->s->primary_key) {
 
10540                 return((
double) rows);
 
10546         time_for_scan = scan_time();
 
10550                 return(time_for_scan);
 
10553         return(ranges + (
double) rows / (
double) total_rows * time_for_scan);
 
10563         return(innobase_buffer_pool_size);
 
10577 innobase_get_mysql_key_number_for_index(
 
10581         const TABLE*            table,  
 
10595         if (index->
table != ib_table) {
 
10597                 ind = dict_table_get_first_index(index->
table);
 
10599                 while (index != ind) {
 
10600                         ind = dict_table_get_next_index(ind);
 
10624                         sql_print_error(
"Cannot find index %s in InnoDB index " 
10625                                         "translation table.", index->
name);
 
10633         for (i = 0; i < table->s->keys; i++) {
 
10635                         ib_table, table->key_info[i].
name);
 
10637                 if (index == ind) {
 
10643         for (ind = dict_table_get_first_index(ib_table);
 
10645              ind = dict_table_get_next_index(ind)) {
 
10646                 if (index == ind) {
 
10652                                         "Find index %s in InnoDB index list " 
10653                                         "but not its MySQL index number " 
10654                                         "It could be an InnoDB internal index.",
 
10672 innodb_rec_per_key(
 
10679         ha_rows         rec_per_key;
 
10680         ib_uint64_t     n_diff;
 
10690                 rec_per_key = records;
 
10691         } 
else if (srv_innodb_stats_method == SRV_STATS_NULLS_IGNORED) {
 
10692                 ib_uint64_t     n_null;
 
10693                 ib_uint64_t     n_non_null;
 
10695                 n_non_null = index->stat_n_non_null_key_vals[
i];
 
10702                 if (records < n_non_null) {
 
10705                         n_null = records - n_non_null;
 
10712                 if (n_diff <= n_null) {
 
10717                         rec_per_key = (ha_rows)
 
10718                                 ((records - n_null) / (n_diff - n_null));
 
10721                 DEBUG_SYNC_C(
"after_checking_for_0");
 
10722                 rec_per_key = (ha_rows) (records / n_diff);
 
10725         return(rec_per_key);
 
10734 ha_innobase::info_low(
 
10740         ha_rows         rec_per_key;
 
10741         ib_uint64_t     n_rows;
 
10742         char            path[FN_REFLEN];
 
10745         DBUG_ENTER(
"info");
 
10755         update_thd(ha_thd());
 
10760         prebuilt->
trx->
op_info = (
char*)
"returning various info to MySQL";
 
10764         ib_table = prebuilt->
table;
 
10767         if (flag & HA_STATUS_TIME) {
 
10768                 if (is_analyze || innobase_stats_on_metadata) {
 
10770                         dict_stats_upd_option_t opt;
 
10773                         prebuilt->
trx->
op_info = 
"updating table statistics";
 
10778                                         opt = DICT_STATS_RECALC_PERSISTENT;
 
10782                                         opt = DICT_STATS_FETCH_ONLY_IF_NOT_IN_MEMORY;
 
10785                                 opt = DICT_STATS_RECALC_TRANSIENT;
 
10791                         if (ret != DB_SUCCESS) {
 
10793                                 DBUG_RETURN(HA_ERR_GENERIC);
 
10797                                 "returning various info to MySQL";
 
10800                 my_snprintf(path, 
sizeof(path), 
"%s/%s%s",
 
10801                             mysql_data_home, ib_table->
name, reg_ext);
 
10803                 unpack_filename(path,path);
 
10809                         stats.create_time = (ulong) stat_info.
ctime;
 
10813         if (flag & HA_STATUS_VARIABLE) {
 
10816                 ulint   stat_clustered_index_size;
 
10817                 ulint   stat_sum_of_other_index_sizes;
 
10819                 if (!(flag & HA_STATUS_NO_LOCK)) {
 
10827                 stat_clustered_index_size
 
10830                 stat_sum_of_other_index_sizes
 
10833                 if (!(flag & HA_STATUS_NO_LOCK)) {
 
10847                 if (n_rows == 0 && !(flag & HA_STATUS_TIME)) {
 
10855                 if (thd_sql_command(user_thd) == SQLCOM_TRUNCATE) {
 
10869                 if (page_size == 0) {
 
10870                         page_size = UNIV_PAGE_SIZE;
 
10873                 stats.records = (ha_rows) n_rows;
 
10875                 stats.data_file_length
 
10876                         = ((ulonglong) stat_clustered_index_size)
 
10878                 stats.index_file_length
 
10879                         = ((ulonglong) stat_sum_of_other_index_sizes)
 
10887                 if (flag & HA_STATUS_NO_LOCK
 
10888                     || !(flag & HA_STATUS_VARIABLE_EXTRA)) {
 
10895                 } 
else if (UNIV_UNLIKELY
 
10899                         stats.delete_length = 0;
 
10901                         ullint  avail_space;
 
10906                         if (avail_space == ULLINT_UNDEFINED) {
 
10908                                 char    errbuf[MYSYS_STRERROR_SIZE];
 
10912                                 push_warning_printf(
 
10914                                         Sql_condition::WARN_LEVEL_WARN,
 
10916                                         "InnoDB: Trying to get the free " 
10917                                         "space for table %s but its " 
10918                                         "tablespace has been discarded or " 
10919                                         "the .ibd file is missing. Setting " 
10920                                         "the free space to zero. " 
10921                                         "(errno: %d - %s)",
 
10922                                         ib_table->
name, errno,
 
10923                                         my_strerror(errbuf, 
sizeof(errbuf),
 
10926                                 stats.delete_length = 0;
 
10928                                 stats.delete_length = avail_space * 1024;
 
10932                 stats.check_time = 0;
 
10935                 if (
stats.records == 0) {
 
10936                         stats.mean_rec_length = 0;
 
10938                         stats.mean_rec_length = (ulong)
 
10943         if (flag & HA_STATUS_CONST) {
 
10950                 if (table->s->keys < num_innodb_index) {
 
10970                                         num_innodb_index--;
 
10974                         if (table->s->keys < num_innodb_index
 
10975                             && innobase_fts_check_doc_id_index(
 
10976                                     ib_table, NULL, NULL)
 
10977                             == FTS_EXIST_DOC_ID_INDEX) {
 
10978                                 num_innodb_index--;
 
10982                 if (table->s->keys != num_innodb_index) {
 
10983                         sql_print_error(
"InnoDB: Table %s contains %lu " 
10984                                         "indexes inside InnoDB, which " 
10985                                         "is different from the number of " 
10986                                         "indexes %u defined in the MySQL ",
 
10987                                         ib_table->
name, num_innodb_index,
 
10991                 if (!(flag & HA_STATUS_NO_LOCK)) {
 
10997                 for (i = 0; i < table->s->keys; i++) {
 
11006                         if (index == NULL) {
 
11007                                 sql_print_error(
"Table %s contains fewer " 
11008                                                 "indexes inside InnoDB than " 
11009                                                 "are defined in the MySQL " 
11010                                                 ".frm file. Have you mixed up " 
11011                                                 ".frm files from different " 
11012                                                 "installations? See " 
11014                                                 "innodb-troubleshooting.html\n",
 
11021                                 if (table->key_info[i].
flags & HA_FULLTEXT) {
 
11028                                 if (j + 1 > index->
n_uniq) {
 
11030                                                 "Index %s of %s has %lu columns" 
11031                                                 " unique inside InnoDB, but " 
11032                                                 "MySQL is asking statistics for" 
11033                                                 " %lu columns. Have you mixed " 
11034                                                 "up .frm files from different " 
11037                                                 "innodb-troubleshooting.html\n",
 
11045                                 rec_per_key = innodb_rec_per_key(
 
11046                                         index, j, 
stats.records);
 
11053                                 rec_per_key = rec_per_key / 2;
 
11055                                 if (rec_per_key == 0) {
 
11060                                   rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
 
11061                                   (ulong) rec_per_key;
 
11065                 if (!(flag & HA_STATUS_NO_LOCK)) {
 
11075         if (flag & HA_STATUS_ERRKEY) {
 
11079                 ut_a(prebuilt->
trx->magic_n == TRX_MAGIC_N);
 
11084                         errkey = innobase_get_mysql_key_number_for_index(
 
11085                                         share, table, ib_table, err_index);
 
11087                         errkey = (
unsigned int) (
 
11089                                  == ULINT_UNDEFINED)
 
11095         if ((flag & HA_STATUS_AUTO) && table->found_next_number_field) {
 
11096                 stats.auto_increment_value = innobase_peek_autoinc();
 
11115         return(this->info_low(flag, 
false ));
 
11124 ha_innobase::analyze(
 
11133         ret = this->info_low(
 
11134                 HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE,
 
11138                 return(HA_ADMIN_FAILED);
 
11141         return(HA_ADMIN_OK);
 
11149 ha_innobase::optimize(
 
11163         if (innodb_optimize_fulltext_only) {
 
11168                 return(HA_ADMIN_OK);
 
11171                 return(HA_ADMIN_TRY_ALTER);
 
11182 ha_innobase::check(
 
11190         ulint           n_rows_in_table = ULINT_UNDEFINED;
 
11191         ibool           
is_ok           = TRUE;
 
11192         ulint           old_isolation_level;
 
11193         ibool           table_corrupted;
 
11195         DBUG_ENTER(
"ha_innobase::check");
 
11196         DBUG_ASSERT(thd == ha_thd());
 
11198         ut_a(prebuilt->
trx->magic_n == TRX_MAGIC_N);
 
11199         ut_a(prebuilt->
trx == thd_to_trx(thd));
 
11205                 build_template(
true);
 
11212                         IB_LOG_LEVEL_ERROR,
 
11213                         ER_TABLESPACE_DISCARDED,
 
11214                         table->s->table_name.str);
 
11216                 DBUG_RETURN(HA_ADMIN_CORRUPT);
 
11221                         thd, IB_LOG_LEVEL_ERROR,
 
11222                         ER_TABLESPACE_MISSING,
 
11223                         table->s->table_name.str);
 
11225                 DBUG_RETURN(HA_ADMIN_CORRUPT);
 
11250                 srv_fatal_semaphore_wait_threshold,
 
11251                 SRV_SEMAPHORE_WAIT_EXTENSION);
 
11253         for (index = dict_table_get_first_index(prebuilt->
table);
 
11255              index = dict_table_get_next_index(index)) {
 
11256                 char    index_name[MAX_FULL_NAME_LEN + 1];
 
11265                                 index_name, 
sizeof index_name,
 
11266                                 index->
name, TRUE);
 
11268                         push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
11270                                             "InnoDB: The B-tree of" 
11271                                             " index %s is corrupted.",
 
11286                                 index_name, 
sizeof index_name,
 
11290                                 push_warning_printf(
 
11292                                         Sql_condition::WARN_LEVEL_WARN,
 
11293                                         HA_ERR_INDEX_CORRUPT,
 
11294                                         "InnoDB: Index %s is marked as" 
11299                                 push_warning_printf(
 
11301                                         Sql_condition::WARN_LEVEL_WARN,
 
11302                                         HA_ERR_TABLE_DEF_CHANGED,
 
11303                                         "InnoDB: Insufficient history for" 
11321                                 index_name, 
sizeof index_name,
 
11322                                 index->
name, TRUE);
 
11324                         push_warning_printf(
 
11325                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
11327                                 "InnoDB: The B-tree of" 
11328                                 " index %s is corrupted.",
 
11332                                 index, prebuilt->
trx, 
"CHECK TABLE-check index");
 
11335                 if (thd_killed(user_thd)) {
 
11340                 fprintf(stderr, 
"%lu entries in index %s\n", n_rows,
 
11344                 if (index == dict_table_get_first_index(prebuilt->
table)) {
 
11345                         n_rows_in_table = n_rows;
 
11346                 } 
else if (!(index->
type & DICT_FTS)
 
11347                            && (n_rows != n_rows_in_table)) {
 
11348                         push_warning_printf(
 
11349                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
11351                                 "InnoDB: Index '%-.200s' contains %lu" 
11352                                 " entries, should be %lu.",
 
11355                                 (ulong) n_rows_in_table);
 
11358                                 index, prebuilt->
trx,
 
11359                                 "CHECK TABLE; Wrong count");
 
11363         if (table_corrupted) {
 
11367                 index = dict_table_get_first_index(prebuilt->
table);
 
11371                                 index, prebuilt->
trx, 
"CHECK TABLE");
 
11382         if (!btr_search_validate()) {
 
11383                 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
 
11385                              "InnoDB: The adaptive hash index is corrupted.");
 
11390         os_decrement_counter_by_amount(
 
11392                 srv_fatal_semaphore_wait_threshold,
 
11393                 SRV_SEMAPHORE_WAIT_EXTENSION);
 
11396         if (thd_killed(user_thd)) {
 
11397                 my_error(ER_QUERY_INTERRUPTED, MYF(0));
 
11400         DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
 
11410 ha_innobase::update_table_comment(
 
11412         const char*     comment)
 
11414         uint    length = (uint) strlen(comment);
 
11422         if (length > 64000 - 3) {
 
11423                 return((
char*) comment); 
 
11426         update_thd(ha_thd());
 
11428         prebuilt->
trx->
op_info = (
char*)
"returning table comment";
 
11456                 } 
else if (length + flen + 3 > 64000) {
 
11457                         flen = 64000 - 3 - length;
 
11463                 str = (
char*) my_malloc(length + flen + 3, MYF(0));
 
11466                         char* pos       = str + length;
 
11468                                 memcpy(str, comment, length);
 
11482         return(str ? str : (
char*) comment);
 
11492 ha_innobase::get_foreign_key_create_info(
void)
 
11498         ut_a(prebuilt != NULL);
 
11504         update_thd(ha_thd());
 
11506         prebuilt->
trx->
op_info = (
char*)
"getting info on foreign keys";
 
11534                 str = (
char*) my_malloc(flen + 1, MYF(0));
 
11554 get_foreign_key_info(
 
11563         char                    tmp_buff[NAME_LEN+1];
 
11564         char                    name_buff[NAME_LEN+1];
 
11571                                                     (uint) strlen(ptr), 1);
 
11577         ut_a(len < 
sizeof(tmp_buff));
 
11581         len = filename_to_tablename(tmp_buff, name_buff, 
sizeof(name_buff));
 
11586         len = filename_to_tablename(ptr, name_buff, 
sizeof(name_buff));
 
11591         ut_a(len < 
sizeof(tmp_buff));
 
11595         len = filename_to_tablename(tmp_buff, name_buff, 
sizeof(name_buff));
 
11600         len = filename_to_tablename(ptr, name_buff, 
sizeof(name_buff));
 
11606                                            (uint) strlen(ptr), 1);
 
11607                 f_key_info.foreign_fields.push_back(name);
 
11610                                            (uint) strlen(ptr), 1);
 
11611                 f_key_info.referenced_fields.push_back(name);
 
11612         } 
while (++i < foreign->n_fields);
 
11629                                                        f_key_info.delete_method,
 
11647                                                        f_key_info.update_method,
 
11652                                         f_key_info.referenced_key_name,
 
11657                 referenced_key_name = NULL;
 
11660         f_key_info.referenced_key_name = referenced_key_name;
 
11665         return(pf_key_info);
 
11676         List<FOREIGN_KEY_INFO>* f_key_list)     
 
11681         ut_a(prebuilt != NULL);
 
11682         update_thd(ha_thd());
 
11684         prebuilt->
trx->
op_info = 
"getting list of foreign keys";
 
11693                 pf_key_info = get_foreign_key_info(thd, foreign);
 
11695                         f_key_list->push_back(pf_key_info);
 
11714         List<FOREIGN_KEY_INFO>* f_key_list)     
 
11719         ut_a(prebuilt != NULL);
 
11720         update_thd(ha_thd());
 
11722         prebuilt->
trx->
op_info = 
"getting list of referencing foreign keys";
 
11731                 pf_key_info = get_foreign_key_info(thd, foreign);
 
11733                         f_key_list->push_back(pf_key_info);
 
11756         DBUG_ENTER(
"ha_innobase::can_switch_engines");
 
11760                         "determining if there are foreign key constraints";
 
11761         row_mysql_freeze_data_dictionary(prebuilt->
trx);
 
11769         DBUG_RETURN(can_switch);
 
11780 ha_innobase::referenced_by_foreign_key(
void)
 
11796 ha_innobase::free_foreign_key_create_info(
 
11810 ha_innobase::extra(
 
11812         enum ha_extra_function operation)
 
11815         check_trx_exists(ha_thd());
 
11821         switch (operation) {
 
11822         case HA_EXTRA_FLUSH:
 
11827         case HA_EXTRA_RESET_STATE:
 
11829                 thd_to_trx(ha_thd())->duplicates = 0;
 
11831         case HA_EXTRA_NO_KEYREAD:
 
11834         case HA_EXTRA_KEYREAD:
 
11837         case HA_EXTRA_KEYREAD_PRESERVE_FIELDS:
 
11847         case HA_EXTRA_INSERT_WITH_UPDATE:
 
11848                 thd_to_trx(ha_thd())->duplicates |= TRX_DUP_IGNORE;
 
11850         case HA_EXTRA_NO_IGNORE_DUP_KEY:
 
11851                 thd_to_trx(ha_thd())->duplicates &= ~TRX_DUP_IGNORE;
 
11853         case HA_EXTRA_WRITE_CAN_REPLACE:
 
11854                 thd_to_trx(ha_thd())->duplicates |= TRX_DUP_REPLACE;
 
11856         case HA_EXTRA_WRITE_CANNOT_REPLACE:
 
11857                 thd_to_trx(ha_thd())->duplicates &= ~TRX_DUP_REPLACE;
 
11903 ha_innobase::start_stmt(
 
11906         thr_lock_type   lock_type)
 
11912         trx = prebuilt->
trx;
 
11923         innobase_srv_conc_force_exit_innodb(trx);
 
11941                    && thd_sql_command(thd) == SQLCOM_SELECT
 
11942                    && lock_type == TL_READ) {
 
11963         innobase_register_trx(ht, thd, trx);
 
11965         if (!trx_is_started(trx)) {
 
11977 innobase_map_isolation_level(
 
11979         enum_tx_isolation       iso)    
 
11982         case ISO_REPEATABLE_READ:       
return(TRX_ISO_REPEATABLE_READ);
 
11983         case ISO_READ_COMMITTED:        
return(TRX_ISO_READ_COMMITTED);
 
11984         case ISO_SERIALIZABLE:          
return(TRX_ISO_SERIALIZABLE);
 
11985         case ISO_READ_UNCOMMITTED:      
return(TRX_ISO_READ_UNCOMMITTED);
 
12004 ha_innobase::external_lock(
 
12011         DBUG_ENTER(
"ha_innobase::external_lock");
 
12012         DBUG_PRINT(
"enter",(
"lock_type: %d", lock_type));
 
12023         if (lock_type == F_WRLCK
 
12025             && thd_binlog_format(thd) == BINLOG_FORMAT_STMT
 
12026             && thd_binlog_filter_ok(thd)
 
12027             && thd_sqlcom_can_generate_row_events(thd)) {
 
12030                 DBUG_EXECUTE_IF(
"no_innodb_binlog_errors", skip = 
true;);
 
12032                         my_error(ER_BINLOG_STMT_MODE_AND_ROW_ENGINE, MYF(0),
 
12033                                  " InnoDB is limited to row-logging when " 
12034                                  "transaction isolation level is " 
12035                                  "READ COMMITTED or READ UNCOMMITTED.");
 
12036                         DBUG_RETURN(HA_ERR_LOGGING_IMPOSSIBLE);
 
12042             && (thd_sql_command(thd) == SQLCOM_UPDATE
 
12043                 || thd_sql_command(thd) == SQLCOM_INSERT
 
12044                 || thd_sql_command(thd) == SQLCOM_REPLACE
 
12045                 || thd_sql_command(thd) == SQLCOM_DROP_TABLE
 
12046                 || thd_sql_command(thd) == SQLCOM_ALTER_TABLE
 
12047                 || thd_sql_command(thd) == SQLCOM_OPTIMIZE
 
12048                 || (thd_sql_command(thd) == SQLCOM_CREATE_TABLE
 
12049                     && lock_type == F_WRLCK)
 
12050                 || thd_sql_command(thd) == SQLCOM_CREATE_INDEX
 
12051                 || thd_sql_command(thd) == SQLCOM_DROP_INDEX
 
12052                 || thd_sql_command(thd) == SQLCOM_DELETE)) {
 
12054                 if (thd_sql_command(thd) == SQLCOM_CREATE_TABLE)
 
12057                                     ER_INNODB_READ_ONLY);
 
12058                         DBUG_RETURN(HA_ERR_INNODB_READ_ONLY);
 
12061                                     ER_READ_ONLY_MODE);
 
12062                         DBUG_RETURN(HA_ERR_TABLE_READONLY);
 
12067         trx = prebuilt->
trx;
 
12078                     && thd_sql_command(thd) == SQLCOM_FLUSH
 
12079                     && lock_type == F_RDLCK) {
 
12109         if (lock_type == F_WRLCK) {
 
12117         if (lock_type != F_UNLCK) {
 
12122                 innobase_register_trx(ht, thd, trx);
 
12126                     && thd_test_options(
 
12127                             thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
12154                         if (thd_sql_command(thd) == SQLCOM_LOCK_TABLES
 
12155                             && THDVAR(thd, table_locks)
 
12156                             && thd_test_options(thd, OPTION_NOT_AUTOCOMMIT)
 
12157                             && thd_in_lock_tables(thd)) {
 
12160                                         prebuilt, NULL, 0);
 
12162                                 if (error != DB_SUCCESS) {
 
12164                                                 convert_error_code_to_mysql(
 
12175                 if (!trx_is_started(trx)
 
12196         innobase_srv_conc_force_exit_innodb(trx);
 
12206                 if (!thd_test_options(
 
12207                                 thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
12209                         if (trx_is_started(trx)) {
 
12210                                 innobase_commit(ht, thd, TRUE);
 
12223         if (!trx_is_started(trx)
 
12239 ha_innobase::transactional_table_lock(
 
12246         DBUG_ENTER(
"ha_innobase::transactional_table_lock");
 
12247         DBUG_PRINT(
"enter",(
"lock_type: %d", lock_type));
 
12255         if (!thd_tablespace_op(thd)) {
 
12260                                 thd, IB_LOG_LEVEL_ERROR,
 
12261                                 ER_TABLESPACE_DISCARDED,
 
12262                                 table->s->table_name.str);
 
12267                                 thd, IB_LOG_LEVEL_ERROR,
 
12268                                 ER_TABLESPACE_MISSING,
 
12269                                 table->s->table_name.str);
 
12272                 DBUG_RETURN(HA_ERR_CRASHED);
 
12275         trx = prebuilt->
trx;
 
12282         if (lock_type == F_WRLCK) {
 
12285         } 
else if (lock_type == F_RDLCK) {
 
12290                         "MySQL is trying to set transactional table lock " 
12291                         "with corrupted lock type to table %s, lock type " 
12292                         "%d does not exist.",
 
12293                         table->s->table_name.str, lock_type);
 
12295                 DBUG_RETURN(HA_ERR_CRASHED);
 
12300         innobase_register_trx(ht, thd, trx);
 
12302         if (THDVAR(thd, table_locks) && thd_in_lock_tables(thd)) {
 
12307                 if (error != DB_SUCCESS) {
 
12309                                 convert_error_code_to_mysql(
 
12313                 if (thd_test_options(
 
12314                         thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
12331 innodb_export_status()
 
12334         if (innodb_inited) {
 
12345 innodb_show_status(
 
12349         stat_print_fn*  stat_print)
 
12352         static const char       truncated_msg[] = 
"... truncated...\n";
 
12353         const long              MAX_STATUS_SIZE = 1048576;
 
12354         ulint                   trx_list_start = ULINT_UNDEFINED;
 
12355         ulint                   trx_list_end = ULINT_UNDEFINED;
 
12357         DBUG_ENTER(
"innodb_show_status");
 
12358         DBUG_ASSERT(hton == innodb_hton_ptr);
 
12367         trx = check_trx_exists(thd);
 
12371         innobase_srv_conc_force_exit_innodb(trx);
 
12377         ssize_t flen, usable_len;
 
12379         mutex_enter(&srv_monitor_file_mutex);
 
12383                                   &trx_list_start, &trx_list_end);
 
12391         if (flen > MAX_STATUS_SIZE) {
 
12392                 usable_len = MAX_STATUS_SIZE;
 
12393                 srv_truncated_status_writes++;
 
12401         if (!(str = (
char*) my_malloc(usable_len + 1, MYF(0)))) {
 
12402                 mutex_exit(&srv_monitor_file_mutex);
 
12408         if (flen < MAX_STATUS_SIZE) {
 
12411         } 
else if (trx_list_end < (ulint) flen
 
12412                    && trx_list_start < trx_list_end
 
12413                    && trx_list_start + (flen - trx_list_end)
 
12414                    < MAX_STATUS_SIZE - 
sizeof truncated_msg - 1) {
 
12419                 memcpy(str + len, truncated_msg, 
sizeof truncated_msg - 1);
 
12420                 len += 
sizeof truncated_msg - 1;
 
12421                 usable_len = (MAX_STATUS_SIZE - 1) - len;
 
12430         mutex_exit(&srv_monitor_file_mutex);
 
12432         stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name),
 
12433                    STRING_WITH_LEN(
""), str, flen);
 
12445 innodb_mutex_show_status(
 
12450         stat_print_fn*  stat_print)     
 
12453         char            buf1[IO_SIZE];
 
12454         char            buf2[IO_SIZE];
 
12457         ulint           block_mutex_oswait_count = 0;
 
12458         ulint           block_lock_oswait_count = 0;
 
12462         ulint           rw_lock_count= 0;
 
12463         ulint           rw_lock_count_spin_loop= 0;
 
12464         ulint           rw_lock_count_spin_rounds= 0;
 
12465         ulint           rw_lock_count_os_wait= 0;
 
12466         ulint           rw_lock_count_os_yield= 0;
 
12467         ulonglong       rw_lock_wait_time= 0;
 
12471         uint            hton_name_len;
 
12473         hton_name_len = (uint) strlen(innobase_hton_name);
 
12475         DBUG_ENTER(
"innodb_mutex_show_status");
 
12476         DBUG_ASSERT(hton == innodb_hton_ptr);
 
12487                         block_mutex = mutex;
 
12492                 buf1len= (uint) my_snprintf(buf1, 
sizeof(buf1), 
"%s:%lu",
 
12494                                      (ulong) mutex->
cline);
 
12495                 buf2len= (uint) my_snprintf(buf2, 
sizeof(buf2), 
"os_waits=%lu",
 
12498                 if (stat_print(thd, innobase_hton_name,
 
12499                                hton_name_len, buf1, buf1len,
 
12507                 buf1len = (uint) my_snprintf(buf1, 
sizeof buf1,
 
12511                                              (ulong) block_mutex->
cline);
 
12512                 buf2len = (uint) my_snprintf(buf2, 
sizeof buf2,
 
12514                                              (ulong) block_mutex_oswait_count);
 
12516                 if (stat_print(thd, innobase_hton_name,
 
12517                                hton_name_len, buf1, buf1len,
 
12526         mutex_enter(&rw_lock_list_mutex);
 
12540                 buf1len = my_snprintf(buf1, 
sizeof buf1, 
"%s:%lu",
 
12542                                      (ulong) lock->
cline);
 
12543                 buf2len = my_snprintf(buf2, 
sizeof buf2, 
"os_waits=%lu",
 
12546                 if (stat_print(thd, innobase_hton_name,
 
12547                                hton_name_len, buf1, buf1len,
 
12549                         mutex_exit(&rw_lock_list_mutex);
 
12555                 buf1len = (uint) my_snprintf(buf1, 
sizeof buf1,
 
12559                                              (ulong) block_lock->
cline);
 
12560                 buf2len = (uint) my_snprintf(buf2, 
sizeof buf2,
 
12562                                              (ulong) block_lock_oswait_count);
 
12564                 if (stat_print(thd, innobase_hton_name,
 
12565                                hton_name_len, buf1, buf1len,
 
12567                         mutex_exit(&rw_lock_list_mutex);
 
12572         mutex_exit(&rw_lock_list_mutex);
 
12575         buf2len = my_snprintf(buf2, 
sizeof buf2,
 
12576                              "count=%lu, spin_waits=%lu, spin_rounds=%lu, " 
12577                              "os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
 
12578                               (ulong) rw_lock_count,
 
12579                               (ulong) rw_lock_count_spin_loop,
 
12580                               (ulong) rw_lock_count_spin_rounds,
 
12581                               (ulong) rw_lock_count_os_wait,
 
12582                               (ulong) rw_lock_count_os_yield,
 
12583                               (ulong) (rw_lock_wait_time / 1000));
 
12585         if (stat_print(thd, innobase_hton_name, hton_name_len,
 
12586                         STRING_WITH_LEN(
"rw_lock_mutexes"), buf2, buf2len)) {
 
12600 innobase_show_status(
 
12605         stat_print_fn*          stat_print,
 
12606         enum ha_stat_type       stat_type)
 
12608         DBUG_ASSERT(hton == innodb_hton_ptr);
 
12610         switch (stat_type) {
 
12611         case HA_ENGINE_STATUS:
 
12613                 return(innodb_show_status(hton, thd, stat_print) != 0);
 
12615         case HA_ENGINE_MUTEX:
 
12617                 return(innodb_mutex_show_status(hton, thd, stat_print) != 0);
 
12619         case HA_ENGINE_LOGS:
 
12635         const char*     table_name)
 
12641         ulint   
fold = ut_fold_string(table_name);
 
12643         HASH_SEARCH(table_name_hash, innobase_open_tables, fold,
 
12650                 uint length = (uint) strlen(table_name);
 
12656                         MYF(MY_FAE | MY_ZEROFILL));
 
12658                 share->
table_name = (
char*) memcpy(share + 1,
 
12659                                                    table_name, length + 1);
 
12662                             innobase_open_tables, fold, share);
 
12664                 thr_lock_init(&share->
lock);
 
12690         ulint   fold = ut_fold_string(share->
table_name);
 
12692         HASH_SEARCH(table_name_hash, innobase_open_tables, fold,
 
12697         ut_a(share2 == share);
 
12701                 ulint   fold = ut_fold_string(share->
table_name);
 
12704                             innobase_open_tables, fold, share);
 
12705                 thr_lock_delete(&share->
lock);
 
12738         enum thr_lock_type      lock_type)      
 
12748         trx = check_trx_exists(thd);
 
12757         if (lock_type != TL_IGNORE
 
12760                         (enum_tx_isolation) thd_tx_isolation(thd));
 
12772         DBUG_ASSERT(EQ_CURRENT_THD(thd));
 
12773         const bool in_lock_tables = thd_in_lock_tables(thd);
 
12774         const uint sql_command = thd_sql_command(thd);
 
12777             && (sql_command == SQLCOM_UPDATE
 
12778                 || sql_command == SQLCOM_INSERT
 
12779                 || sql_command == SQLCOM_REPLACE
 
12780                 || sql_command == SQLCOM_DROP_TABLE
 
12781                 || sql_command == SQLCOM_ALTER_TABLE
 
12782                 || sql_command == SQLCOM_OPTIMIZE
 
12783                 || (sql_command == SQLCOM_CREATE_TABLE
 
12784                     && (lock_type >= TL_WRITE_CONCURRENT_INSERT
 
12785                          && lock_type <= TL_WRITE))
 
12786                 || sql_command == SQLCOM_CREATE_INDEX
 
12787                 || sql_command == SQLCOM_DROP_INDEX
 
12788                 || sql_command == SQLCOM_DELETE)) {
 
12791                             IB_LOG_LEVEL_WARN, ER_READ_ONLY_MODE);
 
12793         } 
else if (sql_command == SQLCOM_FLUSH
 
12794                    && lock_type == TL_READ_NO_INSERT) {
 
12817         } 
else if (sql_command == SQLCOM_DROP_TABLE) {
 
12824         } 
else if ((lock_type == TL_READ && in_lock_tables)
 
12825                    || (lock_type == TL_READ_HIGH_PRIORITY && in_lock_tables)
 
12826                    || lock_type == TL_READ_WITH_SHARED_LOCKS
 
12827                    || lock_type == TL_READ_NO_INSERT
 
12828                    || (lock_type != TL_IGNORE
 
12829                        && sql_command != SQLCOM_SELECT)) {
 
12851                 if (sql_command == SQLCOM_CHECKSUM
 
12855                         && (lock_type == TL_READ
 
12856                             || lock_type == TL_READ_NO_INSERT)
 
12857                         && (sql_command == SQLCOM_INSERT_SELECT
 
12858                             || sql_command == SQLCOM_REPLACE_SELECT
 
12859                             || sql_command == SQLCOM_UPDATE
 
12860                             || sql_command == SQLCOM_CREATE_TABLE))) {
 
12879         } 
else if (lock_type != TL_IGNORE) {
 
12888         if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) {
 
12898                 if (lock_type == TL_READ
 
12899                     && sql_command == SQLCOM_LOCK_TABLES) {
 
12911                         lock_type = TL_READ_NO_INSERT;
 
12924                 if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
 
12925                      && lock_type <= TL_WRITE)
 
12926                     && !(in_lock_tables
 
12927                          && sql_command == SQLCOM_LOCK_TABLES)
 
12928                     && !thd_tablespace_op(thd)
 
12929                     && sql_command != SQLCOM_TRUNCATE
 
12930                     && sql_command != SQLCOM_OPTIMIZE
 
12931                     && sql_command != SQLCOM_CREATE_TABLE) {
 
12933                         lock_type = TL_WRITE_ALLOW_WRITE;
 
12946                 if (lock_type == TL_READ_NO_INSERT
 
12947                     && sql_command != SQLCOM_LOCK_TABLES) {
 
12949                         lock_type = TL_READ;
 
12952                 lock.type = lock_type;
 
12957         if (!trx_is_started(trx)
 
12974 ha_innobase::innobase_get_autoinc(
 
13003 ha_innobase::innobase_peek_autoinc(
void)
 
13006         ulonglong       auto_inc;
 
13009         ut_a(prebuilt != NULL);
 
13012         innodb_table = prebuilt->
table;
 
13018         if (auto_inc == 0) {
 
13020                 fprintf(stderr, 
"  InnoDB: AUTOINC next value generation " 
13021                         "is disabled for '%s'\n", innodb_table->
name);
 
13036         ulonglong       increment,              
 
13038         ulonglong       nb_desired_values,      
 
13040         ulonglong*      first_value,            
 
13041         ulonglong*      nb_reserved_values)     
 
13046         ulonglong       autoinc = 0;
 
13049         update_thd(ha_thd());
 
13051         error = innobase_get_autoinc(&autoinc);
 
13053         if (error != DB_SUCCESS) {
 
13054                 *first_value = (~(ulonglong) 0);
 
13066         trx = prebuilt->
trx;
 
13076                 table->next_number_field);
 
13085                 if (nb_desired_values == 0) {
 
13090                 set_if_bigger(*first_value, autoinc);
 
13093                 set_if_bigger(*first_value, autoinc);
 
13095         } 
else if (*first_value > col_max_value && trx->
n_autoinc_rows > 0) {
 
13105         if (innobase_autoinc_lock_mode != AUTOINC_OLD_STYLE_LOCKING) {
 
13107                 ulonglong       next_value;
 
13109                 current = *first_value > col_max_value ? autoinc : *first_value;
 
13113                         current, *nb_reserved_values, increment, offset,
 
13119                         *first_value = (~(ulonglong) 0);
 
13153         DBUG_ENTER(
"ha_innobase::reset_auto_increment");
 
13157         update_thd(ha_thd());
 
13161         if (error != DB_SUCCESS) {
 
13162                 DBUG_RETURN(convert_error_code_to_mysql(
 
13171         innobase_reset_autoinc(value);
 
13185         trx_t*  trx = check_trx_exists(ha_thd());
 
13188                 system_charset_info);
 
13214         char*   child_table_name,
 
13215         uint    child_table_name_len,
 
13216         char*   child_key_name,
 
13217         uint    child_key_name_len)
 
13222         ut_a(prebuilt->
trx->magic_n == TRX_MAGIC_N);
 
13226         if (err_index == NULL) {
 
13234         p = strchr(err_index->
table->
name, 
'/');
 
13242         len = filename_to_tablename(p, child_table_name, child_table_name_len);
 
13243         child_table_name[len] = 
'\0';
 
13246         ut_snprintf(child_key_name, child_key_name_len, 
"%s", err_index->
name);
 
13258 ha_innobase::cmp_ref(
 
13265         enum_field_types mysql_type;
 
13276                 return(memcmp(ref1, ref2, DATA_ROW_ID_LEN));
 
13282         key_part = table->key_info[table->s->primary_key].key_part;
 
13284         key_part_end = key_part
 
13287         for (; key_part != key_part_end; ++key_part) {
 
13288                 field = key_part->field;
 
13289                 mysql_type = field->type();
 
13291                 if (mysql_type == MYSQL_TYPE_TINY_BLOB
 
13292                         || mysql_type == MYSQL_TYPE_MEDIUM_BLOB
 
13293                         || mysql_type == MYSQL_TYPE_BLOB
 
13294                         || mysql_type == MYSQL_TYPE_LONG_BLOB) {
 
13299                         len1 = innobase_read_from_2_little_endian(ref1);
 
13300                         len2 = innobase_read_from_2_little_endian(ref2);
 
13305                                 ref1, len1, ref2, len2);
 
13307                         result = field->key_cmp(ref1, ref2);
 
13315                 ref1 += key_part->store_length;
 
13316                 ref2 += key_part->store_length;
 
13334         qc_engine_callback*
 
13338         ulonglong       *engine_data)   
 
13340         *call_back = innobase_query_caching_of_table_permitted;
 
13342         return(innobase_query_caching_of_table_permitted(thd, table_key,
 
13351 ha_innobase::get_mysql_bin_log_name()
 
13361 ha_innobase::get_mysql_bin_log_pos()
 
13391         charset = get_charset((uint) charset_id, MYF(MY_WME));
 
13394         ut_ad(charset->mbmaxlen);
 
13398         n_chars = prefix_len / charset->mbmaxlen;
 
13405         if (charset->mbmaxlen > 1) {
 
13424                 char_length = my_charpos(charset, str,
 
13425                                                 str + data_len, (
int) n_chars);
 
13426                 if (char_length > data_len) {
 
13427                         char_length = data_len;
 
13430                 if (data_len < prefix_len) {
 
13431                         char_length = data_len;
 
13433                         char_length = prefix_len;
 
13437         return(char_length);
 
13445 innobase_xa_prepare(
 
13456         trx_t*          trx = check_trx_exists(thd);
 
13458         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13476         innobase_srv_conc_force_exit_innodb(trx);
 
13478         if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
 
13480                 sql_print_error(
"Transaction not registered for MySQL 2PC, " 
13481                                 "but transaction is active");
 
13485             || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
 
13490                 ut_ad(trx_is_registered_for_2pc(trx));
 
13516         if (thd_sql_command(thd) != SQLCOM_XA_PREPARE
 
13518                 || !thd_test_options(
 
13519                         thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
 
13542 innobase_xa_recover(
 
13548         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13550         if (len == 0 || xid_list == NULL) {
 
13564 innobase_commit_by_xid(
 
13571         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13576                 innobase_commit_low(trx);
 
13590 innobase_rollback_by_xid(
 
13598         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13603                 int     ret = innobase_rollback_trx(trx);
 
13619 innobase_create_cursor_view(
 
13624         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13635 innobase_close_cursor_view(
 
13641         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13654 innobase_set_cursor_view(
 
13660         DBUG_ASSERT(hton == innodb_hton_ptr);
 
13673         uint            table_changes)
 
13677         if (table_changes != IS_EQUAL_YES) {
 
13679                 return(COMPATIBLE_DATA_NO);
 
13683         if ((info->used_fields & HA_CREATE_USED_AUTO) &&
 
13684                 info->auto_increment_value != 0) {
 
13686                 return(COMPATIBLE_DATA_NO);
 
13690         if ((info->used_fields & HA_CREATE_USED_ROW_FORMAT)
 
13693                 return(COMPATIBLE_DATA_NO);
 
13697         if (info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE) {
 
13698                 return(COMPATIBLE_DATA_NO);
 
13701         return(COMPATIBLE_DATA_YES);
 
13709 innodb_io_capacity_max_update(
 
13719         ulong   in_val = *
static_cast<const ulong*
>(save);
 
13720         if (in_val < srv_io_capacity) {
 
13721                 in_val = srv_io_capacity;
 
13722                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13723                                     ER_WRONG_ARGUMENTS,
 
13724                                     "innodb_io_capacity_max cannot be" 
13725                                     " set lower than innodb_io_capacity.");
 
13726                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13727                                     ER_WRONG_ARGUMENTS,
 
13728                                     "Setting innodb_io_capacity_max to %lu",
 
13732         srv_max_io_capacity = in_val;
 
13740 innodb_io_capacity_update(
 
13750         ulong   in_val = *
static_cast<const ulong*
>(save);
 
13751         if (in_val > srv_max_io_capacity) {
 
13752                 in_val = srv_max_io_capacity;
 
13753                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13754                                     ER_WRONG_ARGUMENTS,
 
13755                                     "innodb_io_capacity cannot be set" 
13756                                     " higher than innodb_io_capacity_max.");
 
13757                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13758                                     ER_WRONG_ARGUMENTS,
 
13759                                     "Setting innodb_io_capacity to %lu",
 
13760                                     srv_max_io_capacity);
 
13763         srv_io_capacity = in_val;
 
13771 innodb_max_dirty_pages_pct_update(
 
13781         ulong   in_val = *
static_cast<const ulong*
>(save);
 
13782         if (in_val < srv_max_dirty_pages_pct_lwm) {
 
13783                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13784                                     ER_WRONG_ARGUMENTS,
 
13785                                     "innodb_max_dirty_pages_pct cannot be" 
13787                                     " innodb_max_dirty_pages_pct_lwm.");
 
13788                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13789                                     ER_WRONG_ARGUMENTS,
 
13791                                     " innodb_max_dirty_page_pct_lwm to %lu",
 
13794                 srv_max_dirty_pages_pct_lwm = in_val;
 
13797         srv_max_buf_pool_modified_pct = in_val;
 
13805 innodb_max_dirty_pages_pct_lwm_update(
 
13815         ulong   in_val = *
static_cast<const ulong*
>(save);
 
13816         if (in_val > srv_max_buf_pool_modified_pct) {
 
13817                 in_val = srv_max_buf_pool_modified_pct;
 
13818                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13819                                     ER_WRONG_ARGUMENTS,
 
13820                                     "innodb_max_dirty_pages_pct_lwm" 
13821                                     " cannot be set higher than" 
13822                                     " innodb_max_dirty_pages_pct.");
 
13823                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
13824                                     ER_WRONG_ARGUMENTS,
 
13825                                     "Setting innodb_max_dirty_page_pct_lwm" 
13830         srv_max_dirty_pages_pct_lwm = in_val;
 
13838 innobase_file_format_name_lookup(
 
13840         const char*     format_name)    
 
13845         ut_a(format_name != NULL);
 
13849         format_id = (uint) strtoul(format_name, &endp, 10);
 
13852         if (*endp == 
'\0' && *format_name != 
'\0') {
 
13854                 if (format_id <= UNIV_FORMAT_MAX) {
 
13860                 for (format_id = 0; format_id <= UNIV_FORMAT_MAX;
 
13873         return(UNIV_FORMAT_MAX + 1);
 
13882 innobase_file_format_validate_and_set(
 
13884         const char*     format_max)     
 
13888         format_id = innobase_file_format_name_lookup(format_max);
 
13890         if (format_id < UNIV_FORMAT_MAX + 1) {
 
13893                 return((
int) format_id);
 
13905 innodb_file_format_name_validate(
 
13914         const char*     file_format_input;
 
13915         char            buff[STRING_BUFFER_USUAL_SIZE];
 
13916         int             len = 
sizeof(buff);
 
13918         ut_a(save != NULL);
 
13919         ut_a(value != NULL);
 
13921         file_format_input = value->val_str(value, buff, &len);
 
13923         if (file_format_input != NULL) {
 
13926                 format_id = innobase_file_format_name_lookup(
 
13927                         file_format_input);
 
13929                 if (format_id <= UNIV_FORMAT_MAX) {
 
13933                         *
static_cast<const char**
>(save) =
 
13940         *
static_cast<const char**
>(save) = NULL;
 
13949 innodb_file_format_name_update(
 
13959         const char* format_name;
 
13961         ut_a(var_ptr != NULL);
 
13962         ut_a(save != NULL);
 
13964         format_name = *
static_cast<const char*const*
>(save);
 
13969                 format_id = innobase_file_format_name_lookup(format_name);
 
13971                 if (format_id <= UNIV_FORMAT_MAX) {
 
13976         *
static_cast<const char**
>(var_ptr)
 
13986 innodb_file_format_max_validate(
 
13995         const char*     file_format_input;
 
13996         char            buff[STRING_BUFFER_USUAL_SIZE];
 
13997         int             len = 
sizeof(buff);
 
14000         ut_a(save != NULL);
 
14001         ut_a(value != NULL);
 
14003         file_format_input = value->val_str(value, buff, &len);
 
14005         if (file_format_input != NULL) {
 
14007                 format_id = innobase_file_format_validate_and_set(
 
14008                         file_format_input);
 
14010                 if (format_id >= 0) {
 
14013                         *
static_cast<const char**
>(save) =
 
14020                         push_warning_printf(thd,
 
14021                           Sql_condition::WARN_LEVEL_WARN,
 
14022                           ER_WRONG_ARGUMENTS,
 
14023                           "InnoDB: invalid innodb_file_format_max " 
14024                           "value; can be any format up to %s " 
14025                           "or equivalent id of %d",
 
14031         *
static_cast<const char**
>(save) = NULL;
 
14040 innodb_file_format_max_update(
 
14050         const char*     format_name_in;
 
14051         const char**    format_name_out;
 
14054         ut_a(save != NULL);
 
14055         ut_a(var_ptr != NULL);
 
14057         format_name_in = *
static_cast<const char*const*
>(save);
 
14059         if (!format_name_in) {
 
14064         format_id = innobase_file_format_name_lookup(format_name_in);
 
14066         if (format_id > UNIV_FORMAT_MAX) {
 
14068                 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
 
14069                                     ER_WRONG_ARGUMENTS,
 
14070                                     "Ignoring SET innodb_file_format=%s",
 
14075         format_name_out = 
static_cast<const char**
>(var_ptr);
 
14081                         " [Info] InnoDB: the file format in the system " 
14082                         "tablespace is now set to %s.\n", *format_name_out);
 
14092 innodb_stopword_table_validate(
 
14101         const char*     stopword_table_name;
 
14102         char            buff[STRING_BUFFER_USUAL_SIZE];
 
14103         int             len = 
sizeof(buff);
 
14107         ut_a(save != NULL);
 
14108         ut_a(value != NULL);
 
14110         stopword_table_name = value->val_str(value, buff, &len);
 
14112         trx = check_trx_exists(thd);
 
14114         row_mysql_lock_data_dictionary(trx);
 
14118         if (!stopword_table_name
 
14120                 *
static_cast<const char**
>(save) = stopword_table_name;
 
14135 innodb_stopword_table_update(
 
14145         const char*     stopword_table_name;
 
14148         ut_a(save != NULL);
 
14149         ut_a(var_ptr != NULL);
 
14151         stopword_table_name = *
static_cast<const char*const*
>(save);
 
14152         old = *(
char**) var_ptr;
 
14154         if (stopword_table_name) {
 
14155                 *(
char**) var_ptr =  my_strdup(stopword_table_name,  MYF(0));
 
14157                 *(
char**) var_ptr = NULL;
 
14164         fts_server_stopword_table = *(
char**) var_ptr;
 
14173 innodb_internal_table_validate(
 
14183         char            buff[STRING_BUFFER_USUAL_SIZE];
 
14184         int             len = 
sizeof(buff);
 
14188         ut_a(save != NULL);
 
14189         ut_a(value != NULL);
 
14191         table_name = value->val_str(value, buff, &len);
 
14194                 *
static_cast<const char**
>(save) = NULL;
 
14203                         *
static_cast<const char**
>(save) = table_name;
 
14219 innodb_internal_table_update(
 
14232         ut_a(save != NULL);
 
14233         ut_a(var_ptr != NULL);
 
14235         table_name = *
static_cast<const char*const*
>(save);
 
14236         old = *(
char**) var_ptr;
 
14239                 *(
char**) var_ptr =  my_strdup(table_name,  MYF(0));
 
14241                 *(
char**) var_ptr = NULL;
 
14256 innodb_adaptive_hash_index_update(
 
14266         if (*(my_bool*) save) {
 
14278 innodb_cmp_per_index_update(
 
14302 innodb_old_blocks_pct_update(
 
14313                 *static_cast<const uint*>(save), TRUE);
 
14321 innodb_change_buffer_max_size_update(
 
14331         innobase_change_buffer_max_size =
 
14332                         (*
static_cast<const uint*
>(save));
 
14345 innodb_find_change_buffering_value(
 
14347         const char*     input_name)     
 
14352         for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
 
14356                         input_name, innobase_change_buffering_values[use])) {
 
14362         return(IBUF_USE_COUNT);
 
14371 innodb_change_buffering_validate(
 
14380         const char*     change_buffering_input;
 
14381         char            buff[STRING_BUFFER_USUAL_SIZE];
 
14382         int             len = 
sizeof(buff);
 
14384         ut_a(save != NULL);
 
14385         ut_a(value != NULL);
 
14387         change_buffering_input = value->val_str(value, buff, &len);
 
14389         if (change_buffering_input != NULL) {
 
14392                 use = innodb_find_change_buffering_value(
 
14393                         change_buffering_input);
 
14395                 if (use != IBUF_USE_COUNT) {
 
14397                         *
static_cast<const char**
>(save) =
 
14398                                 innobase_change_buffering_values[use];
 
14414 innodb_change_buffering_update(
 
14426         ut_a(var_ptr != NULL);
 
14427         ut_a(save != NULL);
 
14429         use = innodb_find_change_buffering_value(
 
14430                 *static_cast<const char*const*>(save));
 
14432         ut_a(use < IBUF_USE_COUNT);
 
14435         *
static_cast<const char**
>(var_ptr) =
 
14436                  *static_cast<const char*const*>(save);
 
14444 innodb_stats_sample_pages_update(
 
14454 #define STATS_SAMPLE_PAGES_DEPRECATED_MSG \ 
14455         "Using innodb_stats_sample_pages is deprecated and " \ 
14456         "the variable may be removed in future releases. " \ 
14457         "Please use innodb_stats_transient_sample_pages " \ 
14460         push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
 
14461                      HA_ERR_WRONG_COMMAND, STATS_SAMPLE_PAGES_DEPRECATED_MSG);
 
14465                 " InnoDB: Warning: %s\n",
 
14466                 STATS_SAMPLE_PAGES_DEPRECATED_MSG);
 
14468         srv_stats_transient_sample_pages =
 
14469                 *
static_cast<const unsigned long long*
>(save);
 
14477 innodb_monitor_set_option(
 
14491         switch (set_option) {
 
14494                 MONITOR_INIT(monitor_id);
 
14495                 MONITOR_SET_START(monitor_id);
 
14514                 MONITOR_OFF(monitor_id);
 
14515                 MONITOR_SET_OFF(monitor_id);
 
14537 innodb_monitor_update_wildcard(
 
14545         for (ulint use = 0; use < NUM_MONITOR; use++) {
 
14562                                 innodb_monitor_set_option(monitor_info,
 
14570                         if (type & MONITOR_GROUP_MODULE) {
 
14571                                 if ((monitor_id >= MONITOR_MODULE_BUF_PAGE)
 
14572                                      && (monitor_id < MONITOR_MODULE_OS)) {
 
14575                                                 MONITOR_MODULE_BUF_PAGE)) {
 
14580                                                 MONITOR_MODULE_BUF_PAGE,
 
14599 innodb_monitor_id_by_name_get(
 
14610         if (strchr(name, 
'%')) {
 
14615         for (ulint i = 0; i < NUM_MONITOR; i++) {
 
14630 innodb_monitor_validate_wildcard_name(
 
14634         for (ulint i = 0; i < NUM_MONITOR; i++) {
 
14649 innodb_monitor_valid_byname(
 
14662         use = innodb_monitor_id_by_name_get(name);
 
14669         if (use < NUM_MONITOR) {
 
14677                 if ((monitor_info->
monitor_type & MONITOR_GROUP_MODULE)
 
14678                     && (!(monitor_info->
monitor_type & MONITOR_MODULE))) {
 
14680                                 "Monitor counter '%s' cannot" 
14681                                 " be turned on/off individually." 
14682                                 " Please use its module name" 
14683                                 " to turn on/off the counters" 
14684                                 " in the module as a group.\n",
 
14696                 if (!innodb_monitor_validate_wildcard_name(name)) {
 
14702         *
static_cast<const char**
>(save) = name;
 
14712 innodb_monitor_validate(
 
14722         char*           monitor_name;
 
14723         char            buff[STRING_BUFFER_USUAL_SIZE];
 
14724         int             len = 
sizeof(buff);
 
14727         ut_a(save != NULL);
 
14728         ut_a(value != NULL);
 
14730         name = value->val_str(value, buff, &len);
 
14737                 monitor_name = my_strdup(name, MYF(0));
 
14742         ret = innodb_monitor_valid_byname(save, monitor_name);
 
14746                 my_free(monitor_name);
 
14751                 ut_ad(*static_cast<char**>(save) == monitor_name);
 
14763 innodb_monitor_update(
 
14778         ulint           err_monitor = 0;
 
14781         ut_a(save != NULL);
 
14783         name = *
static_cast<const char*const*
>(save);
 
14786                 monitor_id = MONITOR_DEFAULT_START;
 
14788                 monitor_id = innodb_monitor_id_by_name_get(name);
 
14796         if (monitor_id == MONITOR_DEFAULT_START) {
 
14802                         push_warning_printf(
 
14803                                 thd, Sql_condition::WARN_LEVEL_WARN,
 
14805                                 "Default value is not defined for " 
14806                                 "this set option. Please specify " 
14807                                 "correct counter or module name.");
 
14810                                 "Default value is not defined for " 
14811                                 "this set option. Please specify " 
14812                                 "correct counter or module name.\n");
 
14816                         *(
const char**) var_ptr = NULL;
 
14819                 innodb_monitor_update_wildcard(name, set_option);
 
14822                         static_cast<monitor_id_t>(monitor_id));
 
14824                 ut_a(monitor_info);
 
14831                         err_monitor = monitor_id;
 
14844                                 static_cast<monitor_id_t>(monitor_id),
 
14847                         innodb_monitor_set_option(monitor_info, set_option);
 
14855                 sql_print_warning(
"Monitor %s is already enabled.",
 
14859         if (free_mem && name) {
 
14860                 my_free((
void*) name);
 
14875 innodb_srv_buf_dump_filename_validate(
 
14884         const char*     buf_name;
 
14885         char            buff[OS_FILE_MAX_PATH];
 
14886         int             len= 
sizeof(buff);
 
14888         ut_a(save != NULL);
 
14889         ut_a(value != NULL);
 
14891         buf_name = value->val_str(value, buff, &len);
 
14894                 if (is_filename_allowed(buf_name, len, FALSE)){
 
14895                         *
static_cast<const char**
>(save) = buf_name;
 
14898                         push_warning_printf(thd,
 
14899                                 Sql_condition::WARN_LEVEL_WARN,
 
14900                                 ER_WRONG_ARGUMENTS,
 
14901                                 "InnoDB: innodb_buffer_pool_filename " 
14902                                 "cannot have colon (:) in the file name.");
 
14910 # define innodb_srv_buf_dump_filename_validate NULL 
14914 static char* srv_buffer_pool_evict;
 
14920 static __attribute__((warn_unused_result))
 
14922 innodb_buffer_pool_evict_uncompressed(
void)
 
14925         bool    all_evicted = 
true;
 
14927         for (ulint i = 0; i < srv_buf_pool_instances; i++) {
 
14933                              buf_pool->unzip_LRU);
 
14943                                 all_evicted = 
false;
 
14946                         block = prev_block;
 
14952         return(all_evicted);
 
14962 innodb_buffer_pool_evict_update(
 
14970         if (
const char* op = *static_cast<const char*const*>(save)) {
 
14971                 if (!strcmp(op, 
"uncompressed")) {
 
14972                         for (uint tries = 0; tries < 10000; tries++) {
 
14973                                 if (innodb_buffer_pool_evict_uncompressed()) {
 
14993 innodb_enable_monitor_update(
 
15011 innodb_disable_monitor_update(
 
15030 innodb_reset_monitor_update(
 
15049 innodb_reset_all_monitor_update(
 
15071 innodb_enable_monitor_at_startup(
 
15075         static const char*      sep = 
" ;,";
 
15084         for (
char* 
option = strtok_r(str, sep, &last);
 
15086              option = strtok_r(NULL, sep, &last)) {
 
15090                 ret = innodb_monitor_valid_byname(&option_name, 
option);
 
15094                         innodb_monitor_update(NULL, NULL, &
option,
 
15097                         sql_print_warning(
"Invalid monitor counter" 
15114         innodb_export_status();
 
15115         var->type = SHOW_ARRAY;
 
15116         var->value = (
char*) &innodb_status_variables;
 
15129 innobase_index_name_is_reserved(
 
15132         const KEY*      key_info,       
 
15139         for (key_num = 0; key_num < num_of_keys; key_num++) {
 
15140                 key = &key_info[key_num];
 
15143                                         innobase_index_reserve_name) == 0) {
 
15145                         push_warning_printf(thd,
 
15146                                             Sql_condition::WARN_LEVEL_WARN,
 
15147                                             ER_WRONG_NAME_FOR_INDEX,
 
15148                                             "Cannot Create Index with name " 
15149                                             "'%s'. The name is reserved " 
15150                                             "for the system default primary " 
15152                                             innobase_index_reserve_name);
 
15154                         my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0),
 
15155                                  innobase_index_reserve_name);
 
15170 innobase_fts_retrieve_ranking(
 
15179         ft_prebuilt = ((
NEW_FT_INFO*) fts_hdl)->ft_prebuilt;
 
15184                 return(ranking->
rank);
 
15196 innobase_fts_close_ranking(
 
15202         ((
NEW_FT_INFO*) fts_hdl)->ft_prebuilt->in_fts_query = 
false;
 
15208         my_free((uchar*) fts_hdl);
 
15220 innobase_fts_find_ranking(
 
15229         ft_prebuilt = ((
NEW_FT_INFO*) fts_hdl)->ft_prebuilt;
 
15238 static my_bool  innodb_purge_run_now = TRUE;
 
15239 static my_bool  innodb_purge_stop_now = TRUE;
 
15240 static my_bool  innodb_log_checkpoint_now = TRUE;
 
15250                                         __attribute__((unused)),
 
15253                                         __attribute__((unused)),
 
15256                                         __attribute__((unused)),
 
15270 purge_stop_now_set(
 
15273                                         __attribute__((unused)),
 
15276                                         __attribute__((unused)),
 
15279                                         __attribute__((unused)),
 
15292 checkpoint_now_set(
 
15295                                         __attribute__((unused)),
 
15298                                         __attribute__((unused)),
 
15301                                         __attribute__((unused)),
 
15305         if (*(my_bool*) save) {
 
15319 innobase_fts_get_version()
 
15331 innobase_fts_flags()
 
15334         return(FTS_ORDERED_RESULT | FTS_DOCID_IN_RESULT);
 
15342 innobase_fts_retrieve_docid(
 
15349         ft_prebuilt = ((
NEW_FT_INFO *)fts_hdl)->ft_prebuilt;
 
15355                 return(ranking->
doc_id);
 
15358         return(ft_prebuilt->fts_doc_id);
 
15365 innobase_fts_count_matches(
 
15390 static my_bool  innodb_buffer_pool_dump_now = FALSE;
 
15391 static my_bool  innodb_buffer_pool_load_now = FALSE;
 
15392 static my_bool  innodb_buffer_pool_load_abort = FALSE;
 
15399 buffer_pool_dump_now(
 
15402                                         __attribute__((unused)),
 
15405                                         __attribute__((unused)),
 
15408                                         __attribute__((unused)),
 
15422 buffer_pool_load_now(
 
15425                                         __attribute__((unused)),
 
15428                                         __attribute__((unused)),
 
15431                                         __attribute__((unused)),
 
15435         if (*(my_bool*) save) {
 
15445 buffer_pool_load_abort(
 
15448                                         __attribute__((unused)),
 
15451                                         __attribute__((unused)),
 
15454                                         __attribute__((unused)),
 
15458         if (*(my_bool*) save) {
 
15463 static SHOW_VAR innodb_status_variables_export[]= {
 
15464         {
"Innodb", (
char*) &show_innodb_vars, SHOW_FUNC},
 
15465         {NullS, NullS, SHOW_LONG}
 
15469 { MYSQL_HANDLERTON_INTERFACE_VERSION };
 
15474   PLUGIN_VAR_RQCMDARG,
 
15475   "The algorithm InnoDB uses for page checksumming. Possible values are " 
15476   "CRC32 (hardware accelerated if the CPU supports it) " 
15477     "write crc32, allow any of the other checksums to match when reading; " 
15479     "write crc32, do not allow other algorithms to match when reading; " 
15481     "write a software calculated checksum, allow any other checksums " 
15482     "to match when reading; " 
15484     "write a software calculated checksum, do not allow other algorithms " 
15485     "to match when reading; " 
15487     "write a constant magic number, do not do any checksum verification " 
15488     "when reading (same as innodb_checksums=OFF); " 
15490     "write a constant magic number, do not allow values other than that " 
15491     "magic number when reading; " 
15492   "Files updated when this option is set to crc32 or strict_crc32 will " 
15493   "not be readable by MySQL versions older than 5.6.3",
 
15495   &innodb_checksum_algorithm_typelib);
 
15497 static MYSQL_SYSVAR_BOOL(checksums, innobase_use_checksums,
 
15498   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
15499   "DEPRECATED. Use innodb_checksum_algorithm=NONE instead of setting " 
15501   "Enable InnoDB checksums validation (enabled by default). " 
15502   "Disable with --skip-innodb-checksums.",
 
15505 static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
 
15506   PLUGIN_VAR_READONLY,
 
15507   "The common part for InnoDB table spaces.",
 
15510 static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
 
15511   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
15512   "Enable InnoDB doublewrite buffer (enabled by default). " 
15513   "Disable with --skip-innodb-doublewrite.",
 
15516 static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity,
 
15517   PLUGIN_VAR_RQCMDARG,
 
15518   "Number of IOPs the server can do. Tunes the background IO rate",
 
15519   NULL, innodb_io_capacity_update, 200, 100, ~0UL, 0);
 
15521 static MYSQL_SYSVAR_ULONG(io_capacity_max, srv_max_io_capacity,
 
15522   PLUGIN_VAR_RQCMDARG,
 
15523   "Limit to which innodb_io_capacity can be inflated.",
 
15524   NULL, innodb_io_capacity_max_update,
 
15525   SRV_MAX_IO_CAPACITY_DUMMY_DEFAULT, 100,
 
15526   SRV_MAX_IO_CAPACITY_LIMIT, 0);
 
15529 static MYSQL_SYSVAR_BOOL(purge_run_now, innodb_purge_run_now,
 
15530   PLUGIN_VAR_OPCMDARG,
 
15531   "Set purge state to RUN",
 
15532   NULL, purge_run_now_set, FALSE);
 
15534 static MYSQL_SYSVAR_BOOL(purge_stop_now, innodb_purge_stop_now,
 
15535   PLUGIN_VAR_OPCMDARG,
 
15536   "Set purge state to STOP",
 
15537   NULL, purge_stop_now_set, FALSE);
 
15539 static MYSQL_SYSVAR_BOOL(log_checkpoint_now, innodb_log_checkpoint_now,
 
15540   PLUGIN_VAR_OPCMDARG,
 
15541   "Force checkpoint now",
 
15542   NULL, checkpoint_now_set, FALSE);
 
15545 static MYSQL_SYSVAR_ULONG(purge_batch_size, srv_purge_batch_size,
 
15546   PLUGIN_VAR_OPCMDARG,
 
15547   "Number of UNDO log pages to purge in one batch from the history list.",
 
15553 static MYSQL_SYSVAR_ULONG(purge_threads, srv_n_purge_threads,
 
15554   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15555   "Purge threads can be from 1 to 32. Default is 1.",
 
15562   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15563   "Size of the mutex/lock wait array.",
 
15569 static MYSQL_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
 
15570   PLUGIN_VAR_OPCMDARG,
 
15571   "Speeds up the shutdown process of the InnoDB storage engine. Possible " 
15572   "values are 0, 1 (faster) or 2 (fastest - crash-like).",
 
15573   NULL, NULL, 1, 0, 2, 0);
 
15576   PLUGIN_VAR_NOCMDARG,
 
15577   "Stores each InnoDB table to an .ibd file in the database dir.",
 
15580 static MYSQL_SYSVAR_STR(file_format, innobase_file_format_name,
 
15581   PLUGIN_VAR_RQCMDARG,
 
15582   "File format to use for new tables in .ibd files.",
 
15583   innodb_file_format_name_validate,
 
15584   innodb_file_format_name_update, 
"Antelope");
 
15592 static MYSQL_SYSVAR_BOOL(file_format_check, innobase_file_format_check,
 
15593   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
15594   "Whether to perform system file format check.",
 
15601 static MYSQL_SYSVAR_STR(file_format_max, innobase_file_format_max,
 
15602   PLUGIN_VAR_OPCMDARG,
 
15603   "The highest file format in the tablespace.",
 
15604   innodb_file_format_max_validate,
 
15605   innodb_file_format_max_update, 
"Antelope");
 
15607 static MYSQL_SYSVAR_STR(ft_server_stopword_table, innobase_server_stopword_table,
 
15608   PLUGIN_VAR_OPCMDARG,
 
15609   "The user supplied stopword table name.",
 
15610   innodb_stopword_table_validate,
 
15611   innodb_stopword_table_update,
 
15614 static MYSQL_SYSVAR_UINT(flush_log_at_timeout, srv_flush_log_at_timeout,
 
15615   PLUGIN_VAR_OPCMDARG,
 
15616   "Write and flush logs every (n) second.",
 
15617   NULL, NULL, 1, 0, 2700, 0);
 
15619 static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
 
15620   PLUGIN_VAR_OPCMDARG,
 
15621   "Set to 0 (write and flush once per second)," 
15622   " 1 (write and flush at each commit)" 
15623   " or 2 (write at commit, flush once per second).",
 
15624   NULL, NULL, 1, 0, 2, 0);
 
15626 static MYSQL_SYSVAR_STR(flush_method, innobase_file_flush_method,
 
15627   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15628   "With which method to flush data.", NULL, NULL, NULL);
 
15630 static MYSQL_SYSVAR_BOOL(large_prefix, innobase_large_prefix,
 
15631   PLUGIN_VAR_NOCMDARG,
 
15632   "Support large index prefix length of REC_VERSION_56_MAX_INDEX_COL_LEN (3072) bytes.",
 
15633   NULL, NULL, FALSE);
 
15635 static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted,
 
15636   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
15637   "Force InnoDB to load metadata of corrupted table.",
 
15638   NULL, NULL, FALSE);
 
15640 static MYSQL_SYSVAR_BOOL(locks_unsafe_for_binlog, innobase_locks_unsafe_for_binlog,
 
15641   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
15642   "DEPRECATED. This option may be removed in future releases. " 
15643   "Please use READ COMMITTED transaction isolation level instead. " 
15644   "Force InnoDB to not use next-key locking, to use only row-level locking.",
 
15645   NULL, NULL, FALSE);
 
15647 #ifdef UNIV_LOG_ARCHIVE 
15648 static MYSQL_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
 
15649   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15650   "Where full logs should be archived.", NULL, NULL, NULL);
 
15652 static MYSQL_SYSVAR_BOOL(log_archive, innobase_log_archive,
 
15653   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15654   "Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
 
15657 static MYSQL_SYSVAR_STR(log_group_home_dir, srv_log_group_home_dir,
 
15658   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15659   "Path to InnoDB log files.", NULL, NULL, NULL);
 
15661 static MYSQL_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
 
15662   PLUGIN_VAR_RQCMDARG,
 
15663   "Percentage of dirty pages allowed in bufferpool.",
 
15664   NULL, innodb_max_dirty_pages_pct_update, 75, 0, 99, 0);
 
15666 static MYSQL_SYSVAR_ULONG(max_dirty_pages_pct_lwm,
 
15667   srv_max_dirty_pages_pct_lwm,
 
15668   PLUGIN_VAR_RQCMDARG,
 
15669   "Percentage of dirty pages at which flushing kicks in.",
 
15670   NULL, innodb_max_dirty_pages_pct_lwm_update, 0, 0, 99, 0);
 
15672 static MYSQL_SYSVAR_ULONG(adaptive_flushing_lwm,
 
15673   srv_adaptive_flushing_lwm,
 
15674   PLUGIN_VAR_RQCMDARG,
 
15675   "Percentage of log capacity below which no adaptive flushing happens.",
 
15676   NULL, NULL, 10, 0, 70, 0);
 
15678 static MYSQL_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
 
15679   PLUGIN_VAR_NOCMDARG,
 
15680   "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
 
15683 static MYSQL_SYSVAR_ULONG(flushing_avg_loops,
 
15684   srv_flushing_avg_loops,
 
15685   PLUGIN_VAR_RQCMDARG,
 
15686   "Number of iterations over which the background flushing is averaged.",
 
15687   NULL, NULL, 30, 1, 1000, 0);
 
15690   PLUGIN_VAR_RQCMDARG,
 
15691   "Desired maximum length of the purge queue (0 = no limit)",
 
15692   NULL, NULL, 0, 0, ~0UL, 0);
 
15695    PLUGIN_VAR_RQCMDARG,
 
15696    "Maximum delay of user threads in micro-seconds",
 
15702 static MYSQL_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
 
15703   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15704   "Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
 
15705   NULL, NULL, FALSE);
 
15707 static MYSQL_SYSVAR_BOOL(status_file, innobase_create_status_file,
 
15708   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
 
15709   "Enable SHOW ENGINE INNODB STATUS output in the innodb_status.<pid> file",
 
15710   NULL, NULL, FALSE);
 
15712 static MYSQL_SYSVAR_BOOL(stats_on_metadata, innobase_stats_on_metadata,
 
15713   PLUGIN_VAR_OPCMDARG,
 
15714   "Enable statistics gathering for metadata commands such as " 
15715   "SHOW TABLE STATUS for tables that use transient statistics (off by default)",
 
15716   NULL, NULL, FALSE);
 
15718 static MYSQL_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_transient_sample_pages,
 
15719   PLUGIN_VAR_RQCMDARG,
 
15720   "Deprecated, use innodb_stats_transient_sample_pages instead",
 
15721   NULL, innodb_stats_sample_pages_update, 8, 1, ~0ULL, 0);
 
15723 static MYSQL_SYSVAR_ULONGLONG(stats_transient_sample_pages,
 
15724   srv_stats_transient_sample_pages,
 
15725   PLUGIN_VAR_RQCMDARG,
 
15726   "The number of leaf index pages to sample when calculating transient " 
15727   "statistics (if persistent statistics are not used, default 8)",
 
15728   NULL, NULL, 8, 1, ~0ULL, 0);
 
15730 static MYSQL_SYSVAR_BOOL(stats_persistent, srv_stats_persistent,
 
15731   PLUGIN_VAR_OPCMDARG,
 
15732   "InnoDB persistent statistics enabled for all tables unless overridden " 
15736 static MYSQL_SYSVAR_BOOL(stats_auto_recalc, srv_stats_auto_recalc,
 
15737   PLUGIN_VAR_OPCMDARG,
 
15738   "InnoDB automatic recalculation of persistent statistics enabled for all " 
15739   "tables unless overridden at table level (automatic recalculation is only " 
15740   "done when InnoDB decides that the table has changed too much and needs a " 
15744 static MYSQL_SYSVAR_ULONGLONG(stats_persistent_sample_pages,
 
15745   srv_stats_persistent_sample_pages,
 
15746   PLUGIN_VAR_RQCMDARG,
 
15747   "The number of leaf index pages to sample when calculating persistent " 
15748   "statistics (by ANALYZE, default 20)",
 
15749   NULL, NULL, 20, 1, ~0ULL, 0);
 
15752   PLUGIN_VAR_OPCMDARG,
 
15753   "Enable InnoDB adaptive hash index (enabled by default).  " 
15754   "Disable with --skip-innodb-adaptive-hash-index.",
 
15755   NULL, innodb_adaptive_hash_index_update, TRUE);
 
15757 static MYSQL_SYSVAR_ULONG(replication_delay, srv_replication_delay,
 
15758   PLUGIN_VAR_RQCMDARG,
 
15759   "Replication thread delay (ms) on the slave server if " 
15760   "innodb_thread_concurrency is reached (0 by default)",
 
15761   NULL, NULL, 0, 0, ~0UL, 0);
 
15763 static MYSQL_SYSVAR_UINT(compression_level, page_zip_level,
 
15764   PLUGIN_VAR_RQCMDARG,
 
15765   "Compression level used for compressed row format.  0 is no compression" 
15766   ", 1 is fastest, 9 is best compression and default is 6.",
 
15767   NULL, NULL, DEFAULT_COMPRESSION_LEVEL, 0, 9, 0);
 
15769 static MYSQL_SYSVAR_BOOL(log_compressed_pages, page_zip_log_pages,
 
15770        PLUGIN_VAR_OPCMDARG,
 
15771   "Enables/disables the logging of entire compressed page images." 
15772   " InnoDB logs the compressed pages to prevent corruption if" 
15773   " the zlib compression algorithm changes." 
15774   " When turned OFF, InnoDB will assume that the zlib" 
15775   " compression algorithm doesn't change.",
 
15778 static MYSQL_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
 
15779   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15780   "DEPRECATED. This option may be removed in future releases, " 
15781   "together with the option innodb_use_sys_malloc and with the InnoDB's " 
15782   "internal memory allocator. " 
15783   "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
 
15784   NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
 
15786 static MYSQL_SYSVAR_ULONG(autoextend_increment, srv_auto_extend_increment,
 
15787   PLUGIN_VAR_RQCMDARG,
 
15788   "Data file autoextend increment in megabytes",
 
15789   NULL, NULL, 64L, 1L, 1000L, 0);
 
15791 static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
 
15792   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15793   "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
 
15794   NULL, NULL, 128*1024*1024L, 5*1024*1024L, LONGLONG_MAX, 1024*1024L);
 
15796 #if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG 
15798   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15799   "Number of rw_locks protecting buffer pool page_hash. Rounded up to the next power of 2",
 
15803   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15804   "Number of pages reserved in doublewrite buffer for batch flushing",
 
15805   NULL, NULL, 120, 1, 127, 0);
 
15808 static MYSQL_SYSVAR_LONG(buffer_pool_instances, innobase_buffer_pool_instances,
 
15809   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15810   "Number of buffer pool instances, set to higher value on high-end machines to increase scalability",
 
15814   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
 
15815   "Filename to/from which to dump/load the InnoDB buffer pool",
 
15818 static MYSQL_SYSVAR_BOOL(buffer_pool_dump_now, innodb_buffer_pool_dump_now,
 
15819   PLUGIN_VAR_RQCMDARG,
 
15820   "Trigger an immediate dump of the buffer pool into a file named @@innodb_buffer_pool_filename",
 
15821   NULL, buffer_pool_dump_now, FALSE);
 
15824   PLUGIN_VAR_RQCMDARG,
 
15825   "Dump the buffer pool into a file named @@innodb_buffer_pool_filename",
 
15826   NULL, NULL, FALSE);
 
15829 static MYSQL_SYSVAR_STR(buffer_pool_evict, srv_buffer_pool_evict,
 
15830   PLUGIN_VAR_RQCMDARG,
 
15831   "Evict pages from the buffer pool",
 
15832   NULL, innodb_buffer_pool_evict_update, 
"");
 
15835 static MYSQL_SYSVAR_BOOL(buffer_pool_load_now, innodb_buffer_pool_load_now,
 
15836   PLUGIN_VAR_RQCMDARG,
 
15837   "Trigger an immediate load of the buffer pool from a file named @@innodb_buffer_pool_filename",
 
15838   NULL, buffer_pool_load_now, FALSE);
 
15840 static MYSQL_SYSVAR_BOOL(buffer_pool_load_abort, innodb_buffer_pool_load_abort,
 
15841   PLUGIN_VAR_RQCMDARG,
 
15842   "Abort a currently running load of the buffer pool",
 
15843   NULL, buffer_pool_load_abort, FALSE);
 
15846 static MYSQL_SYSVAR_BOOL(buffer_pool_load_at_startup, srv_buffer_pool_load_at_startup,
 
15847   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15848   "Load the buffer pool from a file named @@innodb_buffer_pool_filename",
 
15849   NULL, NULL, FALSE);
 
15852   PLUGIN_VAR_RQCMDARG,
 
15853   "How deep to scan LRU to keep it clean",
 
15854   NULL, NULL, 1024, 100, ~0UL, 0);
 
15857   PLUGIN_VAR_OPCMDARG,
 
15858   "Set to 0 (don't flush neighbors from buffer pool)," 
15859   " 1 (flush contiguous neighbors from buffer pool)" 
15860   " or 2 (flush neighbors from buffer pool)," 
15861   " when flushing a block",
 
15862   NULL, NULL, 1, 0, 2, 0);
 
15864 static MYSQL_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
 
15865   PLUGIN_VAR_RQCMDARG,
 
15866   "Helps in performance tuning in heavily concurrent environments.",
 
15867   innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
 
15870   PLUGIN_VAR_RQCMDARG,
 
15871   "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
 
15872   NULL, NULL, 5000L, 1L, ~0UL, 0);
 
15874 static MYSQL_SYSVAR_LONG(file_io_threads, innobase_file_io_threads,
 
15875   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR,
 
15876   "Number of file I/O threads in InnoDB.",
 
15877   NULL, NULL, 4, 4, 64, 0);
 
15880   PLUGIN_VAR_OPCMDARG,
 
15881   "Whether to enable additional FTS diagnostic printout ",
 
15882   NULL, NULL, FALSE);
 
15884 static MYSQL_SYSVAR_BOOL(disable_sort_file_cache, srv_disable_sort_file_cache,
 
15885   PLUGIN_VAR_OPCMDARG,
 
15886   "Whether to disable OS system file cache for sort I/O",
 
15887   NULL, NULL, FALSE);
 
15890   PLUGIN_VAR_NOCMDARG,
 
15891   "FTS internal auxiliary table to be checked",
 
15892   innodb_internal_table_validate,
 
15893   innodb_internal_table_update, NULL);
 
15896   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15897   "InnoDB Fulltext search cache size in bytes",
 
15898   NULL, NULL, 8000000, 1600000, 80000000, 0);
 
15901   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15902   "Total memory allocated for InnoDB Fulltext Search cache",
 
15903   NULL, NULL, 640000000, 32000000, 1600000000, 0);
 
15906   PLUGIN_VAR_RQCMDARG,
 
15907   "InnoDB Fulltext search query result cache limit in bytes",
 
15908   NULL, NULL, 2000000000L, 1000000L, ~0UL, 0);
 
15911   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15912   "InnoDB Fulltext search minimum token size in characters",
 
15913   NULL, NULL, 3, 0, 16, 0);
 
15916   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15917   "InnoDB Fulltext search maximum token size in characters",
 
15922   PLUGIN_VAR_OPCMDARG,
 
15923   "InnoDB Fulltext search number of words to optimize for each optimize table call ",
 
15924   NULL, NULL, 2000, 1000, 10000, 0);
 
15926 static MYSQL_SYSVAR_ULONG(ft_sort_pll_degree, fts_sort_pll_degree,
 
15927   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15928   "InnoDB Fulltext search parallel sort degree, will round up to nearest power of 2 number",
 
15929   NULL, NULL, 2, 1, 16, 0);
 
15932   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15933   "Memory buffer size for index creation",
 
15934   NULL, NULL, 1048576, 65536, 64<<20, 0);
 
15937   PLUGIN_VAR_RQCMDARG,
 
15938   "Maximum modification log file size for online index creation",
 
15939   NULL, NULL, 128<<20, 65536, ~0ULL, 0);
 
15941 static MYSQL_SYSVAR_BOOL(optimize_fulltext_only, innodb_optimize_fulltext_only,
 
15942   PLUGIN_VAR_NOCMDARG,
 
15943   "Only optimize the Fulltext index of the table",
 
15944   NULL, NULL, FALSE);
 
15946 static MYSQL_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
 
15947   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15948   "Number of background read I/O threads in InnoDB.",
 
15949   NULL, NULL, 4, 1, 64, 0);
 
15951 static MYSQL_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
 
15952   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15953   "Number of background write I/O threads in InnoDB.",
 
15954   NULL, NULL, 4, 1, 64, 0);
 
15957   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15958   "Helps to save your data in case the disk image of the database becomes corrupt.",
 
15959   NULL, NULL, 0, 0, 6, 0);
 
15963   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15964   "Kills the server during crash recovery.",
 
15965   NULL, NULL, 0, 0, 10, 0);
 
15968 static MYSQL_SYSVAR_ULONG(page_size, srv_page_size,
 
15969   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
15970   "Page size to use for all InnoDB tablespaces.",
 
15971   NULL, NULL, UNIV_PAGE_SIZE_DEF,
 
15972   UNIV_PAGE_SIZE_MIN, UNIV_PAGE_SIZE_MAX, 0);
 
15974 static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
 
15975   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15976   "The size of the buffer which InnoDB uses to write log to the log files on disk.",
 
15977   NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
 
15979 static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
 
15980   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15981   "Size of each log file in a log group.",
 
15982   NULL, NULL, 48*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 1024*1024L);
 
15984 static MYSQL_SYSVAR_ULONG(log_files_in_group, srv_n_log_files,
 
15985   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15986   "Number of log files in the log group. InnoDB writes to the files in a circular fashion.",
 
15991 static MYSQL_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
 
15992   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
15993   "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
 
15994   NULL, NULL, 0, 0, 10, 0);
 
15996 static MYSQL_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
 
15997   PLUGIN_VAR_RQCMDARG,
 
15998   "Percentage of the buffer pool to reserve for 'old' blocks.",
 
15999   NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
 
16002   PLUGIN_VAR_RQCMDARG,
 
16003   "Move blocks to the 'new' end of the buffer pool if the first access" 
16004   " was at least this many milliseconds ago." 
16005   " The timeout is disabled if 0.",
 
16006   NULL, NULL, 1000, 0, UINT_MAX32, 0);
 
16008 static MYSQL_SYSVAR_LONG(open_files, innobase_open_files,
 
16009   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
16010   "How many files at the maximum InnoDB keeps open at the same time.",
 
16011   NULL, NULL, 0L, 0L, LONG_MAX, 0);
 
16013 static MYSQL_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
 
16014   PLUGIN_VAR_RQCMDARG,
 
16015   "Count of spin-loop rounds in InnoDB mutexes (30 by default)",
 
16016   NULL, NULL, 30L, 0L, ~0UL, 0);
 
16018 static MYSQL_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
 
16019   PLUGIN_VAR_OPCMDARG,
 
16020   "Maximum delay between polling for a spin lock (6 by default)",
 
16021   NULL, NULL, 6L, 0L, ~0UL, 0);
 
16024   PLUGIN_VAR_RQCMDARG,
 
16025   "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
 
16026   NULL, NULL, 0, 0, 1000, 0);
 
16028 #ifdef HAVE_ATOMIC_BUILTINS 
16029 static MYSQL_SYSVAR_ULONG(
 
16030   adaptive_max_sleep_delay, srv_adaptive_max_sleep_delay,
 
16031   PLUGIN_VAR_RQCMDARG,
 
16032   "The upper limit of the sleep delay in usec. Value of 0 disables it.",
 
16040   PLUGIN_VAR_RQCMDARG,
 
16041   "Time of innodb thread sleeping before joining InnoDB queue (usec). " 
16042   "Value 0 disable a sleep",
 
16048 static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path,
 
16049   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
16050   "Path to individual files and their sizes.",
 
16054   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
16055   "Directory where undo tablespace files live, this path can be absolute.",
 
16059   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
16060   "Number of undo tablespaces to use. ",
 
16066 static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs,
 
16067   PLUGIN_VAR_OPCMDARG,
 
16068   "Number of undo logs to use.",
 
16072   TRX_SYS_N_RSEGS, 0);  
 
16075 static MYSQL_SYSVAR_ULONG(rollback_segments, srv_undo_logs,
 
16076   PLUGIN_VAR_OPCMDARG,
 
16077   "Number of undo logs to use (deprecated).",
 
16081   TRX_SYS_N_RSEGS, 0);  
 
16083 static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
 
16084   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
16085   "The AUTOINC lock modes supported by InnoDB:               " 
16086   "0 => Old style AUTOINC locking (for backward" 
16088   "1 => New style AUTOINC locking                            " 
16089   "2 => No AUTOINC locking (unsafe for SBR)",
 
16091   AUTOINC_NEW_STYLE_LOCKING,    
 
16092   AUTOINC_OLD_STYLE_LOCKING,    
 
16093   AUTOINC_NO_LOCKING, 0);       
 
16095 static MYSQL_SYSVAR_STR(version, innodb_version_str,
 
16096   PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
 
16097   "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
 
16099 static MYSQL_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
 
16100   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
16101   "DEPRECATED. This option may be removed in future releases, " 
16102   "together with the InnoDB's internal memory allocator. " 
16103   "Use OS memory allocator instead of InnoDB's internal memory allocator",
 
16106 static MYSQL_SYSVAR_BOOL(use_native_aio, srv_use_native_aio,
 
16107   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
16108   "Use native AIO if supported on this platform.",
 
16112   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
16113   "Enable binlog for applications direct access InnoDB through InnoDB APIs",
 
16114   NULL, NULL, FALSE);
 
16117   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
16118   "Enable MDL for applications direct access InnoDB through InnoDB APIs",
 
16119   NULL, NULL, FALSE);
 
16122   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
16123   "Disable row lock when direct access InnoDB through InnoDB APIs",
 
16124   NULL, NULL, FALSE);
 
16127   PLUGIN_VAR_OPCMDARG,
 
16128   "InnoDB API transaction isolation level",
 
16135   PLUGIN_VAR_OPCMDARG,
 
16136   "Background commit interval in seconds",
 
16140   1024 * 1024 * 1024, 0);       
 
16142 static MYSQL_SYSVAR_STR(change_buffering, innobase_change_buffering,
 
16143   PLUGIN_VAR_RQCMDARG,
 
16144   "Buffer changes to reduce random access: " 
16145   "OFF, ON, inserting, deleting, changing, or purging.",
 
16146   innodb_change_buffering_validate,
 
16147   innodb_change_buffering_update, 
"all");
 
16149 static MYSQL_SYSVAR_UINT(change_buffer_max_size,
 
16150   innobase_change_buffer_max_size,
 
16151   PLUGIN_VAR_RQCMDARG,
 
16152   "Maximum on-disk size of change buffer in terms of percentage" 
16153   " of the buffer pool.",
 
16154   NULL, innodb_change_buffer_max_size_update,
 
16157 static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method,
 
16158    PLUGIN_VAR_RQCMDARG,
 
16159   "Specifies how InnoDB index statistics collection code should " 
16160   "treat NULLs. Possible values are NULLS_EQUAL (default), " 
16161   "NULLS_UNEQUAL and NULLS_IGNORED",
 
16162    NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib);
 
16164 #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG 
16165 static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug,
 
16166   PLUGIN_VAR_RQCMDARG,
 
16167   "Debug flags for InnoDB change buffering (0=none, 2=crash at merge)",
 
16168   NULL, NULL, 0, 0, 2, 0);
 
16170 static MYSQL_SYSVAR_BOOL(disable_background_merge,
 
16171   srv_ibuf_disable_background_merge,
 
16172   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_RQCMDARG,
 
16173   "Disable change buffering merges by the master thread",
 
16174   NULL, NULL, FALSE);
 
16177 static MYSQL_SYSVAR_BOOL(random_read_ahead, srv_random_read_ahead,
 
16178   PLUGIN_VAR_NOCMDARG,
 
16179   "Whether to use read ahead for random access within an extent.",
 
16180   NULL, NULL, FALSE);
 
16182 static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
 
16183   PLUGIN_VAR_RQCMDARG,
 
16184   "Number of pages that must be accessed sequentially for InnoDB to " 
16185   "trigger a readahead.",
 
16186   NULL, NULL, 56, 0, 64, 0);
 
16188 static MYSQL_SYSVAR_STR(monitor_enable, innobase_enable_monitor_counter,
 
16189   PLUGIN_VAR_RQCMDARG,
 
16190   "Turn on a monitor counter",
 
16191   innodb_monitor_validate,
 
16192   innodb_enable_monitor_update, NULL);
 
16194 static MYSQL_SYSVAR_STR(monitor_disable, innobase_disable_monitor_counter,
 
16195   PLUGIN_VAR_RQCMDARG,
 
16196   "Turn off a monitor counter",
 
16197   innodb_monitor_validate,
 
16198   innodb_disable_monitor_update, NULL);
 
16200 static MYSQL_SYSVAR_STR(monitor_reset, innobase_reset_monitor_counter,
 
16201   PLUGIN_VAR_RQCMDARG,
 
16202   "Reset a monitor counter",
 
16203   innodb_monitor_validate,
 
16204   innodb_reset_monitor_update, NULL);
 
16206 static MYSQL_SYSVAR_STR(monitor_reset_all, innobase_reset_all_monitor_counter,
 
16207   PLUGIN_VAR_RQCMDARG,
 
16208   "Reset all values for a monitor counter",
 
16209   innodb_monitor_validate,
 
16210   innodb_reset_all_monitor_update, NULL);
 
16213   PLUGIN_VAR_OPCMDARG,
 
16214   "Print all deadlocks to MySQL error log (off by default)",
 
16215   NULL, NULL, FALSE);
 
16217 static MYSQL_SYSVAR_ULONG(compression_failure_threshold_pct,
 
16219   "If the compression failure rate of a table is greater than this number" 
16220   " more padding is added to the pages to reduce the failures. A value of" 
16221   " zero implies no padding",
 
16222   NULL, NULL, 5, 0, 100, 0);
 
16224 static MYSQL_SYSVAR_ULONG(compression_pad_pct_max,
 
16226   "Percentage of empty space on a data page that can be reserved" 
16227   " to make the page compressible.",
 
16228   NULL, NULL, 50, 0, 75, 0);
 
16231   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
16232   "Start InnoDB in read only mode (off by default)",
 
16233   NULL, NULL, FALSE);
 
16236   PLUGIN_VAR_OPCMDARG,
 
16237   "Enable INFORMATION_SCHEMA.innodb_cmp_per_index, " 
16238   "may have negative impact on performance (off by default)",
 
16239   NULL, innodb_cmp_per_index_update, FALSE);
 
16242 static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug,
 
16243   PLUGIN_VAR_RQCMDARG,
 
16244   "Debug flags for InnoDB to limit TRX_RSEG_N_SLOTS for trx_rsegf_undo_find_free()",
 
16245   NULL, NULL, 0, 0, 1024, 0);
 
16247 static MYSQL_SYSVAR_UINT(limit_optimistic_insert_debug,
 
16248   btr_cur_limit_optimistic_insert_debug, PLUGIN_VAR_RQCMDARG,
 
16249   "Artificially limit the number of records per B-tree page (0=unlimited).",
 
16250   NULL, NULL, 0, 0, UINT_MAX32, 0);
 
16252 static MYSQL_SYSVAR_BOOL(trx_purge_view_update_only_debug,
 
16253   srv_purge_view_update_only_debug, PLUGIN_VAR_NOCMDARG,
 
16254   "Pause actual purging any delete-marked records, but merely update the purge view. " 
16255   "It is to create artificially the situation the purge view have been updated " 
16256   "but the each purges were not done yet.",
 
16257   NULL, NULL, FALSE);
 
16261   MYSQL_SYSVAR(additional_mem_pool_size),
 
16262   MYSQL_SYSVAR(api_trx_level),
 
16263   MYSQL_SYSVAR(api_bk_commit_interval),
 
16264   MYSQL_SYSVAR(autoextend_increment),
 
16265   MYSQL_SYSVAR(buffer_pool_size),
 
16266   MYSQL_SYSVAR(buffer_pool_instances),
 
16267   MYSQL_SYSVAR(buffer_pool_filename),
 
16268   MYSQL_SYSVAR(buffer_pool_dump_now),
 
16269   MYSQL_SYSVAR(buffer_pool_dump_at_shutdown),
 
16271   MYSQL_SYSVAR(buffer_pool_evict),
 
16273   MYSQL_SYSVAR(buffer_pool_load_now),
 
16274   MYSQL_SYSVAR(buffer_pool_load_abort),
 
16275   MYSQL_SYSVAR(buffer_pool_load_at_startup),
 
16276   MYSQL_SYSVAR(lru_scan_depth),
 
16277   MYSQL_SYSVAR(flush_neighbors),
 
16278   MYSQL_SYSVAR(checksum_algorithm),
 
16279   MYSQL_SYSVAR(checksums),
 
16280   MYSQL_SYSVAR(commit_concurrency),
 
16281   MYSQL_SYSVAR(concurrency_tickets),
 
16282   MYSQL_SYSVAR(compression_level),
 
16283   MYSQL_SYSVAR(data_file_path),
 
16284   MYSQL_SYSVAR(data_home_dir),
 
16285   MYSQL_SYSVAR(doublewrite),
 
16286   MYSQL_SYSVAR(api_enable_binlog),
 
16287   MYSQL_SYSVAR(api_enable_mdl),
 
16288   MYSQL_SYSVAR(api_disable_rowlock),
 
16289   MYSQL_SYSVAR(fast_shutdown),
 
16290   MYSQL_SYSVAR(file_io_threads),
 
16291   MYSQL_SYSVAR(read_io_threads),
 
16292   MYSQL_SYSVAR(write_io_threads),
 
16293   MYSQL_SYSVAR(file_per_table),
 
16294   MYSQL_SYSVAR(file_format),
 
16295   MYSQL_SYSVAR(file_format_check),
 
16296   MYSQL_SYSVAR(file_format_max),
 
16297   MYSQL_SYSVAR(flush_log_at_timeout),
 
16298   MYSQL_SYSVAR(flush_log_at_trx_commit),
 
16299   MYSQL_SYSVAR(flush_method),
 
16300   MYSQL_SYSVAR(force_recovery),
 
16302   MYSQL_SYSVAR(force_recovery_crash),
 
16304   MYSQL_SYSVAR(ft_cache_size),
 
16305   MYSQL_SYSVAR(ft_total_cache_size),
 
16306   MYSQL_SYSVAR(ft_result_cache_limit),
 
16307   MYSQL_SYSVAR(ft_enable_stopword),
 
16308   MYSQL_SYSVAR(ft_max_token_size),
 
16309   MYSQL_SYSVAR(ft_min_token_size),
 
16310   MYSQL_SYSVAR(ft_num_word_optimize),
 
16311   MYSQL_SYSVAR(ft_sort_pll_degree),
 
16312   MYSQL_SYSVAR(large_prefix),
 
16313   MYSQL_SYSVAR(force_load_corrupted),
 
16314   MYSQL_SYSVAR(locks_unsafe_for_binlog),
 
16315   MYSQL_SYSVAR(lock_wait_timeout),
 
16316 #ifdef UNIV_LOG_ARCHIVE 
16317   MYSQL_SYSVAR(log_arch_dir),
 
16318   MYSQL_SYSVAR(log_archive),
 
16320   MYSQL_SYSVAR(page_size),
 
16321   MYSQL_SYSVAR(log_buffer_size),
 
16322   MYSQL_SYSVAR(log_file_size),
 
16323   MYSQL_SYSVAR(log_files_in_group),
 
16324   MYSQL_SYSVAR(log_group_home_dir),
 
16325   MYSQL_SYSVAR(log_compressed_pages),
 
16326   MYSQL_SYSVAR(max_dirty_pages_pct),
 
16327   MYSQL_SYSVAR(max_dirty_pages_pct_lwm),
 
16328   MYSQL_SYSVAR(adaptive_flushing_lwm),
 
16329   MYSQL_SYSVAR(adaptive_flushing),
 
16330   MYSQL_SYSVAR(flushing_avg_loops),
 
16331   MYSQL_SYSVAR(max_purge_lag),
 
16332   MYSQL_SYSVAR(max_purge_lag_delay),
 
16333   MYSQL_SYSVAR(mirrored_log_groups),
 
16334   MYSQL_SYSVAR(old_blocks_pct),
 
16335   MYSQL_SYSVAR(old_blocks_time),
 
16336   MYSQL_SYSVAR(open_files),
 
16337   MYSQL_SYSVAR(optimize_fulltext_only),
 
16338   MYSQL_SYSVAR(rollback_on_timeout),
 
16339   MYSQL_SYSVAR(ft_aux_table),
 
16340   MYSQL_SYSVAR(ft_enable_diag_print),
 
16341   MYSQL_SYSVAR(ft_server_stopword_table),
 
16342   MYSQL_SYSVAR(ft_user_stopword_table),
 
16343   MYSQL_SYSVAR(disable_sort_file_cache),
 
16344   MYSQL_SYSVAR(stats_on_metadata),
 
16345   MYSQL_SYSVAR(stats_sample_pages),
 
16346   MYSQL_SYSVAR(stats_transient_sample_pages),
 
16347   MYSQL_SYSVAR(stats_persistent),
 
16348   MYSQL_SYSVAR(stats_persistent_sample_pages),
 
16349   MYSQL_SYSVAR(stats_auto_recalc),
 
16350   MYSQL_SYSVAR(adaptive_hash_index),
 
16351   MYSQL_SYSVAR(stats_method),
 
16352   MYSQL_SYSVAR(replication_delay),
 
16353   MYSQL_SYSVAR(status_file),
 
16354   MYSQL_SYSVAR(strict_mode),
 
16355   MYSQL_SYSVAR(support_xa),
 
16356   MYSQL_SYSVAR(sort_buffer_size),
 
16357   MYSQL_SYSVAR(online_alter_log_max_size),
 
16358   MYSQL_SYSVAR(sync_spin_loops),
 
16359   MYSQL_SYSVAR(spin_wait_delay),
 
16360   MYSQL_SYSVAR(table_locks),
 
16361   MYSQL_SYSVAR(thread_concurrency),
 
16362 #ifdef HAVE_ATOMIC_BUILTINS 
16363   MYSQL_SYSVAR(adaptive_max_sleep_delay),
 
16365   MYSQL_SYSVAR(thread_sleep_delay),
 
16366   MYSQL_SYSVAR(autoinc_lock_mode),
 
16367   MYSQL_SYSVAR(version),
 
16368   MYSQL_SYSVAR(use_sys_malloc),
 
16369   MYSQL_SYSVAR(use_native_aio),
 
16370   MYSQL_SYSVAR(change_buffering),
 
16371   MYSQL_SYSVAR(change_buffer_max_size),
 
16372 #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG 
16373   MYSQL_SYSVAR(change_buffering_debug),
 
16374   MYSQL_SYSVAR(disable_background_merge),
 
16376   MYSQL_SYSVAR(random_read_ahead),
 
16377   MYSQL_SYSVAR(read_ahead_threshold),
 
16378   MYSQL_SYSVAR(read_only),
 
16379   MYSQL_SYSVAR(io_capacity),
 
16380   MYSQL_SYSVAR(io_capacity_max),
 
16381   MYSQL_SYSVAR(monitor_enable),
 
16382   MYSQL_SYSVAR(monitor_disable),
 
16383   MYSQL_SYSVAR(monitor_reset),
 
16384   MYSQL_SYSVAR(monitor_reset_all),
 
16385   MYSQL_SYSVAR(purge_threads),
 
16386   MYSQL_SYSVAR(purge_batch_size),
 
16388   MYSQL_SYSVAR(purge_run_now),
 
16389   MYSQL_SYSVAR(purge_stop_now),
 
16390   MYSQL_SYSVAR(log_checkpoint_now),
 
16392 #if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG 
16393   MYSQL_SYSVAR(page_hash_locks),
 
16394   MYSQL_SYSVAR(doublewrite_batch_size),
 
16396   MYSQL_SYSVAR(print_all_deadlocks),
 
16397   MYSQL_SYSVAR(cmp_per_index_enabled),
 
16398   MYSQL_SYSVAR(undo_logs),
 
16399   MYSQL_SYSVAR(rollback_segments),
 
16400   MYSQL_SYSVAR(undo_directory),
 
16401   MYSQL_SYSVAR(undo_tablespaces),
 
16402   MYSQL_SYSVAR(sync_array_size),
 
16403   MYSQL_SYSVAR(compression_failure_threshold_pct),
 
16404   MYSQL_SYSVAR(compression_pad_pct_max),
 
16406   MYSQL_SYSVAR(trx_rseg_n_slots_debug),
 
16407   MYSQL_SYSVAR(limit_optimistic_insert_debug),
 
16408   MYSQL_SYSVAR(trx_purge_view_update_only_debug),
 
16413 mysql_declare_plugin(innobase)
 
16415   MYSQL_STORAGE_ENGINE_PLUGIN,
 
16416   &innobase_storage_engine,
 
16417   innobase_hton_name,
 
16419   "Supports transactions, row-level locking, and foreign keys",
 
16420   PLUGIN_LICENSE_GPL,
 
16423   INNODB_VERSION_SHORT,
 
16424   innodb_status_variables_export,
 
16425   innobase_system_variables, 
 
16431 i_s_innodb_lock_waits,
 
16433 i_s_innodb_cmp_reset,
 
16435 i_s_innodb_cmpmem_reset,
 
16436 i_s_innodb_cmp_per_index,
 
16437 i_s_innodb_cmp_per_index_reset,
 
16438 i_s_innodb_buffer_page,
 
16439 i_s_innodb_buffer_page_lru,
 
16440 i_s_innodb_buffer_stats,
 
16441 i_s_innodb_metrics,
 
16442 i_s_innodb_ft_default_stopword,
 
16443 i_s_innodb_ft_deleted,
 
16444 i_s_innodb_ft_being_deleted,
 
16445 i_s_innodb_ft_config,
 
16446 i_s_innodb_ft_index_cache,
 
16447 i_s_innodb_ft_index_table,
 
16448 i_s_innodb_sys_tables,
 
16449 i_s_innodb_sys_tablestats,
 
16450 i_s_innodb_sys_indexes,
 
16451 i_s_innodb_sys_columns,
 
16452 i_s_innodb_sys_fields,
 
16453 i_s_innodb_sys_foreign,
 
16454 i_s_innodb_sys_foreign_cols,
 
16455 i_s_innodb_sys_tablespaces,
 
16456 i_s_innodb_sys_datafiles
 
16458 mysql_declare_plugin_end;
 
16471 innobase_commit_concurrency_init_default()
 
16474         MYSQL_SYSVAR_NAME(commit_concurrency).def_val
 
16475                 = innobase_commit_concurrency;
 
16485 innobase_undo_logs_init_default_max()
 
16488         MYSQL_SYSVAR_NAME(undo_logs).max_val
 
16489                 = MYSQL_SYSVAR_NAME(undo_logs).def_val
 
16490                 = srv_available_undo_logs;
 
16493 #ifdef UNIV_COMPILE_TEST_FUNCS 
16495 struct innobase_convert_name_test_t {
 
16503         const char*     expected;
 
16507 test_innobase_convert_name()
 
16512         innobase_convert_name_test_t test_input[] = {
 
16513                 {
buf, 
sizeof(
buf), 
"abcd", 4, NULL, TRUE, 
"\"abcd\""},
 
16514                 {
buf, 7, 
"abcd", 4, NULL, TRUE, 
"\"abcd\""},
 
16515                 {
buf, 6, 
"abcd", 4, NULL, TRUE, 
"\"abcd\""},
 
16516                 {
buf, 5, 
"abcd", 4, NULL, TRUE, 
"\"abc\""},
 
16517                 {
buf, 4, 
"abcd", 4, NULL, TRUE, 
"\"ab\""},
 
16519                 {
buf, 
sizeof(
buf), 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab`cd\""},
 
16520                 {
buf, 9, 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab`cd\""},
 
16521                 {
buf, 8, 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab`cd\""},
 
16522                 {
buf, 7, 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab`cd\""},
 
16523                 {
buf, 6, 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab`c\""},
 
16524                 {
buf, 5, 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab`\""},
 
16525                 {
buf, 4, 
"ab@0060cd", 9, NULL, TRUE, 
"\"ab\""},
 
16527                 {
buf, 
sizeof(
buf), 
"ab\"cd", 5, NULL, TRUE,
 
16528                         "\"#mysql50#ab\"\"cd\""},
 
16529                 {
buf, 17, 
"ab\"cd", 5, NULL, TRUE,
 
16530                         "\"#mysql50#ab\"\"cd\""},
 
16531                 {
buf, 16, 
"ab\"cd", 5, NULL, TRUE,
 
16532                         "\"#mysql50#ab\"\"c\""},
 
16533                 {
buf, 15, 
"ab\"cd", 5, NULL, TRUE,
 
16534                         "\"#mysql50#ab\"\"\""},
 
16535                 {
buf, 14, 
"ab\"cd", 5, NULL, TRUE,
 
16536                         "\"#mysql50#ab\""},
 
16537                 {
buf, 13, 
"ab\"cd", 5, NULL, TRUE,
 
16538                         "\"#mysql50#ab\""},
 
16539                 {
buf, 12, 
"ab\"cd", 5, NULL, TRUE,
 
16541                 {
buf, 11, 
"ab\"cd", 5, NULL, TRUE,
 
16543                 {
buf, 10, 
"ab\"cd", 5, NULL, TRUE,
 
16546                 {
buf, 
sizeof(
buf), 
"ab/cd", 5, NULL, TRUE, 
"\"ab\".\"cd\""},
 
16547                 {
buf, 9, 
"ab/cd", 5, NULL, TRUE, 
"\"ab\".\"cd\""},
 
16548                 {
buf, 8, 
"ab/cd", 5, NULL, TRUE, 
"\"ab\".\"c\""},
 
16549                 {
buf, 7, 
"ab/cd", 5, NULL, TRUE, 
"\"ab\".\"\""},
 
16550                 {
buf, 6, 
"ab/cd", 5, NULL, TRUE, 
"\"ab\"."},
 
16551                 {
buf, 5, 
"ab/cd", 5, NULL, TRUE, 
"\"ab\"."},
 
16552                 {
buf, 4, 
"ab/cd", 5, NULL, TRUE, 
"\"ab\""},
 
16553                 {
buf, 3, 
"ab/cd", 5, NULL, TRUE, 
"\"a\""},
 
16554                 {
buf, 2, 
"ab/cd", 5, NULL, TRUE, 
"\"\""},
 
16558                 {
buf, 0, 
"ab/cd", 5, NULL, TRUE, 
""},
 
16561         for (i = 0; i < 
sizeof(test_input) / 
sizeof(test_input[0]); i++) {
 
16567                 fprintf(stderr, 
"TESTING %lu, %s, %lu, %s\n",
 
16568                         test_input[i].buflen,
 
16570                         test_input[i].idlen,
 
16571                         test_input[i].expected);
 
16575                         test_input[i].buflen,
 
16577                         test_input[i].idlen,
 
16579                         test_input[i].file_id);
 
16581                 res_len = (size_t) (end - test_input[i].buf);
 
16583                 if (res_len != strlen(test_input[i].expected)) {
 
16585                         fprintf(stderr, 
"unexpected len of the result: %u, " 
16586                                 "expected: %u\n", (
unsigned) res_len,
 
16587                                 (
unsigned) strlen(test_input[i].expected));
 
16591                 if (memcmp(test_input[i].buf,
 
16592                            test_input[i].expected,
 
16593                            strlen(test_input[i].expected)) != 0
 
16596                         fprintf(stderr, 
"unexpected result: %.*s, " 
16597                                 "expected: %s\n", (
int) res_len,
 
16599                                 test_input[i].expected);
 
16604                         fprintf(stderr, 
"OK: res: %.*s\n\n", (
int) res_len,
 
16607                         fprintf(stderr, 
"FAILED\n\n");
 
16626         void*           seq_init_param,
 
16631         return(ds_mrr.
dsmrr_init(
this, seq, seq_init_param,
 
16632                                  n_ranges, mode, buf));
 
16639         return(ds_mrr.dsmrr_next(range_info));
 
16646         void*           seq_init_param,
 
16653         ds_mrr.init(
this, table);
 
16654         return(ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param,
 
16655                                        n_ranges, bufsz, flags, cost));
 
16667         ds_mrr.init(
this, table);
 
16668         return(ds_mrr.dsmrr_info(keyno, n_ranges, keys, bufsz, flags, cost));
 
16685         DBUG_ENTER(
"innobase_index_cond");
 
16689         DBUG_ASSERT(h->pushed_idx_cond);
 
16690         DBUG_ASSERT(h->pushed_idx_cond_keyno != MAX_KEY);
 
16692         if (h->end_range && h->compare_key_icp(h->end_range) > 0) {
 
16695                 DBUG_RETURN(ICP_OUT_OF_RANGE);
 
16698         DBUG_RETURN(h->pushed_idx_cond->val_int() ? ICP_MATCH : ICP_NO_MATCH);
 
16710         class Item*     idx_cond)
 
16712         DBUG_ENTER(
"ha_innobase::idx_cond_push");
 
16713         DBUG_ASSERT(keyno != MAX_KEY);
 
16714         DBUG_ASSERT(idx_cond != NULL);
 
16716         pushed_idx_cond = idx_cond;
 
16717         pushed_idx_cond_keyno = keyno;
 
16718         in_range_check_pushed_down = TRUE;
 
16754         va_start(args, code);
 
16757         int             size = _vscprintf(format, args) + 1;
 
16758         str = 
static_cast<char*
>(malloc(size));
 
16759         str[size - 1] = 0x0;
 
16760         vsnprintf(str, size, format, args);
 
16761 #elif HAVE_VASPRINTF 
16762         (void) vasprintf(&str, format, args);
 
16765         str = 
static_cast<char*
>(malloc(BUFSIZ));
 
16766         my_vsnprintf(str, BUFSIZ, format, args);
 
16769         Sql_condition::enum_warning_level       l;
 
16771         l = Sql_condition::WARN_LEVEL_NOTE;
 
16774         case IB_LOG_LEVEL_INFO:
 
16776         case IB_LOG_LEVEL_WARN:
 
16777                 l = Sql_condition::WARN_LEVEL_WARN;
 
16779         case IB_LOG_LEVEL_ERROR:
 
16781                 my_printf_error(code, 
"%s", MYF(0), str);
 
16783         case IB_LOG_LEVEL_FATAL:
 
16784                 l = Sql_condition::WARN_LEVEL_END;
 
16788         if (level != IB_LOG_LEVEL_ERROR) {
 
16789                 push_warning_printf(thd, l, code, 
"InnoDB: %s", str);
 
16795         if (level == IB_LOG_LEVEL_FATAL) {
 
16818         const char*     format,         
 
16830         va_start(args, format);
 
16833         int             size = _vscprintf(format, args) + 1;
 
16834         str = 
static_cast<char*
>(malloc(size));
 
16835         str[size - 1] = 0x0;
 
16836         vsnprintf(str, size, format, args);
 
16837 #elif HAVE_VASPRINTF 
16838         (void) vasprintf(&str, format, args);
 
16841         str = 
static_cast<char*
>(malloc(BUFSIZ));
 
16842         my_vsnprintf(str, BUFSIZ, format, args);
 
16858         const char*     format,         
 
16864         va_start(args, format);
 
16867         int             size = _vscprintf(format, args) + 1;
 
16868         str = 
static_cast<char*
>(malloc(size));
 
16869         str[size - 1] = 0x0;
 
16870         vsnprintf(str, size, format, args);
 
16871 #elif HAVE_VASPRINTF 
16872         (void) vasprintf(&str, format, args);
 
16875         str = 
static_cast<char*
>(malloc(BUFSIZ));
 
16876         my_vsnprintf(str, BUFSIZ, format, args);
 
16880         case IB_LOG_LEVEL_INFO:
 
16881                 sql_print_information(
"InnoDB: %s", str);
 
16883         case IB_LOG_LEVEL_WARN:
 
16884                 sql_print_warning(
"InnoDB: %s", str);
 
16886         case IB_LOG_LEVEL_ERROR:
 
16887                 sql_print_error(
"InnoDB: %s", str);
 
16889         case IB_LOG_LEVEL_FATAL:
 
16890                 sql_print_error(
"InnoDB: %s", str);
 
16897         if (level == IB_LOG_LEVEL_FATAL) {
 
16906 innobase_convert_to_filename_charset(
 
16916         return(strconvert(cs_from, from, cs_to, to, len, &errors));
 
16923 innobase_convert_to_system_charset(
 
16933         return(strconvert(cs1, from, cs2, to, len, errors));