~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/ha_innodb.cc

  • Committer: Monty Taylor
  • Date: 2010-11-25 01:53:19 UTC
  • mto: (1953.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1955.
  • Revision ID: mordred@inaugust.com-20101125015319-ia85msn25uemopgc
Re-enabled -Wformat and then cleaned up the carnage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
#include "log0log.h"
103
103
#include "lock0lock.h"
104
104
#include "dict0crea.h"
105
 
#include "create_replication.h"
106
105
#include "btr0cur.h"
107
106
#include "btr0btr.h"
108
107
#include "fsp0fsp.h"
120
119
 
121
120
#include "ha_innodb.h"
122
121
#include "data_dictionary.h"
123
 
#include "replication_dictionary.h"
124
122
#include "internal_dictionary.h"
125
123
#include "handler0vars.h"
126
124
 
129
127
#include <string>
130
128
 
131
129
#include "plugin/innobase/handler/status_function.h"
132
 
#include "plugin/innobase/handler/replication_log.h"
133
 
 
134
 
#include <google/protobuf/io/zero_copy_stream.h>
135
 
#include <google/protobuf/io/zero_copy_stream_impl.h>
136
 
#include <google/protobuf/io/coded_stream.h>
137
 
#include <google/protobuf/text_format.h>
138
130
 
139
131
using namespace std;
140
132
using namespace drizzled;
170
162
static plugin::TableFunction* innodb_trx_tool= NULL;
171
163
static plugin::TableFunction* innodb_locks_tool= NULL;
172
164
static plugin::TableFunction* innodb_lock_waits_tool= NULL;
173
 
static plugin::TableFunction* innodb_sys_tables_tool= NULL;
174
 
static plugin::TableFunction* innodb_sys_tablestats_tool= NULL;
175
 
 
176
 
static plugin::TableFunction* innodb_sys_indexes_tool= NULL;
177
 
static plugin::TableFunction* innodb_sys_columns_tool= NULL;
178
 
static plugin::TableFunction* innodb_sys_fields_tool= NULL;
179
 
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
180
 
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
181
 
 
182
 
static ReplicationLog *replication_logger= NULL;
183
 
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
184
 
static open_files_constraint innobase_open_files;
185
 
typedef constrained_check<uint32_t, 10, 1> mirrored_log_groups_constraint;
186
 
static mirrored_log_groups_constraint innobase_mirrored_log_groups;
187
 
typedef constrained_check<uint32_t, 100, 2> log_files_in_group_constraint;
188
 
static log_files_in_group_constraint innobase_log_files_in_group;
189
 
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
190
 
force_recovery_constraint innobase_force_recovery;
191
 
typedef constrained_check<size_t, SIZE_MAX, 256*1024, 1024> log_buffer_constraint;
192
 
static log_buffer_constraint innobase_log_buffer_size;
193
 
typedef constrained_check<size_t, SIZE_MAX, 512*1024, 1024> additional_mem_pool_constraint;
194
 
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
195
 
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
196
 
static autoextend_constraint innodb_auto_extend_increment;
197
 
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
198
 
static buffer_pool_constraint innobase_buffer_pool_size;
199
 
typedef constrained_check<uint32_t, MAX_BUFFER_POOLS, 1> buffer_pool_instances_constraint;
200
 
static buffer_pool_instances_constraint innobase_buffer_pool_instances;
201
 
typedef constrained_check<uint32_t, UINT32_MAX, 100> io_capacity_constraint;
202
 
static io_capacity_constraint innodb_io_capacity;
203
 
typedef constrained_check<uint32_t, 5000, 1> purge_batch_constraint;
204
 
static purge_batch_constraint innodb_purge_batch_size;
205
 
typedef constrained_check<uint32_t, 1, 0> purge_threads_constraint;
206
 
static purge_threads_constraint innodb_n_purge_threads;
207
 
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
208
 
static trinary_constraint innodb_flush_log_at_trx_commit;
209
 
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
210
 
static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
211
 
static uint64_constraint innodb_max_purge_lag;
212
 
static uint64_nonzero_constraint innodb_stats_sample_pages;
213
 
typedef constrained_check<uint32_t, 64, 1> io_threads_constraint;
214
 
static io_threads_constraint innobase_read_io_threads;
215
 
static io_threads_constraint innobase_write_io_threads;
216
 
 
217
 
typedef constrained_check<uint32_t, 1000, 0> concurrency_constraint;
218
 
static concurrency_constraint innobase_commit_concurrency;
219
 
static concurrency_constraint innobase_thread_concurrency;
220
 
static uint32_nonzero_constraint innodb_concurrency_tickets;
221
 
 
222
 
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
223
 
static log_file_constraint innobase_log_file_size;
224
 
 
225
 
static uint64_constraint innodb_replication_delay;
 
165
 
 
166
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
 
167
  innobase_log_buffer_size,
 
168
  innobase_force_recovery, innobase_open_files;
 
169
static long innobase_additional_mem_pool_size= 8*1024*1024L;
 
170
static ulong innobase_commit_concurrency = 0;
 
171
static ulong innobase_read_io_threads;
 
172
static ulong innobase_write_io_threads;
 
173
 
 
174
/**
 
175
 * @TODO: Turn this into size_t as soon as we have a Variable<size_t>
 
176
 */
 
177
static int64_t innobase_buffer_pool_size= 128*1024*1024;
 
178
static int64_t innobase_log_file_size;
226
179
 
227
180
/** Percentage of the buffer pool to reserve for 'old' blocks.
228
181
Connected to buf_LRU_old_ratio. */
229
 
typedef constrained_check<uint32_t, 95, 5> old_blocks_constraint;
230
 
static old_blocks_constraint innobase_old_blocks_pct;
231
 
 
232
 
static uint32_constraint innodb_sync_spin_loops;
233
 
static uint32_constraint innodb_spin_wait_delay;
234
 
static uint32_constraint innodb_thread_sleep_delay;
235
 
 
236
 
typedef constrained_check<uint32_t, 64, 0> read_ahead_threshold_constraint;
237
 
static read_ahead_threshold_constraint innodb_read_ahead_threshold;
 
182
static uint innobase_old_blocks_pct;
238
183
 
239
184
/* The default values for the following char* start-up parameters
240
185
are determined in innobase_init below: */
241
186
 
242
 
std::string innobase_data_home_dir;
243
 
std::string innobase_data_file_path;
244
 
std::string innobase_log_group_home_dir;
245
 
static string innobase_file_format_name;
246
 
static string innobase_change_buffering;
247
 
 
248
 
/* The highest file format being used in the database. The value can be
249
 
set by user, however, it will be adjusted to the newer file format if
250
 
a table of such format is created/opened. */
251
 
static string innobase_file_format_max;
 
187
static char*  innobase_data_home_dir      = NULL;
 
188
static char*  innobase_data_file_path     = NULL;
 
189
static char*  innobase_log_group_home_dir   = NULL;
 
190
static char*  innobase_file_format_name   = NULL;
 
191
static char*  innobase_change_buffering   = NULL;
 
192
 
 
193
/* Note: This variable can be set to on/off and any of the supported
 
194
file formats in the configuration file, but can only be set to any
 
195
of the supported file formats during runtime. */
 
196
static char*  innobase_file_format_check    = NULL;
 
197
 
 
198
static char*  innobase_file_flush_method   = NULL;
252
199
 
253
200
/* Below we have boolean-valued start-up parameters, and their default
254
201
values */
255
202
 
256
 
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
257
 
static trinary_constraint innobase_fast_shutdown;
258
 
 
259
 
/* "innobase_file_format_check" decides whether we would continue
260
 
booting the server if the file format stamped on the system
261
 
table space exceeds the maximum file format supported
262
 
by the server. Can be set during server startup at command
263
 
line or configure file, and a read only variable after
264
 
server startup */
265
 
 
266
 
/* If a new file format is introduced, the file format
267
 
name needs to be updated accordingly. Please refer to
268
 
file_format_name_map[] defined in trx0sys.c for the next
269
 
file format name. */
270
 
 
271
 
static my_bool  innobase_file_format_check = TRUE;
 
203
static ulong  innobase_fast_shutdown      = 1;
 
204
#ifdef UNIV_LOG_ARCHIVE
 
205
static my_bool  innobase_log_archive      = FALSE;
 
206
static char*  innobase_log_arch_dir     = NULL;
 
207
#endif /* UNIV_LOG_ARCHIVE */
272
208
static my_bool  innobase_use_doublewrite    = TRUE;
273
209
static my_bool  innobase_use_checksums      = TRUE;
274
210
static my_bool  innobase_rollback_on_timeout    = FALSE;
275
211
static my_bool  innobase_create_status_file   = FALSE;
276
 
static bool innobase_use_replication_log;
277
 
static bool support_xa;
278
 
static bool strict_mode;
279
 
typedef constrained_check<uint32_t, 1024*1024*1024, 1> lock_wait_constraint;
280
 
static lock_wait_constraint lock_wait_timeout;
281
212
 
282
213
static char*  internal_innobase_data_file_path  = NULL;
283
214
 
 
215
static char*  innodb_version_str = (char*) INNODB_VERSION_STR;
 
216
 
284
217
/* The following counter is used to convey information to InnoDB
285
218
about server activity: in selects it is not sensible to call
286
219
srv_active_wake_master_thread after each fetch or search, we only do
298
231
/** Allowed values of innodb_change_buffering */
299
232
static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = {
300
233
  "none",   /* IBUF_USE_NONE */
301
 
  "inserts",    /* IBUF_USE_INSERT */
302
 
  "deletes",    /* IBUF_USE_DELETE_MARK */
303
 
  "changes",    /* IBUF_USE_INSERT_DELETE_MARK */
304
 
  "purges",     /* IBUF_USE_DELETE */
305
 
  "all"         /* IBUF_USE_ALL */
 
234
  "inserts" /* IBUF_USE_INSERT */
306
235
};
307
236
 
308
237
/* "GEN_CLUST_INDEX" is the name reserved for Innodb default
360
289
    }
361
290
    
362
291
    /* These get strdup'd from vm variables */
 
292
    free(innobase_data_home_dir);
 
293
    free(innobase_log_group_home_dir);
363
294
 
364
295
  }
365
296
 
514
445
 
515
446
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
516
447
                             const drizzled::SchemaIdentifier &schema_identifier,
517
 
                             drizzled::TableIdentifier::vector &set_of_identifiers);
 
448
                             drizzled::TableIdentifiers &set_of_identifiers);
518
449
  bool validateCreateTableOption(const std::string &key, const std::string &state);
519
450
  void dropTemporarySchema();
520
451
 
543
474
 
544
475
void InnobaseEngine::doGetTableIdentifiers(drizzled::CachedDirectory &directory,
545
476
                                           const drizzled::SchemaIdentifier &schema_identifier,
546
 
                                           drizzled::TableIdentifier::vector &set_of_identifiers)
 
477
                                           drizzled::TableIdentifiers &set_of_identifiers)
547
478
{
548
479
  CachedDirectory::Entries entries= directory.getEntries();
549
480
 
619
550
  return ENOENT;
620
551
}
621
552
 
 
553
/** @brief Initialize the default value of innodb_commit_concurrency.
 
554
 
 
555
Once InnoDB is running, the innodb_commit_concurrency must not change
 
556
from zero to nonzero. (Bug #42101)
 
557
 
 
558
The initial default value is 0, and without this extra initialization,
 
559
SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter
 
560
to 0, even if it was initially set to nonzero at the command line
 
561
or configuration file. */
 
562
static
 
563
void
 
564
innobase_commit_concurrency_init_default(void);
 
565
/*==========================================*/
622
566
 
623
567
/************************************************************//**
624
568
Validate the file format name and return its corresponding id.
631
575
            name */
632
576
/************************************************************//**
633
577
Validate the file format check config parameters, as a side effect it
634
 
sets the srv_max_file_format_at_startup variable.
 
578
sets the srv_check_file_format_at_startup variable.
 
579
@return true if one of  "on" or "off" */
 
580
static
 
581
bool
 
582
innobase_file_format_check_on_off(
 
583
/*==============================*/
 
584
  const char* format_check);    /*!< in: parameter value */
 
585
/************************************************************//**
 
586
Validate the file format check config parameters, as a side effect it
 
587
sets the srv_check_file_format_at_startup variable.
635
588
@return the format_id if valid config value, otherwise, return -1 */
636
589
static
637
590
int
638
591
innobase_file_format_validate_and_set(
639
592
/*================================*/
640
 
  const char* format_max);    /*!< in: parameter value */
 
593
  const char* format_check);    /*!< in: parameter value */
641
594
 
642
595
static const char innobase_engine_name[]= "InnoDB";
643
596
 
 
597
/*************************************************************//**
 
598
Check for a valid value of innobase_commit_concurrency.
 
599
@return 0 for valid innodb_commit_concurrency */
 
600
static
 
601
int
 
602
innobase_commit_concurrency_validate(
 
603
/*=================================*/
 
604
  Session*      , /*!< in: thread handle */
 
605
  drizzle_sys_var*  , /*!< in: pointer to system
 
606
            variable */
 
607
  void*       save, /*!< out: immediate result
 
608
            for update function */
 
609
  drizzle_value*    value)  /*!< in: incoming string */
 
610
{
 
611
  int64_t   intbuf;
 
612
  ulong   commit_concurrency;
 
613
 
 
614
  if (value->val_int(value, &intbuf)) {
 
615
    /* The value is NULL. That is invalid. */
 
616
    return(1);
 
617
  }
 
618
 
 
619
  *reinterpret_cast<ulong*>(save) = commit_concurrency
 
620
    = static_cast<ulong>(intbuf);
 
621
 
 
622
  /* Allow the value to be updated, as long as it remains zero
 
623
  or nonzero. */
 
624
  return(!(!commit_concurrency == !innobase_commit_concurrency));
 
625
}
 
626
 
 
627
static DRIZZLE_SessionVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG,
 
628
  "Enable InnoDB support for the XA two-phase commit",
 
629
  /* check_func */ NULL, /* update_func */ NULL,
 
630
  /* default */ TRUE);
 
631
 
 
632
static DRIZZLE_SessionVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
 
633
  "Enable InnoDB locking in LOCK TABLES",
 
634
  /* check_func */ NULL, /* update_func */ NULL,
 
635
  /* default */ TRUE);
 
