~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-02 22:51:54 UTC
  • mto: (1975.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1976.
  • Revision ID: mordred@inaugust.com-20101202225154-h54ifmga9x6cckgs
Refactored syslog module and changed it to use sys_var directly.

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;
179
171
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
180
172
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
181
173
 
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;
 
174
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
 
175
  innobase_log_buffer_size,
 
176
  innobase_force_recovery, innobase_open_files;
 
177
static long innobase_additional_mem_pool_size= 8*1024*1024L;
 
178
static ulong innobase_commit_concurrency = 0;
 
179
static ulong innobase_read_io_threads;
 
180
static ulong innobase_write_io_threads;
 
181
static int64_t innobase_buffer_pool_instances = 1;
 
182
 
 
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;
226
188
 
227
189
/** Percentage of the buffer pool to reserve for 'old' blocks.
228
190
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;
 
191
static uint innobase_old_blocks_pct;
238
192
 
239
193
/* The default values for the following char* start-up parameters
240
194
are determined in innobase_init below: */
241
195
 
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;
 
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;
247
201
 
248
202
/* The highest file format being used in the database. The value can be
249
203
set by user, however, it will be adjusted to the newer file format if
250
204
a table of such format is created/opened. */
251
 
static string innobase_file_format_max;
 
205
static char*    innobase_file_format_max                = NULL;
 
206
 
 
207
static char*  innobase_file_flush_method   = NULL;
252
208
 
253
209
/* Below we have boolean-valued start-up parameters, and their default
254
210
values */
255
211
 
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
 
 
 
212
static ulong  innobase_fast_shutdown      = 1;
271
213
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 */
272
218
static my_bool  innobase_use_doublewrite    = TRUE;
273
219
static my_bool  innobase_use_checksums      = TRUE;
274
220
static my_bool  innobase_rollback_on_timeout    = FALSE;
275
221
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
222
 
282
223
static char*  internal_innobase_data_file_path  = NULL;
283
224
 
 
225
static char*  innodb_version_str = (char*) INNODB_VERSION_STR;
 
226
 
284
227
/* The following counter is used to convey information to InnoDB
285
228
about server activity: in selects it is not sensible to call
286
229
srv_active_wake_master_thread after each fetch or search, we only do
360
303
    }
361
304
    
362
305
    /* These get strdup'd from vm variables */
 
306
    free(innobase_data_home_dir);
 
307
    free(innobase_log_group_home_dir);
363
308
 
364
309
  }
365
310
 
619
564
  return ENOENT;
620
565
}
621
566
 
 
567
/** @brief Initialize the default value of innodb_commit_concurrency.
 
568
 
 
569
Once InnoDB is running, the innodb_commit_concurrency must not change
 
570
from zero to nonzero. (Bug #42101)
 
571
 
 
572
The initial default value is 0, and without this extra initialization,
 
573
SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter
 
574
to 0, even if it was initially set to nonzero at the command line
 
575
or configuration file. */
 
576
static
 
577
void
 
578
innobase_commit_concurrency_init_default(void);
 
579
/*==========================================*/
622
580
 
623
581
/************************************************************//**
624
582
Validate the file format name and return its corresponding id.
641
599
 
642
600
static const char innobase_engine_name[]= "InnoDB";
643
601
 
 
602
/*************************************************************//**
 
603
Check for a valid value of innobase_commit_concurrency.
 
604
@return 0 for valid innodb_commit_concurrency */
 
605
static
 
606
int
 
607
innobase_commit_concurrency_validate(
 
608
/*=================================*/
 
609
  Session*      , /*!< in: thread handle */
 
610
  drizzle_sys_var*  , /*!< in: pointer to system
 
611
            variable */
 
612
  void*       save, /*!< out: immediate result
 
613
            for update function */
 
614
  drizzle_value*    value)  /*!< in: incoming string */
 
615
{
 
616
  int64_t   intbuf;
 
617
  ulong   commit_concurrency;
 
618
 
 
619
  if (value->val_int(value, &intbuf)) {
 
620
    /* The value is NULL. That is invalid. */
 
621
    return(1);
 
622
  }
 
623
 
 
624
  *reinterpret_cast<ulong*>(save) = commit_concurrency
 
625
    = static_cast<ulong>(intbuf);
 
626
 
 
627
  /* Allow the value to be updated, as long as it remains zero
 
628
  or nonzero. */
 
629
  return(!(!commit_concurrency == !innobase_commit_concurrency));
 
630
}
 
631
 
 
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
 
644
650
 
645
651
/*****************************************************************//**
646
652
Commits a transaction in an InnoDB database. */
907
913
ibool
908
914
thd_supports_xa(
909
915
/*============*/
910
 
  void* )  /*!< in: thread handle (Session*), or NULL to query
 
916
  void* session)  /*!< in: thread handle (Session*), or NULL to query
911
917
        the global innodb_supports_xa */
912
918
{
913
 
  /* TODO: Add support here for per-session value */
914
 
  return(support_xa);
 
919
  return(SessionVAR((Session*) session, support_xa));
915
920
}
916
921
 
917
922
/******************************************************************//**
921
926
ulong
922
927
thd_lock_wait_timeout(
923
928
/*==================*/
924
 
  void*)  /*!< in: thread handle (Session*), or NULL to query
 
929
  void* session)  /*!< in: thread handle (Session*), or NULL to query
925
930
      the global innodb_lock_wait_timeout */
