~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-12-06 21:17:06 UTC
  • mto: (1977.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1980.
  • Revision ID: mordred@inaugust.com-20101206211706-iiuzzkxhh3fm10zf
Add ability to add a validation function to any sys_var. duh.

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"
105
106
#include "btr0cur.h"
106
107
#include "btr0btr.h"
107
108
#include "fsp0fsp.h"
119
120
 
120
121
#include "ha_innodb.h"
121
122
#include "data_dictionary.h"
 
123
#include "replication_dictionary.h"
122
124
#include "internal_dictionary.h"
123
125
#include "handler0vars.h"
124
126
 
127
129
#include <string>
128
130
 
129
131
#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>
130
138
 
131
139
using namespace std;
132
140
using namespace drizzled;
171
179
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
172
180
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
173
181
 
 
182
static plugin::TransactionApplier *replication_logger= NULL;
 
183
 
174
184
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
175
185
  innobase_log_buffer_size,
176
186
  innobase_force_recovery, innobase_open_files;
177
 
static long innobase_additional_mem_pool_size= 8*1024*1024L;
 
187
typedef constrained_check<size_t, SIZE_MAX, 512*1024, 1024> additional_mem_pool_constraint;
 
188
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
 
189
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
 
190
static autoextend_constraint innodb_auto_extend_increment;
 
191
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
 
192
static buffer_pool_constraint innobase_buffer_pool_size;
 
193
typedef constrained_check<uint32_t, MAX_BUFFER_POOLS, 1> buffer_pool_instances_constraint;
 
194
static buffer_pool_instances_constraint innobase_buffer_pool_instances;
 
195
typedef constrained_check<uint32_t, UINT32_MAX, 100> io_capacity_constraint;
 
196
static io_capacity_constraint innodb_io_capacity;
 
197
typedef constrained_check<uint32_t, 5000, 1> purge_batch_constraint;
 
198
static purge_batch_constraint innodb_purge_batch_size;
 
199
typedef constrained_check<uint32_t, 1, 0> purge_threads_constraint;
 
200
static purge_threads_constraint innodb_n_purge_threads;
 
201
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
 
202
static trinary_constraint innodb_flush_log_at_trx_commit;
 
203
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
 
204
static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
 
205
static uint64_constraint innodb_max_purge_lag;
 
206
static uint64_nonzero_constraint innodb_stats_sample_pages;
 
207
 
 
208
 
 
209
 
 
210
 
178
211
static ulong innobase_commit_concurrency = 0;
179
212
static ulong innobase_read_io_threads;
180
213
static ulong innobase_write_io_threads;
181
 
static int64_t innobase_buffer_pool_instances = 1;
182
214
 
183
 
/**
184
 
 * @TODO: Turn this into size_t as soon as we have a Variable<size_t>
185
 
 */
186
 
static int64_t innobase_buffer_pool_size= 128*1024*1024;
187
 
static int64_t innobase_log_file_size;
 
215
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
 
216
static log_file_constraint innobase_log_file_size;
188
217
 
189
218
/** Percentage of the buffer pool to reserve for 'old' blocks.
190
219
Connected to buf_LRU_old_ratio. */
193
222
/* The default values for the following char* start-up parameters
194
223
are determined in innobase_init below: */
195
224
 
196
 
static char*  innobase_data_home_dir      = NULL;
197
 
static char*  innobase_data_file_path     = NULL;
198
 
static char*  innobase_log_group_home_dir   = NULL;
199
 
static char*  innobase_file_format_name   = NULL;
200
 
static char*  innobase_change_buffering   = NULL;
 
225
std::string innobase_data_home_dir;
 
226
std::string innobase_data_file_path;
 
227
std::string innobase_log_group_home_dir;
 
228
static string innobase_file_format_name;
 
229
static char* innobase_change_buffering= NULL;
201
230
 
202
231
/* The highest file format being used in the database. The value can be
203
232
set by user, however, it will be adjusted to the newer file format if
204
233
a table of such format is created/opened. */
205
 
static char*    innobase_file_format_max                = NULL;
206
 
 
207
 
static char*  innobase_file_flush_method   = NULL;
 
234
static string innobase_file_format_max;
208
235
 
209
236
/* Below we have boolean-valued start-up parameters, and their default
210
237
values */
211
238
 
212
 
static ulong  innobase_fast_shutdown      = 1;
 
239
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
 
240
static trinary_constraint innobase_fast_shutdown;
 
241
 
213
242
static my_bool  innobase_file_format_check = TRUE;
214
 
#ifdef UNIV_LOG_ARCHIVE
215
 
static my_bool  innobase_log_archive      = FALSE;
216
 
static char*  innobase_log_arch_dir     = NULL;
217
 
#endif /* UNIV_LOG_ARCHIVE */
218
243
static my_bool  innobase_use_doublewrite    = TRUE;
219
244
static my_bool  innobase_use_checksums      = TRUE;
220
245
static my_bool  innobase_rollback_on_timeout    = FALSE;
221
246
static my_bool  innobase_create_status_file   = FALSE;
 
247
static bool support_xa;
 
248
static bool strict_mode;
 
249
typedef constrained_check<uint32_t, 1024*1024*1024, 1> lock_wait_constraint;
 
250
static lock_wait_constraint lock_wait_timeout;
222
251
 
223
252
static char*  internal_innobase_data_file_path  = NULL;
224
253
 
225
 
static char*  innodb_version_str = (char*) INNODB_VERSION_STR;
226
 
 
227
254
/* The following counter is used to convey information to InnoDB
228
255
about server activity: in selects it is not sensible to call
229
256
srv_active_wake_master_thread after each fetch or search, we only do
303
330
    }
304
331
    
305
332
    /* These get strdup'd from vm variables */
306
 
    free(innobase_data_home_dir);
307
 
    free(innobase_log_group_home_dir);
308
333
 
309
334
  }
310
335
 
629
654
  return(!(!commit_concurrency == !innobase_commit_concurrency));
630
655
}
631
656
 
632
 
static DRIZZLE_SessionVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG,
633
 
  "Enable InnoDB support for the XA two-phase commit",
634
 
  /* check_func */ NULL, /* update_func */ NULL,
635
 
  /* default */ TRUE);
636
 
 
637
 
static DRIZZLE_SessionVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
638
 
  "Enable InnoDB locking in LOCK TABLES",
639
 
  /* check_func */ NULL, /* update_func */ NULL,
640
 
  /* default */ TRUE);
641
 
 
642
 
static DRIZZLE_SessionVAR_BOOL(strict_mode, PLUGIN_VAR_OPCMDARG,
643
 
  "Use strict mode when evaluating create options.",
644
 
  NULL, NULL, TRUE);
645
 
 
646
 
static DRIZZLE_SessionVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
647
 
  "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
648
 
  NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
649
 
 
650
657
 
651
658
/*****************************************************************//**
652
659
Commits a transaction in an InnoDB database. */
913
920
ibool
914
921
thd_supports_xa(
915
922
/*============*/
916
 
  void* session)  /*!< in: thread handle (Session*), or NULL to query
 
923
  void* )  /*!< in: thread handle (Session*), or NULL to query
917
924
        the global innodb_supports_xa */
918
925
{
919
 
  return(SessionVAR((Session*) session, support_xa));
 
926
  /* TODO: Add support here for per-session value */
 
927
  return(support_xa);
920
928
}
921
929
 
922
930
/******************************************************************//**
926
934
ulong
927
935
thd_lock_wait_timeout(
928
936
/*==================*/
929
 
  void* session)  /*!< in: thread handle (Session*), or NULL to query
 
937
  void*)  /*!< in: thread handle (Session*), or NULL to query
930
938
      the global innodb_lock_wait_timeout */
931
939
{
 
940
  /* TODO: Add support here for per-session value */
932
941
  /* According to <drizzle/plugin.h>, passing session == NULL
933
942
  returns the global value of the session variable. */
934
 
  return(SessionVAR((Session*) session, lock_wait_timeout));
 
943
  return((ulong)lock_wait_timeout.get());
 
944
}
 
945
 
 
946
/******************************************************************//**
 
947
Set the time waited for the lock for the current query. */
 
948
extern "C" UNIV_INTERN
 
949
void
 
950
thd_set_lock_wait_time(
 
951
/*===================*/
 
952
        void*   thd,    /*!< in: thread handle (THD*) */
 
953
        ulint   value)  /*!< in: time waited for the lock */
 
954
{
 
955
        if (thd) {
 
956
          static_cast<Session*>(thd)->utime_after_lock+= value;
 
957
        }
935
958
}
936
959
 