636
 
 
637
static DRIZZLE_SessionVAR_BOOL(strict_mode, PLUGIN_VAR_OPCMDARG,
 
638
  "Use strict mode when evaluating create options.",
 
639
  NULL, NULL, FALSE);
 
640
 
 
641
static DRIZZLE_SessionVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
 
642
  "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
 
643
  NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
 
644
 
644
645
 
645
646
/*****************************************************************//**
646
647
Commits a transaction in an InnoDB database. */
907
908
ibool
908
909
thd_supports_xa(
909
910
/*============*/
910
 
  void* )  /*!< in: thread handle (Session*), or NULL to query
 
911
  void* session)  /*!< in: thread handle (Session*), or NULL to query
911
912
        the global innodb_supports_xa */
912
913
{
913
 
  /* TODO: Add support here for per-session value */
914
 
  return(support_xa);
 
914
  return(SessionVAR((Session*) session, support_xa));
915
915
}
916
916
 
917
917
/******************************************************************//**
921
921
ulong
922
922
thd_lock_wait_timeout(
923
923
/*==================*/
924
 
  void*)  /*!< in: thread handle (Session*), or NULL to query
 
924
  void* session)  /*!< in: thread handle (Session*), or NULL to query
925
925
      the global innodb_lock_wait_timeout */
926
926
{
927
 
  /* TODO: Add support here for per-session value */
928
927
  /* According to <drizzle/plugin.h>, passing session == NULL
929
928
  returns the global value of the session variable. */
930
 
  return((ulong)lock_wait_timeout.get());
931
 
}
932
 
 
933
 
/******************************************************************//**
934
 
Set the time waited for the lock for the current query. */
935
 
extern "C" UNIV_INTERN
936
 
void
937
 
thd_set_lock_wait_time(
938
 
/*===================*/
939
 
        void*   thd,    /*!< in: thread handle (THD*) */
940
 
        ulint   value)  /*!< in: time waited for the lock */
941
 
{
942
 
        if (thd) {
943
 
          static_cast<Session*>(thd)->utime_after_lock+= value;
944
 
        }
 
929
  return(SessionVAR((Session*) session, lock_wait_timeout));
945
930
}
946
931
 
947
932
/********************************************************************//**
956
941
  return *(trx_t**) session->getEngineData(innodb_engine_ptr);
957
942
}
958
943
 
959
 
 
960
 
plugin::ReplicationReturnCode ReplicationLog::apply(Session &session,
961
 
                                                    const message::Transaction &message)
962
 
{
963
 
  char *data= new char[message.ByteSize()];
964
 
 
965
 
  message.SerializeToArray(data, message.ByteSize());
966
 
 
967
 
  trx_t *trx= session_to_trx(&session);
968
 
 
969
 
  uint64_t trx_id= message.transaction_context().transaction_id();
970
 
  ulint error= insert_replication_message(data, message.ByteSize(), trx, trx_id);
971
 
  (void)error;
972
 
 
973
 
  delete[] data;
974
 
 
975
 
  return plugin::SUCCESS;
976
 
}
977
 
 
978
944
/********************************************************************//**
979
945
Call this function when mysqld passes control to the client. That is to
980
946
avoid deadlocks on the adaptive hash S-latch possibly held by session. For more
1039
1005
  case DB_INTERRUPTED:
1040
1006
    my_error(ER_QUERY_INTERRUPTED, MYF(0));
1041
1007
    /* fall through */
1042
 
 
1043
 
  case DB_FOREIGN_EXCEED_MAX_CASCADE:
1044
 
    push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1045
 
                        HA_ERR_ROW_IS_REFERENCED,
1046
 
                        "InnoDB: Cannot delete/update "
1047
 
                        "rows with cascading foreign key "
1048
 
                        "constraints that exceed max "
1049
 
                        "depth of %d. Please "
1050
 
                        "drop extra constraints and try "
1051
 
                        "again", DICT_FK_MAX_RECURSIVE_LOAD);
1052
 
    /* fall through */
1053
 
 
1054
1008
  case DB_ERROR:
1055
1009
  default:
1056
1010
    return(-1); /* unspecified error */
1208
1162
  if (cs) {
1209
1163
    *mbminlen = cs->mbminlen;
1210
1164
    *mbmaxlen = cs->mbmaxlen;
1211
 
    ut_ad(*mbminlen < DATA_MBMAX);
1212
 
    ut_ad(*mbmaxlen < DATA_MBMAX);
1213
1165
  } else {
1214
1166
    ut_a(cset == 0);
1215
1167
    *mbminlen = *mbmaxlen = 0;
1299
1251
 
1300
1252
/**********************************************************************//**
1301
1253
Determines the current SQL statement.
1302
 
@return        SQL statement string */
 
1254
@return SQL statement string */
1303
1255
extern "C" UNIV_INTERN
1304
1256
const char*
1305
1257
innobase_get_stmt(
1306
1258
/*==============*/
1307
 
       void*   session,        /*!< in: MySQL thread handle */
1308
 
       size_t* length)         /*!< out: length of the SQL statement */
 
1259
        void*   session,        /*!< in: MySQL thread handle */
 
1260
        size_t* length)         /*!< out: length of the SQL statement */
1309
1261
{
1310
1262
  return static_cast<Session*>(session)->getQueryStringCopy(*length);
1311
1263
}
1816
1768
/*==========*/
1817
1769
        trx_t*  trx)    /*!< in: transaction */
1818
1770
{
1819
 
        return(trx && trx->mysql_thd
1820
 
               && true);
 
1771
  return(trx && trx->mysql_thd && true);
1821
1772
}
1822
1773
 
1823
1774
/**************************************************************//**
1839
1790
  value= value - (value % align_val);
1840
1791
}
1841
1792
 
1842
 
static void auto_extend_update(Session *, sql_var_t)
1843
 
{
1844
 
  srv_auto_extend_increment= innodb_auto_extend_increment.get();
1845
 
}
1846
 
 
1847
 
static void io_capacity_update(Session *, sql_var_t)
1848
 
{
1849
 
  srv_io_capacity= innodb_io_capacity.get();
1850
 
}
1851
 
 
1852
 
static void purge_batch_update(Session *, sql_var_t)
1853
 
{
1854
 
  srv_purge_batch_size= innodb_purge_batch_size.get();
1855
 
}
1856
 
 
1857
 
static void purge_threads_update(Session *, sql_var_t)
1858
 
{
1859
 
  srv_n_purge_threads= innodb_n_purge_threads.get();
1860
 
}
1861
 
 
1862
 
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
1863
 
{
1864
 
  if (btr_search_enabled)
1865
 
  {
1866
 
    btr_search_enable();
1867
 
  } else {
1868
 
    btr_search_disable();
1869
 
  }
1870
 
}
1871
 
 
1872
 
static void innodb_old_blocks_pct_update(Session *, sql_var_t)
1873
 
{
1874
 
  innobase_old_blocks_pct= buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(), TRUE);
1875
 
}
1876
 
 
1877
 
static void innodb_thread_concurrency_update(Session *, sql_var_t)
1878
 
{
1879
 
  srv_thread_concurrency= innobase_thread_concurrency.get();
1880
 
}
1881
 
 
1882
 
static void innodb_sync_spin_loops_update(Session *, sql_var_t)
1883
 
{
1884
 
  srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1885
 
}
1886
 
 
1887
 
static void innodb_spin_wait_delay_update(Session *, sql_var_t)
1888
 
{
1889
 
  srv_spin_wait_delay= innodb_spin_wait_delay.get();
1890
 
}
1891
 
 
1892
 
static void innodb_thread_sleep_delay_update(Session *, sql_var_t)
1893
 
{
1894
 
  srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1895
 
}
1896
 
 
1897
 
static void innodb_read_ahead_threshold_update(Session *, sql_var_t)
1898
 
{
1899
 
  srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1900
 
}
1901
 
 
1902
 
 
1903
 
static int innodb_commit_concurrency_validate(Session *session, set_var *var)
1904
 
{
1905
 
   uint32_t new_value= var->save_result.uint32_t_value;
1906
 
 
1907
 
   if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
1908
 
       (innobase_commit_concurrency.get() != 0 && new_value == 0))
1909
 
   {
1910
 
     push_warning_printf(session,
1911
 
                         DRIZZLE_ERROR::WARN_LEVEL_WARN,
1912
 
                         ER_WRONG_ARGUMENTS,
1913
 
                         _("Once InnoDB is running, innodb_commit_concurrency "
1914
 
                           "must not change between zero and nonzero."));
1915
 
     return 1;
1916
 
   }
1917
 
   return 0;
1918
 
}
1919
 
 
1920
 
/*************************************************************//**
1921
 
Check if it is a valid file format. This function is registered as
1922
 
a callback with MySQL.
1923
 
@return 0 for valid file format */
1924
 
static
1925
 
int
1926
 
innodb_file_format_name_validate(
1927
 
/*=============================*/
1928
 
  Session*      , /*!< in: thread handle */
1929
 
  set_var *var)
1930
 
{
1931
 
  const char *file_format_input = var->value->str_value.ptr();
1932
 
  if (file_format_input == NULL)
1933
 
    return 1;
1934
 
 
1935
 
  if (file_format_input != NULL) {
1936
 
    uint  format_id;
1937
 
 
1938
 
    format_id = innobase_file_format_name_lookup(
1939
 
      file_format_input);
1940
 
 
1941
 
    if (format_id <= DICT_TF_FORMAT_MAX) {
1942
 
      innobase_file_format_name =
1943
 
        trx_sys_file_format_id_to_name(format_id);
1944
 
 
1945
 
      return(0);
1946
 
    }
1947
 
  }
1948
 
 
1949
 
  return(1);
1950
 
}
1951
 
 
1952
 
/*************************************************************//**
1953
 
Check if it is a valid value of innodb_change_buffering. This function is
1954
 
registered as a callback with MySQL.
1955
 
@return 0 for valid innodb_change_buffering */
1956
 
static
1957
 
int
1958
 
innodb_change_buffering_validate(
1959
 
/*=============================*/
1960
 
  Session*      , /*!< in: thread handle */
1961
 
  set_var *var)
1962
 
{
1963
 
  const char *change_buffering_input = var->value->str_value.ptr();
1964
 
 
1965
 
  if (change_buffering_input == NULL)
1966
 
    return 1;
1967
 
 
1968
 
  ulint use;
1969
 
 
1970
 
  for (use = 0;
1971
 
       use < UT_ARR_SIZE(innobase_change_buffering_values);
1972
 
       ++use) {
1973
 
    if (!innobase_strcasecmp(change_buffering_input,
1974
 
                             innobase_change_buffering_values[use]))
1975
 
    {
1976
 
      ibuf_use= static_cast<ibuf_use_t>(use); 
1977
 
      return 0;
1978
 
    }
1979
 
  }
1980
 
 
1981
 
  return 1;
1982
 
}
1983
 
 
1984
 
 
1985
 
/*************************************************************//**
1986
 
Check if valid argument to innodb_file_format_max. This function
1987
 
is registered as a callback with MySQL.
1988
 
@return 0 for valid file format */
1989
 
static
1990
 
int
1991
 
innodb_file_format_max_validate(
1992
 
/*==============================*/
1993
 
  Session*   session, /*!< in: thread handle */
1994
 
  set_var *var)
1995
 
{
1996
 
  const char *file_format_input = var->value->str_value.ptr();
1997
 
  if (file_format_input == NULL)
1998
 
    return 1;
1999
 
 
2000
 
  if (file_format_input != NULL) {
2001
 
    int format_id = innobase_file_format_validate_and_set(file_format_input);
2002
 
 
2003
 
    if (format_id > DICT_TF_FORMAT_MAX) {
2004
 
      /* DEFAULT is "on", which is invalid at runtime. */
2005
 
      return 1;
2006
 
    }
2007
 
 
2008
 
    if (format_id >= 0) {
2009
 
      innobase_file_format_max= 
2010
 
        trx_sys_file_format_id_to_name((uint)format_id);
2011
 
 
2012
 
      /* Update the max format id in the system tablespace. */
2013
 
      char name_buff[100];
2014
 
      strcpy(name_buff, innobase_file_format_max.c_str());
2015
 
      if (trx_sys_file_format_max_set(format_id, (const char **)&name_buff))
2016
 
      {
2017
 
        errmsg_printf(ERRMSG_LVL_WARN,
2018
 
                      " [Info] InnoDB: the file format in the system "
2019
 
                      "tablespace is now set to %s.\n", name_buff);
2020
 
        innobase_file_format_max= name_buff;
2021
 
      }
2022
 
      return(0);
2023
 
 
2024
 
    } else {
2025
 
      push_warning_printf(session,
2026
 
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
2027
 
                          ER_WRONG_ARGUMENTS,
2028
 
                          "InnoDB: invalid innodb_file_format_max "
2029
 
                          "value; can be any format up to %s "
2030
 
                          "or equivalent id of %d",
2031
 
                          trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
2032
 
                          DICT_TF_FORMAT_MAX);
2033
 
    }
2034
 
  }
2035
 
 
2036
 
  return(1);
2037
 
}
2038
 
 
2039
 
 
2040
1793
/*********************************************************************//**
2041
1794
Opens an InnoDB database.
2042
1795
@return 0 on success, error code on failure */
2052
1805
  InnobaseEngine *actuall_engine_ptr;
2053
1806
  const module::option_map &vm= context.getOptions();
2054
1807
 
2055
 
  srv_auto_extend_increment= innodb_auto_extend_increment.get();
2056
 
  srv_io_capacity= innodb_io_capacity.get();
2057
 
  srv_purge_batch_size= innodb_purge_batch_size.get();
2058
 
  srv_n_purge_threads= innodb_n_purge_threads.get();
2059
 
  srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
2060
 
  srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
2061
 
  srv_max_purge_lag= innodb_max_purge_lag.get();
2062
 
  srv_stats_sample_pages= innodb_stats_sample_pages.get();
2063
 
  srv_n_free_tickets_to_enter= innodb_concurrency_tickets.get();
2064
 
  srv_replication_delay= innodb_replication_delay.get();
2065
 
  srv_thread_concurrency= innobase_thread_concurrency.get();
2066
 
  srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
2067
 
  srv_spin_wait_delay= innodb_spin_wait_delay.get();
2068
 
  srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