926
931
{
927
 
  /* TODO: Add support here for per-session value */
928
932
  /* According to <drizzle/plugin.h>, passing session == NULL
929
933
  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
 
        }
 
934
  return(SessionVAR((Session*) session, lock_wait_timeout));
945
935
}
946
936
 
947
937
/********************************************************************//**
956
946
  return *(trx_t**) session->getEngineData(innodb_engine_ptr);
957
947
}
958
948
 
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
949
/********************************************************************//**
979
950
Call this function when mysqld passes control to the client. That is to
980
951
avoid deadlocks on the adaptive hash S-latch possibly held by session. For more
1039
1010
  case DB_INTERRUPTED:
1040
1011
    my_error(ER_QUERY_INTERRUPTED, MYF(0));
1041
1012
    /* 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
1013
  case DB_ERROR:
1055
1014
  default:
1056
1015
    return(-1); /* unspecified error */
1177
1136
           use the default max length */
1178
1137
{
1179
1138
  Session *session= reinterpret_cast<Session *>(in_session);
1180
 
  drizzled::identifier::User::const_shared_ptr user_identifier(session->user());
1181
 
 
1182
1139
  fprintf(f,
1183
1140
          "Drizzle thread %"PRIu64", query id %"PRIu64", %s, %s, %s ",
1184
1141
          static_cast<uint64_t>(session->getSessionId()),
1185
1142
          static_cast<uint64_t>(session->getQueryId()),
1186
1143
          glob_hostname,
1187
 
          user_identifier->address().c_str(),
1188
 
          user_identifier->username().c_str()
 
1144
          session->getSecurityContext().getIp().c_str(),
 
1145
          session->getSecurityContext().getUser().c_str()
1189
1146
  );
1190
1147
  fprintf(f, "\n%s", session->getQueryString()->c_str());
1191
1148
  putc('\n', f);
1210
1167
  if (cs) {
1211
1168
    *mbminlen = cs->mbminlen;
1212
1169
    *mbmaxlen = cs->mbmaxlen;
1213
 
    ut_ad(*mbminlen < DATA_MBMAX);
1214
 
    ut_ad(*mbmaxlen < DATA_MBMAX);
1215
1170
  } else {
1216
1171
    ut_a(cset == 0);
1217
1172
    *mbminlen = *mbmaxlen = 0;
1841
1796
  value= value - (value % align_val);
1842
1797
}
1843
1798
 
1844
 
static void auto_extend_update(Session *, sql_var_t)
1845
 
{
1846
 
  srv_auto_extend_increment= innodb_auto_extend_increment.get();
1847
 
}
1848
 
 
1849
 
static void io_capacity_update(Session *, sql_var_t)
1850
 
{
1851
 
  srv_io_capacity= innodb_io_capacity.get();
1852
 
}
1853
 
 
1854
 
static void purge_batch_update(Session *, sql_var_t)
1855
 
{
1856
 
  srv_purge_batch_size= innodb_purge_batch_size.get();
1857
 
}
1858
 
 
1859
 
static void purge_threads_update(Session *, sql_var_t)
1860
 
{
1861
 
  srv_n_purge_threads= innodb_n_purge_threads.get();
1862
 
}
1863
 
 
1864
 
static void innodb_adaptive_hash_index_update(Session *, sql_var_t)
1865
 
{
1866
 
  if (btr_search_enabled)
1867
 
  {
1868
 
    btr_search_enable();
1869
 
  } else {
1870
 
    btr_search_disable();
1871
 
  }
1872
 
}
1873
 
 
1874
 
static void innodb_old_blocks_pct_update(Session *, sql_var_t)
1875
 
{
1876
 
  innobase_old_blocks_pct= buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(), TRUE);
1877
 
}
1878
 
 
1879
 
static void innodb_thread_concurrency_update(Session *, sql_var_t)
1880
 
{
1881
 
  srv_thread_concurrency= innobase_thread_concurrency.get();
1882
 
}
1883
 
 
1884
 
static void innodb_sync_spin_loops_update(Session *, sql_var_t)
1885
 
{
1886
 
  srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
1887
 
}
1888
 
 
1889
 
static void innodb_spin_wait_delay_update(Session *, sql_var_t)
1890
 
{
1891
 
  srv_spin_wait_delay= innodb_spin_wait_delay.get();
1892
 
}
1893
 
 
1894
 
static void innodb_thread_sleep_delay_update(Session *, sql_var_t)
1895
 
{
1896
 
  srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
1897
 
}
1898
 
 
1899
 
static void innodb_read_ahead_threshold_update(Session *, sql_var_t)
1900
 
{
1901
 
  srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
1902
 
}
1903
 
 
1904
 
 
1905
 
static int innodb_commit_concurrency_validate(Session *session, set_var *var)
1906
 
{
1907
 
   uint32_t new_value= var->save_result.uint32_t_value;
1908
 
 
1909
 
   if ((innobase_commit_concurrency.get() == 0 && new_value != 0) ||
1910
 
       (innobase_commit_concurrency.get() != 0 && new_value == 0))
1911
 
   {
1912
 
     push_warning_printf(session,
1913
 
                         DRIZZLE_ERROR::WARN_LEVEL_WARN,
1914
 
                         ER_WRONG_ARGUMENTS,
1915
 
                         _("Once InnoDB is running, innodb_commit_concurrency "
1916
 
                           "must not change between zero and nonzero."));
1917
 
     return 1;
1918
 
   }
1919
 
   return 0;
1920
 
}
1921
 
 
1922
 
/*************************************************************//**
1923
 
Check if it is a valid file format. This function is registered as
1924
 
a callback with MySQL.
1925
 
@return 0 for valid file format */
1926
 
static
1927
 
int
1928
 
innodb_file_format_name_validate(
1929
 
/*=============================*/
1930
 
  Session*      , /*!< in: thread handle */
1931
 
  set_var *var)
1932
 
{
1933
 
  const char *file_format_input = var->value->str_value.ptr();
1934
 
  if (file_format_input == NULL)
1935
 
    return 1;
1936
 
 
1937
 
  if (file_format_input != NULL) {
1938
 
    uint  format_id;
1939
 
 
1940
 
    format_id = innobase_file_format_name_lookup(
1941
 
      file_format_input);
1942
 
 
1943
 
    if (format_id <= DICT_TF_FORMAT_MAX) {
1944
 
      innobase_file_format_name =
1945
 
        trx_sys_file_format_id_to_name(format_id);
1946
 
 
1947
 
      return(0);
1948
 
    }
1949
 
  }
1950
 
 
1951
 
  return(1);
1952
 
}
1953
 
 
1954
 
/*************************************************************//**
1955
 
Check if it is a valid value of innodb_change_buffering. This function is
1956
 
registered as a callback with MySQL.
1957
 
@return 0 for valid innodb_change_buffering */
1958
 
static
1959
 
int
1960
 
innodb_change_buffering_validate(
1961
 
/*=============================*/
1962
 
  Session*      , /*!< in: thread handle */
1963
 
  set_var *var)
1964
 
{
1965
 
  const char *change_buffering_input = var->value->str_value.ptr();
1966
 
 
1967
 
  if (change_buffering_input == NULL)
1968
 
    return 1;
1969
 
 
1970
 
  ulint use;
1971
 
 
1972
 
  for (use = 0;
1973
 
       use < UT_ARR_SIZE(innobase_change_buffering_values);
1974
 
       ++use) {
1975
 
    if (!innobase_strcasecmp(change_buffering_input,
1976
 
                             innobase_change_buffering_values[use]))
1977
 
    {
1978
 
      ibuf_use= static_cast<ibuf_use_t>(use); 
1979
 
      return 0;
1980
 
    }
1981
 
  }
1982
 
 
1983
 
  return 1;
1984
 
}
1985
 
 
1986
 
 
1987
 
/*************************************************************//**
1988
 
Check if valid argument to innodb_file_format_max. This function
1989
 
is registered as a callback with MySQL.
1990
 
@return 0 for valid file format */
1991
 
static
1992
 
int
1993
 
innodb_file_format_max_validate(
1994
 
/*==============================*/
1995
 
  Session*   session, /*!< in: thread handle */
1996
 
  set_var *var)
1997
 
{
1998
 
  const char *file_format_input = var->value->str_value.ptr();
1999
 
  if (file_format_input == NULL)
2000
 
    return 1;
2001
 
 
2002
 
  if (file_format_input != NULL) {
2003
 
    int format_id = innobase_file_format_validate_and_set(file_format_input);
2004
 
 
2005
 
    if (format_id > DICT_TF_FORMAT_MAX) {
2006
 
      /* DEFAULT is "on", which is invalid at runtime. */
2007
 
      return 1;
2008
 
    }
2009
 
 
2010
 
    if (format_id >= 0) {
2011
 
      innobase_file_format_max= 
2012
 
        trx_sys_file_format_id_to_name((uint)format_id);
2013
 
 
2014
 
      /* Update the max format id in the system tablespace. */
2015
 
      char name_buff[100];
2016
 
      strcpy(name_buff, innobase_file_format_max.c_str());
2017
 
      if (trx_sys_file_format_max_set(format_id, (const char **)&name_buff))
2018
 
      {
2019
 
        errmsg_printf(ERRMSG_LVL_WARN,
2020
 
                      " [Info] InnoDB: the file format in the system "
2021
 
                      "tablespace is now set to %s.\n", name_buff);
2022
 
        innobase_file_format_max= name_buff;
2023
 
      }
2024
 
      return(0);
2025
 
 
2026
 
    } else {
2027
 
      push_warning_printf(session,
2028
 
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
2029
 
                          ER_WRONG_ARGUMENTS,
2030
 
                          "InnoDB: invalid innodb_file_format_max "
2031
 
                          "value; can be any format up to %s "
2032
 
                          "or equivalent id of %d",
2033
 
                          trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX),
2034
 
                          DICT_TF_FORMAT_MAX);
2035
 
    }
2036
 
  }
2037
 
 
2038
 
  return(1);
2039
 
}
2040
 
 
2041
 
 
2042
1799
/*********************************************************************//**
2043
1800
Opens an InnoDB database.
2044
1801
@return 0 on success, error code on failure */
2054
1811
  InnobaseEngine *actuall_engine_ptr;
2055
1812
  const module::option_map &vm= context.getOptions();
2056
1813
 
2057
 
  srv_auto_extend_increment= innodb_auto_extend_increment.get();
2058
 
  srv_io_capacity= innodb_io_capacity.get();
2059
 
  srv_purge_batch_size= innodb_purge_batch_size.get();
2060
 
  srv_n_purge_threads= innodb_n_purge_threads.get();
2061
 
  srv_flush_log_at_trx_commit= innodb_flush_log_at_trx_commit.get();
2062
 
  srv_max_buf_pool_modified_pct= innodb_max_dirty_pages_pct.get();
2063
 
  srv_max_purge_lag= innodb_max_purge_lag.get();
2064
 
  srv_stats_sample_pages= innodb_stats_sample_pages.get();
2065
 
  srv_n_free_tickets_to_enter= innodb_concurrency_tickets.get();
2066
 
  srv_replication_delay= innodb_replication_delay.get();
2067
 
  srv_thread_concurrency= innobase_thread_concurrency.get();
2068
 
  srv_n_spin_wait_rounds= innodb_sync_spin_loops.get();
2069
 
  srv_spin_wait_delay= innodb_spin_wait_delay.get();
2070
 
  srv_thread_sleep_delay= innodb_thread_sleep_delay.get();
2071
 
  srv_read_ahead_threshold= innodb_read_ahead_threshold.get();
2072
 
 
2073
1814
  /* Inverted Booleans */
2074
1815
 
2075
1816
  innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
2076
1817
  innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
2077
1818
  srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
2078
1819
  srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2079
 
  support_xa= (vm.count("disable-xa")) ? false : true;
2080
 
  btr_search_enabled= (vm.count("disable-adaptive-hash-index")) ? false : true;
2081
 
 
2082
 
 
2083
 
  /* Hafta do this here because we need to late-bind the default value */
 
1820
  (SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
 
1821
  (SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
 
1822
 
 
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
 
2084
1832
  if (vm.count("data-home-dir"))
2085
1833
  {
2086
 
    innobase_data_home_dir= vm["data-home-dir"].as<string>();
2087
 
  }
2088
 
  else
2089
 
  {
2090
 
    innobase_data_home_dir= getDataHome().file_string();
2091
 
  }
2092
 
 
 
1834
    innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
 
1835
  }
 
1836
  else
 
1837
  {
 
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());
 
1853
  }
 
1854
 
 
1855
  if (vm.count("file-format-check"))
 
1856
  {
 
1857
    innobase_file_format_check= vm["file-format-check"].as<bool>();
 
1858
  }
 
1859
 
 
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
 
 
1899
  if (vm.count("stats-sample-pages"))
 