937
960
/********************************************************************//**
946
969
  return *(trx_t**) session->getEngineData(innodb_engine_ptr);
947
970
}
948
971
 
 
972
 
 
973
plugin::ReplicationReturnCode ReplicationLog::apply(Session &session,
 
974
                                                    const message::Transaction &message)
 
975
{
 
976
  char *data= new char[message.ByteSize()];
 
977
 
 
978
  message.SerializeToArray(data, message.ByteSize());
 
979
 
 
980
  trx_t *trx= session_to_trx(&session);
 
981
 
 
982
  uint64_t trx_id= message.transaction_context().transaction_id();
 
983
  ulint error= insert_replication_message(data, message.ByteSize(), trx, trx_id);
 
984
  (void)error;
 
985
 
 
986
  delete[] data;
 
987
 
 
988
  return plugin::SUCCESS;
 
989
}
 
990
 
949
991
/********************************************************************//**
950
992
Call this function when mysqld passes control to the client. That is to
951
993
avoid deadlocks on the adaptive hash S-latch possibly held by session. For more
1167
1209
  if (cs) {
1168
1210
    *mbminlen = cs->mbminlen;
1169
1211
    *mbmaxlen = cs->mbmaxlen;
 
1212
    ut_ad(*mbminlen < DATA_MBMAX);
 
1213
    ut_ad(*mbmaxlen < DATA_MBMAX);
1170
1214
  } else {
1171
1215
    ut_a(cset == 0);
1172
1216
    *mbminlen = *mbmaxlen = 0;
1796
1840
  value= value - (value % align_val);
1797
1841
}
1798
1842
 
 
1843
static void auto_extend_update(Session *, sql_var_t)
 
1844
{
 
1845
  srv_auto_extend_increment= innodb_auto_extend_increment.get();
 
1846
}
 
1847
 
 
1848
static void io_capacity_update(Session *, sql_var_t)
 
1849
{
 
1850
  srv_io_capacity= innodb_io_capacity.get();
 
1851
}
 
1852
 
 
1853
static void purge_batch_update(Session *, sql_var_t)
 
1854
{
 
1855
  srv_purge_batch_size= innodb_purge_batch_size.get();
 
1856
}
 
1857
 
 
1858
static void purge_threads_update(Session *, sql_var_t)
 
1859
{
 
1860
  srv_n_purge_threads= innodb_n_purge_threads.get();
 
1861
}
 
1862
 
 
1863
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
 
1864
{
 
1865
  if (btr_search_enabled)
 
1866
  {
 
1867
    btr_search_enable();
 
1868
  } else {
 
1869
    btr_search_disable();
 
1870
  }
 
1871
}
 
1872
 
 
1873
/*************************************************************//**
 
1874
Check if it is a valid file format. This function is registered as
 
1875
a callback with MySQL.
 
1876
@return 0 for valid file format */
 
1877
static
 
1878
int
 
1879
innodb_file_format_name_validate(
 
1880
/*=============================*/
 
1881
  Session*      , /*!< in: thread handle */
 
1882
  set_var *var)
 
1883
{
 
1884
  const char *file_format_input = var->value->str_value.ptr();
 
1885
  if (file_format_input == NULL)
 
1886
    return 1;
 
1887
 
 
1888
  if (file_format_input != NULL) {
 
1889
    uint  format_id;
 
1890
 
 
1891
    format_id = innobase_file_format_name_lookup(
 
1892
      file_format_input);
 
1893
 
 
1894
    if (format_id <= DICT_TF_FORMAT_MAX) {
 
1895
      innobase_file_format_name =
 
1896
        trx_sys_file_format_id_to_name(format_id);
 
1897
 
 
1898
      return(0);
 
1899
    }
 
1900
  }
 
1901
 
 
1902
  return(1);
 
1903
}
 
1904
 
 
1905
/*************************************************************//**
 
1906
Check if valid argument to innodb_file_format_max. This function
 
1907
is registered as a callback with MySQL.
 
1908
@return 0 for valid file format */
 
1909
static
 
1910
int
 
1911
innodb_file_format_max_validate(
 
1912
/*==============================*/
 
1913
  Session*   session, /*!< in: thread handle */
 
1914
  set_var *var)
 
1915
{
 
1916
  const char *file_format_input = var->value->str_value.ptr();
 
1917
  if (file_format_input == NULL)
 
1918
    return 1;
 
1919
 
 
1920
  if (file_format_input != NULL) {
 
1921
    int format_id = innobase_file_format_validate_and_set(file_format_input);
 
1922
 
 
1923
    if (format_id > DICT_TF_FORMAT_MAX) {
 
1924
      /* DEFAULT is "on", which is invalid at runtime. */
 
1925
      return 1;
 
1926
    }
 
1927
 
 
1928
    if (format_id >= 0) {
 
1929
      innobase_file_format_max= 
 
1930
        trx_sys_file_format_id_to_name((uint)format_id);
 
1931
 
 
1932
      /* Update the max format id in the system tablespace. */
 
1933
      char name_buff[100];
 
1934
      strcpy(name_buff, innobase_file_format_max.c_str());
 
1935
      if (trx_sys_file_format_max_set(format_id, (const char **)&name_buff))
 
1936
      {
 
1937
        errmsg_printf(ERRMSG_LVL_WARN,
 
1938
                      " [Info] InnoDB: the file format in the system "
 
1939
                      "tablespace is now set to %s.\n", name_buff);
 
1940
        innobase_file_format_max= name_buff;
 
1941
      }
 
1942
      return(0);
 
1943
 
 
1944
    } else {
 
1945
      push_warning_printf(session,
 
1946
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1947
                          ER_WRONG_ARGUMENTS,
 
1948
                          "InnoDB: invalid innodb_file_format_max "
 
1949
                          "value; can be any format up to %s "
 
1950
                          "or equivalent id of %d",
 
1951
                          trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
 
1952
                          DICT_TF_FORMAT_MAX);
 
1953
    }
 
1954
  }
 
1955
 
 
1956
  return(1);
 
1957
}
 
1958
 
 
1959
 
1799
1960
/*********************************************************************//**
1800
1961
Opens an InnoDB database.
1801
1962
@return 0 on success, error code on failure */
1811
1972
  InnobaseEngine *actuall_engine_ptr;
1812
1973
  const module::option_map &vm= context.getOptions();
1813
1974
 
 
1975
  srv_auto_extend_increment= innodb_auto_extend_increment.get();
 
1976
  srv_io_capacity= innodb_io_capacity.get();
 
1977
  srv_purge_batch_size= innodb_purge_batch_size.get();
 
1978
  srv_n_purge_threads= innodb_n_purge_threads.get();
 
1979
  srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
 
1980
  srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
 
1981
  srv_max_purge_lag= innodb_max_purge_lag.get();
 
1982
  srv_stats_sample_pages= innodb_stats_sample_pages.get();
 
1983
 
1814
1984
  /* Inverted Booleans */
1815
1985
 
1816
1986
  innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
1817
1987
  innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
1818
1988
  srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
1819
1989
  srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
1820
 
  (SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
1821
 
  (SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
 
1990
  support_xa= (vm.count("disable-xa")) ? false : true;
 
1991
  btr_search_enabled= (vm.count("disable-adaptive-hash-index")) ? false : true;
1822
1992
 
1823
 
  if (vm.count("io-capacity"))
1824
 
  {
1825
 
    if (srv_io_capacity < 100)
1826
 
    {
1827
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
1828
 
      exit(-1);
1829
 
    }
1830
 
  }
1831
1993
 
1832
1994
  if (vm.count("data-home-dir"))
1833
1995
  {
1834
 
    innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
 
1996
    innobase_data_home_dir= vm["data-home-dir"].as<string>();
1835
1997
  }
1836
1998
  else
1837
1999
  {
1838
 
    innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
1839
 
  }
1840
 
 
1841
 
  if (vm.count("fast-shutdown"))
1842
 
  {
1843
 
    if (innobase_fast_shutdown > 2)
1844
 
    {
1845
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
1846
 
      exit(-1);
1847
 
    }
1848
 
  }
1849
 
 
1850
 
  if (vm.count("file-format-max"))
1851
 
  {
1852
 
    innobase_file_format_max= const_cast<char *>(vm["file-format-max"].as<string>().c_str());
 
2000
    innobase_data_home_dir= getDataHome().file_string();
1853
2001
  }
1854
2002
 
1855
2003
  if (vm.count("file-format-check"))
1857
2005
    innobase_file_format_check= vm["file-format-check"].as<bool>();
1858
2006
  }
1859
2007
 
1860
 
  if (vm.count("flush-log-at-trx-commit"))
1861
 
  {
1862
 
    if (srv_flush_log_at_trx_commit > 2)
1863
 
    {
1864
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
1865
 
      exit(-1);
1866
 
    }
1867
 
  }
1868
 
 
1869
 
  if (vm.count("flush-method"))
1870
 
  {
1871
 
    innobase_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
1872
 
  }
1873
 
  else
1874
 
  {
1875
 
    innobase_file_flush_method= NULL;
1876
 
  }
1877
 
 
1878
 
#ifdef UNIV_LOG_ARCHIVE
1879
 
  if (vm.count("log-arch-dir"))
1880
 
  {
1881
 
    innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
1882
 
  }
1883
 
 
1884
 
  else
1885
 
  {
1886
 
    innobase_log_arch_dir= NULL;
1887
 
  }
1888
 
#endif /* UNIV_LOG_ARCHIVE */
1889
 
 
1890
 
  if (vm.count("max-dirty-pages-pct"))
1891
 
  {
1892
 
    if (srv_max_buf_pool_modified_pct > 99)
1893
 
    {
1894
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
1895
 
      exit(-1);
1896
 
    }
1897
 
  }
1898
2008
 
1899
2009
  if (vm.count("stats-sample-pages"))
1900
2010
  {
1905
2015
    }
1906
2016
  }