2069
 
  srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
2070
 
 
2071
1808
  /* Inverted Booleans */
2072
1809
 
2073
1810
  innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
2074
1811
  innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
2075
1812
  srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
2076
1813
  srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2077
 
  support_xa= (vm.count("disable-xa")) ? false : true;
2078
 
  btr_search_enabled= (vm.count("disable-adaptive-hash-index")) ? false : true;
2079
 
 
2080
 
 
2081
 
  /* Hafta do this here because we need to late-bind the default value */
 
1814
  (SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
 
1815
  (SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
 
1816
 
 
1817
  if (vm.count("io-capacity"))
 
1818
  {
 
1819
    if (srv_io_capacity < 100)
 
1820
    {
 
1821
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
 
1822
      exit(-1);
 
1823
    }
 
1824
  }
 
1825
 
2082
1826
  if (vm.count("data-home-dir"))
2083
1827
  {
2084
 
    innobase_data_home_dir= vm["data-home-dir"].as<string>();
2085
 
  }
2086
 
  else
2087
 
  {
2088
 
    innobase_data_home_dir= getDataHome().file_string();
2089
 
  }
2090
 
 
 
1828
    innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
 
1829
  }
 
1830
  else
 
1831
  {
 
1832
    innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
 
1833
  }
 
1834
 
 
1835
  if (vm.count("fast-shutdown"))
 
1836
  {
 
1837
    if (innobase_fast_shutdown > 2)
 
1838
    {
 
1839
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
 
1840
      exit(-1);
 
1841
    }
 
1842
  }
 
1843
 
 
1844
  if (vm.count("file-format-check"))
 
1845
  {
 
1846
    innobase_file_format_check= const_cast<char *>(vm["file-format-check"].as<string>().c_str());
 
1847
  }
 
1848
 
 
1849
  if (vm.count("flush-log-at-trx-commit"))
 
1850
  {
 
1851
    if (srv_flush_log_at_trx_commit > 2)
 
1852
    {
 
1853
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
 
1854
      exit(-1);
 
1855
    }
 
1856
  }
 
1857
 
 
1858
  if (vm.count("flush-method"))
 
1859
  {
 
1860
    innobase_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
 
1861
  }
 
1862
  else
 
1863
  {
 
1864
    innobase_file_flush_method= NULL;
 
1865
  }
 
1866
 
 
1867
#ifdef UNIV_LOG_ARCHIVE
 
1868
  if (vm.count("log-arch-dir"))
 
1869
  {
 
1870
    innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
 
1871
  }
 
1872
 
 
1873
  else
 
1874
  {
 
1875
    innobase_log_arch_dir= NULL;
 
1876
  }
 
1877
#endif /* UNIV_LOG_ARCHIVE */
 
1878
 
 
1879
  if (vm.count("max-dirty-pages-pct"))
 
1880
  {
 
1881
    if (srv_max_buf_pool_modified_pct > 99)
 
1882
    {
 
1883
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
 
1884
      exit(-1);
 
1885
    }
 
1886
  }
 
1887
 
 
1888
  if (vm.count("stats-sample-pages"))
 
1889
  {
 
1890
    if (srv_stats_sample_pages < 8)
 
1891
    {
 
1892
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
 
1893
      exit(-1);
 
1894
    }
 
1895
  }
 
1896
 
 
1897
  if (vm.count("additional-mem-pool-size"))
 
1898
  {
 
1899
    align_value(innobase_additional_mem_pool_size);
 
1900
 
 
1901
    if (innobase_additional_mem_pool_size < 512*1024L)
 
1902
    {
 
1903
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
 
1904
      exit(-1);
 
1905
    }
 
1906
 
 
1907
  }
 
1908
 
 
1909
  if (vm.count("autoextend-increment"))
 
1910
  {
 
1911
    if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
 
1912
    {
 
1913
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
 
1914
      exit(-1);
 
1915
    }
 
1916
  }
 
1917
 
 
1918
  if (vm.count("buffer-pool-size"))
 
1919
  {
 
1920
    align_value(innobase_buffer_pool_size, 1024*1024);
 
1921
    if (innobase_buffer_pool_size < 5*1024*1024)
 
1922
    {
 
1923
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
 
1924
      exit(-1);
 
1925
    }
 
1926
    
 
1927
  }
 
1928
 
 
1929
  if (vm.count("commit-concurrency"))
 
1930
  {
 
1931
    if (srv_replication_delay > 1000)
 
1932
    {
 
1933
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
 
1934
      exit(-1);
 
1935
    }
 
1936
  }
 
1937
 
 
1938
  if (vm.count("concurrency-tickets"))
 
1939
  {
 
1940
    if (srv_n_free_tickets_to_enter < 1)
 
1941
    {
 
1942
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
 
1943
      exit(-1);
 
1944
    }
 
1945
  }
 
1946
 
 
1947
  if (vm.count("read-io-threads"))
 
1948
  {
 
1949
    if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
 
1950
    {
 
1951
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
 
1952
      exit(-1);
 
1953
    }
 
1954
  }
 
1955
 
 
1956
  if (vm.count("write-io-threads"))
 
1957
  {
 
1958
    if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
 
1959
    {
 
1960
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
 
1961
      exit(-1);
 
1962
    }
 
1963
  }
 
1964
 
 
1965
  if (vm.count("force-recovery"))
 
1966
  {
 
1967
    if (innobase_force_recovery > 6)
 
1968
    {
 
1969
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
 
1970
      exit(-1);
 
1971
    }
 
1972
  }
 
1973
 
 
1974
  if (vm.count("log-buffer-size"))
 
1975
  {
 
1976
    align_value(innobase_log_buffer_size);
 
1977
    if (innobase_log_buffer_size < 256*1024L)
 
1978
    {
 
1979
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
 
1980
      exit(-1);
 
1981
    }
 
1982
  }
 
1983
 
 
1984
  if (vm.count("log-file-size"))
 
1985
  {
 
1986
    align_value(innobase_log_file_size, 1024*1024);
 
1987
    if (innobase_log_file_size < 1*1024*1024L)
 
1988
    {
 
1989
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
 
1990
      exit(-1);
 
1991
    }
 
1992
  }
 
1993
 
 
1994
  if (vm.count("log-files-in-group"))
 
1995
  {
 
1996
    if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
 
1997
    {
 
1998
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
 
1999
      exit(-1);
 
2000
    }
 
2001
  }
 
2002
 
 
2003
  if (vm.count("mirrored-log-groups"))
 
2004
  {
 
2005
    if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
 
2006
    {
 
2007
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
 
2008
      exit(-1);
 
2009
    }
 
2010
  }
 
2011
 
 
2012
  if (vm.count("open-files"))
 
2013
  {
 
2014
    if (innobase_open_files < 10)
 
2015
    {
 
2016
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
 
2017
      exit(-1);
 
2018
    }
 
2019
  }
 
2020
 
 
2021
  if (vm.count("thread-concurrency"))
 
2022
  {
 
2023
    if (srv_thread_concurrency > 1000)
 
2024
    {
 
2025
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
 
2026
      exit(-1);
 
2027
    }
 
2028
  }
2091
2029
 
2092
2030
  if (vm.count("data-file-path"))
2093
2031
  {
2094
 
    innobase_data_file_path= vm["data-file-path"].as<string>();
2095
 
  }
2096
 
 
 
2032
    innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
 
2033
  }
 
2034
  else
 
2035
  {
 
2036
    innobase_data_file_path= NULL;
 
2037
  }
 
2038
 
 
2039
  if (vm.count("version"))
 
2040
  {
 
2041
    innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
 
2042
  }
 
2043
 
 
2044
  if (vm.count("read-ahead-threshold"))
 
2045
  {
 
2046
    if (srv_read_ahead_threshold > 64)
 
2047
    {
 
2048
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
 
2049
      exit(-1);
 
2050
    }
 
2051
  }
 
2052
 
 
2053
  if (vm.count("strict-mode"))
 
2054
  {
 
2055
    (SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
 
2056
  }
 
2057
 
 
2058
  if (vm.count("lock-wait-timeout"))
 
2059
  {
 
2060
    if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
 
2061
    {
 
2062
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
 
2063
      exit(-1);
 
2064
    }
 
2065
 
 
2066
    (SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
 
2067
  }
2097
2068
 
2098
2069
  innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2099
2070
 
2117
2088
  }
2118
2089
#endif /* UNIV_DEBUG */
2119
2090
 
 
2091
  /* Check that values don't overflow on 32-bit systems. */
 
2092
  if (sizeof(ulint) == 4) {
 
2093
    if (innobase_buffer_pool_size > UINT32_MAX) {
 
2094
      errmsg_printf(ERRMSG_LVL_ERROR, 
 
2095
                    "innobase_buffer_pool_size can't be over 4GB"
 
2096
                    " on 32-bit systems");
 
2097
 
 
2098
      goto error;
 
2099
    }
 
2100
 
 
2101
    if (innobase_log_file_size > UINT32_MAX) {
 
2102
      errmsg_printf(ERRMSG_LVL_ERROR, 
 
2103
                    "innobase_log_file_size can't be over 4GB"
 
2104
                    " on 32-bit systems");
 
2105
 
 
2106
      goto error;
 
2107
    }
 
2108
  }
 
2109
 
2120
2110
  os_innodb_umask = (ulint)internal::my_umask;
2121
2111
 
2122
2112
 
2127
2117
 
2128
2118
  /* The default dir for data files is the datadir of MySQL */
2129
2119
 
2130
 
  srv_data_home = (char *)innobase_data_home_dir.c_str();
 
2120
  srv_data_home = (char *)innobase_data_home_dir;
2131
2121
 
2132
2122
  /* Set default InnoDB data file size to 10 MB and let it be
2133
2123
    auto-extending. Thus users can use InnoDB in >= 4.0 without having
2134
2124
    to specify any startup options. */
2135
2125
 
2136
 
  if (innobase_data_file_path.empty()) 
2137
 
  {
2138
 
    innobase_data_file_path= std::string("ibdata1:10M:autoextend");
 
2126
  if (!innobase_data_file_path) {
 
2127
    innobase_data_file_path = (char*) "ibdata1:10M:autoextend";
2139
2128
  }
2140
2129
 
2141
2130
  /* Since InnoDB edits the argument in the next call, we make another
2142
2131
    copy of it: */
2143
2132
 
2144
 
  internal_innobase_data_file_path = strdup(innobase_data_file_path.c_str());
 
2133
  internal_innobase_data_file_path = strdup(innobase_data_file_path);
2145
2134
 
2146
2135
  ret = (bool) srv_parse_data_file_paths_and_sizes(
2147
2136
                                                   internal_innobase_data_file_path);
2161
2150
 
2162
2151
  if (vm.count("log-group-home-dir"))
2163
2152
  {
2164
 
    innobase_log_group_home_dir= vm["log-group-home-dir"].as<string>();
 
2153
    innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str());
2165
2154
  }
2166
2155
  else
2167
2156
  {
2168
 
    innobase_log_group_home_dir= getDataHome().file_string();
 
2157
    innobase_log_group_home_dir = strdup(getDataHome().file_string().c_str());
2169
2158
  }
2170
2159
 
 
2160
#ifdef UNIV_LOG_ARCHIVE
 
2161
  /* Since innodb_log_arch_dir has no relevance under MySQL,
 
2162
    starting from 4.0.6 we always set it the same as
 
2163
innodb_log_group_home_dir: */
 
2164
 
 
2165
  innobase_log_arch_dir = innobase_log_group_home_dir;
 
2166
 
 
2167
  srv_arch_dir = innobase_log_arch_dir;
 
2168
#endif /* UNIG_LOG_ARCHIVE */
 
2169
 
2171
2170
  ret = (bool)
2172
 
    srv_parse_log_group_home_dirs((char *)innobase_log_group_home_dir.c_str());
 
2171
    srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
2173
2172
 
2174
 
  if (ret == FALSE || innobase_mirrored_log_groups.get() != 1) {
2175
 
    errmsg_printf(ERRMSG_LVL_ERROR,
2176
 
                  _("syntax error in innodb_log_group_home_dir, or a "
2177
 
                  "wrong number of mirrored log groups"));
 
2173
  if (ret == FALSE || innobase_mirrored_log_groups != 1) {
 
2174
    errmsg_printf(ERRMSG_LVL_ERROR, "syntax error in innodb_log_group_home_dir, or a "
 
2175
                  "wrong number of mirrored log groups");
2178
2176
 
2179
2177
    goto mem_free_and_error;
2180
2178
  }
2199
2197
 
2200
2198
  srv_file_format = format_id;
2201
2199
 
2202
 
  innobase_file_format_name =
2203
 
    trx_sys_file_format_id_to_name(format_id);
2204
 
 
2205
 
  /* Check innobase_file_format_check variable */
2206
 
  if (!innobase_file_format_check)
2207
 
  {
2208
 
    /* Set the value to disable checking. */
2209
 
    srv_max_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
2210
 
  } else {
2211
 
    /* Set the value to the lowest supported format. */
2212
 
    srv_max_file_format_at_startup = DICT_TF_FORMAT_MIN;
2213
 
  }
2214
 
 
2215
 
  /* Did the user specify a format name that we support?
2216
 
     As a side effect it will update the variable
2217
 
     srv_max_file_format_at_startup */
2218
 
  if (innobase_file_format_validate_and_set(innobase_file_format_max.c_str()) < 0)
2219
 
  {
2220
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("InnoDB: invalid "
2221
 
                    "innodb_file_format_max value: "
2222
 
                    "should be any value up to %s or its "
2223
 
                    "equivalent numeric id"),
2224
 
                    trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
2225
 
    goto mem_free_and_error;
 
2200
  /* Given the type of innobase_file_format_name we have little
 
2201
    choice but to cast away the constness from the returned name.
 
2202
    innobase_file_format_name is used in the MySQL set variable
 
2203
    interface and so can't be const. */
 
2204
 
 
2205
  innobase_file_format_name = 
 
2206
    (char*) trx_sys_file_format_id_to_name(format_id);
 
2207
 
 
2208
  /* Process innobase_file_format_check variable */
 
2209
  ut_a(innobase_file_format_check != NULL);
 
2210
 
 
2211
  /* As a side effect it will set srv_check_file_format_at_startup
 
2212
    on valid input. First we check for "on"/"off". */
 
2213
  if (!innobase_file_format_check_on_off(innobase_file_format_check)) {
 
2214
 
 
2215
    /* Did the user specify a format name that we support ?
 
2216
      As a side effect it will update the variable
 
2217
      srv_check_file_format_at_startup */
 
2218
    if (innobase_file_format_validate_and_set(
 
2219
                                innobase_file_format_check) < 0) {
 
2220
      errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: invalid "
 
2221
                    "innodb_file_format_check value: "
 
2222
                    "should be either 'on' or 'off' or "
 
2223
                    "any value up to %s or its "
 
2224
                    "equivalent numeric id",
 
2225
                    trx_sys_file_format_id_to_name(
 
2226
                                                   DICT_TF_FORMAT_MAX));
 
2227
 
 
2228
      goto mem_free_and_error;
 
2229
    }
2226
2230
  }
2227
2231
 
2228
2232
  if (vm.count("change-buffering"))
2233
2237
         use < UT_ARR_SIZE(innobase_change_buffering_values);
2234
2238
         use++) {
2235
2239
      if (!innobase_strcasecmp(
2236
 
                               innobase_change_buffering.c_str(),
 
2240
                               vm["change-buffering"].as<string>().c_str(),
2237
2241
                               innobase_change_buffering_values[use])) {
2238
 
        ibuf_use = static_cast<ibuf_use_t>(use);
 
2242
        ibuf_use = (ibuf_use_t) use;
2239
2243
        goto innobase_change_buffering_inited_ok;
2240
2244
      }
2241
2245
    }
2242
2246
 
2243
2247
    errmsg_printf(ERRMSG_LVL_ERROR,
2244
2248
                  "InnoDB: invalid value "
2245
 
                  "innodb_change_buffering=%s",
 
2249
                  "innodb_file_format_check=%s",
2246
2250
                  vm["change-buffering"].as<string>().c_str());
2247
2251
    goto mem_free_and_error;
2248
2252
  }