1900
  {
 
1901
    if (srv_stats_sample_pages < 8)
 
1902
    {
 
1903
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
 
1904
      exit(-1);
 
1905
    }
 
1906
  }
 
1907
 
 
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
 
 
1950
  if (vm.count("commit-concurrency"))
 
1951
  {
 
1952
    if (srv_replication_delay > 1000)
 
1953
    {
 
1954
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
 
1955
      exit(-1);
 
1956
    }
 
1957
  }
 
1958
 
 
1959
  if (vm.count("concurrency-tickets"))
 
1960
  {
 
1961
    if (srv_n_free_tickets_to_enter < 1)
 
1962
    {
 
1963
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
 
1964
      exit(-1);
 
1965
    }
 
1966
  }
 
1967
 
 
1968
  if (vm.count("read-io-threads"))
 
1969
  {
 
1970
    if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
 
1971
    {
 
1972
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
 
1973
      exit(-1);
 
1974
    }
 
1975
  }
 
1976
 
 
1977
  if (vm.count("write-io-threads"))
 
1978
  {
 
1979
    if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
 
1980
    {
 
1981
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
 
1982
      exit(-1);
 
1983
    }
 
1984
  }
 
1985
 
 
1986
  if (vm.count("force-recovery"))
 
1987
  {
 
1988
    if (innobase_force_recovery > 6)
 
1989
    {
 
1990
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
 
1991
      exit(-1);
 
1992
    }
 
1993
  }
 
1994
 
 
1995
  if (vm.count("log-buffer-size"))
 
1996
  {
 
1997
    align_value(innobase_log_buffer_size);
 
1998
    if (innobase_log_buffer_size < 256*1024L)
 
1999
    {
 
2000
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
 
2001
      exit(-1);
 
2002
    }
 
2003
  }
 
2004
 
 
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
 
 
2015
  if (vm.count("log-files-in-group"))
 
2016
  {
 
2017
    if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
 
2018
    {
 
2019
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
 
2020
      exit(-1);
 
2021
    }
 
2022
  }
 
2023
 
 
2024
  if (vm.count("mirrored-log-groups"))
 
2025
  {
 
2026
    if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
 
2027
    {
 
2028
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
 
2029
      exit(-1);
 
2030
    }
 
2031
  }
 
2032
 
 
2033
  if (vm.count("open-files"))
 
2034
  {
 
2035
    if (innobase_open_files < 10)
 
2036
    {
 
2037
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
 
2038
      exit(-1);
 
2039
    }
 
2040
  }
 
2041
 
 
2042
  if (vm.count("thread-concurrency"))
 
2043
  {
 
2044
    if (srv_thread_concurrency > 1000)
 
2045
    {
 
2046
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
 
2047
      exit(-1);
 
2048
    }
 
2049
  }
2093
2050
 
2094
2051
  if (vm.count("data-file-path"))
2095
2052
  {
2096
 
    innobase_data_file_path= vm["data-file-path"].as<string>();
2097
 
  }
2098
 
 
 
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());
 
2063
  }
 
2064
 
 
2065
  if (vm.count("read-ahead-threshold"))
 
2066
  {
 
2067
    if (srv_read_ahead_threshold > 64)
 
2068
    {
 
2069
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
 
2070
      exit(-1);
 
2071
    }
 
2072
  }
 
2073
 
 
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
  }
2099
2089
 
2100
2090
  innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2101
2091
 
2119
2109
  }
2120
2110
#endif /* UNIV_DEBUG */
2121
2111
 
 
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
 
2122
2131
  os_innodb_umask = (ulint)internal::my_umask;
2123
2132
 
2124
2133
 
2129
2138
 
2130
2139
  /* The default dir for data files is the datadir of MySQL */
2131
2140
 
2132
 
  srv_data_home = (char *)innobase_data_home_dir.c_str();
 
2141
  srv_data_home = (char *)innobase_data_home_dir;
2133
2142
 
2134
2143
  /* Set default InnoDB data file size to 10 MB and let it be
2135
2144
    auto-extending. Thus users can use InnoDB in >= 4.0 without having
2136
2145
    to specify any startup options. */
2137
2146
 
2138
 
  if (innobase_data_file_path.empty()) 
2139
 
  {
2140
 
    innobase_data_file_path= std::string("ibdata1:10M:autoextend");
 
2147
  if (!innobase_data_file_path) {
 
2148
    innobase_data_file_path = (char*) "ibdata1:10M:autoextend";
2141
2149
  }
2142
2150
 
2143
2151
  /* Since InnoDB edits the argument in the next call, we make another
2144
2152
    copy of it: */
2145
2153
 
2146
 
  internal_innobase_data_file_path = strdup(innobase_data_file_path.c_str());
 
2154
  internal_innobase_data_file_path = strdup(innobase_data_file_path);
2147
2155
 
2148
2156
  ret = (bool) srv_parse_data_file_paths_and_sizes(
2149
2157
                                                   internal_innobase_data_file_path);
2163
2171
 
2164
2172
  if (vm.count("log-group-home-dir"))
2165
2173
  {
2166
 
    innobase_log_group_home_dir= vm["log-group-home-dir"].as<string>();
 
2174
    innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str());
2167
2175
  }
2168
2176
  else
2169
2177
  {
2170
 
    innobase_log_group_home_dir= getDataHome().file_string();
 
2178
    innobase_log_group_home_dir = strdup(getDataHome().file_string().c_str());
2171
2179
  }
2172
2180
 
 
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
 
2173
2191
  ret = (bool)
2174
 
    srv_parse_log_group_home_dirs((char *)innobase_log_group_home_dir.c_str());
 
2192
    srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
2175
2193
 
2176
 
  if (ret == FALSE || innobase_mirrored_log_groups.get() != 1) {
2177
 
    errmsg_printf(ERRMSG_LVL_ERROR,
2178
 
                  _("syntax error in innodb_log_group_home_dir, or a "
2179
 
                  "wrong number of mirrored log groups"));
 
2194
  if (ret == FALSE || innobase_mirrored_log_groups != 1) {
 
2195
    errmsg_printf(ERRMSG_LVL_ERROR, "syntax error in innodb_log_group_home_dir, or a "
 
2196
                  "wrong number of mirrored log groups");
2180
2197
 
2181
2198
    goto mem_free_and_error;
2182
2199
  }
2199
2216
    format_id = 0;
2200
2217
  }
2201
2218
 
 
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
 
2202
2239
  srv_file_format = format_id;
2203
2240
 
 
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
 
2204
2246
  innobase_file_format_name =
2205
 
    trx_sys_file_format_id_to_name(format_id);
 
2247
    (char*) trx_sys_file_format_id_to_name(format_id);
2206
2248
 
2207
2249
  /* Check innobase_file_format_check variable */
2208
2250
  if (!innobase_file_format_check)
2217
2259
  /* Did the user specify a format name that we support?
2218
2260
     As a side effect it will update the variable
2219
2261
     srv_max_file_format_at_startup */
2220
 
  if (innobase_file_format_validate_and_set(innobase_file_format_max.c_str()) < 0)
 
2262
  if (innobase_file_format_validate_and_set(innobase_file_format_max) < 0)
2221
2263
  {
2222
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("InnoDB: invalid "
 
2264
    errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: invalid "
2223
2265
                    "innodb_file_format_max value: "
2224
2266
                    "should be any value up to %s or its "
2225
 
                    "equivalent numeric id"),
 
2267
                    "equivalent numeric id",
2226
2268
                    trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
2227
2269
    goto mem_free_and_error;
2228
2270
  }
2235
2277
         use < UT_ARR_SIZE(innobase_change_buffering_values);
2236
2278
         use++) {
2237
2279
      if (!innobase_strcasecmp(
2238
 
                               innobase_change_buffering.c_str(),
 
2280
                               vm["change-buffering"].as<string>().c_str(),
2239
2281
                               innobase_change_buffering_values[use])) {
2240
 
        ibuf_use = static_cast<ibuf_use_t>(use);
 
2282
        ibuf_use = (ibuf_use_t) use;
2241
2283
        goto innobase_change_buffering_inited_ok;
2242
2284
      }
2243
2285
    }
2251
2293
 