1907
2017
 
1908
 
  if (vm.count("additional-mem-pool-size"))
1909
 
  {
1910
 
    align_value(innobase_additional_mem_pool_size);
1911
 
 
1912
 
    if (innobase_additional_mem_pool_size < 512*1024L)
1913
 
    {
1914
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
1915
 
      exit(-1);
1916
 
    }
1917
 
 
1918
 
  }
1919
 
 
1920
 
  if (vm.count("autoextend-increment"))
1921
 
  {
1922
 
    if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
1923
 
    {
1924
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
1925
 
      exit(-1);
1926
 
    }
1927
 
  }
1928
 
 
1929
 
  if (vm.count("buffer-pool-size"))
1930
 
  {
1931
 
    align_value(innobase_buffer_pool_size, 1024*1024);
1932
 
    if (innobase_buffer_pool_size < 5*1024*1024)
1933
 
    {
1934
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
1935
 
      exit(-1);
1936
 
    }
1937
 
    
1938
 
  }
1939
 
 
1940
 
  if (vm.count("buffer-pool-instances"))
1941
 
  {
1942
 
    if (innobase_buffer_pool_instances > MAX_BUFFER_POOLS)
1943
 
    {
1944
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-instances\n"));
1945
 
      exit(-1);
1946
 
    }
1947
 
    
1948
 
  }
1949
2018
 
1950
2019
  if (vm.count("commit-concurrency"))
1951
2020
  {
2002
2071
    }
2003
2072
  }
2004
2073
 
2005
 
  if (vm.count("log-file-size"))
2006
 
  {
2007
 
    align_value(innobase_log_file_size, 1024*1024);
2008
 
    if (innobase_log_file_size < 1*1024*1024L)
2009
 
    {
2010
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
2011
 
      exit(-1);
2012
 
    }
2013
 
  }
2014
2074
 
2015
2075
  if (vm.count("log-files-in-group"))
2016
2076
  {
2050
2110
 
2051
2111
  if (vm.count("data-file-path"))
2052
2112
  {
2053
 
    innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
2054
 
  }
2055
 
  else
2056
 
  {
2057
 
    innobase_data_file_path= NULL;
2058
 
  }
2059
 
 
2060
 
  if (vm.count("version"))
2061
 
  {
2062
 
    innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
 
2113
    innobase_data_file_path= vm["data-file-path"].as<string>();
2063
2114
  }
2064
2115
 
2065
2116
  if (vm.count("read-ahead-threshold"))
2071
2122
    }
2072
2123
  }
2073
2124
 
2074
 
  if (vm.count("strict-mode"))