2249
2253
 
2250
2254
innobase_change_buffering_inited_ok:
2251
2255
  ut_a((ulint) ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
2252
 
  innobase_change_buffering = innobase_change_buffering_values[ibuf_use];
 
2256
  innobase_change_buffering = (char*)
 
2257
    innobase_change_buffering_values[ibuf_use];
2253
2258
 
2254
2259
  /* --------------------------------------------------*/
2255
2260
 
2256
 
  if (vm.count("flush-method") != 0)
2257
 
  {
2258
 
    srv_file_flush_method_str = (char *)vm["flush-method"].as<string>().c_str();
2259
 
  }
 
2261
  srv_file_flush_method_str = innobase_file_flush_method;
2260
2262
 
2261
2263
  srv_n_log_groups = (ulint) innobase_mirrored_log_groups;
2262
2264
  srv_n_log_files = (ulint) innobase_log_files_in_group;
2263
2265
  srv_log_file_size = (ulint) innobase_log_file_size;
2264
2266
 
 
2267
#ifdef UNIV_LOG_ARCHIVE
 
2268
  srv_log_archive_on = (ulint) innobase_log_archive;
 
2269
#endif /* UNIV_LOG_ARCHIVE */
2265
2270
  srv_log_buffer_size = (ulint) innobase_log_buffer_size;
2266
2271
 
2267
2272
  srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
2268
 
  srv_buf_pool_instances = (ulint) innobase_buffer_pool_instances;
2269
2273
 
2270
2274
  srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
2271
2275
 
2296
2300
 
2297
2301
  data_mysql_default_charset_coll = (ulint)default_charset_info->number;
2298
2302
 
 
2303
  innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct,
 
2304
                                                     FALSE);
 
2305
 
 
2306
  innobase_commit_concurrency_init_default();
 
2307
 
2299
2308
  /* Since we in this module access directly the fields of a trx
2300
2309
    struct, and due to different headers and flags it might happen that
2301
2310
    mutex_t has a different size in this module and in InnoDB
2304
2313
 
2305
2314
  err = innobase_start_or_create_for_mysql();
2306
2315
 
2307
 
  if (err != DB_SUCCESS)
2308
 
  {
2309
 
    goto mem_free_and_error;
2310
 
  }
2311
 
 
2312
 
  err = dict_create_sys_replication_log();
2313
 
 
2314
2316
  if (err != DB_SUCCESS) {
2315
2317
    goto mem_free_and_error;
2316
2318
  }
2317
2319
 
2318
 
 
2319
 
  innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(),
2320
 
                                                     TRUE);
2321
 
 
2322
2320
  innobase_open_tables = hash_create(200);
2323
2321
  pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
2324
2322
  pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
2356
2354
  innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
2357
2355
  context.add(innodb_lock_waits_tool);
2358
2356
 
2359
 
  innodb_sys_tables_tool= new(std::nothrow)InnodbSysTablesTool();
2360
 
  context.add(innodb_sys_tables_tool);
2361
 
 
2362
 
  innodb_sys_tablestats_tool= new(std::nothrow)InnodbSysTableStatsTool();
2363
 
  context.add(innodb_sys_tablestats_tool);
2364
 
 
2365
 
  innodb_sys_indexes_tool= new(std::nothrow)InnodbSysIndexesTool();
2366
 
  context.add(innodb_sys_indexes_tool);
2367
 
 
2368
 
  innodb_sys_columns_tool= new(std::nothrow)InnodbSysColumnsTool();
2369
 
  context.add(innodb_sys_columns_tool);
2370
 
 
2371
 
  innodb_sys_fields_tool= new(std::nothrow)InnodbSysFieldsTool();
2372
 
  context.add(innodb_sys_fields_tool);
2373
 
 
2374
 
  innodb_sys_foreign_tool= new(std::nothrow)InnodbSysForeignTool();
2375
 
  context.add(innodb_sys_foreign_tool);
2376
 
 
2377
 
  innodb_sys_foreign_cols_tool= new(std::nothrow)InnodbSysForeignColsTool();
2378
 
  context.add(innodb_sys_foreign_cols_tool);
2379
 
 
2380
2357
  context.add(new(std::nothrow)InnodbInternalTables());
2381
 
  context.add(new(std::nothrow)InnodbReplicationTable());
2382
 
 
2383
 
  if (innobase_use_replication_log)
2384
 
  {
2385
 
    replication_logger= new(std::nothrow)ReplicationLog();
2386
 
    context.add(replication_logger);
2387
 
    ReplicationLog::setup(replication_logger);
2388
 
  }
2389
 
 
2390
 
  context.registerVariable(new sys_var_const_string_val("data-home-dir", innobase_data_home_dir));
2391
 
  context.registerVariable(new sys_var_const_string_val("flush-method", 
2392
 
                                                        vm.count("flush-method") ?  vm["flush-method"].as<string>() : ""));
2393
 
  context.registerVariable(new sys_var_const_string_val("log-group-home-dir", innobase_log_group_home_dir));
2394
 
  context.registerVariable(new sys_var_const_string_val("data-file-path", innobase_data_file_path));
2395
 
  context.registerVariable(new sys_var_const_string_val("version", vm["version"].as<string>()));
2396
 
 
2397
 
 
2398
 
  context.registerVariable(new sys_var_bool_ptr_readonly("replication_log", &innobase_use_replication_log));
2399
 
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
2400
 
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
2401
 
  context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
2402
 
  context.registerVariable(new sys_var_bool_ptr_readonly("file-format-check", &innobase_file_format_check));
2403
 
  context.registerVariable(new sys_var_bool_ptr("adaptive-flushing", &srv_adaptive_flushing));
2404
 
  context.registerVariable(new sys_var_bool_ptr("status-file", &innobase_create_status_file));
2405
 
  context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2406
 
  context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2407
 
 
2408
 
  context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2409
 
  context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
2410
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
2411
 
 
2412
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
2413
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
2414
 
                                                                   innodb_auto_extend_increment,
2415
 
                                                                   auto_extend_update));
2416
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
2417
 
                                                                   innodb_io_capacity,
2418
 
                                                                   io_capacity_update));
2419
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
2420
 
                                                                   innodb_purge_batch_size,
2421
 
                                                                   purge_batch_update));
2422
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
2423
 
                                                                   innodb_n_purge_threads,
2424
 
                                                                   purge_threads_update));
2425
 
  context.registerVariable(new sys_var_constrained_value<uint16_t>("fast_shutdown", innobase_fast_shutdown));
2426
 
  context.registerVariable(new sys_var_std_string("file_format",
2427
 
                                                  innobase_file_format_name,
2428
 
                                                  innodb_file_format_name_validate));
2429
 
  context.registerVariable(new sys_var_std_string("change_buffering",
2430
 
                                                  innobase_change_buffering,
2431
 
                                                  innodb_change_buffering_validate));
2432
 
  context.registerVariable(new sys_var_std_string("file_format_max",
2433
 
                                                  innobase_file_format_max,
2434
 
                                                  innodb_file_format_max_validate));
2435
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
2436
 
  context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
2437
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit",
2438
 
                                                  innodb_flush_log_at_trx_commit));
2439
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
2440
 
                                                  innodb_max_dirty_pages_pct));
2441
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
2442
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
2443
 
  context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
2444
 
 
2445
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("commit_concurrency",
2446
 
                                                                   innobase_commit_concurrency,
2447
 
                                                                   innodb_commit_concurrency_validate));
2448
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("concurrency_tickets",
2449
 
                                                                   innodb_concurrency_tickets));
2450
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_io_threads", innobase_read_io_threads));
2451
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_io_threads", innobase_write_io_threads));
2452
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("replication_delay", innodb_replication_delay));
2453
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
2454
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("log_buffer_size", innobase_log_buffer_size));
2455
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("log_files_in_group", innobase_log_files_in_group));
2456
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("mirrored_log_groups", innobase_mirrored_log_groups));
2457
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", innobase_open_files));
2458
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("old_blocks_pct",
2459
 
                                                                   innobase_old_blocks_pct,
2460
 
                                                                   innodb_old_blocks_pct_update));
2461
 
  context.registerVariable(new sys_var_uint32_t_ptr("old_blocks_time", &buf_LRU_old_threshold_ms));
2462
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("sync_spin_loops", innodb_sync_spin_loops, innodb_sync_spin_loops_update));
2463
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("spin_wait_delay", innodb_spin_wait_delay, innodb_spin_wait_delay_update));
2464
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_sleep_delay", innodb_thread_sleep_delay, innodb_thread_sleep_delay_update));
2465
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_concurrency",
2466
 
                                                                   innobase_thread_concurrency,
2467
 
                                                                   innodb_thread_concurrency_update));
2468
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("read_ahead_threshold",
2469
 
                                                                   innodb_read_ahead_threshold,
2470
 
                                                                   innodb_read_ahead_threshold_update));
 
2358
 
2471
2359
  /* Get the current high water mark format. */
2472
 
  innobase_file_format_max = trx_sys_file_format_max_get();
2473
 
  btr_search_fully_disabled = (!btr_search_enabled);
 
2360
  innobase_file_format_check = (char*) trx_sys_file_format_max_get();
2474
2361
 
2475
2362
  return(FALSE);
2476
2363
error:
2579
2466
    Note, the position is current because of
2580
2467
    prepare_commit_mutex */