2252
2294
innobase_change_buffering_inited_ok:
2253
2295
  ut_a((ulint) ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
2254
 
  innobase_change_buffering = innobase_change_buffering_values[ibuf_use];
 
2296
  innobase_change_buffering = (char*)
 
2297
    innobase_change_buffering_values[ibuf_use];
2255
2298
 
2256
2299
  /* --------------------------------------------------*/
2257
2300
 
2258
 
  if (vm.count("flush-method") != 0)
2259
 
  {
2260
 
    srv_file_flush_method_str = (char *)vm["flush-method"].as<string>().c_str();
2261
 
  }
 
2301
  srv_file_flush_method_str = innobase_file_flush_method;
2262
2302
 
2263
2303
  srv_n_log_groups = (ulint) innobase_mirrored_log_groups;
2264
2304
  srv_n_log_files = (ulint) innobase_log_files_in_group;
2265
2305
  srv_log_file_size = (ulint) innobase_log_file_size;
2266
2306
 
 
2307
#ifdef UNIV_LOG_ARCHIVE
 
2308
  srv_log_archive_on = (ulint) innobase_log_archive;
 
2309
#endif /* UNIV_LOG_ARCHIVE */
2267
2310
  srv_log_buffer_size = (ulint) innobase_log_buffer_size;
2268
2311
 
2269
2312
  srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
2298
2341
 
2299
2342
  data_mysql_default_charset_coll = (ulint)default_charset_info->number;
2300
2343
 
 
2344
  innobase_commit_concurrency_init_default();
 
2345
 
2301
2346
  /* Since we in this module access directly the fields of a trx
2302
2347
    struct, and due to different headers and flags it might happen that
2303
2348
    mutex_t has a different size in this module and in InnoDB
2306
2351
 
2307
2352
  err = innobase_start_or_create_for_mysql();
2308
2353
 
2309
 
  if (err != DB_SUCCESS)
2310
 
  {
2311
 
    goto mem_free_and_error;
2312
 
  }
2313
 
 
2314
 
  err = dict_create_sys_replication_log();
2315
 
 
2316
2354
  if (err != DB_SUCCESS) {
2317
2355
    goto mem_free_and_error;
2318
2356
  }
2319
2357
 
2320
 
 
2321
 
  innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(),
 
2358
  innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct,
2322
2359
                                                     TRUE);
2323
2360
 
2324
2361
  innobase_open_tables = hash_create(200);
2380
2417
  context.add(innodb_sys_foreign_cols_tool);
2381
2418
 
2382
2419
  context.add(new(std::nothrow)InnodbInternalTables());
2383
 
  context.add(new(std::nothrow)InnodbReplicationTable());
2384
 
 
2385
 
  if (innobase_use_replication_log)
2386
 
  {
2387
 
    replication_logger= new(std::nothrow)ReplicationLog();
2388
 
    context.add(replication_logger);
2389
 
    ReplicationLog::setup(replication_logger);
2390
 
  }
2391
 
 
2392
 
  context.registerVariable(new sys_var_const_string_val("data-home-dir", innobase_data_home_dir));
2393
 
  context.registerVariable(new sys_var_const_string_val("flush-method", 
2394
 
                                                        vm.count("flush-method") ?  vm["flush-method"].as<string>() : ""));
2395
 
  context.registerVariable(new sys_var_const_string_val("log-group-home-dir", innobase_log_group_home_dir));
2396
 
  context.registerVariable(new sys_var_const_string_val("data-file-path", innobase_data_file_path));
2397
 
  context.registerVariable(new sys_var_const_string_val("version", vm["version"].as<string>()));
2398
 
 
2399
 
 
2400
 
  context.registerVariable(new sys_var_bool_ptr_readonly("replication_log", &innobase_use_replication_log));
2401
 
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
2402
 
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
2403
 
  context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
2404
 
  context.registerVariable(new sys_var_bool_ptr_readonly("file-format-check", &innobase_file_format_check));
2405
 
  context.registerVariable(new sys_var_bool_ptr("adaptive-flushing", &srv_adaptive_flushing));
2406
 
  context.registerVariable(new sys_var_bool_ptr("status-file", &innobase_create_status_file));
2407
 
  context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2408
 
  context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2409
 
 
2410
 
  context.registerVariable(new sys_var_bool_ptr("support-xa", &support_xa));
2411
 
  context.registerVariable(new sys_var_bool_ptr("strict_mode", &strict_mode));
2412
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("lock_wait_timeout", lock_wait_timeout));
2413
 
 
2414
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
2415
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("autoextend_increment",
2416
 
                                                                   innodb_auto_extend_increment,
2417
 
                                                                   auto_extend_update));
2418
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("io_capacity",
2419
 
                                                                   innodb_io_capacity,
2420
 
                                                                   io_capacity_update));
2421
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_batch_size",
2422
 
                                                                   innodb_purge_batch_size,
2423
 
                                                                   purge_batch_update));
2424
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("purge_threads",
2425
 
                                                                   innodb_n_purge_threads,
2426
 
                                                                   purge_threads_update));
2427
 
  context.registerVariable(new sys_var_constrained_value<uint16_t>("fast_shutdown", innobase_fast_shutdown));
2428
 
  context.registerVariable(new sys_var_std_string("file_format",
2429
 
                                                  innobase_file_format_name,
2430
 
                                                  innodb_file_format_name_validate));
2431
 
  context.registerVariable(new sys_var_std_string("change_buffering",
2432
 
                                                  innobase_change_buffering,
2433
 
                                                  innodb_change_buffering_validate));
2434
 
  context.registerVariable(new sys_var_std_string("file_format_max",
2435
 
                                                  innobase_file_format_max,
2436
 
                                                  innodb_file_format_max_validate));
2437
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
2438
 
  context.registerVariable(new sys_var_constrained_value_readonly<int64_t>("log_file_size", innobase_log_file_size));
2439
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint16_t>("flush_log_at_trx_commit",
2440
 
                                                  innodb_flush_log_at_trx_commit));
2441
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct",
2442
 
                                                  innodb_max_dirty_pages_pct));
2443
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", innodb_max_purge_lag));
2444
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("stats_sample_pages", innodb_stats_sample_pages));
2445
 
  context.registerVariable(new sys_var_bool_ptr("adaptive_hash_index", &btr_search_enabled, innodb_adaptive_hash_index_update));
2446
 
 
2447
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("commit_concurrency",
2448
 
                                                                   innobase_commit_concurrency,
2449
 
                                                                   innodb_commit_concurrency_validate));
2450
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("concurrency_tickets",
2451
 
                                                                   innodb_concurrency_tickets));
2452
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_io_threads", innobase_read_io_threads));
2453
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("write_io_threads", innobase_write_io_threads));
2454
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("replication_delay", innodb_replication_delay));
2455
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
2456
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("log_buffer_size", innobase_log_buffer_size));
2457
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("log_files_in_group", innobase_log_files_in_group));
2458
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("mirrored_log_groups", innobase_mirrored_log_groups));
2459
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", innobase_open_files));
2460
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("old_blocks_pct",
2461
 
                                                                   innobase_old_blocks_pct,
2462
 
                                                                   innodb_old_blocks_pct_update));
2463
 
  context.registerVariable(new sys_var_uint32_t_ptr("old_blocks_time", &buf_LRU_old_threshold_ms));
2464
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("sync_spin_loops", innodb_sync_spin_loops, innodb_sync_spin_loops_update));
2465
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("spin_wait_delay", innodb_spin_wait_delay, innodb_spin_wait_delay_update));
2466
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_sleep_delay", innodb_thread_sleep_delay, innodb_thread_sleep_delay_update));
2467
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("thread_concurrency",
2468
 
                                                                   innobase_thread_concurrency,
2469
 
                                                                   innodb_thread_concurrency_update));
2470
 
  context.registerVariable(new sys_var_constrained_value<uint32_t>("read_ahead_threshold",
2471
 
                                                                   innodb_read_ahead_threshold,
2472
 
                                                                   innodb_read_ahead_threshold_update));
 
2420
 
2473
2421
  /* Get the current high water mark format. */
2474
 
  innobase_file_format_max = trx_sys_file_format_max_get();
2475
 
  btr_search_fully_disabled = (!btr_search_enabled);
 
2422
  innobase_file_format_max = (char*) trx_sys_file_format_max_get();
2476
2423
 
2477
2424
  return(FALSE);
2478
2425
error:
2581
2528
    Note, the position is current because of
2582
2529
    prepare_commit_mutex */
2583
2530
retry:
2584
 
    if (innobase_commit_concurrency.get() > 0) {
 
2531
    if (innobase_commit_concurrency > 0) {
2585
2532
      pthread_mutex_lock(&commit_cond_m);
2586
2533
      commit_threads++;
2587
2534
 
2588
 
      if (commit_threads > innobase_commit_concurrency.get()) {
 
2535
      if (commit_threads > innobase_commit_concurrency) {
2589
2536
        commit_threads--;
2590
2537
        pthread_cond_wait(&commit_cond,
2591
2538
          &commit_cond_m);
2610
2557
    innobase_commit_low(trx);
2611
2558
    trx->flush_log_later = FALSE;
2612
2559
 
2613
 
    if (innobase_commit_concurrency.get() > 0) {
 
2560
    if (innobase_commit_concurrency > 0) {
2614
2561
      pthread_mutex_lock(&commit_cond_m);
2615
2562
      commit_threads--;
2616
2563
      pthread_cond_signal(&commit_cond);
2857
2804
  /* Warn if rolling back some things... */
2858
2805
  if (session->getKilled() != Session::NOT_KILLED &&
2859
2806
      trx->conc_state != TRX_NOT_STARTED &&
2860
 
      trx->undo_no > 0 &&
 
2807
      trx->undo_no.low > 0 &&
2861
2808
      global_system_variables.log_warnings)
2862
2809
  {
2863
 
      errmsg_printf(ERRMSG_LVL_WARN,
 
2810
      errmsg_printf(ERRMSG_LVL_WARN, 
2864
2811
      "Drizzle is closing a connection during a KILL operation\n"
2865
 
      "that has an active InnoDB transaction.  %llu row modifications will "
 
2812
      "that has an active InnoDB transaction.  %lu row modifications will "
2866
2813
      "roll back.\n",
2867
 
      (ullint) trx->undo_no);
 
2814
      (ulong) trx->undo_no.low);
2868
2815
  }
2869
2816
 
2870
2817
  innobase_rollback_trx(trx);
3298
3245
    err = row_search_max_autoinc(index, col_name, &read_auto_inc);
3299
3246
 
3300
3247
    switch (err) {
3301
 
    case DB_SUCCESS: {
3302
 
      uint64_t col_max_value;
3303
 
 
3304
 
      col_max_value = innobase_get_int_col_max_value(field);
3305
 
 
 
3248
    case DB_SUCCESS:
3306
3249
      /* At the this stage we do not know the increment
3307
 
         nor the offset, so use a default increment of 1. */
3308
 
 
3309
 
      auto_inc = innobase_next_autoinc(read_auto_inc, 1, 1, col_max_value);
3310
 
 
 
3250
         or the offset, so use a default increment of 1. */
 
3251
      auto_inc = read_auto_inc + 1;
3311
3252
      break;
3312
 
    }
 
3253
 
3313
3254
    case DB_RECORD_NOT_FOUND:
3314
3255
      ut_print_timestamp(stderr);
3315
3256
      fprintf(stderr, "  InnoDB: MySQL and InnoDB data "
3582
3523
    /* We update the highest file format in the system table
3583
3524
    space, if this table has higher file format setting. */
3584
3525
 
3585
 
    char changed_file_format_max[100];
3586
 
    strcpy(changed_file_format_max, innobase_file_format_max.c_str());
3587
 
    trx_sys_file_format_max_upgrade((const char **)&changed_file_format_max,
 
3526
    trx_sys_file_format_max_upgrade(
 
3527
      (const char**) &innobase_file_format_max,
3588
3528
      dict_table_get_format(prebuilt->table));
3589
 
    innobase_file_format_max= changed_file_format_max;
3590
3529
  }
3591
3530
 
 
3531
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
 
3532
 
3592
3533
  /* Only if the table has an AUTOINC column. */
3593
3534
  if (prebuilt->table != NULL && getTable()->found_next_number_field != NULL) {
3594
3535
 
3606
3547
    dict_table_autoinc_unlock(prebuilt->table);
3607
3548
  }
3608
3549
 
3609
 
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
3610
 
 
3611
3550
  return(0);
3612
3551
}
3613
3552
 
3855
3794
  case DRIZZLE_TYPE_DATETIME:
3856
3795
  case DRIZZLE_TYPE_DATE:
3857
3796
  case DRIZZLE_TYPE_TIMESTAMP:
3858
 
  case DRIZZLE_TYPE_ENUM:
3859
3797
    return(DATA_INT);
3860
3798
  case DRIZZLE_TYPE_DOUBLE:
3861
3799
    return(DATA_DOUBLE);
3862
3800
  case DRIZZLE_TYPE_BLOB:
3863
3801
    return(DATA_BLOB);
3864
 
  case DRIZZLE_TYPE_UUID:
3865
 
    return(DATA_FIXBINARY);
3866
 
  case DRIZZLE_TYPE_NULL:
 
3802
  default:
3867
3803
    ut_error;
3868
3804
  }
3869
3805
 
4103
4039
      ulint     key_len;
4104
4040
      const unsigned char*    src_start;
4105
4041
      enum_field_types  real_type;
4106
 
      const CHARSET_INFO* cs= field->charset();
4107
4042
 
4108
4043
      key_len = key_part->length;
4109
4044
 
4125
4060
      memcpy(buff, src_start, true_len);
4126
4061
      buff += true_len;
4127
4062
 
4128
 
      /* Pad the unused space with spaces. */
 
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. */
4129
4068
 
4130
4069
      if (true_len < key_len) {
4131
 
        ulint   pad_len = key_len - true_len;
4132
 
        ut_a(!(pad_len % cs->mbminlen));
4133
 
 
4134
 
        cs->cset->fill(cs, buff, pad_len,
4135
 
                       0x20 /* space */);
 
4070
        ulint pad_len = key_len - true_len;
 
4071
        memset(buff, ' ', pad_len);
4136
4072
        buff += pad_len;
4137
4073
      }
4138
4074
    }
4240
4176
 
4241
4177
  /* Note that in InnoDB, i is the column number. MySQL calls columns
4242
4178
  'fields'. */
4243
 
  for (i = 0; i < n_fields; i++)
 
4179
  for (i = 0; i < n_fields; i++) 
4244
4180
  {
4245
 
    const dict_col_t *col= &index->table->cols[i];
4246
4181
    templ = prebuilt->mysql_template + n_requested_fields;
4247
4182
    field = table->getField(i);
4248
4183
 
4290
4225
    templ->col_no = i;
4291
4226
 
4292
4227
    if (index == clust_index) {
4293
 
      templ->rec_field_no = dict_col_get_clust_pos(col, index);
 
4228
      templ->rec_field_no = dict_col_get_clust_pos(
 
4229
        &index->table->cols[i], index);
4294
4230
    } else {
4295
4231
      templ->rec_field_no = dict_index_get_nth_col_pos(
4296
4232
                index, i);
4319
4255
      mysql_prefix_len = templ->mysql_col_offset
4320
4256
        + templ->mysql_col_len;
4321
4257
    }
4322
 
    templ->type = col->mtype;
 
4258
    templ->type = index->table->cols[i].mtype;
4323
4259
    templ->mysql_type = (ulint)field->type();
4324
4260
 
4325
4261
    if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
4327
4263
        (((Field_varstring*)field)->pack_length_no_ptr());
4328
4264
    }
4329
4265
 
4330
 
    templ->charset = dtype_get_charset_coll(col->prtype);
4331
 
    templ->mbminlen = dict_col_get_mbminlen(col);
4332
 
    templ->mbmaxlen = dict_col_get_mbmaxlen(col);
4333
 
    templ->is_unsigned = col->prtype & DATA_UNSIGNED;
 
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;
4334
4272
    if (templ->type == DATA_BLOB) {
4335
4273
      prebuilt->templ_contains_blob = TRUE;
4336
4274
    }
4548
4486
 
4549
4487
  error = row_insert_for_mysql((byte*) record, prebuilt);
4550
4488
 
4551
 
  user_session->setXaId(trx->id);
 
4489
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4552
4490
 
4553
4491
  /* Handle duplicate key errors */
4554
4492
  if (auto_inc_used) {
4871
4809
 
4872
4810
  error = row_update_for_mysql((byte*) old_row, prebuilt);
4873
4811
 
4874
 
  user_session->setXaId(trx->id);
 
4812
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4875
4813
 
4876
4814
  /* We need to do some special AUTOINC handling for the following case:
4877
4815
 
4963
4901
 
4964
4902
  error = row_update_for_mysql((byte*) record, prebuilt);
4965
4903
 
4966
 
  user_session->setXaId(trx->id);
 
4904
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4967
4905
 
4968
4906
  innodb_srv_conc_exit_innodb(trx);
4969
4907
 
6234
6172
# error "DICT_TF_ZSSIZE_MAX < 1"
6235
6173
#endif
6236
6174
 
6237
 
    if (strict_mode)
 
6175
    if (SessionVAR(&session, strict_mode))
6238
6176
    {
6239
6177
      if (! srv_file_per_table)
6240
6178
      {
6281
6219
                          lex_identified_temp_table ? name2 : NULL,
6282
6220
                          iflags);
6283
6221
 
6284
 
  session.setXaId(trx->id);
 
6222
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6285
6223
 
6286
6224
  if (error) {
6287
6225
    goto cleanup;
6362
6300
    /* We update the highest file format in the system table
6363
6301
      space, if this table has higher file format setting. */
6364
6302
 
6365
 
    char changed_file_format_max[100];
6366
 
    strcpy(changed_file_format_max, innobase_file_format_max.c_str());
6367
 
    trx_sys_file_format_max_upgrade((const char **)&changed_file_format_max,
6368
 
      dict_table_get_format(innobase_table));
6369
 
    innobase_file_format_max= changed_file_format_max;
 
6303
    trx_sys_file_format_max_upgrade((const char**) &innobase_file_format_max,
 
6304
                                    dict_table_get_format(innobase_table));
6370
6305
  }
6371
6306
 
6372
6307
  /* Note: We can't call update_session() as prebuilt will not be
6538
6473
                                   session_sql_command(&session)
6539
6474
                                   == SQLCOM_DROP_DB);
6540
6475
 
6541
 
  session.setXaId(trx->id);
 
6476
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6542
6477
 
6543
6478
  /* Flush the log to reduce probability that the .frm files and
6544
6479
    the InnoDB data dictionary get out-of-sync if the user runs
6760
6695
 
6761
6696
  error = innobase_rename_table(trx, from.getPath().c_str(), to.getPath().c_str(), TRUE);
6762
6697
 
6763
 
  session.setXaId(trx->id);
 
6698
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6764
6699
 
6765
6700
  /* Tell the InnoDB server that there might be work for
6766
6701
    utility threads: */
7068
7003
 
7069
7004
        /* If index does not belong to the table of share structure. Search
7070
7005
        index->table instead */
7071
 
        if (index->table != ib_table) {
 
7006
        if (index->table != ib_table
 
7007
            && strcmp(index->table->name, share->table_name)) {
7072
7008
                i = 0;
7073
7009
                ind = dict_table_get_first_index(index->table);
7074
7010
 
7132
7068
  dict_index_t* index;
7133
7069
  ha_rows   rec_per_key;
7134
7070
  ib_int64_t  n_rows;
 
7071
  ulong   j;
 
7072
  ulong   i;
7135
7073
  os_file_stat_t  stat_info;
7136
7074
 
7137
7075
  /* If we are forcing recovery at a high level, we will suppress
7138
7076
  statistics calculation on tables, because that may crash the
7139
7077
  server if an index is badly corrupted. */
7140
7078
 
 
7079
  if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
 
7080
 
 
7081
    /* We return success (0) instead of HA_ERR_CRASHED,
 
7082
    because we want MySQL to process this query and not
 
7083
    stop, like it would do if it received the error code
 
7084
    HA_ERR_CRASHED. */
 
7085
 
 
7086
    return(0);
 
7087
  }
 
7088
 
7141
7089
  /* We do not know if MySQL can call this function before calling
7142
7090
  external_lock(). To be safe, update the session of the current table
7143
7091
  handle. */
7229
7177
    acquiring latches inside InnoDB, we do not call it if we
7230
7178
    are asked by MySQL to avoid locking. Another reason to
7231
7179
    avoid the call is that it uses quite a lot of CPU.
7232
 
    See Bug#38185. */
7233
 
    if (flag & HA_STATUS_NO_LOCK) {
7234
 
      /* We do not update delete_length if no
7235
 
         locking is requested so the "old" value can
7236
 
         remain. delete_length is initialized to 0 in
7237
 
         the ha_statistics' constructor. */
7238
 
    } else if (UNIV_UNLIKELY
7239
 
               (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) {
7240
 
      /* Avoid accessing the tablespace if
7241
 
         innodb_crash_recovery is set to a high value. */
7242
 
      stats.delete_length = 0;
7243
 
    } else {
 
7180
    See Bug#38185.
 
7181
    We do not update delete_length if no locking is requested
 
7182
    so the "old" value can remain. delete_length is initialized
 
7183
    to 0 in the ha_statistics' constructor. */
 
7184
    if (!(flag & HA_STATUS_NO_LOCK)) {
 
7185
 
7244
7186
      /* lock the data dictionary to avoid races with
7245
7187
      ibd_file_missing and tablespace_discarded */
7246
7188
      row_mysql_lock_data_dictionary(prebuilt->trx);
7286
7228
  }
7287
7229
 
7288
7230
  if (flag & HA_STATUS_CONST) {
7289
 
    ulong i;
7290
7231
    /* Verify the number of index in InnoDB and MySQL
7291
7232
       matches up. If prebuilt->clust_index_was_generated
7292
7233
       holds, InnoDB defines GEN_CLUST_INDEX internally */
7302
7243
    }
7303
7244
 
7304
7245
    for (i = 0; i < getTable()->getShare()->sizeKeys(); i++) {
7305
 
      ulong j;
7306
7246
      /* We could get index quickly through internal
7307
7247
         index mapping with the index translation table.
7308
7248
         The identity of index (match up index name with
7368
7308
    }
7369
7309
  }
7370
7310
 
7371
 
  if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
7372
 
    goto func_exit;
7373
 
  }
7374
 
 
7375
7311
  if (flag & HA_STATUS_ERRKEY) {
7376
7312
    const dict_index_t* err_index;
7377
7313
 
7393
7329
    stats.auto_increment_value = innobase_peek_autoinc();
7394
7330
  }
7395
7331
 
7396
 
func_exit:
7397
7332
  prebuilt->trx->op_info = (char*)"";
7398
7333
 
7399
7334
  return(0);
8094
8029
{
8095
8030
  trx_t*      trx;
8096
8031
  static const char truncated_msg[] = "... truncated...\n";
8097
 
  const long    MAX_STATUS_SIZE = 1048576;
 
8032
  const long    MAX_STATUS_SIZE = 64000;
8098
8033
  ulint     trx_list_start = ULINT_UNDEFINED;
8099
8034
  ulint     trx_list_end = ULINT_UNDEFINED;
8100
8035
 
8123
8058
 
8124
8059
  if (flen > MAX_STATUS_SIZE) {
8125
8060
    usable_len = MAX_STATUS_SIZE;
8126
 
    srv_truncated_status_writes++;
8127
8061
  } else {
8128
8062
    usable_len = flen;
8129
8063
  }
8159
8093
 
8160
8094
  mutex_exit(&srv_monitor_file_mutex);
8161
8095
 
8162
 
  stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
8163
 
             STRING_WITH_LEN(""), str, flen);
 
8096
  bool result = FALSE;
8164
8097
 
 
8098
  if (stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
 
8099
      STRING_WITH_LEN(""), str, flen)) {
 
8100
    result= TRUE;
 
8101
  }
8165
8102
  free(str);
8166
8103
 
8167
8104
  return(FALSE);
8510
8447
        && (sql_command == SQLCOM_INSERT_SELECT
8511
8448
            || sql_command == SQLCOM_REPLACE_SELECT
8512
8449
            || sql_command == SQLCOM_UPDATE
8513
 
            || sql_command == SQLCOM_CREATE_TABLE
8514
 
            || sql_command == SQLCOM_SET_OPTION)) {
 
8450
            || sql_command == SQLCOM_CREATE_TABLE)) {
8515
8451
 
8516
8452
      /* If we either have innobase_locks_unsafe_for_binlog
8517
8453
      option set or this session is using READ COMMITTED
8519
8455
      is not set to serializable and MySQL is doing
8520
8456
      INSERT INTO...SELECT or REPLACE INTO...SELECT
8521
8457
      or UPDATE ... = (SELECT ...) or CREATE  ...
8522
 
      SELECT... or SET ... = (SELECT ...) without
8523
 
      FOR UPDATE or IN SHARE MODE in select,
8524
 
      then we use consistent read for select. */
 
8458
      SELECT... without FOR UPDATE or IN SHARE
 
8459
      MODE in select, then we use consistent read
 
8460
      for select. */
8525
8461
 
8526
8462
      prebuilt->select_lock_type = LOCK_NONE;
8527
8463
      prebuilt->stored_select_lock_type = LOCK_NONE;
8609
8545
}
8610
8546
 
8611
8547
/*******************************************************************//**
8612
 
This function reads the global auto-inc counter. It doesn't use the
 
8548
This function reads the global auto-inc counter. It doesn't use the 
8613
8549
AUTOINC lock even if the lock mode is set to TRADITIONAL.
8614
8550
@return the autoinc value */
8615
8551
UNIV_INTERN
8629
8565
 
8630
8566
  auto_inc = dict_table_autoinc_read(innodb_table);
8631
8567
 
8632
 
  if (auto_inc == 0) {
8633
 
    ut_print_timestamp(stderr);
8634
 
    fprintf(stderr, "  InnoDB: AUTOINC next value generation "
8635
 
            "is disabled for '%s'\n", innodb_table->name);
8636
 
  }
 
8568
  ut_a(auto_inc > 0);
8637
8569
 
8638
8570
  dict_table_autoinc_unlock(innodb_table);
8639
8571
 
9051
8983
uint64_t InnobaseEngine::doGetCurrentTransactionId(Session *session)
9052
8984
{
9053
8985
  trx_t *trx= session_to_trx(session);
9054
 
  return (trx->id);
 
8986
  return (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
9055
8987
}
9056
8988
 
9057
8989
uint64_t InnobaseEngine::doGetNewTransactionId(Session *session)
9069
9001
  trx->id= trx_sys_get_new_trx_id();
9070
9002
  mutex_exit(&kernel_mutex);
9071
9003
 
9072
 
  uint64_t transaction_id= trx->id;
 
9004
  uint64_t transaction_id= (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
9073
9005
 
9074
9006
  return transaction_id;
9075
9007
}
9206
9138
  }
9207
9139
}
9208
9140
 
9209
 
 
 
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
/****************************************************************//**
 
9347
Update the system variable innodb_old_blocks_pct using the "saved"
 
9348
value. This function is registered as a callback with MySQL. */
 
9349
static
 
9350
void
 
9351
innodb_old_blocks_pct_update(
 
9352
/*=========================*/
 
9353
        Session*                        ,       /*!< in: thread handle */
 
9354
        drizzle_sys_var*        ,       /*!< in: pointer to
 
9355
                                                system variable */
 
9356
        void*                           ,/*!< out: where the
 
9357
                                                formal string goes */
 
9358
        const void*                     save)   /*!< in: immediate result
 
9359
                                                from check function */
 
9360
{
 
9361
        innobase_old_blocks_pct = buf_LRU_old_ratio_update(
 
9362
                *static_cast<const uint*>(save), TRUE);
 
9363
}
 
9364
 
 
9365
/*************************************************************//**
 
9366
Check if it is a valid value of innodb_change_buffering. This function is
 
9367
registered as a callback with MySQL.
 
9368
@return 0 for valid innodb_change_buffering */
 
9369
static
 
9370
int
 
9371
innodb_change_buffering_validate(
 
9372
/*=============================*/
 
9373
  Session*      , /*!< in: thread handle */
 
9374
  drizzle_sys_var*  , /*!< in: pointer to system
 
9375
            variable */
 
9376
  void*       save, /*!< out: immediate result
 
9377
            for update function */
 
9378
  drizzle_value*    value)  /*!< in: incoming string */
 
9379
{
 
9380
  const char* change_buffering_input;
 
9381
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9382
  int   len = sizeof(buff);
 
9383
 
 
9384
  ut_a(save != NULL);
 
9385
  ut_a(value != NULL);
 
9386
 
 
9387
  change_buffering_input = value->val_str(value, buff, &len);
 
9388
 
 
9389
  if (change_buffering_input != NULL) {
 
9390
    ulint use;
 
9391
 
 
9392
    for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
 
9393
         use++) {
 
9394
      if (!innobase_strcasecmp(
 
9395
            change_buffering_input,
 
9396
            innobase_change_buffering_values[use])) {
 
9397
        *(ibuf_use_t*) save = (ibuf_use_t) use;
 
9398
        return(0);
 
9399
      }
 
9400
    }
 
9401
  }
 
9402
 
 
9403
  return(1);
 
9404
}
 
9405
 
 
9406
/****************************************************************//**
 
9407
Update the system variable innodb_change_buffering using the "saved"
 
9408
value. This function is registered as a callback with MySQL. */
 
9409
static
 
9410
void
 
9411
innodb_change_buffering_update(
 
9412
/*===========================*/
 
9413
  Session*      ,   /*!< in: thread handle */
 
9414
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9415
              system variable */
 
9416
  void*       var_ptr,  /*!< out: where the
 
9417
              formal string goes */
 
9418
  const void*     save)   /*!< in: immediate result
 
9419
              from check function */
 
9420
{
 
9421
  ut_a(var_ptr != NULL);
 
9422
  ut_a(save != NULL);
 
9423
  ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
 
9424
 
 
9425
  ibuf_use = *(const ibuf_use_t*) save;
 
9426
 
 
9427
  *(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
 
9428
}
 
9429
 
 
9430
/* 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
 
 
9487
/* "innobase_file_format_check" decides whether we would continue
 
9488
booting the server if the file format stamped on the system
 
9489
table space exceeds the maximum file format supported
 
9490
by the server. Can be set during server startup at command
 
9491
line or configure file, and a read only variable after
 
9492
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
 
 
9498
/* If a new file format is introduced, the file format
 
9499
name needs to be updated accordingly. Please refer to
 
9500
file_format_name_map[] defined in trx0sys.c for the next
 
9501
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
 
 
9564
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
 
9565
  PLUGIN_VAR_RQCMDARG,
 
9566
  "Replication thread delay (ms) on the slave server if "
 
9567
  "innodb_thread_concurrency is reached (0 by default)",
 
9568
  NULL, NULL, 0, 0, ~0UL, 0);
 
9569
 
 
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
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
 
9591
  PLUGIN_VAR_RQCMDARG,
 
9592
  "Helps in performance tuning in heavily concurrent environments.",
 
9593
  innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
 
9594
 
 
9595
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
 
9596
  PLUGIN_VAR_RQCMDARG,
 
9597
  "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
 
9598
  NULL, NULL, 500L, 1L, ~0L, 0);
 
9599
 
 
9600
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
 
9601
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9602
  "Number of background read I/O threads in InnoDB.",
 
9603
  NULL, NULL, 4, 1, 64, 0);
 
9604
 
 
9605
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
 
9606
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9607
  "Number of background write I/O threads in InnoDB.",
 
9608
  NULL, NULL, 4, 1, 64, 0);
 
9609
 
 
9610
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
 
9611
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9612
  "Helps to save your data in case the disk image of the database becomes corrupt.",
 
9613
  NULL, NULL, 0, 0, 6, 0);
 
9614
 
 
9615
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
 
9616
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9617
  "The size of the buffer which InnoDB uses to write log to the log files on disk.",
 
9618
  NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
 
9619
 
 
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
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
 
9626
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9627
  "Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
 
9628
  NULL, NULL, 2, 2, 100, 0);
 
9629
 
 
9630
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
 
9631
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9632
  "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
 
9633
  NULL, NULL, 1, 1, 10, 0);
 
9634
 
 
9635
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
 
9636
  PLUGIN_VAR_RQCMDARG,
 
9637
  "Percentage of the buffer pool to reserve for 'old' blocks.",
 
9638
  NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
 
9639
 
 
9640
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
 
9641
  PLUGIN_VAR_RQCMDARG,
 
9642
  "Move blocks to the 'new' end of the buffer pool if the first access"
 
9643
  " was at least this many milliseconds ago."
 
9644
  " The timeout is disabled if 0 (the default).",
 
9645
  NULL, NULL, 0, 0, UINT32_MAX, 0);
 
9646
 
 
9647
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
 
9648
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9649
  "How many files at the maximum InnoDB keeps open at the same time.",
 
9650
  NULL, NULL, 300L, 10L, LONG_MAX, 0);
 
9651
 
 
9652
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
 
9653
  PLUGIN_VAR_RQCMDARG,
 
9654
  "Count of spin-loop rounds in InnoDB mutexes (30 by default)",
 
9655
  NULL, NULL, 30L, 0L, ~0L, 0);
 
9656
 
 
9657
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
 
9658
  PLUGIN_VAR_OPCMDARG,
 
9659
  "Maximum delay between polling for a spin lock (6 by default)",
 
9660
  NULL, NULL, 6L, 0L, ~0L, 0);
 
9661
 
 
9662
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
 
9663
  PLUGIN_VAR_RQCMDARG,
 
9664
  "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
 
9665
  NULL, NULL, 0, 0, 1000, 0);
 
9666
 
 
9667
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
 
9668
  PLUGIN_VAR_RQCMDARG,
 
9669
  "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
 
9670
  NULL, NULL, 10000L, 0L, ~0L, 0);
 
9671
 
 
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
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
 
9692
  PLUGIN_VAR_RQCMDARG,
 
9693
  "Buffer changes to reduce random access: "
 
9694
  "OFF, ON, inserting, deleting, changing or purging..",
 
9695
  innodb_change_buffering_validate,
 
9696
  innodb_change_buffering_update, "all");
 
9697
 
 
9698
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
 
9699
  PLUGIN_VAR_RQCMDARG,
 
9700
  "Number of pages that must be accessed sequentially for InnoDB to "
 
9701
  "trigger a readahead.",
 
9702
  NULL, NULL, 56, 0, 64, 0);
9210
9703
 
9211
9704
static void init_options(drizzled::module::option_context &context)
9212
9705
{
9218
9711
  context("disable-doublewrite",
9219
9712
          "Disable InnoDB doublewrite buffer.");
9220
9713
  context("io-capacity",
9221
 
          po::value<io_capacity_constraint>(&innodb_io_capacity)->default_value(200),
 
9714
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
9222
9715
          "Number of IOPs the server can do. Tunes the background IO rate");
9223
9716
  context("fast-shutdown",
9224
 
          po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1), 
 
9717
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1), 
9225
9718
          "Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like).");
9226
9719
  context("purge-batch-size",
9227
 
          po::value<purge_batch_constraint>(&innodb_purge_batch_size)->default_value(20),
 
9720
          po::value<unsigned long>(&srv_purge_batch_size)->default_value(20),
9228
9721
          "Number of UNDO logs to purge in one batch from the history list. "
9229
9722
          "Default is 20.");
9230
9723
  context("purge-threads",
9231
 
          po::value<purge_threads_constraint>(&innodb_n_purge_threads)->default_value(0),
 
9724
          po::value<unsigned long>(&srv_n_purge_threads)->default_value(0),
9232
9725
          "Purge threads can be either 0 or 1. Defalut is 0.");
9233
9726
  context("file-per-table",
9234
9727
          po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
9235
9728
          "Stores each InnoDB table to an .ibd file in the database dir.");
9236
9729
  context("file-format",
9237
 
          po::value<string>(&innobase_file_format_name)->default_value("Antelope"),
 
9730
          po::value<string>()->default_value("Antelope"),
9238
9731
          "File format to use for new tables in .ibd files.");
9239
9732
  context("file-format-max",
9240
 
          po::value<string>(&innobase_file_format_max)->default_value("Antelope"),
 
9733
          po::value<string>()->default_value("Antelope"),
9241
9734
          "The highest file format in the tablespace.");
9242
9735
  context("file-format-check",
9243
9736
          po::value<bool>(&innobase_file_format_check)->default_value(true)->zero_tokens(),
9244
9737
          "Whether to perform system file format check.");
9245
9738
  context("flush-log-at-trx-commit",
9246
 
          po::value<trinary_constraint>(&innodb_flush_log_at_trx_commit)->default_value(1),
 
9739
          po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
9247
9740
          "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).");
9248
9741
  context("flush-method",
9249
9742
          po::value<string>(),
9250
9743
          "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 */
9251
9752
  context("log-group-home-dir",
9252
9753
          po::value<string>(),
9253
9754
          "Path to InnoDB log files.");
9254
9755
  context("max-dirty-pages-pct",
9255
 
          po::value<max_dirty_pages_constraint>(&innodb_max_dirty_pages_pct)->default_value(75),
 
9756
          po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
9256
9757
          "Percentage of dirty pages allowed in bufferpool.");
9257
9758
  context("disable-adaptive-flushing",
9258
9759
          "Do not attempt flushing dirty pages to avoid IO bursts at checkpoints.");
9259
9760
  context("max-purge-lag",
9260
 
          po::value<uint64_constraint>(&innodb_max_purge_lag)->default_value(0),
 
9761
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
9261
9762
          "Desired maximum length of the purge queue (0 = no limit)");
9262
9763
  context("status-file",
9263
9764
          po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
9265
9766
  context("disable-stats-on-metadata",
9266
9767
          "Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9267
9768
  context("stats-sample-pages",
9268
 
          po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
 
9769
          po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9269
9770
          "The number of index pages to sample when calculating statistics (default 8)");
9270
9771
  context("disable-adaptive-hash-index",
9271
9772
          "Enable InnoDB adaptive hash index (enabled by default)");
9272
9773
  context("replication-delay",
9273
 
          po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
 
9774
          po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9274
9775
          "Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9275
9776
  context("additional-mem-pool-size",
9276
 
          po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
9777
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9277
9778
          "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9278
9779
  context("autoextend-increment",
9279
 
          po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
 
9780
          po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9280
9781
          "Data file autoextend increment in megabytes");
9281
9782
  context("buffer-pool-size",
9282
 
          po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
9783
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9283
9784
          "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9284
9785
  context("buffer-pool-instances",
9285
 
          po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
 
9786
          po::value<int64_t>(&innobase_buffer_pool_instances)->default_value(1),
9286
9787
          "Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9287
9788
 
9288
9789
  context("commit-concurrency",
9289
 
          po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
 
9790
          po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9290
9791
          "Helps in performance tuning in heavily concurrent environments.");
9291
9792
  context("concurrency-tickets",
9292
 
          po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
 
9793
          po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9293
9794
          "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9294
9795
  context("read-io-threads",
9295
 
          po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
 
9796
          po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9296
9797
          "Number of background read I/O threads in InnoDB.");
9297
9798
  context("write-io-threads",
9298
 
          po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
 
9799
          po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9299
9800
          "Number of background write I/O threads in InnoDB.");
9300
9801
  context("force-recovery",
9301
 
          po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
 
9802
          po::value<long>(&innobase_force_recovery)->default_value(0),
9302
9803
          "Helps to save your data in case the disk image of the database becomes corrupt.");
9303
9804
  context("log-buffer-size",
9304
 
          po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
 
9805
          po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9305
9806
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9306
9807
  context("log-file-size",
9307
 
          po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
 
9808
          po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9308
9809
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9309
9810
  context("log-files-in-group",
9310
 
          po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
 
9811
          po::value<long>(&innobase_log_files_in_group)->default_value(2),
9311
9812
          "Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9312
9813
  context("mirrored-log-groups",
9313
 
          po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
 
9814
          po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9314
9815
          "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9315
9816
  context("open-files",
9316
 
          po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
 
9817
          po::value<long>(&innobase_open_files)->default_value(300L),
9317
9818
          "How many files at the maximum InnoDB keeps open at the same time.");
9318
9819
  context("sync-spin-loops",
9319
 
          po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
 
9820
          po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9320
9821
          "Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9321
9822
  context("spin-wait-delay",
9322
 
          po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
 
9823
          po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9323
9824
          "Maximum delay between polling for a spin lock (6 by default)");
9324
9825
  context("thread-concurrency",
9325
 
          po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
 
9826
          po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9326
9827
          "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.");
9327
9828
  context("thread-sleep-delay",
9328
 
          po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
 
9829
          po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9329
9830
          "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9330
9831
  context("data-file-path",
9331
9832
          po::value<string>(),
9336
9837
  context("use-internal-malloc",
9337
9838
          "Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9338
9839
  context("change-buffering",
9339
 
          po::value<string>(&innobase_change_buffering),
 
9840
          po::value<string>(),
9340
9841
          "Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9341
9842
  context("read-ahead-threshold",
9342
 
          po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
 
9843
          po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9343
9844
          "Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9344
9845
  context("disable-xa",
9345
9846
          "Disable InnoDB support for the XA two-phase commit");
9346
9847
  context("disable-table-locks",
9347
9848
          "Disable InnoDB locking in LOCK TABLES");
9348
9849
  context("strict-mode",
9349
 
          po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
 
9850
          po::value<bool>()->default_value(false)->zero_tokens(),
9350
9851
          "Use strict mode when evaluating create options.");
9351
 
  context("replication-log",
9352
 
          po::value<bool>(&innobase_use_replication_log)->default_value(false),
9353
 
          _("Enable internal replication log."));
9354
9852
  context("lock-wait-timeout",
9355
 
          po::value<lock_wait_constraint>(&lock_wait_timeout)->default_value(50),
9356
 
          _("Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
9357
 
  context("old-blocks-pct",
9358
 
          po::value<old_blocks_constraint>(&innobase_old_blocks_pct)->default_value(100 * 3 / 8),
9359
 
          _("Percentage of the buffer pool to reserve for 'old' blocks."));
9360
 
  context("old-blocks-time",
9361
 
          po::value<uint32_t>(&buf_LRU_old_threshold_ms)->default_value(0),
9362
 
          _("ove blocks to the 'new' end of the buffer pool if the first access"
9363
 
            " was at least this many milliseconds ago."
9364
 
            " The timeout is disabled if 0 (the default)."));
 
9853
          po::value<unsigned long>()->default_value(50),
 
9854
          "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9365
9855
}
9366
9856
 
9367
 
 
 
9857
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
  DRIZZLE_SYSVAR(commit_concurrency),
 
9864
  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
  DRIZZLE_SYSVAR(read_io_threads),
 
9870
  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
  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
  DRIZZLE_SYSVAR(log_buffer_size),
 
9884
  DRIZZLE_SYSVAR(log_file_size),
 
9885
  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
  DRIZZLE_SYSVAR(mirrored_log_groups),
 
9891
  DRIZZLE_SYSVAR(old_blocks_pct),
 
9892
  DRIZZLE_SYSVAR(old_blocks_time),
 
9893
  DRIZZLE_SYSVAR(open_files),
 
9894
  DRIZZLE_SYSVAR(stats_sample_pages),
 
9895
  DRIZZLE_SYSVAR(adaptive_hash_index),
 
9896
  DRIZZLE_SYSVAR(replication_delay),
 
9897
  DRIZZLE_SYSVAR(status_file),
 
9898
  DRIZZLE_SYSVAR(strict_mode),
 
9899
  DRIZZLE_SYSVAR(support_xa),
 
9900
  DRIZZLE_SYSVAR(sync_spin_loops),
 
9901
  DRIZZLE_SYSVAR(spin_wait_delay),
 
9902
  DRIZZLE_SYSVAR(table_locks),
 
9903
  DRIZZLE_SYSVAR(thread_concurrency),
 
9904
  DRIZZLE_SYSVAR(thread_sleep_delay),
 
9905
  DRIZZLE_SYSVAR(version),
 
9906
  DRIZZLE_SYSVAR(use_sys_malloc),
 
9907
  DRIZZLE_SYSVAR(use_native_aio),
 
9908
  DRIZZLE_SYSVAR(change_buffering),
 
9909
  DRIZZLE_SYSVAR(read_ahead_threshold),
 
9910
  DRIZZLE_SYSVAR(io_capacity),
 
9911
  DRIZZLE_SYSVAR(purge_threads),
 
9912
  DRIZZLE_SYSVAR(purge_batch_size),
 
9913
  NULL
 
9914
};
9368
9915
 
9369
9916
DRIZZLE_DECLARE_PLUGIN
9370
9917
{
9375
9922
  "Supports transactions, row-level locking, and foreign keys",
9376
9923
  PLUGIN_LICENSE_GPL,
9377
9924
  innobase_init, /* Plugin Init */
9378
 
  NULL, /* system variables */
 
9925
  innobase_system_variables, /* system variables */
9379
9926
  init_options /* reserved */
9380
9927
}
9381
9928
DRIZZLE_DECLARE_PLUGIN_END;
9403
9950
  return res;
9404
9951
}
9405
9952
 
 
9953
/** @brief Initialize the default value of innodb_commit_concurrency.
 
9954
 
 
9955
Once InnoDB is running, the innodb_commit_concurrency must not change
 
9956
from zero to nonzero. (Bug #42101)
 
9957
 
 
9958
The initial default value is 0, and without this extra initialization,
 
9959
SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter
 
9960
to 0, even if it was initially set to nonzero at the command line
 
9961
or configuration file. */
 
9962
static
 
9963
void
 
9964
innobase_commit_concurrency_init_default(void)
 
9965
/*==========================================*/
 
9966
{
 
9967
  DRIZZLE_SYSVAR_NAME(commit_concurrency).def_val
 
9968
    = innobase_commit_concurrency;
 
9969
}
 
9970
 
9406
9971
/***********************************************************************
9407
9972
This function checks each index name for a table against reserved
9408
9973
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,