2075
 
  {
2076
 
    (SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
2077
 
  }
2078
 
 
2079
 
  if (vm.count("lock-wait-timeout"))
2080
 
  {
2081
 
    if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
2082
 
    {
2083
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
2084
 
      exit(-1);
2085
 
    }
2086
 
 
2087
 
    (SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
2088
 
  }
 
2125
 
2089
2126
 
2090
2127
  innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2091
2128
 
2109
2146
  }
2110
2147
#endif /* UNIV_DEBUG */
2111
2148
 
2112
 
  /* Check that values don't overflow on 32-bit systems. */
2113
 
  if (sizeof(ulint) == 4) {
2114
 
    if (innobase_buffer_pool_size > UINT32_MAX) {
2115
 
      errmsg_printf(ERRMSG_LVL_ERROR, 
2116
 
                    "innobase_buffer_pool_size can't be over 4GB"
2117
 
                    " on 32-bit systems");
2118
 
 
2119
 
      goto error;
2120
 
    }
2121
 
 
2122
 
    if (innobase_log_file_size > UINT32_MAX) {
2123
 
      errmsg_printf(ERRMSG_LVL_ERROR, 
2124
 
                    "innobase_log_file_size can't be over 4GB"
2125
 
                    " on 32-bit systems");
2126
 
 
2127
 
      goto error;
2128
 
    }
2129
 
  }
2130
 
 
2131
2149
  os_innodb_umask = (ulint)internal::my_umask;
2132
2150
 
2133
2151
 
2138
2156
 
2139
2157
  /* The default dir for data files is the datadir of MySQL */
2140
2158
 
2141
 
  srv_data_home = (char *)innobase_data_home_dir;
 
2159
  srv_data_home = (char *)innobase_data_home_dir.c_str();
2142
2160
 
2143
2161
  /* Set default InnoDB data file size to 10 MB and let it be
2144
2162
    auto-extending. Thus users can use InnoDB in >= 4.0 without having
2145
2163
    to specify any startup options. */
2146
2164
 
2147
 
  if (!innobase_data_file_path) {
2148
 
    innobase_data_file_path = (char*) "ibdata1:10M:autoextend";
 
2165
  if (innobase_data_file_path.empty()) 
 
2166
  {
 
2167
    innobase_data_file_path= std::string("ibdata1:10M:autoextend");
2149
2168
  }
2150
2169
 
2151
2170
  /* Since InnoDB edits the argument in the next call, we make another
2152
2171
    copy of it: */
2153
2172
 
2154
 
  internal_innobase_data_file_path = strdup(innobase_data_file_path);
 
2173
  internal_innobase_data_file_path = strdup(innobase_data_file_path.c_str());
2155
2174
 
2156
2175
  ret = (bool) srv_parse_data_file_paths_and_sizes(
2157
2176
                                                   internal_innobase_data_file_path);
2171
2190
 
2172
2191
  if (vm.count("log-group-home-dir"))
2173
2192
  {
2174
 
    innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str());
 
2193
    innobase_log_group_home_dir= vm["log-group-home-dir"].as<string>();
2175
2194
  }
2176
2195
  else
2177
2196
  {
2178
 
    innobase_log_group_home_dir = strdup(getDataHome().file_string().c_str());
 
2197
    innobase_log_group_home_dir= getDataHome().file_string();
2179
2198
  }
2180
2199
 
2181
 
#ifdef UNIV_LOG_ARCHIVE
2182
 
  /* Since innodb_log_arch_dir has no relevance under MySQL,
2183
 
    starting from 4.0.6 we always set it the same as
2184
 
innodb_log_group_home_dir: */
2185
 
 
2186
 
  innobase_log_arch_dir = innobase_log_group_home_dir;
2187
 
 
2188
 
  srv_arch_dir = innobase_log_arch_dir;
2189
 
#endif /* UNIG_LOG_ARCHIVE */
2190
 
 
2191
2200
  ret = (bool)
2192
 
    srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
 
2201
    srv_parse_log_group_home_dirs((char *)innobase_log_group_home_dir.c_str());
2193
2202
 
2194
2203
  if (ret == FALSE || innobase_mirrored_log_groups != 1) {
2195
2204
    errmsg_printf(ERRMSG_LVL_ERROR, "syntax error in innodb_log_group_home_dir, or a "
2216
2225
    format_id = 0;
2217
2226
  }
2218
2227
 
2219
 
  if (vm.count("purge-batch-size"))
2220
 
  {
2221
 
    srv_purge_batch_size= vm["purge-batch-size"].as<unsigned long>();
2222
 
    if (srv_purge_batch_size < 1 || srv_purge_batch_size > 5000)
2223
 
    {
2224
 
      errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: wrong purge-batch_size.");
2225
 
      goto mem_free_and_error;
2226
 
    }
2227
 
  }
2228
 
 
2229
 
  if (vm.count("n-purge-threads"))
2230
 
  {
2231
 
    srv_n_purge_threads= vm["n-purge-threads"].as<unsigned long>();
2232
 
    if (srv_n_purge_threads > 1)
2233
 
    {
2234
 
      errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: wrong n-purge-threads.");
2235
 
      goto mem_free_and_error;
2236
 
    }
2237
 
  }
2238
 
 
2239
2228
  srv_file_format = format_id;
2240
2229
 
2241
 
  /* Given the type of innobase_file_format_name we have little
2242
 
    choice but to cast away the constness from the returned name.
2243
 
    innobase_file_format_name is used in the MySQL set variable
2244
 
    interface and so can't be const. */
2245
 
 
2246
2230
  innobase_file_format_name =
2247
 
    (char*) trx_sys_file_format_id_to_name(format_id);
 
2231
    trx_sys_file_format_id_to_name(format_id);
2248
2232
 
2249
2233
  /* Check innobase_file_format_check variable */
2250
2234
  if (!innobase_file_format_check)
2259
2243
  /* Did the user specify a format name that we support?
2260
2244
     As a side effect it will update the variable
2261
2245
     srv_max_file_format_at_startup */
2262
 
  if (innobase_file_format_validate_and_set(innobase_file_format_max) < 0)
 
2246
  if (innobase_file_format_validate_and_set(innobase_file_format_max.c_str()) < 0)
2263
2247
  {
2264
 
    errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: invalid "
 
2248
    errmsg_printf(ERRMSG_LVL_ERROR, _("InnoDB: invalid "
2265
2249
                    "innodb_file_format_max value: "
2266
2250
                    "should be any value up to %s or its "
2267
 
                    "equivalent numeric id",
 
2251
                    "equivalent numeric id"),
2268
2252
                    trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
2269
2253
    goto mem_free_and_error;
2270
2254
  }
2298
2282
 
2299
2283
  /* --------------------------------------------------*/
2300
2284
 
2301
 
  srv_file_flush_method_str = innobase_file_flush_method;
 
2285
  if (vm.count("flush-method") != 0)
 
2286
  {
 
2287
    srv_file_flush_method_str = (char *)vm["flush-method"].as<string>().c_str();
 
2288
  }
2302
2289
 
2303
2290
  srv_n_log_groups = (ulint) innobase_mirrored_log_groups;
2304
2291
  srv_n_log_files = (ulint) innobase_log_files_in_group;
2305
2292
  srv_log_file_size = (ulint) innobase_log_file_size;
2306
2293
 
2307
 
#ifdef UNIV_LOG_ARCHIVE
2308
 
  srv_log_archive_on = (ulint) innobase_log_archive;
2309
 
#endif /* UNIV_LOG_ARCHIVE */
2310
2294
  srv_log_buffer_size = (ulint) innobase_log_buffer_size;
2311
2295
 
2312
2296
  srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
2351
2335
 
2352
2336
  err = innobase_start_or_create_for_mysql();
2353
2337
 
 
2338
  if (err != DB_SUCCESS)
 
2339
  {
 
2340
    goto mem_free_and_error;
 
2341
  }
 
2342
 
 
2343
  err = dict_create_sys_replication_log();
 
2344
 
2354
2345
  if (err != DB_SUCCESS) {
2355
2346
    goto mem_free_and_error;
2356
2347
  }
2417
2408
  context.add(innodb_sys_foreign_cols_tool);
2418
2409
 
2419
2410
  context.add(new(std::nothrow)InnodbInternalTables());
 
2411
  context.registerVariable(new sys_var_const_string_val("data-home-dir", innobase_data_home_dir));
 
2412
  context.registerVariable(new sys_var_const_string_val("flush-method", 
 
2413
                                                        vm.count("flush-method") ?  vm["flush-method"].as<string>() : ""));
 
2414
  context.registerVariable(new sys_var_const_string_val("log-group-home-dir", innobase_log_group_home_dir));
 
2415
  context.registerVariable(new sys_var_const_string_val("data-file-path", innobase_data_file_path));
 
2416
  context.registerVariable(new sys_var_const_string_val("version", vm["version"].as<string>()));
 
2417
 
 
2418
 
 
2419
  context.add(new(std::nothrow)InnodbReplicationTable());
 
2420
 
 
2421
  replication_logger= new(std::nothrow)ReplicationLog();
 
2422
  context.add(replication_logger);
 
2423
 
 
2424
  if (vm.count("replication-log") and vm["replication-log"].as<bool>())
 
2425
  {
 
2426
    ReplicationLog::setup(static_cast<ReplicationLog *>(replication_logger));
 
2427
  }
 
2428
 
 
2429
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
 
2430
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
 
2431
  context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
 
2432
  context.registerVariable(new sys_var_bool_ptr_readonly("file-format-check", &innobase_file_format_check));
 
2433
  context.registerVariable(new sys_var_bool_ptr("adaptive-flushing", &srv_adaptive_flushing));
 
2434
  context.registerVariable(new sys_var_bool_ptr("status-file", &innobase_create_status_file));
 
2435
  context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
 
2436
  context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
 
2437
 
 
2438
  context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
 
2439
  context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
 
2440
  context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
 
2441
 
 
2442
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
 
2443
  context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
 
2444
                                                                   innodb_auto_extend_increment,
 
2445
                                                                   auto_extend_update));
 
2446
  context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
 
2447
                                                                   innodb_io_capacity,
 
2448
                                                                   io_capacity_update));
 
2449
  context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
 
2450
                                                                   innodb_purge_batch_size,
 
2451
                                                                   purge_batch_update));
 
2452
  context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
 
2453
                                                                   innodb_n_purge_threads,
 
2454
                                                                   purge_threads_update));
 
2455
  context.registerVariable(new sys_var_constrained_value<uint16_t>("fast_shutdown", innobase_fast_shutdown));
 
2456
  context.registerVariable(new sys_var_std_string("file_format",
 
2457
                                                  innobase_file_format_name,
 
2458
                                                  innodb_file_format_name_validate));
 
2459
  context.registerVariable(new sys_var_std_string("file_format_max",
 
2460
                                                  innobase_file_format_max,
 
2461
                                                  innodb_file_format_max_validate));
 
2462
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
 
2463
  context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
 
2464
  context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit",
 
2465
                                                  innodb_flush_log_at_trx_commit));
 
2466
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
 
2467
                                                  innodb_max_dirty_pages_pct));
 
2468
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
 
2469
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
 
2470
  context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
 
2471
 
2420
2472
 
2421
2473
  /* Get the current high water mark format. */
2422
 
  innobase_file_format_max = (char*) trx_sys_file_format_max_get();
 
2474
  innobase_file_format_max = trx_sys_file_format_max_get();
 
2475
  btr_search_fully_disabled = (!btr_search_enabled);
2423
2476
 
2424
2477
  return(FALSE);
2425
2478
error:
2804
2857
  /* Warn if rolling back some things... */
2805
2858
  if (session->getKilled() != Session::NOT_KILLED &&
2806
2859
      trx->conc_state != TRX_NOT_STARTED &&
2807
 
      trx->undo_no.low > 0 &&
 
2860
      trx->undo_no > 0 &&
2808
2861
      global_system_variables.log_warnings)
2809
2862
  {
2810
 
      errmsg_printf(ERRMSG_LVL_WARN, 
 
2863
      errmsg_printf(ERRMSG_LVL_WARN,
2811
2864
      "Drizzle is closing a connection during a KILL operation\n"
2812
 
      "that has an active InnoDB transaction.  %lu row modifications will "
 
2865
      "that has an active InnoDB transaction.  %llu row modifications will "
2813
2866
      "roll back.\n",
2814
 
      (ulong) trx->undo_no.low);
 
2867
      (ullint) trx->undo_no);
2815
2868
  }
2816
2869
 
2817
2870
  innobase_rollback_trx(trx);
3523
3576
    /* We update the highest file format in the system table
3524
3577
    space, if this table has higher file format setting. */
3525
3578
 
3526
 
    trx_sys_file_format_max_upgrade(
3527
 
      (const char**) &innobase_file_format_max,
 
3579
    char changed_file_format_max[100];
 
3580
    strcpy(changed_file_format_max, innobase_file_format_max.c_str());
 
3581
    trx_sys_file_format_max_upgrade((const char **)&changed_file_format_max,
3528
3582
      dict_table_get_format(prebuilt->table));
 
3583
    innobase_file_format_max= changed_file_format_max;
3529
3584
  }