2581
2468
retry:
2582
 
    if (innobase_commit_concurrency.get() > 0) {
 
2469
    if (innobase_commit_concurrency > 0) {
2583
2470
      pthread_mutex_lock(&commit_cond_m);
2584
2471
      commit_threads++;
2585
2472
 
2586
 
      if (commit_threads > innobase_commit_concurrency.get()) {
 
2473
      if (commit_threads > innobase_commit_concurrency) {
2587
2474
        commit_threads--;
2588
2475
        pthread_cond_wait(&commit_cond,
2589
2476
          &commit_cond_m);
2608
2495
    innobase_commit_low(trx);
2609
2496
    trx->flush_log_later = FALSE;
2610
2497
 
2611
 
    if (innobase_commit_concurrency.get() > 0) {
 
2498
    if (innobase_commit_concurrency > 0) {
2612
2499
      pthread_mutex_lock(&commit_cond_m);
2613
2500
      commit_threads--;
2614
2501
      pthread_cond_signal(&commit_cond);
2855
2742
  /* Warn if rolling back some things... */
2856
2743
  if (session->getKilled() != Session::NOT_KILLED &&
2857
2744
      trx->conc_state != TRX_NOT_STARTED &&
2858
 
      trx->undo_no > 0 &&
 
2745
      trx->undo_no.low > 0 &&
2859
2746
      global_system_variables.log_warnings)
2860
2747
  {
2861
 
      errmsg_printf(ERRMSG_LVL_WARN,
 
2748
      errmsg_printf(ERRMSG_LVL_WARN, 
2862
2749
      "Drizzle is closing a connection during a KILL operation\n"
2863
 
      "that has an active InnoDB transaction.  %llu row modifications will "
 
2750
      "that has an active InnoDB transaction.  %lu row modifications will "
2864
2751
      "roll back.\n",
2865
 
      (ullint) trx->undo_no);
 
2752
      (ulong) trx->undo_no.low);
2866
2753
  }
2867
2754
 
2868
2755
  innobase_rollback_trx(trx);
3117
3004
        dict_index_t**  index_mapping;
3118
3005
        ibool           ret = TRUE;
3119
3006
 
3120
 
        mutex_enter(&dict_sys->mutex);
3121
 
 
3122
3007
        mysql_num_index = table->getShare()->keys;
3123
3008
        ib_num_index = UT_LIST_GET_LEN(ib_table->indexes);
3124
3009
 
3148
3033
                                                         sizeof(*index_mapping));
3149
3034
 
3150
3035
                if (!index_mapping) {
3151
 
                        /* Report an error if index_mapping continues to be
3152
 
                        NULL and mysql_num_index is a non-zero value */
3153
 
                        errmsg_printf(ERRMSG_LVL_ERROR,
3154
 
                                      "InnoDB: fail to allocate memory for "
3155
 
                                        "index translation table. Number of "
3156
 
                                        "Index:%lu, array size:%lu",
3157
 
                                        mysql_num_index,
3158
 
                                        share->idx_trans_tbl.array_size);
3159
3036
                        ret = FALSE;
3160
3037
                        goto func_exit;
3161
3038
                }
3163
3040
                share->idx_trans_tbl.array_size = mysql_num_index;
3164
3041
        }
3165
3042
 
 
3043
 
3166
3044
        /* For each index in the mysql key_info array, fetch its
3167
3045
        corresponding InnoDB index pointer into index_mapping
3168
3046
        array. */
3208
3086
 
3209
3087
        share->idx_trans_tbl.index_mapping = index_mapping;
3210
3088
 
3211
 
        mutex_exit(&dict_sys->mutex);
3212
 
 
3213
3089
        return(ret);
3214
3090
}
3215
3091
 
3296
3172
    err = row_search_max_autoinc(index, col_name, &read_auto_inc);
3297
3173
 
3298
3174
    switch (err) {
3299
 
    case DB_SUCCESS: {
3300
 
      uint64_t col_max_value;
3301
 
 
3302
 
      col_max_value = innobase_get_int_col_max_value(field);
3303
 
 
 
3175
    case DB_SUCCESS:
3304
3176
      /* At the this stage we do not know the increment
3305
 
         nor the offset, so use a default increment of 1. */
3306
 
 
3307
 
      auto_inc = innobase_next_autoinc(read_auto_inc, 1, 1, col_max_value);
3308
 
 
 
3177
         or the offset, so use a default increment of 1. */
 
3178
      auto_inc = read_auto_inc + 1;
3309
3179
      break;
3310
 
    }
 
3180
 
3311
3181
    case DB_RECORD_NOT_FOUND:
3312
3182
      ut_print_timestamp(stderr);
3313
3183
      fprintf(stderr, "  InnoDB: MySQL and InnoDB data "
3580
3450
    /* We update the highest file format in the system table
3581
3451
    space, if this table has higher file format setting. */
3582
3452
 
3583
 
    char changed_file_format_max[100];
3584
 
    strcpy(changed_file_format_max, innobase_file_format_max.c_str());
3585
 
    trx_sys_file_format_max_upgrade((const char **)&changed_file_format_max,
 
3453
    trx_sys_file_format_max_upgrade(
 
3454
      (const char**) &innobase_file_format_check,
3586
3455
      dict_table_get_format(prebuilt->table));
3587
 
    innobase_file_format_max= changed_file_format_max;
3588
3456
  }
3589
3457
 
 
3458
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
 
3459
 
3590
3460
  /* Only if the table has an AUTOINC column. */
3591
3461
  if (prebuilt->table != NULL && getTable()->found_next_number_field != NULL) {
3592
3462
 
3604
3474
    dict_table_autoinc_unlock(prebuilt->table);
3605
3475
  }
3606
3476
 
3607
 
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
3608
 
 
3609
3477
  return(0);
3610
3478
}
3611
3479
 
3853
3721
  case DRIZZLE_TYPE_DATETIME:
3854
3722
  case DRIZZLE_TYPE_DATE:
3855
3723
  case DRIZZLE_TYPE_TIMESTAMP:
3856
 
  case DRIZZLE_TYPE_ENUM:
3857
3724
    return(DATA_INT);
3858
3725
  case DRIZZLE_TYPE_DOUBLE:
3859
3726
    return(DATA_DOUBLE);
3860
3727
  case DRIZZLE_TYPE_BLOB:
3861
 
    return(DATA_BLOB);
3862
 
  case DRIZZLE_TYPE_UUID:
3863
 
    return(DATA_FIXBINARY);
3864
 
  case DRIZZLE_TYPE_NULL:
 
3728
                return(DATA_BLOB);
 
3729
  default:
3865
3730
    ut_error;
3866
3731
  }
3867
3732
 
4101
3966
      ulint     key_len;
4102
3967
      const unsigned char*    src_start;
4103
3968
      enum_field_types  real_type;
4104
 
      const CHARSET_INFO* cs= field->charset();
4105
3969
 
4106
3970
      key_len = key_part->length;
4107
3971
 
4123
3987
      memcpy(buff, src_start, true_len);
4124
3988
      buff += true_len;
4125
3989
 
4126
 
      /* Pad the unused space with spaces. */
 
3990
      /* Pad the unused space with spaces. Note that no
 
3991
      padding is ever needed for UCS-2 because in MySQL,
 
3992
      all UCS2 characters are 2 bytes, as MySQL does not
 
3993
      support surrogate pairs, which are needed to represent
 
3994
      characters in the range U+10000 to U+10FFFF. */
4127
3995
 
4128
3996
      if (true_len < key_len) {
4129
 
        ulint   pad_len = key_len - true_len;
4130
 
        ut_a(!(pad_len % cs->mbminlen));
4131
 
 
4132
 
        cs->cset->fill(cs, buff, pad_len,
4133
 
                       0x20 /* space */);
 
3997
        ulint pad_len = key_len - true_len;
 
3998
        memset(buff, ' ', pad_len);
4134
3999
        buff += pad_len;
4135
4000
      }
4136
4001
    }
4238
4103
 
4239
4104
  /* Note that in InnoDB, i is the column number. MySQL calls columns
4240
4105
  'fields'. */
4241
 
  for (i = 0; i < n_fields; i++)
 
4106
  for (i = 0; i < n_fields; i++) 
4242
4107
  {
4243
 
    const dict_col_t *col= &index->table->cols[i];
4244
4108
    templ = prebuilt->mysql_template + n_requested_fields;
4245
4109
    field = table->getField(i);
4246
4110
 
4288
4152
    templ->col_no = i;
4289
4153
 
4290
4154
    if (index == clust_index) {
4291
 
      templ->rec_field_no = dict_col_get_clust_pos(col, index);
 
4155
      templ->rec_field_no = dict_col_get_clust_pos(
 
4156
        &index->table->cols[i], index);
4292
4157
    } else {
4293
4158
      templ->rec_field_no = dict_index_get_nth_col_pos(
4294
4159
                index, i);
4317
4182
      mysql_prefix_len = templ->mysql_col_offset
4318
4183
        + templ->mysql_col_len;
4319
4184
    }
4320
 
    templ->type = col->mtype;
 
4185
    templ->type = index->table->cols[i].mtype;
4321
4186
    templ->mysql_type = (ulint)field->type();
4322
4187
 
4323
4188
    if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
4325
4190
        (((Field_varstring*)field)->pack_length_no_ptr());
4326
4191
    }
4327
4192
 
4328
 
    templ->charset = dtype_get_charset_coll(col->prtype);
4329
 
    templ->mbminlen = dict_col_get_mbminlen(col);
4330
 
    templ->mbmaxlen = dict_col_get_mbmaxlen(col);
4331
 
    templ->is_unsigned = col->prtype & DATA_UNSIGNED;
 
4193
    templ->charset = dtype_get_charset_coll(
 
4194
      index->table->cols[i].prtype);
 
4195
    templ->mbminlen = index->table->cols[i].mbminlen;
 
4196
    templ->mbmaxlen = index->table->cols[i].mbmaxlen;
 
4197
    templ->is_unsigned = index->table->cols[i].prtype
 
4198
              & DATA_UNSIGNED;
4332
4199
    if (templ->type == DATA_BLOB) {
4333
4200
      prebuilt->templ_contains_blob = TRUE;
4334
4201
    }
4546
4413
 
4547
4414
  error = row_insert_for_mysql((byte*) record, prebuilt);
4548
4415
 
4549
 
  user_session->setXaId(trx->id);
 
4416
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4550
4417
 
4551
4418
  /* Handle duplicate key errors */
4552
4419
  if (auto_inc_used) {
4869
4736
 
4870
4737
  error = row_update_for_mysql((byte*) old_row, prebuilt);
4871
4738
 
4872
 
  user_session->setXaId(trx->id);
 
4739
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4873
4740
 
4874
4741
  /* We need to do some special AUTOINC handling for the following case:
4875
4742
 
4961
4828
 
4962
4829
  error = row_update_for_mysql((byte*) record, prebuilt);
4963
4830
 
4964
 
  user_session->setXaId(trx->id);
 
4831
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4965
4832
 
4966
4833
  innodb_srv_conc_exit_innodb(trx);
4967
4834
 
5221
5088
    return(HA_ERR_CRASHED);
5222
5089
  }
5223
5090
 
5224
 
  if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
5225
 
    return(HA_ERR_TABLE_DEF_CHANGED);
5226
 
  }
5227
5091
 
5228
5092
  /* Note that if the index for which the search template is built is not
5229
5093
  necessarily prebuilt->index, but can also be the clustered index */
5818
5682
 
5819
5683
    col_type = get_innobase_type_from_mysql_type(&unsigned_type,
5820
5684
                  field);
5821
 
 
5822
 
    if (!col_type) {
5823
 
      push_warning_printf(
5824
 
                          (Session*) trx->mysql_thd,
5825
 
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
5826
 
                          ER_CANT_CREATE_TABLE,
5827
 
                          "Error creating table '%s' with "
5828
 
                          "column '%s'. Please check its "
5829
 
                          "column type and try to re-create "
5830
 
                          "the table with an appropriate "
5831
 
                          "column type.",
5832
 
                          table->name, (char*) field->field_name);
5833
 
      goto err_col;
5834
 
    }
5835
 
 
5836
5685
    if (field->null_ptr) {
5837
5686
      nulls_allowed = 0;
5838
5687
    } else {
5890
5739
    if (dict_col_name_is_reserved(field->field_name)){
5891
5740
      my_error(ER_WRONG_COLUMN_NAME, MYF(0), field->field_name);
5892
5741
 
5893
 
  err_col:
5894
5742
      dict_mem_table_free(table);
5895
5743
      trx_commit_for_mysql(trx);
5896
5744
 
6232
6080
# error "DICT_TF_ZSSIZE_MAX < 1"
6233
6081
#endif
6234
6082
 
6235
 
    if (strict_mode)
 
6083
    if (SessionVAR(&session, strict_mode))
6236
6084
    {
6237
6085
      if (! srv_file_per_table)
6238
6086
      {
6279
6127
                          lex_identified_temp_table ? name2 : NULL,
6280
6128
                          iflags);
6281
6129
 
6282
 
  session.setXaId(trx->id);
 
6130
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6283
6131
 
6284
6132
  if (error) {
6285
6133
    goto cleanup;
6360
6208
    /* We update the highest file format in the system table
6361
6209
      space, if this table has higher file format setting. */
6362
6210
 
6363
 
    char changed_file_format_max[100];
6364
 
    strcpy(changed_file_format_max, innobase_file_format_max.c_str());
6365
 
    trx_sys_file_format_max_upgrade((const char **)&changed_file_format_max,
6366
 
      dict_table_get_format(innobase_table));
6367
 
    innobase_file_format_max= changed_file_format_max;
 
6211
    trx_sys_file_format_max_upgrade((const char**) &innobase_file_format_check,
 
6212
                                    dict_table_get_format(innobase_table));
6368
6213
  }
6369
6214
 
6370
6215
  /* Note: We can't call update_session() as prebuilt will not be
6536
6381
                                   session_sql_command(&session)
6537
6382
                                   == SQLCOM_DROP_DB);
6538
6383
 
6539
 
  session.setXaId(trx->id);
 
6384
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6540
6385
 
6541
6386
  /* Flush the log to reduce probability that the .frm files and
6542
6387
    the InnoDB data dictionary get out-of-sync if the user runs
6758
6603
 
6759
6604
  error = innobase_rename_table(trx, from.getPath().c_str(), to.getPath().c_str(), TRUE);
6760
6605
 
6761
 
  session.setXaId(trx->id);
 
6606
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6762
6607
 
6763
6608
  /* Tell the InnoDB server that there might be work for
6764
6609
    utility threads: */
6846
6691
    goto func_exit;
6847
6692
  }
6848
6693
 
6849
 
  if (UNIV_UNLIKELY(!row_merge_is_index_usable(prebuilt->trx, index))) {
6850
 
    n_rows = HA_ERR_TABLE_DEF_CHANGED;
6851
 
    goto func_exit;
6852
 
  }
6853
 
 
6854
6694
  heap = mem_heap_create(2 * (key->key_parts * sizeof(dfield_t)
6855
6695
            + sizeof(dtuple_t)));
6856
6696
 
7047
6887
 
7048
6888
        /* If index does not belong to the table of share structure. Search
7049
6889
        index->table instead */
7050
 
        if (index->table != ib_table) {
7051
 
                i = 0;
7052
 
                ind = dict_table_get_first_index(index->table);
7053
 
 
7054
 
                while (index != ind) {
7055
 
                        ind = dict_table_get_next_index(ind);
7056
 
                        i++;
7057
 
                }
7058
 
 
7059
 
                if (row_table_got_default_clust_index(index->table)) {
7060
 
                        ut_a(i > 0);
7061
 
                        i--;
7062
 
                }
7063
 
 
7064
 
                return(i);
7065
 
        }
7066
 
 
7067
 
        /* If index does not belong to the table of share structure. Search
7068
 
        index->table instead */
7069
 
        if (index->table != ib_table) {
 
6890
        if (index->table != ib_table
 
6891
            && strcmp(index->table->name, share->table_name)) {
7070
6892
                i = 0;
7071
6893
                ind = dict_table_get_first_index(index->table);
7072
6894
 
7130
6952
  dict_index_t* index;
7131
6953
  ha_rows   rec_per_key;
7132
6954
  ib_int64_t  n_rows;
 
6955
  ulong   j;
 
6956
  ulong   i;
7133
6957
  os_file_stat_t  stat_info;
7134
6958
 
7135
6959
  /* If we are forcing recovery at a high level, we will suppress
7136
6960
  statistics calculation on tables, because that may crash the
7137
6961
  server if an index is badly corrupted. */
7138
6962
 
 
6963
  if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
 
6964
 
 
6965
    /* We return success (0) instead of HA_ERR_CRASHED,
 
6966
    because we want MySQL to process this query and not
 
6967
    stop, like it would do if it received the error code
 
6968
    HA_ERR_CRASHED. */
 
6969
 
 
6970
    return(0);
 
6971
  }
 
6972
 
7139
6973
  /* We do not know if MySQL can call this function before calling
7140
6974
  external_lock(). To be safe, update the session of the current table
7141
6975
  handle. */
7227
7061
    acquiring latches inside InnoDB, we do not call it if we
7228
7062
    are asked by MySQL to avoid locking. Another reason to
7229
7063
    avoid the call is that it uses quite a lot of CPU.
7230
 
    See Bug#38185. */
7231
 
    if (flag & HA_STATUS_NO_LOCK) {
7232
 
      /* We do not update delete_length if no
7233
 
         locking is requested so the "old" value can
7234
 
         remain. delete_length is initialized to 0 in
7235
 
         the ha_statistics' constructor. */
7236
 
    } else if (UNIV_UNLIKELY
7237
 
               (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) {
7238
 
      /* Avoid accessing the tablespace if
7239
 
         innodb_crash_recovery is set to a high value. */
7240
 
      stats.delete_length = 0;
7241
 
    } else {
 
7064
    See Bug#38185.
 
7065
    We do not update delete_length if no locking is requested
 
7066
    so the "old" value can remain. delete_length is initialized
 
7067
    to 0 in the ha_statistics' constructor. */
 
7068
    if (!(flag & HA_STATUS_NO_LOCK)) {
 
7069
 
7242
7070
      /* lock the data dictionary to avoid races with
7243
7071
      ibd_file_missing and tablespace_discarded */
7244
7072
      row_mysql_lock_data_dictionary(prebuilt->trx);
7284
7112
  }
7285
7113
 
7286
7114
  if (flag & HA_STATUS_CONST) {
7287
 
    ulong i;
7288
7115
    /* Verify the number of index in InnoDB and MySQL
7289
7116
       matches up. If prebuilt->clust_index_was_generated
7290
7117
       holds, InnoDB defines GEN_CLUST_INDEX internally */
7300
7127
    }
7301
7128
 
7302
7129
    for (i = 0; i < getTable()->getShare()->sizeKeys(); i++) {
7303
 
      ulong j;
7304
7130
      /* We could get index quickly through internal
7305
7131
         index mapping with the index translation table.
7306
7132
         The identity of index (match up index name with
7366
7192
    }
7367
7193
  }
7368
7194
 
7369
 
  if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
7370
 
    goto func_exit;
7371
 
  }
7372
 
 
7373
7195
  if (flag & HA_STATUS_ERRKEY) {
7374
7196
    const dict_index_t* err_index;
7375
7197
 
7391
7213
    stats.auto_increment_value = innobase_peek_autoinc();
7392
7214
  }
7393
7215
 
7394
 
func_exit:
7395
7216
  prebuilt->trx->op_info = (char*)"";
7396
7217
 
7397
7218
  return(0);
8092
7913
{
8093
7914
  trx_t*      trx;
8094
7915
  static const char truncated_msg[] = "... truncated...\n";
8095
 
  const long    MAX_STATUS_SIZE = 1048576;
 
7916
  const long    MAX_STATUS_SIZE = 64000;
8096
7917
  ulint     trx_list_start = ULINT_UNDEFINED;
8097
7918
  ulint     trx_list_end = ULINT_UNDEFINED;
8098
7919
 
8121
7942
 
8122
7943
  if (flen > MAX_STATUS_SIZE) {
8123
7944
    usable_len = MAX_STATUS_SIZE;
8124
 
    srv_truncated_status_writes++;
8125
7945
  } else {
8126
7946
    usable_len = flen;
8127
7947
  }
8157
7977
 
8158
7978
  mutex_exit(&srv_monitor_file_mutex);
8159
7979
 
8160
 
  stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
8161
 
             STRING_WITH_LEN(""), str, flen);
 
7980
  bool result = FALSE;
8162
7981
 
 
7982
  if (stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
 
7983
      STRING_WITH_LEN(""), str, flen)) {
 
7984
    result= TRUE;
 
7985
  }
8163
7986
  free(str);
8164
7987
 
8165
7988
  return(FALSE);
8508
8331
        && (sql_command == SQLCOM_INSERT_SELECT
8509
8332
            || sql_command == SQLCOM_REPLACE_SELECT
8510
8333
            || sql_command == SQLCOM_UPDATE
8511
 
            || sql_command == SQLCOM_CREATE_TABLE
8512
 
            || sql_command == SQLCOM_SET_OPTION)) {
 
8334
            || sql_command == SQLCOM_CREATE_TABLE)) {
8513
8335
 
8514
8336
      /* If we either have innobase_locks_unsafe_for_binlog
8515
8337
      option set or this session is using READ COMMITTED
8517
8339
      is not set to serializable and MySQL is doing
8518
8340
      INSERT INTO...SELECT or REPLACE INTO...SELECT
8519
8341
      or UPDATE ... = (SELECT ...) or CREATE  ...
8520
 
      SELECT... or SET ... = (SELECT ...) without
8521
 
      FOR UPDATE or IN SHARE MODE in select,
8522
 
      then we use consistent read for select. */
 
8342
      SELECT... without FOR UPDATE or IN SHARE
 
8343
      MODE in select, then we use consistent read
 
8344
      for select. */
8523
8345
 
8524
8346
      prebuilt->select_lock_type = LOCK_NONE;
8525
8347
      prebuilt->stored_select_lock_type = LOCK_NONE;
8607
8429
}
8608
8430
 
8609
8431
/*******************************************************************//**
8610
 
This function reads the global auto-inc counter. It doesn't use the
 
8432
This function reads the global auto-inc counter. It doesn't use the 
8611
8433
AUTOINC lock even if the lock mode is set to TRADITIONAL.
8612
8434
@return the autoinc value */
8613
8435
UNIV_INTERN
8627
8449
 
8628
8450
  auto_inc = dict_table_autoinc_read(innodb_table);
8629
8451
 
8630
 
  if (auto_inc == 0) {
8631
 
    ut_print_timestamp(stderr);
8632
 
    fprintf(stderr, "  InnoDB: AUTOINC next value generation "
8633
 
            "is disabled for '%s'\n", innodb_table->name);
8634
 
  }
 
8452
  ut_a(auto_inc > 0);
8635
8453
 
8636
8454
  dict_table_autoinc_unlock(innodb_table);
8637
8455
 
9049
8867
uint64_t InnobaseEngine::doGetCurrentTransactionId(Session *session)
9050
8868
{
9051
8869
  trx_t *trx= session_to_trx(session);
9052
 
  return (trx->id);
 
8870
  return (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
9053
8871
}
9054
8872
 
9055
8873
uint64_t InnobaseEngine::doGetNewTransactionId(Session *session)
9067
8885
  trx->id= trx_sys_get_new_trx_id();
9068
8886
  mutex_exit(&kernel_mutex);
9069
8887
 
9070
 
  uint64_t transaction_id= trx->id;
 
8888
  uint64_t transaction_id= (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
9071
8889
 
9072
8890
  return transaction_id;
9073
8891
}
9183
9001
}
9184
9002
 
9185
9003
/************************************************************//**
 
9004
Validate the file format check value, is it one of "on" or "off",
 
9005
as a side effect it sets the srv_check_file_format_at_startup variable.
 
9006
@return true if config value one of "on" or  "off" */
 
9007
static
 
9008
bool
 
9009
innobase_file_format_check_on_off(
 
9010
/*==============================*/
 
9011
  const char* format_check) /*!< in: parameter value */
 
9012
{
 
9013
  bool    ret = true;
 
9014
 
 
9015
  if (!innobase_strcasecmp(format_check, "off")) {
 
9016
 
 
9017
    /* Set the value to disable checking. */
 
9018
    srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
 
9019
 
 
9020
  } else if (!innobase_strcasecmp(format_check, "on")) {
 
9021
 
 
9022
    /* Set the value to the lowest supported format. */
 
9023
    srv_check_file_format_at_startup = DICT_TF_FORMAT_51;
 
9024
  } else {
 
9025
    ret = FALSE;
 
9026
  }
 
9027
 
 
9028
  return(ret);
 
9029
}
 
9030
 
 
9031
/************************************************************//**
9186
9032
Validate the file format check config parameters, as a side effect it
9187
 
sets the srv_max_file_format_at_startup variable.
 
9033
sets the srv_check_file_format_at_startup variable.
9188
9034
@return the format_id if valid config value, otherwise, return -1 */
9189
9035
static
9190
9036
int
9191
9037
innobase_file_format_validate_and_set(
9192
9038
/*================================*/
9193
 
  const char* format_max) /*!< in: parameter value */
 
9039
  const char* format_check) /*!< in: parameter value */
9194
9040
{
9195
9041
  uint    format_id;
9196
9042
 
9197
 
  format_id = innobase_file_format_name_lookup(format_max);
 
9043
  format_id = innobase_file_format_name_lookup(format_check);
9198
9044
 
9199
9045
  if (format_id < DICT_TF_FORMAT_MAX + 1) {
9200
 
    srv_max_file_format_at_startup = format_id;
 
9046
    srv_check_file_format_at_startup = format_id;
9201
9047
    return((int) format_id);
9202
9048
  } else {
9203
9049
    return(-1);
9204
9050
  }
9205
9051
}
9206
9052
 
9207
 
 
 
9053
/*************************************************************//**
 
9054
Check if it is a valid file format. This function is registered as
 
9055
a callback with MySQL.
 
9056
@return 0 for valid file format */
 
9057
static
 
9058
int
 
9059
innodb_file_format_name_validate(
 
9060
/*=============================*/
 
9061
  Session*      , /*!< in: thread handle */
 
9062
  drizzle_sys_var*  , /*!< in: pointer to system
 
9063
            variable */
 
9064
  void*       save, /*!< out: immediate result
 
9065
            for update function */
 
9066
  drizzle_value*    value)  /*!< in: incoming string */
 
9067
{
 
9068
  const char* file_format_input;
 
9069
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9070
  int   len = sizeof(buff);
 
9071
 
 
9072
  ut_a(save != NULL);
 
9073
  ut_a(value != NULL);
 
9074
 
 
9075
  file_format_input = value->val_str(value, buff, &len);
 
9076
 
 
9077
  if (file_format_input != NULL) {
 
9078
    uint  format_id;
 
9079
 
 
9080
    format_id = innobase_file_format_name_lookup(
 
9081
      file_format_input);
 
9082
 
 
9083
    if (format_id <= DICT_TF_FORMAT_MAX) {
 
9084
      /* Save a pointer to the name in the
 
9085
         'file_format_name_map' constant array. */
 
9086
      *static_cast<const char**>(save) =
 
9087
        trx_sys_file_format_id_to_name(format_id);
 
9088
 
 
9089
      return(0);
 
9090
    }
 
9091
  }
 
9092
 
 
9093
  *static_cast<const char**>(save) = NULL;
 
9094
  return(1);
 
9095
}
 
9096
 
 
9097
/****************************************************************//**
 
9098
Update the system variable innodb_file_format using the "saved"
 
9099
value. This function is registered as a callback with MySQL. */
 
9100
static
 
9101
void
 
9102
innodb_file_format_name_update(
 
9103
/*===========================*/
 
9104
  Session*      ,   /*!< in: thread handle */
 
9105
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9106
              system variable */
 
9107
  void*       var_ptr,  /*!< out: where the
 
9108
              formal string goes */
 
9109
  const void*     save)   /*!< in: immediate result
 
9110
              from check function */
 
9111
{
 
9112
  const char* format_name;
 
9113
 
 
9114
  ut_a(var_ptr != NULL);
 
9115
  ut_a(save != NULL);
 
9116
 
 
9117
  format_name = *static_cast<const char*const*>(save);
 
9118
 
 
9119
  if (format_name) {
 
9120
    uint  format_id;
 
9121
 
 
9122
    format_id = innobase_file_format_name_lookup(format_name);
 
9123
 
 
9124
    if (format_id <= DICT_TF_FORMAT_MAX) {
 
9125
      srv_file_format = format_id;
 
9126
    }
 
9127
  }
 
9128
 
 
9129
  *static_cast<const char**>(var_ptr)
 
9130
    = trx_sys_file_format_id_to_name(srv_file_format);
 
9131
}
 
9132
 
 
9133
/*************************************************************//**
 
9134
Check if valid argument to innodb_file_format_check. This
 
9135
function is registered as a callback with MySQL.
 
9136
@return 0 for valid file format */
 
9137
static
 
9138
int
 
9139
innodb_file_format_check_validate(
 
9140
/*==============================*/
 
9141
  Session*      session, /*!< in: thread handle */
 
9142
  drizzle_sys_var*  , /*!< in: pointer to system
 
9143
            variable */
 
9144
  void*       save, /*!< out: immediate result
 
9145
            for update function */
 
9146
  drizzle_value*    value)  /*!< in: incoming string */
 
9147
{
 
9148
  const char* file_format_input;
 
9149
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9150
  int   len = sizeof(buff);
 
9151
  int   format_id;
 
9152
 
 
9153
  ut_a(save != NULL);
 
9154
  ut_a(value != NULL);
 
9155
 
 
9156
  file_format_input = value->val_str(value, buff, &len);
 
9157
 
 
9158
  if (file_format_input != NULL) {
 
9159
 
 
9160
    /* Check if user set on/off, we want to print a suitable
 
9161
    message if they did so. */
 
9162
 
 
9163
    if (innobase_file_format_check_on_off(file_format_input)) {
 
9164
      push_warning_printf(session,
 
9165
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
9166
                          ER_WRONG_ARGUMENTS,
 
9167
        "InnoDB: invalid innodb_file_format_check "
 
9168
        "value; on/off can only be set at startup or "
 
9169
        "in the configuration file");
 
9170
    } else {
 
9171
      format_id = innobase_file_format_validate_and_set(file_format_input);
 
9172
      if (format_id >= 0) {
 
9173
        /* Save a pointer to the name in the
 
9174
           'file_format_name_map' constant array. */
 
9175
        *static_cast<const char**>(save) =
 
9176
          trx_sys_file_format_id_to_name(
 
9177
                                         (uint)format_id);
 
9178
 
 
9179
        return(0);
 
9180
 
 
9181
      } else {
 
9182
        push_warning_printf(session,
 
9183
                            DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
9184
                            ER_WRONG_ARGUMENTS,
 
9185
                            "InnoDB: invalid innodb_file_format_check "
 
9186
                            "value; can be any format up to %s "
 
9187
                            "or its equivalent numeric id",
 
9188
                            trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
 
9189
      }
 
9190
    }
 
9191
  }
 
9192
 
 
9193
  *static_cast<const char**>(save) = NULL;
 
9194
  return(1);
 
9195
}
 
9196
 
 
9197
/****************************************************************//**
 
9198
Update the system variable innodb_file_format_check using the "saved"
 
9199
value. This function is registered as a callback with MySQL. */
 
9200
static
 
9201
void
 
9202
innodb_file_format_check_update(
 
9203
/*============================*/
 
9204
  Session*      session,  /*!< in: thread handle */
 
9205
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9206
              system variable */
 
9207
  void*       var_ptr,  /*!< out: where the
 
9208
              formal string goes */
 
9209
  const void*     save)   /*!< in: immediate result
 
9210
              from check function */
 
9211
{
 
9212
  const char* format_name_in;
 
9213
  const char**  format_name_out;
 
9214
  uint    format_id;
 
9215
 
 
9216
  ut_a(save != NULL);
 
9217
  ut_a(var_ptr != NULL);
 
9218
 
 
9219
  format_name_in = *static_cast<const char*const*>(save);
 
9220
 
 
9221
  if (!format_name_in) {
 
9222
 
 
9223
    return;
 
9224
  }
 
9225
 
 
9226
  format_id = innobase_file_format_name_lookup(format_name_in);
 
9227
 
 
9228
  if (format_id > DICT_TF_FORMAT_MAX) {
 
9229
    /* DEFAULT is "on", which is invalid at runtime. */
 
9230
    push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
9231
            ER_WRONG_ARGUMENTS,
 
9232
            "Ignoring SET innodb_file_format=%s",
 
9233
            format_name_in);
 
9234
    return;
 
9235
  }
 
9236
 
 
9237
  format_name_out = static_cast<const char**>(var_ptr);
 
9238
 
 
9239
  /* Update the max format id in the system tablespace. */
 
9240
  if (trx_sys_file_format_max_set(format_id, format_name_out)) {
 
9241
    ut_print_timestamp(stderr);
 
9242
    fprintf(stderr,
 
9243
      " [Info] InnoDB: the file format in the system "
 
9244
      "tablespace is now set to %s.\n", *format_name_out);
 
9245
  }
 
9246
}
 
9247
 
 
9248
/****************************************************************//**
 
9249
Update the system variable innodb_adaptive_hash_index using the "saved"
 
9250
value. This function is registered as a callback with MySQL. */
 
9251
static
 
9252
void
 
9253
innodb_adaptive_hash_index_update(
 
9254
/*==============================*/
 
9255
  Session*      ,   /*!< in: thread handle */
 
9256
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9257
              system variable */
 
9258
  void*       , /*!< out: where the
 
9259
              formal string goes */
 
9260
  const void*     save)   /*!< in: immediate result
 
9261
              from check function */
 
9262
{
 
9263
  if (*(bool*) save) {
 
9264
    btr_search_enable();
 
9265
  } else {
 
9266
    btr_search_disable();
 
9267
  }
 
9268
}
 
9269
 
 
9270
/****************************************************************//**
 
9271
Update the system variable innodb_old_blocks_pct using the "saved"
 
9272
value. This function is registered as a callback with MySQL. */
 
9273
static
 
9274
void
 
9275
innodb_old_blocks_pct_update(
 
9276
/*=========================*/
 
9277
        Session*                        ,       /*!< in: thread handle */
 
9278
        drizzle_sys_var*        ,       /*!< in: pointer to
 
9279
                                                system variable */
 
9280
        void*                           ,/*!< out: where the
 
9281
                                                formal string goes */
 
9282
        const void*                     save)   /*!< in: immediate result
 
9283
                                                from check function */
 
9284
{
 
9285
        innobase_old_blocks_pct = buf_LRU_old_ratio_update(
 
9286
                *static_cast<const uint*>(save), TRUE);
 
9287
}
 
9288
 
 
9289
/*************************************************************//**
 
9290
Check if it is a valid value of innodb_change_buffering.  This function is
 
9291
registered as a callback with MySQL.
 
9292
@return 0 for valid innodb_change_buffering */
 
9293
static
 
9294
int
 
9295
innodb_change_buffering_validate(
 
9296
/*=============================*/
 
9297
  Session*      , /*!< in: thread handle */
 
9298
  drizzle_sys_var*  , /*!< in: pointer to system
 
9299
            variable */
 
9300
  void*       save, /*!< out: immediate result
 
9301
            for update function */
 
9302
  drizzle_value*    value)  /*!< in: incoming string */
 
9303
{
 
9304
  const char* change_buffering_input;
 
9305
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9306
  int   len = sizeof(buff);
 
9307
 
 
9308
  ut_a(save != NULL);
 
9309
  ut_a(value != NULL);
 
9310
 
 
9311
  change_buffering_input = value->val_str(value, buff, &len);
 
9312
 
 
9313
  if (change_buffering_input != NULL) {
 
9314
    ulint use;
 
9315
 
 
9316
    for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
 
9317
         use++) {
 
9318
      if (!innobase_strcasecmp(
 
9319
            change_buffering_input,
 
9320
            innobase_change_buffering_values[use])) {
 
9321
        *(ibuf_use_t*) save = (ibuf_use_t) use;
 
9322
        return(0);
 
9323
      }
 
9324
    }
 
9325
  }
 
9326
 
 
9327
  return(1);
 
9328
}
 
9329
 
 
9330
/****************************************************************//**
 
9331
Update the system variable innodb_change_buffering using the "saved"
 
9332
value. This function is registered as a callback with MySQL. */
 
9333
static
 
9334
void
 
9335
innodb_change_buffering_update(
 
9336
/*===========================*/
 
9337
  Session*      ,   /*!< in: thread handle */
 
9338
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9339
              system variable */
 
9340
  void*       var_ptr,  /*!< out: where the
 
9341
              formal string goes */
 
9342
  const void*     save)   /*!< in: immediate result
 
9343
              from check function */
 
9344
{
 
9345
  ut_a(var_ptr != NULL);
 
9346
  ut_a(save != NULL);
 
9347
  ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
 
9348
 
 
9349
  ibuf_use = *(const ibuf_use_t*) save;
 
9350
 
 
9351
  *(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
 
9352
}
 
9353
 
 
9354
/* plugin options */
 
9355
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
 
9356
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
9357
  "Enable InnoDB checksums validation (enabled by default). ",
 
9358
  NULL, NULL, TRUE);
 
9359
 
 
9360
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
 
9361
  PLUGIN_VAR_READONLY,
 
9362
  "The common part for InnoDB table spaces.",
 
9363
  NULL, NULL, NULL);
 
9364
 
 
9365
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
 
9366
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
9367
  "Enable InnoDB doublewrite buffer (enabled by default). ",
 
9368
  NULL, NULL, TRUE);
 
9369
 
 
9370
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
 
9371
  PLUGIN_VAR_RQCMDARG,
 
9372
  "Number of IOPs the server can do. Tunes the background IO rate",
 
9373
  NULL, NULL, 200, 100, ~0L, 0);
 
9374
 
 
9375
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
 
9376
  PLUGIN_VAR_OPCMDARG,
 
9377
  "Speeds up the shutdown process of the InnoDB storage engine. Possible "
 
9378
  "values are 0, 1 (faster)"
 
9379
  " or 2 (fastest - crash-like)"
 
9380
  ".",
 
9381
  NULL, NULL, 1, 0, 2, 0);
 
9382
 
 
9383
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
 
9384
  PLUGIN_VAR_NOCMDARG,
 
9385
  "Stores each InnoDB table to an .ibd file in the database dir.",
 
9386
  NULL, NULL, FALSE);
 
9387
 
 
9388
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
 
9389
  PLUGIN_VAR_RQCMDARG,
 
9390
  "File format to use for new tables in .ibd files.",
 
9391
  innodb_file_format_name_validate,
 
9392
  innodb_file_format_name_update, "Antelope");
 
9393
 
 
9394
/* If a new file format is introduced, the file format
 
9395
name needs to be updated accordingly. Please refer to
 
9396
file_format_name_map[] defined in trx0sys.c for the next
 
9397
file format name. */
 
9398
static DRIZZLE_SYSVAR_STR(file_format_check, innobase_file_format_check,
 
9399
  PLUGIN_VAR_OPCMDARG,
 
9400
  "The highest file format in the tablespace.",
 
9401
  innodb_file_format_check_validate,
 
9402
  innodb_file_format_check_update,
 
9403
  "Barracuda");
 
9404
 
 
9405
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
 
9406
  PLUGIN_VAR_OPCMDARG,
 
9407
  "Set to 0 (write and flush once per second),"
 
9408
  " 1 (write and flush at each commit)"
 
9409
  " or 2 (write at commit, flush once per second).",
 
9410
  NULL, NULL, 1, 0, 2, 0);
 
9411
 
 
9412
static DRIZZLE_SYSVAR_STR(flush_method, innobase_file_flush_method,
 
9413
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9414
  "With which method to flush data.", NULL, NULL, NULL);
 
9415
 
 
9416
#ifdef UNIV_LOG_ARCHIVE
 
9417
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
 
9418
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9419
  "Where full logs should be archived.", NULL, NULL, NULL);
 