3530
3585
 
3531
3586
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
4039
4094
      ulint     key_len;
4040
4095
      const unsigned char*    src_start;
4041
4096
      enum_field_types  real_type;
 
4097
      const CHARSET_INFO* cs= field->charset();
4042
4098
 
4043
4099
      key_len = key_part->length;
4044
4100
 
4060
4116
      memcpy(buff, src_start, true_len);
4061
4117
      buff += true_len;
4062
4118
 
4063
 
      /* Pad the unused space with spaces. Note that no
4064
 
      padding is ever needed for UCS-2 because in MySQL,
4065
 
      all UCS2 characters are 2 bytes, as MySQL does not
4066
 
      support surrogate pairs, which are needed to represent
4067
 
      characters in the range U+10000 to U+10FFFF. */
 
4119
      /* Pad the unused space with spaces. */
4068
4120
 
4069
4121
      if (true_len < key_len) {
4070
 
        ulint pad_len = key_len - true_len;
4071
 
        memset(buff, ' ', pad_len);
 
4122
        ulint   pad_len = key_len - true_len;
 
4123
        ut_a(!(pad_len % cs->mbminlen));
 
4124
 
 
4125
        cs->cset->fill(cs, buff, pad_len,
 
4126
                       0x20 /* space */);
4072
4127
        buff += pad_len;
4073
4128
      }
4074
4129
    }
4176
4231
 
4177
4232
  /* Note that in InnoDB, i is the column number. MySQL calls columns
4178
4233
  'fields'. */
4179
 
  for (i = 0; i < n_fields; i++) 
 
4234
  for (i = 0; i < n_fields; i++)
4180
4235
  {
 
4236
    const dict_col_t *col= &index->table->cols[i];
4181
4237
    templ = prebuilt->mysql_template + n_requested_fields;
4182
4238
    field = table->getField(i);
4183
4239
 
4225
4281
    templ->col_no = i;
4226
4282
 
4227
4283
    if (index == clust_index) {
4228
 
      templ->rec_field_no = dict_col_get_clust_pos(
4229
 
        &index->table->cols[i], index);
 
4284
      templ->rec_field_no = dict_col_get_clust_pos(col, index);
4230
4285
    } else {
4231
4286
      templ->rec_field_no = dict_index_get_nth_col_pos(
4232
4287
                index, i);
4255
4310
      mysql_prefix_len = templ->mysql_col_offset
4256
4311
        + templ->mysql_col_len;
4257
4312
    }
4258
 
    templ->type = index->table->cols[i].mtype;
 
4313
    templ->type = col->mtype;
4259
4314
    templ->mysql_type = (ulint)field->type();
4260
4315
 
4261
4316
    if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
4263
4318
        (((Field_varstring*)field)->pack_length_no_ptr());
4264
4319
    }
4265
4320
 
4266
 
    templ->charset = dtype_get_charset_coll(
4267
 
      index->table->cols[i].prtype);
4268
 
    templ->mbminlen = index->table->cols[i].mbminlen;
4269
 
    templ->mbmaxlen = index->table->cols[i].mbmaxlen;
4270
 
    templ->is_unsigned = index->table->cols[i].prtype
4271
 
              & DATA_UNSIGNED;
 
4321
    templ->charset = dtype_get_charset_coll(col->prtype);
 
4322
    templ->mbminlen = dict_col_get_mbminlen(col);
 
4323
    templ->mbmaxlen = dict_col_get_mbmaxlen(col);
 
4324
    templ->is_unsigned = col->prtype & DATA_UNSIGNED;
4272
4325
    if (templ->type == DATA_BLOB) {
4273
4326
      prebuilt->templ_contains_blob = TRUE;
4274
4327
    }
4486
4539
 
4487
4540
  error = row_insert_for_mysql((byte*) record, prebuilt);
4488
4541
 
4489
 
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
 
4542
  user_session->setXaId(trx->id);
4490
4543
 
4491
4544
  /* Handle duplicate key errors */
4492
4545
  if (auto_inc_used) {
4809
4862
 
4810
4863
  error = row_update_for_mysql((byte*) old_row, prebuilt);
4811
4864
 
4812
 
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
 
4865
  user_session->setXaId(trx->id);
4813
4866
 
4814
4867
  /* We need to do some special AUTOINC handling for the following case:
4815
4868
 
4901
4954
 
4902
4955
  error = row_update_for_mysql((byte*) record, prebuilt);
4903
4956
 
4904
 
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
 
4957
  user_session->setXaId(trx->id);
4905
4958
 
4906
4959
  innodb_srv_conc_exit_innodb(trx);
4907
4960
 
6172
6225
# error "DICT_TF_ZSSIZE_MAX < 1"
6173
6226
#endif
6174
6227
 
6175
 
    if (SessionVAR(&session, strict_mode))
 
6228
    if (strict_mode)
6176
6229
    {
6177
6230
      if (! srv_file_per_table)
6178
6231
      {
6219
6272
                          lex_identified_temp_table ? name2 : NULL,
6220
6273
                          iflags);
6221
6274
 
6222
 
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
 
6275
  session.setXaId(trx->id);
6223
6276
 
6224
6277
  if (error) {
6225
6278
    goto cleanup;
6300
6353
    /* We update the highest file format in the system table
6301
6354
      space, if this table has higher file format setting. */
6302
6355
 
6303
 
    trx_sys_file_format_max_upgrade((const char**) &innobase_file_format_max,
6304
 
                                    dict_table_get_format(innobase_table));
 
6356
    char changed_file_format_max[100];
 
6357
    strcpy(changed_file_format_max, innobase_file_format_max.c_str());
 
6358
    trx_sys_file_format_max_upgrade((const char **)&changed_file_format_max,
 
6359
      dict_table_get_format(innobase_table));
 
6360
    innobase_file_format_max= changed_file_format_max;
6305
6361
  }
6306
6362
 
6307
6363
  /* Note: We can't call update_session() as prebuilt will not be
6473
6529
                                   session_sql_command(&session)
6474
6530
                                   == SQLCOM_DROP_DB);
6475
6531
 
6476
 
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
 
6532
  session.setXaId(trx->id);
6477
6533
 
6478
6534
  /* Flush the log to reduce probability that the .frm files and
6479
6535
    the InnoDB data dictionary get out-of-sync if the user runs
6695
6751
 
6696
6752
  error = innobase_rename_table(trx, from.getPath().c_str(), to.getPath().c_str(), TRUE);
6697
6753
 
6698
 
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
 
6754
  session.setXaId(trx->id);
6699
6755
 
6700
6756
  /* Tell the InnoDB server that there might be work for
6701
6757
    utility threads: */
7003
7059
 
7004
7060
        /* If index does not belong to the table of share structure. Search
7005
7061
        index->table instead */
7006
 
        if (index->table != ib_table
7007
 
            && strcmp(index->table->name, share->table_name)) {
 
7062
        if (index->table != ib_table) {
7008
7063
                i = 0;
7009
7064
                ind = dict_table_get_first_index(index->table);
7010
7065
 
8983
9038
uint64_t InnobaseEngine::doGetCurrentTransactionId(Session *session)
8984
9039
{
8985
9040
  trx_t *trx= session_to_trx(session);
8986
 
  return (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
 
9041
  return (trx->id);
8987
9042
}
8988
9043
 
8989
9044
uint64_t InnobaseEngine::doGetNewTransactionId(Session *session)
9001
9056
  trx->id= trx_sys_get_new_trx_id();
9002
9057
  mutex_exit(&kernel_mutex);
9003
9058
 
9004
 
  uint64_t transaction_id= (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
 
9059
  uint64_t transaction_id= trx->id;
9005
9060
 
9006
9061
  return transaction_id;
9007
9062
}
9138
9193
  }
9139
9194
}
9140
9195
 
9141
 
/*************************************************************//**
9142
 
Check if it is a valid file format. This function is registered as
9143
 
a callback with MySQL.
9144
 
@return 0 for valid file format */
9145
 
static
9146
 
int
9147
 
innodb_file_format_name_validate(
9148
 
/*=============================*/
9149
 
  Session*      , /*!< in: thread handle */
9150
 
  drizzle_sys_var*  , /*!< in: pointer to system
9151
 
            variable */
9152
 
  void*       save, /*!< out: immediate result
9153
 
            for update function */
9154
 
  drizzle_value*    value)  /*!< in: incoming string */
9155
 
{
9156
 
  const char* file_format_input;
9157
 
  char    buff[STRING_BUFFER_USUAL_SIZE];
9158
 
  int   len = sizeof(buff);
9159
 
 
9160
 
  ut_a(save != NULL);
9161
 
  ut_a(value != NULL);
9162
 
 
9163
 
  file_format_input = value->val_str(value, buff, &len);
9164
 
 
9165
 
  if (file_format_input != NULL) {
9166
 
    uint  format_id;
9167
 
 
9168
 
    format_id = innobase_file_format_name_lookup(
9169
 
      file_format_input);
9170
 
 
9171
 
    if (format_id <= DICT_TF_FORMAT_MAX) {
9172
 
      /* Save a pointer to the name in the
9173
 
         'file_format_name_map' constant array. */
9174
 
      *static_cast<const char**>(save) =
9175
 
        trx_sys_file_format_id_to_name(format_id);
9176
 
 
9177
 
      return(0);
9178
 
    }
9179
 
  }
9180
 
 
9181
 
  *static_cast<const char**>(save) = NULL;
9182
 
  return(1);
9183
 
}
9184
 
 
9185
 
/****************************************************************//**
9186
 
Update the system variable innodb_file_format using the "saved"
9187
 
value. This function is registered as a callback with MySQL. */
9188
 
static
9189
 
void
9190
 
innodb_file_format_name_update(
9191
 
/*===========================*/
9192
 
  Session*      ,   /*!< in: thread handle */
9193
 
  drizzle_sys_var*  ,   /*!< in: pointer to
9194
 
              system variable */
9195
 
  void*       var_ptr,  /*!< out: where the
9196
 
              formal string goes */
9197
 
  const void*     save)   /*!< in: immediate result
9198
 
              from check function */
9199
 
{
9200
 
  const char* format_name;
9201
 
 
9202
 
  ut_a(var_ptr != NULL);
9203
 
  ut_a(save != NULL);
9204
 
 
9205
 
  format_name = *static_cast<const char*const*>(save);
9206
 
 
9207
 
  if (format_name) {
9208
 
    uint  format_id;
9209
 
 
9210
 
    format_id = innobase_file_format_name_lookup(format_name);
9211
 
 
9212
 
    if (format_id <= DICT_TF_FORMAT_MAX) {
9213
 
      srv_file_format = format_id;
9214
 
    }
9215
 
  }
9216
 
 
9217
 
  *static_cast<const char**>(var_ptr)
9218
 
    = trx_sys_file_format_id_to_name(srv_file_format);
9219
 
}
9220
 
 
9221
 
/*************************************************************//**
9222
 
Check if valid argument to innodb_file_format_max. This function
9223
 
is registered as a callback with MySQL.
9224
 
@return 0 for valid file format */
9225
 
static
9226
 
int
9227
 
innodb_file_format_max_validate(
9228
 
/*==============================*/
9229
 
  Session*      session, /*!< in: thread handle */
9230
 
  drizzle_sys_var*  , /*!< in: pointer to system
9231
 
            variable */
9232
 
  void*       save, /*!< out: immediate result
9233
 
            for update function */
9234
 
  drizzle_value*    value)  /*!< in: incoming string */
9235
 
{
9236
 
  const char* file_format_input;
9237
 
  char    buff[STRING_BUFFER_USUAL_SIZE];
9238
 
  int   len = sizeof(buff);
9239
 
  int   format_id;
9240
 
 
9241
 
  ut_a(save != NULL);
9242
 
  ut_a(value != NULL);
9243
 
 
9244
 
  file_format_input = value->val_str(value, buff, &len);
9245
 
 
9246
 
  if (file_format_input != NULL) {
9247
 
    format_id = innobase_file_format_validate_and_set(file_format_input);
9248
 
 
9249
 
    if (format_id >= 0) {
9250
 
      /* Save a pointer to the name in the
9251
 
         'file_format_name_map' constant array. */
9252
 
      *static_cast<const char**>(save) =
9253
 
        trx_sys_file_format_id_to_name((uint)format_id);
9254
 
 
9255
 
      return(0);
9256
 
 
9257
 
    } else {
9258
 
      push_warning_printf(session,
9259
 
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
9260
 
                          ER_WRONG_ARGUMENTS,
9261
 
                          "InnoDB: invalid innodb_file_format_max "
9262
 
                          "value; can be any format up to %s "
9263
 
                          "or equivalent id of %d",
9264
 
                          trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
9265
 
                          DICT_TF_FORMAT_MAX);
9266
 
    }
9267
 
  }
9268
 
 
9269
 
  *static_cast<const char**>(save) = NULL;
9270
 
  return(1);
9271
 
}
9272
 
 
9273
 
/****************************************************************//**
9274
 
Update the system variable innodb_file_format_max using the "saved"
9275
 
value. This function is registered as a callback with MySQL. */
9276
 
static
9277
 
void
9278
 
innodb_file_format_max_update(
9279
 
/*============================*/
9280
 
  Session*      session,  /*!< in: thread handle */
9281
 
  drizzle_sys_var*  ,   /*!< in: pointer to
9282
 
              system variable */
9283
 
  void*       var_ptr,  /*!< out: where the
9284
 
              formal string goes */
9285
 
  const void*     save)   /*!< in: immediate result
9286
 
              from check function */
9287
 
{
9288
 
  const char* format_name_in;
9289
 
  const char**  format_name_out;
9290
 
  uint    format_id;
9291
 
 
9292
 
  ut_a(save != NULL);
9293
 
  ut_a(var_ptr != NULL);
9294
 
 
9295
 
  format_name_in = *static_cast<const char*const*>(save);
9296
 
 
9297
 
  if (!format_name_in) {
9298
 
 
9299
 
    return;
9300
 
  }
9301
 
 
9302
 
  format_id = innobase_file_format_name_lookup(format_name_in);
9303
 
 
9304
 
  if (format_id > DICT_TF_FORMAT_MAX) {
9305
 
    /* DEFAULT is "on", which is invalid at runtime. */
9306
 
    push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
9307
 
            ER_WRONG_ARGUMENTS,
9308
 
            "Ignoring SET innodb_file_format=%s",
9309
 
            format_name_in);
9310
 
    return;
9311
 
  }
9312
 
 
9313
 
  format_name_out = static_cast<const char**>(var_ptr);
9314
 
 
9315
 
  /* Update the max format id in the system tablespace. */
9316
 
  if (trx_sys_file_format_max_set(format_id, format_name_out)) {
9317
 
    ut_print_timestamp(stderr);
9318
 
    fprintf(stderr,
9319
 
      " [Info] InnoDB: the file format in the system "
9320
 
      "tablespace is now set to %s.\n", *format_name_out);
9321
 
  }
9322
 
}
9323
 
 
9324
 
/****************************************************************//**
9325
 
Update the system variable innodb_adaptive_hash_index using the "saved"
9326
 
value. This function is registered as a callback with MySQL. */
9327
 
static
9328
 
void
9329
 
innodb_adaptive_hash_index_update(
9330
 
/*==============================*/
9331
 
  Session*      ,   /*!< in: thread handle */
9332
 
  drizzle_sys_var*  ,   /*!< in: pointer to
9333
 
              system variable */
9334
 
  void*       , /*!< out: where the
9335
 
              formal string goes */
9336
 
  const void*     save)   /*!< in: immediate result
9337
 
              from check function */
9338
 
{
9339
 
  if (*(bool*) save) {
9340
 
    btr_search_enable();
9341
 
  } else {
9342
 
    btr_search_disable();
9343
 
  }
9344
 
}
9345
 
 
9346
9196
/****************************************************************//**
9347
9197
Update the system variable innodb_old_blocks_pct using the "saved"
9348
9198
value. This function is registered as a callback with MySQL. */
9428
9278
}
9429
9279
 
9430
9280
/* plugin options */
9431
 
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
9432
 
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9433
 
  "Enable InnoDB checksums validation (enabled by default). ",
9434
 
  NULL, NULL, TRUE);
9435
 
 
9436
 
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
9437
 
  PLUGIN_VAR_READONLY,
9438
 
  "The common part for InnoDB table spaces.",
9439
 
  NULL, NULL, NULL);
9440
 
 
9441
 
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
9442
 
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9443
 
  "Enable InnoDB doublewrite buffer (enabled by default). ",
9444
 
  NULL, NULL, TRUE);
9445
 
 
9446
 
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
9447
 
  PLUGIN_VAR_RQCMDARG,
9448
 
  "Number of IOPs the server can do. Tunes the background IO rate",
9449
 
  NULL, NULL, 200, 100, ~0L, 0);
9450
 
 
9451
 