9420
 
 
9421
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
 
9422
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
9423
  "Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
 
9424
#endif /* UNIV_LOG_ARCHIVE */
 
9425
 
 
9426
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
 
9427
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9428
  "Path to InnoDB log files.", NULL, NULL, NULL);
 
9429
 
 
9430
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
 
9431
  PLUGIN_VAR_RQCMDARG,
 
9432
  "Percentage of dirty pages allowed in bufferpool.",
 
9433
  NULL, NULL, 75, 0, 99, 0);
 
9434
 
 
9435
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
 
9436
  PLUGIN_VAR_NOCMDARG,
 
9437
  "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
 
9438
  NULL, NULL, TRUE);
 
9439
 
 
9440
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
 
9441
  PLUGIN_VAR_RQCMDARG,
 
9442
  "Desired maximum length of the purge queue (0 = no limit)",
 
9443
  NULL, NULL, 0, 0, ~0L, 0);
 
9444
 
 
9445
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
 
9446
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
 
9447
  "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
 
9448
  NULL, NULL, FALSE);
 
9449
 
 
9450
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
 
9451
  PLUGIN_VAR_RQCMDARG,
 
9452
  "The number of index pages to sample when calculating statistics (default 8)",
 
9453
  NULL, NULL, 8, 1, ~0ULL, 0);
 
9454
 
 
9455
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
 
9456
  PLUGIN_VAR_OPCMDARG,
 
9457
  "Enable InnoDB adaptive hash index (enabled by default).",
 
9458
  NULL, innodb_adaptive_hash_index_update, TRUE);
 
9459
 
 
9460
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
 
9461
  PLUGIN_VAR_RQCMDARG,
 
9462
  "Replication thread delay (ms) on the slave server if "
 
9463
  "innodb_thread_concurrency is reached (0 by default)",
 
9464
  NULL, NULL, 0, 0, ~0UL, 0);
 
9465
 
 
9466
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
 
9467
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9468
  "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
 
9469
  NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
 
9470
 
 
9471
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
 
9472
  PLUGIN_VAR_RQCMDARG,
 
9473
  "Data file autoextend increment in megabytes",
 
9474
  NULL, NULL, 8L, 1L, 1000L, 0);
 
9475
 
 
9476
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
 
9477
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9478
  "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
 
9479
  NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
 
9480
 
 
9481
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
 
9482
  PLUGIN_VAR_RQCMDARG,
 
9483
  "Helps in performance tuning in heavily concurrent environments.",
 
9484
  innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
 
9485
 
 
9486
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
 
9487
  PLUGIN_VAR_RQCMDARG,
 
9488
  "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
 
9489
  NULL, NULL, 500L, 1L, ~0L, 0);
 
9490
 
 
9491
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
 
9492
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9493
  "Number of background read I/O threads in InnoDB.",
 
9494
  NULL, NULL, 4, 1, 64, 0);
 
9495
 
 
9496
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
 
9497
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9498
  "Number of background write I/O threads in InnoDB.",
 
9499
  NULL, NULL, 4, 1, 64, 0);
 
9500
 
 
9501
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
 
9502
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9503
  "Helps to save your data in case the disk image of the database becomes corrupt.",
 
9504
  NULL, NULL, 0, 0, 6, 0);
 
9505
 
 
9506
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
 
9507
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9508
  "The size of the buffer which InnoDB uses to write log to the log files on disk.",
 
9509
  NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
 
9510
 
 
9511
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
 
9512
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9513
  "Size of each log file in a log group.",
 
9514
  NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
 
9515
 
 
9516
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
 
9517
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9518
  "Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
 
9519
  NULL, NULL, 2, 2, 100, 0);
 
9520
 
 
9521
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
 
9522
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9523
  "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
 
9524
  NULL, NULL, 1, 1, 10, 0);
 
9525
 
 
9526
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
 
9527
  PLUGIN_VAR_RQCMDARG,
 
9528
  "Percentage of the buffer pool to reserve for 'old' blocks.",
 
9529
  NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
 
9530
 
 
9531
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
 
9532
  PLUGIN_VAR_RQCMDARG,
 
9533
  "Move blocks to the 'new' end of the buffer pool if the first access"
 
9534
  " was at least this many milliseconds ago."
 
9535
  " The timeout is disabled if 0 (the default).",
 
9536
  NULL, NULL, 0, 0, UINT32_MAX, 0);
 
9537
 
 
9538
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
 
9539
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9540
  "How many files at the maximum InnoDB keeps open at the same time.",
 
9541
  NULL, NULL, 300L, 10L, LONG_MAX, 0);
 
9542
 
 
9543
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
 
9544
  PLUGIN_VAR_RQCMDARG,
 
9545
  "Count of spin-loop rounds in InnoDB mutexes (30 by default)",
 
9546
  NULL, NULL, 30L, 0L, ~0L, 0);
 
9547
 
 
9548
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
 
9549
  PLUGIN_VAR_OPCMDARG,
 
9550
  "Maximum delay between polling for a spin lock (6 by default)",
 
9551
  NULL, NULL, 6L, 0L, ~0L, 0);
 
9552
 
 
9553
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
 
9554
  PLUGIN_VAR_RQCMDARG,
 
9555
  "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
 
9556
  NULL, NULL, 0, 0, 1000, 0);
 
9557
 
 
9558
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
 
9559
  PLUGIN_VAR_RQCMDARG,
 
9560
  "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
 
9561
  NULL, NULL, 10000L, 0L, ~0L, 0);
 
9562
 
 
9563
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
 