static DRIZZLE_SYSVAR_ULONG(purge_batch_size, srv_purge_batch_size,
9452
 
  PLUGIN_VAR_OPCMDARG,
9453
 
  "Number of UNDO logs to purge in one batch from the history list. "
9454
 
  "Default is 20",
9455
 
  NULL, NULL,
9456
 
  20,                   /* Default setting */
9457
 
  1,                    /* Minimum value */
9458
 
  5000, 0);             /* Maximum value */
9459
 
 
9460
 
static DRIZZLE_SYSVAR_ULONG(purge_threads, srv_n_purge_threads,
9461
 
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
9462
 
  "Purge threads can be either 0 or 1. Default is 0.",
9463
 
  NULL, NULL,
9464
 
  0,                    /* Default setting */
9465
 
  0,                    /* Minimum value */
9466
 
  1, 0);                /* Maximum value */
9467
 
 
9468
 
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
9469
 
  PLUGIN_VAR_OPCMDARG,
9470
 
  "Speeds up the shutdown process of the InnoDB storage engine. Possible "
9471
 
  "values are 0, 1 (faster)"
9472
 
  " or 2 (fastest - crash-like)"
9473
 
  ".",
9474
 
  NULL, NULL, 1, 0, 2, 0);
9475
 
 
9476
 
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
9477
 
  PLUGIN_VAR_NOCMDARG,
9478
 
  "Stores each InnoDB table to an .ibd file in the database dir.",
9479
 
  NULL, NULL, TRUE);
9480
 
 
9481
 
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
9482
 
  PLUGIN_VAR_RQCMDARG,
9483
 
  "File format to use for new tables in .ibd files.",
9484
 
  innodb_file_format_name_validate,
9485
 
  innodb_file_format_name_update, "Barracuda");
9486
9281
 
9487
9282
/* "innobase_file_format_check" decides whether we would continue
9488
9283
booting the server if the file format stamped on the system
9490
9285
by the server. Can be set during server startup at command
9491
9286
line or configure file, and a read only variable after
9492
9287
server startup */
9493
 
static DRIZZLE_SYSVAR_BOOL(file_format_check, innobase_file_format_check,
9494
 
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
9495
 
  "Whether to perform system file format check.",
9496
 
  NULL, NULL, TRUE);
9497
9288
 
9498
9289
/* If a new file format is introduced, the file format
9499
9290
name needs to be updated accordingly. Please refer to
9500
9291
file_format_name_map[] defined in trx0sys.c for the next
9501
9292
file format name. */
9502
 
static DRIZZLE_SYSVAR_STR(file_format_max, innobase_file_format_max,
9503
 
  PLUGIN_VAR_OPCMDARG,
9504
 
  "The highest file format in the tablespace.",
9505
 
  innodb_file_format_max_validate,
9506
 
  innodb_file_format_max_update,
9507
 
  "Antelope");
9508
 
 
9509
 
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
9510
 
  PLUGIN_VAR_OPCMDARG,
9511
 
  "Set to 0 (write and flush once per second),"
9512
 
  " 1 (write and flush at each commit)"
9513
 
  " or 2 (write at commit, flush once per second).",
9514
 
  NULL, NULL, 1, 0, 2, 0);
9515
 
 
9516
 
static DRIZZLE_SYSVAR_STR(flush_method, innobase_file_flush_method,
9517
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9518
 
  "With which method to flush data.", NULL, NULL, NULL);
9519
 
 
9520
 
#ifdef UNIV_LOG_ARCHIVE
9521
 
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
9522
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9523
 
  "Where full logs should be archived.", NULL, NULL, NULL);
9524
 
 
9525
 
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
9526
 
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
9527
 
  "Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
9528
 
#endif /* UNIV_LOG_ARCHIVE */
9529
 
 
9530
 
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
9531
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9532
 
  "Path to InnoDB log files.", NULL, NULL, NULL);
9533
 
 
9534
 
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
9535
 
  PLUGIN_VAR_RQCMDARG,
9536
 
  "Percentage of dirty pages allowed in bufferpool.",
9537
 
  NULL, NULL, 75, 0, 99, 0);
9538
 
 
9539
 
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
9540
 
  PLUGIN_VAR_NOCMDARG,
9541
 
  "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
9542
 
  NULL, NULL, TRUE);
9543
 
 
9544
 
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
9545
 
  PLUGIN_VAR_RQCMDARG,
9546
 
  "Desired maximum length of the purge queue (0 = no limit)",
9547
 
  NULL, NULL, 0, 0, ~0L, 0);
9548
 
 
9549
 
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
9550
 
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
9551
 
  "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
9552
 
  NULL, NULL, FALSE);
9553
 
 
9554
 
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
9555
 
  PLUGIN_VAR_RQCMDARG,
9556
 
  "The number of index pages to sample when calculating statistics (default 8)",
9557
 
  NULL, NULL, 8, 1, ~0ULL, 0);
9558
 
 
9559
 
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
9560
 
  PLUGIN_VAR_OPCMDARG,
9561
 
  "Enable InnoDB adaptive hash index (enabled by default).",
9562
 
  NULL, innodb_adaptive_hash_index_update, TRUE);
9563
9293
 
9564
9294
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
9565
9295
  PLUGIN_VAR_RQCMDARG,
9567
9297
  "innodb_thread_concurrency is reached (0 by default)",
9568
9298
  NULL, NULL, 0, 0, ~0UL, 0);
9569
9299
 
9570
 
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
9571
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9572
 
  "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
9573
 
  NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
9574
 
 
9575
 
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
9576
 
  PLUGIN_VAR_RQCMDARG,
9577
 
  "Data file autoextend increment in megabytes",
9578
 
  NULL, NULL, 8L, 1L, 1000L, 0);
9579
 
 
9580
 
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
9581
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9582
 
  "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
9583
 
  NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
9584
 
 
9585
 
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_instances, innobase_buffer_pool_instances,
9586
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9587
 
  "Number of buffer pool instances, set to higher value on high-end machines to increase scalability",
9588
 
  NULL, NULL, 1L, 1L, MAX_BUFFER_POOLS, 1L);
9589
 
 
9590
9300
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
9591
9301
  PLUGIN_VAR_RQCMDARG,
9592
9302
  "Helps in performance tuning in heavily concurrent environments.",
9617
9327
  "The size of the buffer which InnoDB uses to write log to the log files on disk.",
9618
9328
  NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
9619
9329
 
9620
 
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
9621
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9622
 
  "Size of each log file in a log group.",
9623
 
  NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
9624
 
 
9625
9330
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
9626
9331
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9627
9332
  "Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
9669
9374
  "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
9670
9375
  NULL, NULL, 10000L, 0L, ~0L, 0);
9671
9376
 
9672
 
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
9673
 
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
9674
 
  "Path to individual files and their sizes.",
9675
 
  NULL, NULL, NULL);
9676
 
 
9677
 
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
9678
 
  PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
9679
 
  "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
9680
 
 
9681
 
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
9682
 
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9683
 
  "Use OS memory allocator instead of InnoDB's internal memory allocator",
9684
 
  NULL, NULL, TRUE);
9685
 
 
9686
 
static DRIZZLE_SYSVAR_BOOL(use_native_aio, srv_use_native_aio,
9687
 
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
9688
 
  "Use native AIO if supported on this platform.",
9689
 
  NULL, NULL, TRUE);
9690
 
 
9691
9377
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
9692
9378
  PLUGIN_VAR_RQCMDARG,
9693
9379
  "Buffer changes to reduce random access: "
9711
9397
  context("disable-doublewrite",
9712
9398
          "Disable InnoDB doublewrite buffer.");
9713
9399
  context("io-capacity",
9714
 
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
 
9400
          po::value<io_capacity_constraint>(&innodb_io_capacity)->default_value(200),
9715
9401
          "Number of IOPs the server can do. Tunes the background IO rate");
9716
9402
  context("fast-shutdown",
9717
 
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1), 
 
9403
          po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1), 
9718
9404
          "Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like).");
9719
9405
  context("purge-batch-size",
9720
 
          po::value<unsigned long>(&srv_purge_batch_size)->default_value(20),
 
9406
          po::value<purge_batch_constraint>(&innodb_purge_batch_size)->default_value(20),
9721
9407
          "Number of UNDO logs to purge in one batch from the history list. "
9722
9408
          "Default is 20.");
9723
9409
  context("purge-threads",
9724
 
          po::value<unsigned long>(&srv_n_purge_threads)->default_value(0),
 
9410
          po::value<purge_threads_constraint>(&innodb_n_purge_threads)->default_value(0),
9725
9411
          "Purge threads can be either 0 or 1. Defalut is 0.");
9726
9412
  context("file-per-table",
9727
9413
          po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
9728
9414
          "Stores each InnoDB table to an .ibd file in the database dir.");
9729
9415
  context("file-format",
9730
 
          po::value<string>()->default_value("Antelope"),
 
9416
          po::value<string>(&innobase_file_format_name)->default_value("Antelope"),
9731
9417
          "File format to use for new tables in .ibd files.");
9732
9418
  context("file-format-max",
9733
 
          po::value<string>()->default_value("Antelope"),
 
9419
          po::value<string>(&innobase_file_format_max)->default_value("Antelope"),
9734
9420
          "The highest file format in the tablespace.");
9735
9421
  context("file-format-check",
9736
9422
          po::value<bool>(&innobase_file_format_check)->default_value(true)->zero_tokens(),
9737
9423
          "Whether to perform system file format check.");
9738
9424
  context("flush-log-at-trx-commit",
9739
 
          po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
 
9425
          po::value<trinary_constraint>(&innodb_flush_log_at_trx_commit)->default_value(1),
9740
9426
          "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).");
9741
9427
  context("flush-method",
9742
9428
          po::value<string>(),
9743
9429
          "With which method to flush data.");
9744
 
#ifdef UNIV_LOG_ARCHIVE
9745
 
  context("log-arch-dir",
9746
 
          po::value<string>(),
9747
 
          "Where full logs should be archived.");
9748
 
  context("log-archive",
9749
 
          po::value<bool>(&innobase_log_archive)->default_value(false)->zero_tokens(),
9750
 
          "Set to 1 if you want to have logs archived.");
9751
 
#endif /* UNIV_LOG_ARCHIVE */
9752
9430
  context("log-group-home-dir",
9753
9431
          po::value<string>(),
9754
9432
          "Path to InnoDB log files.");
9755
9433
  context("max-dirty-pages-pct",
9756
 
          po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
 
9434
          po::value<max_dirty_pages_constraint>(&innodb_max_dirty_pages_pct)->default_value(75),
9757
9435
          "Percentage of dirty pages allowed in bufferpool.");
9758
9436
  context("disable-adaptive-flushing",
9759
9437
          "Do not attempt flushing dirty pages to avoid IO bursts at checkpoints.");
9760
9438
  context("max-purge-lag",
9761
 
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
 
9439
          po::value<uint64_constraint>(&innodb_max_purge_lag)->default_value(0),
9762
9440
          "Desired maximum length of the purge queue (0 = no limit)");
9763
9441
  context("status-file",
9764
9442
          po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
9766
9444
  context("disable-stats-on-metadata",
9767
9445
          "Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9768
9446
  context("stats-sample-pages",
9769
 
          po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
 
9447
          po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
9770
9448
          "The number of index pages to sample when calculating statistics (default 8)");
9771
9449
  context("disable-adaptive-hash-index",
9772
9450
          "Enable InnoDB adaptive hash index (enabled by default)");
9774
9452
          po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9775
9453
          "Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9776
9454
  context("additional-mem-pool-size",
9777
 
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
9455
          po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9778
9456
          "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9779
9457
  context("autoextend-increment",
9780
 
          po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
 
9458
          po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
9781
9459
          "Data file autoextend increment in megabytes");
9782
9460
  context("buffer-pool-size",
9783
 
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
9461
          po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9784
9462
          "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9785
9463
  context("buffer-pool-instances",
9786
 
          po::value<int64_t>(&innobase_buffer_pool_instances)->default_value(1),
 
9464
          po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9787
9465
          "Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9788
9466
 
9789
9467
  context("commit-concurrency",
9805
9483
          po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9806
9484
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9807
9485
  context("log-file-size",
9808
 
          po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
 
9486
          po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
9809
9487
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9810
9488
  context("log-files-in-group",
9811
9489
          po::value<long>(&innobase_log_files_in_group)->default_value(2),
9847
9525
  context("disable-table-locks",
9848
9526
          "Disable InnoDB locking in LOCK TABLES");
9849
9527
  context("strict-mode",
9850
 
          po::value<bool>()->default_value(false)->zero_tokens(),
 
9528
          po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
9851
9529
          "Use strict mode when evaluating create options.");
 
9530
  context("replication-log",
 
9531
          po::value<bool>()->default_value(false),
 
9532
          "Enable internal replication log.");
9852
9533
  context("lock-wait-timeout",
9853
 
          po::value<unsigned long>()->default_value(50),
 
9534
          po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9854
9535
          "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9855
9536
}
9856
9537
 
9857
9538
static drizzle_sys_var* innobase_system_variables[]= {
9858
 
  DRIZZLE_SYSVAR(additional_mem_pool_size),
9859
 
  DRIZZLE_SYSVAR(autoextend_increment),
9860
 
  DRIZZLE_SYSVAR(buffer_pool_size),
9861
 
  DRIZZLE_SYSVAR(buffer_pool_instances),
9862
 
  DRIZZLE_SYSVAR(checksums),
9863
9539
  DRIZZLE_SYSVAR(commit_concurrency),
9864
9540
  DRIZZLE_SYSVAR(concurrency_tickets),
9865
 
  DRIZZLE_SYSVAR(data_file_path),
9866
 
  DRIZZLE_SYSVAR(data_home_dir),
9867
 
  DRIZZLE_SYSVAR(doublewrite),
9868
 
  DRIZZLE_SYSVAR(fast_shutdown),
9869
9541
  DRIZZLE_SYSVAR(read_io_threads),
9870
9542
  DRIZZLE_SYSVAR(write_io_threads),
9871
 
  DRIZZLE_SYSVAR(file_per_table),
9872
 
  DRIZZLE_SYSVAR(file_format),
9873
 
  DRIZZLE_SYSVAR(file_format_check),
9874
 
  DRIZZLE_SYSVAR(file_format_max),
9875
 
  DRIZZLE_SYSVAR(flush_log_at_trx_commit),
9876
 
  DRIZZLE_SYSVAR(flush_method),
9877
9543
  DRIZZLE_SYSVAR(force_recovery),
9878
 
  DRIZZLE_SYSVAR(lock_wait_timeout),
9879
 
#ifdef UNIV_LOG_ARCHIVE
9880
 
  DRIZZLE_SYSVAR(log_arch_dir),
9881
 
  DRIZZLE_SYSVAR(log_archive),
9882
 
#endif /* UNIV_LOG_ARCHIVE */
9883
9544
  DRIZZLE_SYSVAR(log_buffer_size),
9884
 
  DRIZZLE_SYSVAR(log_file_size),
9885
9545
  DRIZZLE_SYSVAR(log_files_in_group),
9886
 
  DRIZZLE_SYSVAR(log_group_home_dir),
9887
 
  DRIZZLE_SYSVAR(max_dirty_pages_pct),
9888
 
  DRIZZLE_SYSVAR(max_purge_lag),
9889
 
  DRIZZLE_SYSVAR(adaptive_flushing),
9890
9546
  DRIZZLE_SYSVAR(mirrored_log_groups),
9891
9547
  DRIZZLE_SYSVAR(old_blocks_pct),
9892
9548
  DRIZZLE_SYSVAR(old_blocks_time),
9893
9549
  DRIZZLE_SYSVAR(open_files),
9894
 
  DRIZZLE_SYSVAR(stats_sample_pages),
9895
 
  DRIZZLE_SYSVAR(adaptive_hash_index),
9896
9550
  DRIZZLE_SYSVAR(replication_delay),
9897
 
  DRIZZLE_SYSVAR(status_file),
9898
 
  DRIZZLE_SYSVAR(strict_mode),
9899
 
  DRIZZLE_SYSVAR(support_xa),
9900
9551
  DRIZZLE_SYSVAR(sync_spin_loops),
9901
9552
  DRIZZLE_SYSVAR(spin_wait_delay),
9902
 
  DRIZZLE_SYSVAR(table_locks),
9903
9553
  DRIZZLE_SYSVAR(thread_concurrency),
9904
9554
  DRIZZLE_SYSVAR(thread_sleep_delay),
9905
 
  DRIZZLE_SYSVAR(version),
9906
 
  DRIZZLE_SYSVAR(use_sys_malloc),
9907
 
  DRIZZLE_SYSVAR(use_native_aio),
9908
9555
  DRIZZLE_SYSVAR(change_buffering),
9909
9556
  DRIZZLE_SYSVAR(read_ahead_threshold),
9910
 
  DRIZZLE_SYSVAR(io_capacity),
9911
 
  DRIZZLE_SYSVAR(purge_threads),
9912
 
  DRIZZLE_SYSVAR(purge_batch_size),
9913
9557
  NULL
9914
9558
};
9915
9559