9564
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9565
  "Path to individual files and their sizes.",
 
9566
  NULL, NULL, NULL);
 
9567
 
 
9568
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
 
9569
  PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
 
9570
  "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
 
9571
 
 
9572
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
 
9573
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
9574
  "Use OS memory allocator instead of InnoDB's internal memory allocator",
 
9575
  NULL, NULL, TRUE);
 
9576
 
 
9577
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
 
9578
  PLUGIN_VAR_RQCMDARG,
 
9579
  "Buffer changes to reduce random access: "
 
9580
  "OFF, ON, none, inserts.",
 
9581
  innodb_change_buffering_validate,
 
9582
  innodb_change_buffering_update, NULL);
 
9583
 
 
9584
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
 
9585
  PLUGIN_VAR_RQCMDARG,
 
9586
  "Number of pages that must be accessed sequentially for InnoDB to "
 
9587
  "trigger a readahead.",
 
9588
  NULL, NULL, 56, 0, 64, 0);
9208
9589
 
9209
9590
static void init_options(drizzled::module::option_context &context)
9210
9591
{
9216
9597
  context("disable-doublewrite",
9217
9598
          "Disable InnoDB doublewrite buffer.");
9218
9599
  context("io-capacity",
9219
 
          po::value<io_capacity_constraint>(&innodb_io_capacity)->default_value(200),
 
9600
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
9220
9601
          "Number of IOPs the server can do. Tunes the background IO rate");
9221
9602
  context("fast-shutdown",
9222
 
          po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1), 
 
9603
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1), 
9223
9604
          "Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like).");
9224
 
  context("purge-batch-size",
9225
 
          po::value<purge_batch_constraint>(&innodb_purge_batch_size)->default_value(20),
9226
 
          "Number of UNDO logs to purge in one batch from the history list. "
9227
 
          "Default is 20.");
9228
 
  context("purge-threads",
9229
 
          po::value<purge_threads_constraint>(&innodb_n_purge_threads)->default_value(0),
9230
 
          "Purge threads can be either 0 or 1. Defalut is 0.");
9231
9605
  context("file-per-table",
9232
9606
          po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
9233
9607
          "Stores each InnoDB table to an .ibd file in the database dir.");
9234
9608
  context("file-format",
9235
 
          po::value<string>(&innobase_file_format_name)->default_value("Antelope"),
 
9609
          po::value<string>()->default_value("Antelope"),
9236
9610
          "File format to use for new tables in .ibd files.");
9237
 
  context("file-format-max",
9238
 
          po::value<string>(&innobase_file_format_max)->default_value("Antelope"),
 
9611
  context("file-format-check",
 
9612
          po::value<string>()->default_value("on"),
9239
9613
          "The highest file format in the tablespace.");
9240
 
  context("file-format-check",
9241
 
          po::value<bool>(&innobase_file_format_check)->default_value(true)->zero_tokens(),
9242
 
          "Whether to perform system file format check.");
9243
9614
  context("flush-log-at-trx-commit",
9244
 
          po::value<trinary_constraint>(&innodb_flush_log_at_trx_commit)->default_value(1),
 
9615
          po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
9245
9616
          "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).");
9246
9617
  context("flush-method",
9247
9618
          po::value<string>(),
9248
9619
          "With which method to flush data.");
 
9620
#ifdef UNIV_LOG_ARCHIVE
 
9621
  context("log-arch-dir",
 
9622
          po::value<string>(),
 
9623
          "Where full logs should be archived.");
 
9624
  context("log-archive",
 
9625
          po::value<bool>(&innobase_log_archive)->default_value(false)->zero_tokens(),
 
9626
          "Set to 1 if you want to have logs archived.");
 
9627
#endif /* UNIV_LOG_ARCHIVE */
9249
9628
  context("log-group-home-dir",
9250
9629
          po::value<string>(),
9251
9630
          "Path to InnoDB log files.");
9252
9631
  context("max-dirty-pages-pct",
9253
 
          po::value<max_dirty_pages_constraint>(&innodb_max_dirty_pages_pct)->default_value(75),
 
9632
          po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
9254
9633
          "Percentage of dirty pages allowed in bufferpool.");
9255
9634
  context("disable-adaptive-flushing",
9256
9635
          "Do not attempt flushing dirty pages to avoid IO bursts at checkpoints.");
9257
9636
  context("max-purge-lag",
9258
 
          po::value<uint64_constraint>(&innodb_max_purge_lag)->default_value(0),
 
9637
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
9259
9638
          "Desired maximum length of the purge queue (0 = no limit)");
9260
9639
  context("status-file",
9261
9640
          po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
9263
9642
  context("disable-stats-on-metadata",
9264
9643
          "Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9265
9644
  context("stats-sample-pages",
9266
 
          po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
 
9645
          po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9267
9646
          "The number of index pages to sample when calculating statistics (default 8)");
9268
9647
  context("disable-adaptive-hash-index",
9269
9648
          "Enable InnoDB adaptive hash index (enabled by default)");
9270
9649
  context("replication-delay",
9271
 
          po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
 
9650
          po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9272
9651
          "Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9273
9652
  context("additional-mem-pool-size",
9274
 
          po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
9653
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9275
9654
          "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9276
9655
  context("autoextend-increment",
9277
 
          po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
 
9656
          po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9278
9657
          "Data file autoextend increment in megabytes");
9279
9658
  context("buffer-pool-size",
9280
 
          po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
9659
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9281
9660
          "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9282
 
  context("buffer-pool-instances",
9283
 
          po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9284
 
          "Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9285
 
 
9286
9661
  context("commit-concurrency",
9287
 
          po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
 
9662
          po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9288
9663
          "Helps in performance tuning in heavily concurrent environments.");
9289
9664
  context("concurrency-tickets",
9290
 
          po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
 
9665
          po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9291
9666
          "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9292
9667
  context("read-io-threads",
9293
 
          po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
 
9668
          po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9294
9669
          "Number of background read I/O threads in InnoDB.");
9295
9670
  context("write-io-threads",
9296
 
          po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
 
9671
          po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9297
9672
          "Number of background write I/O threads in InnoDB.");
9298
9673
  context("force-recovery",
9299
 
          po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
 
9674
          po::value<long>(&innobase_force_recovery)->default_value(0),
9300
9675
          "Helps to save your data in case the disk image of the database becomes corrupt.");
9301
9676
  context("log-buffer-size",
9302
 
          po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
 
9677
          po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9303
9678
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9304
9679
  context("log-file-size",
9305
 
          po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
 
9680
          po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9306
9681
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9307
9682
  context("log-files-in-group",
9308
 
          po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
 
9683
          po::value<long>(&innobase_log_files_in_group)->default_value(2),
9309
9684
          "Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9310
9685
  context("mirrored-log-groups",
9311
 
          po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
 
9686
          po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9312
9687
          "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9313
9688
  context("open-files",
9314
 
          po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
 
9689
          po::value<long>(&innobase_open_files)->default_value(300L),
9315
9690
          "How many files at the maximum InnoDB keeps open at the same time.");
9316
9691
  context("sync-spin-loops",
9317
 
          po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
 
9692
          po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9318
9693
          "Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9319
9694
  context("spin-wait-delay",
9320
 
          po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
 
9695
          po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9321
9696
          "Maximum delay between polling for a spin lock (6 by default)");
9322
9697
  context("thread-concurrency",
9323
 
          po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
 
9698
          po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9324
9699
          "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9325
9700
  context("thread-sleep-delay",
9326
 
          po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
 
9701
          po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9327
9702
          "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9328
9703
  context("data-file-path",
9329
9704
          po::value<string>(),
9334
9709
  context("use-internal-malloc",
9335
9710
          "Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9336
9711
  context("change-buffering",
9337
 
          po::value<string>(&innobase_change_buffering),
 
9712
          po::value<string>(),
9338
9713
          "Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9339
9714
  context("read-ahead-threshold",
9340
 
          po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
 
9715
          po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9341
9716
          "Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9342
9717
  context("disable-xa",
9343
9718
          "Disable InnoDB support for the XA two-phase commit");
9344
9719
  context("disable-table-locks",
9345
9720
          "Disable InnoDB locking in LOCK TABLES");
9346
9721
  context("strict-mode",
9347
 
          po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
 
9722
          po::value<bool>()->default_value(false)->zero_tokens(),
9348
9723
          "Use strict mode when evaluating create options.");
9349
 
  context("replication-log",
9350
 
          po::value<bool>(&innobase_use_replication_log)->default_value(false),
9351
 
          _("Enable internal replication log."));
9352
9724
  context("lock-wait-timeout",
9353
 
          po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9354
 
          _("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9355
 
  context("old-blocks-pct",
9356
 
          po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9357
 
          _("Percentage of the buffer pool to reserve for 'old' blocks."));
9358
 
  context("old-blocks-time",
9359
 
          po::value<uint32_t>(&buf_LRU_old_threshold_ms)->default_value(0),
9360
 
          _("ove blocks to the 'new' end of the buffer pool if the first access"
9361
 
            " was at least this many milliseconds ago."
9362
 
            " The timeout is disabled if 0 (the default)."));
 
9725
          po::value<unsigned long>()->default_value(50),
 
9726
          "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9363
9727
}
9364
9728
 
9365
 
 
 
9729
static drizzle_sys_var* innobase_system_variables[]= {
 
9730
  DRIZZLE_SYSVAR(additional_mem_pool_size),
 
9731
  DRIZZLE_SYSVAR(autoextend_increment),
 
9732
  DRIZZLE_SYSVAR(buffer_pool_size),
 
9733
  DRIZZLE_SYSVAR(checksums),
 
9734
  DRIZZLE_SYSVAR(commit_concurrency),
 
9735
  DRIZZLE_SYSVAR(concurrency_tickets),
 
9736
  DRIZZLE_SYSVAR(data_file_path),
 
9737
  DRIZZLE_SYSVAR(data_home_dir),
 
9738
  DRIZZLE_SYSVAR(doublewrite),
 
9739
  DRIZZLE_SYSVAR(fast_shutdown),
 
9740
  DRIZZLE_SYSVAR(read_io_threads),
 
9741
  DRIZZLE_SYSVAR(write_io_threads),
 
9742
  DRIZZLE_SYSVAR(file_per_table),
 
9743
  DRIZZLE_SYSVAR(file_format),
 
9744
  DRIZZLE_SYSVAR(file_format_check),
 
9745
  DRIZZLE_SYSVAR(flush_log_at_trx_commit),
 
9746
  DRIZZLE_SYSVAR(flush_method),
 
9747
  DRIZZLE_SYSVAR(force_recovery),
 
9748
  DRIZZLE_SYSVAR(lock_wait_timeout),
 
9749
#ifdef UNIV_LOG_ARCHIVE
 
9750
  DRIZZLE_SYSVAR(log_arch_dir),
 
9751
  DRIZZLE_SYSVAR(log_archive),
 
9752
#endif /* UNIV_LOG_ARCHIVE */
 
9753
  DRIZZLE_SYSVAR(log_buffer_size),
 
9754
  DRIZZLE_SYSVAR(log_file_size),
 
9755
  DRIZZLE_SYSVAR(log_files_in_group),
 
9756
  DRIZZLE_SYSVAR(log_group_home_dir),
 
9757
  DRIZZLE_SYSVAR(max_dirty_pages_pct),
 
9758
  DRIZZLE_SYSVAR(max_purge_lag),
 
9759
  DRIZZLE_SYSVAR(adaptive_flushing),
 
9760
  DRIZZLE_SYSVAR(mirrored_log_groups),
 
9761
  DRIZZLE_SYSVAR(old_blocks_pct),
 
9762
  DRIZZLE_SYSVAR(old_blocks_time),
 
9763
  DRIZZLE_SYSVAR(open_files),
 
9764
  DRIZZLE_SYSVAR(stats_sample_pages),
 
9765
  DRIZZLE_SYSVAR(adaptive_hash_index),
 
9766
  DRIZZLE_SYSVAR(replication_delay),
 
9767
  DRIZZLE_SYSVAR(status_file),
 
9768
  DRIZZLE_SYSVAR(strict_mode),
 
9769
  DRIZZLE_SYSVAR(support_xa),
 
9770
  DRIZZLE_SYSVAR(sync_spin_loops),
 
9771
  DRIZZLE_SYSVAR(spin_wait_delay),
 
9772
  DRIZZLE_SYSVAR(table_locks),
 
9773
  DRIZZLE_SYSVAR(thread_concurrency),
 
9774
  DRIZZLE_SYSVAR(thread_sleep_delay),
 
9775
  DRIZZLE_SYSVAR(version),
 
9776
  DRIZZLE_SYSVAR(use_sys_malloc),
 
9777
  DRIZZLE_SYSVAR(change_buffering),
 
9778
  DRIZZLE_SYSVAR(read_ahead_threshold),
 
9779
  DRIZZLE_SYSVAR(io_capacity),
 
9780
  NULL
 
9781
};
9366
9782
 
9367
9783
DRIZZLE_DECLARE_PLUGIN
9368
9784
{
9373
9789
  "Supports transactions, row-level locking, and foreign keys",
9374
9790
  PLUGIN_LICENSE_GPL,
9375
9791
  innobase_init, /* Plugin Init */
9376
 
  NULL, /* system variables */
 
9792
  innobase_system_variables, /* system variables */
9377
9793
  init_options /* reserved */
9378
9794
}
9379
9795
DRIZZLE_DECLARE_PLUGIN_END;
9401
9817
  return res;
9402
9818
}
9403
9819
 
 
9820
/** @brief Initialize the default value of innodb_commit_concurrency.
 
9821
 
 
9822
Once InnoDB is running, the innodb_commit_concurrency must not change
 
9823
from zero to nonzero. (Bug #42101)
 
9824
 
 
9825
The initial default value is 0, and without this extra initialization,
 
9826
SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter
 
9827
to 0, even if it was initially set to nonzero at the command line
 
9828
or configuration file. */
 
9829
static
 
9830
void
 
9831
innobase_commit_concurrency_init_default(void)
 
9832
/*==========================================*/
 
9833
{
 
9834
  DRIZZLE_SYSVAR_NAME(commit_concurrency).def_val
 
9835
    = innobase_commit_concurrency;
 
9836
}
 
9837
 
9404
9838
/***********************************************************************
9405
9839
This function checks each index name for a table against reserved
9406
9840
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,