~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: David Shrewsbury
  • Date: 2010-11-19 15:23:07 UTC
  • mto: (1942.1.3 b)
  • mto: This revision was merged to the branch mainline in revision 1943.
  • Revision ID: shrewsbury.dave@gmail.com-20101119152307-srnssq2n5num5tit
Add --replicate-query option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
#include "log0log.h"
103
103
#include "lock0lock.h"
104
104
#include "dict0crea.h"
105
 
#include "create_replication.h"
106
105
#include "btr0cur.h"
107
106
#include "btr0btr.h"
108
107
#include "fsp0fsp.h"
120
119
 
121
120
#include "ha_innodb.h"
122
121
#include "data_dictionary.h"
123
 
#include "replication_dictionary.h"
124
122
#include "internal_dictionary.h"
125
123
#include "handler0vars.h"
126
124
 
129
127
#include <string>
130
128
 
131
129
#include "plugin/innobase/handler/status_function.h"
132
 
#include "plugin/innobase/handler/replication_log.h"
133
 
 
134
 
#include <google/protobuf/io/zero_copy_stream.h>
135
 
#include <google/protobuf/io/zero_copy_stream_impl.h>
136
 
#include <google/protobuf/io/coded_stream.h>
137
 
#include <google/protobuf/text_format.h>
138
130
 
139
131
using namespace std;
140
132
using namespace drizzled;
170
162
static plugin::TableFunction* innodb_trx_tool= NULL;
171
163
static plugin::TableFunction* innodb_locks_tool= NULL;
172
164
static plugin::TableFunction* innodb_lock_waits_tool= NULL;
173
 
static plugin::TableFunction* innodb_sys_tables_tool= NULL;
174
 
static plugin::TableFunction* innodb_sys_tablestats_tool= NULL;
175
 
 
176
 
static plugin::TableFunction* innodb_sys_indexes_tool= NULL;
177
 
static plugin::TableFunction* innodb_sys_columns_tool= NULL;
178
 
static plugin::TableFunction* innodb_sys_fields_tool= NULL;
179
 
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
180
 
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
181
 
 
182
 
static ReplicationLog *replication_logger= NULL;
183
 
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
184
 
static open_files_constraint innobase_open_files;
185
 
typedef constrained_check<uint32_t, 10, 1> mirrored_log_groups_constraint;
186
 
static mirrored_log_groups_constraint innobase_mirrored_log_groups;
187
 
typedef constrained_check<uint32_t, 100, 2> log_files_in_group_constraint;
188
 
static log_files_in_group_constraint innobase_log_files_in_group;
189
 
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
190
 
force_recovery_constraint innobase_force_recovery;
191
 
typedef constrained_check<size_t, SIZE_MAX, 256*1024, 1024> log_buffer_constraint;
192
 
static log_buffer_constraint innobase_log_buffer_size;
193
 
typedef constrained_check<size_t, SIZE_MAX, 512*1024, 1024> additional_mem_pool_constraint;
194
 
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
195
 
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
196
 
static autoextend_constraint innodb_auto_extend_increment;
197
 
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
198
 
static buffer_pool_constraint innobase_buffer_pool_size;
199
 
typedef constrained_check<uint32_t, MAX_BUFFER_POOLS, 1> buffer_pool_instances_constraint;
200
 
static buffer_pool_instances_constraint innobase_buffer_pool_instances;
201
 
typedef constrained_check<uint32_t, UINT32_MAX, 100> io_capacity_constraint;
202
 
static io_capacity_constraint innodb_io_capacity;
203
 
typedef constrained_check<uint32_t, 5000, 1> purge_batch_constraint;
204
 
static purge_batch_constraint innodb_purge_batch_size;
205
 
typedef constrained_check<uint32_t, 1, 0> purge_threads_constraint;
206
 
static purge_threads_constraint innodb_n_purge_threads;
207
 
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
208
 
static trinary_constraint innodb_flush_log_at_trx_commit;
209
 
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
210
 
static max_dirty_pages_constraint innodb_max_dirty_pages_pct;
211
 
static uint64_constraint innodb_max_purge_lag;
212
 
static uint64_nonzero_constraint innodb_stats_sample_pages;
213
 
typedef constrained_check<uint32_t, 64, 1> io_threads_constraint;
214
 
static io_threads_constraint innobase_read_io_threads;
215
 
static io_threads_constraint innobase_write_io_threads;
216
 
 
217
 
typedef constrained_check<uint32_t, 1000, 0> concurrency_constraint;
218
 
static concurrency_constraint innobase_commit_concurrency;
219
 
static concurrency_constraint innobase_thread_concurrency;
220
 
static uint32_nonzero_constraint innodb_concurrency_tickets;
221
 
 
222
 
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
223
 
static log_file_constraint innobase_log_file_size;
224
 
 
225
 
static uint64_constraint innodb_replication_delay;
 
165
 
 
166
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
 
167
  innobase_log_buffer_size,
 
168
  innobase_force_recovery, innobase_open_files;
 
169
static long innobase_additional_mem_pool_size= 8*1024*1024L;
 
170
static ulong innobase_commit_concurrency = 0;
 
171
static ulong innobase_read_io_threads;
 
172
static ulong innobase_write_io_threads;
 
173
 
 
174
/**
 
175
 * @TODO: Turn this into size_t as soon as we have a Variable<size_t>
 
176
 */
 
177
static int64_t innobase_buffer_pool_size= 128*1024*1024;
 
178
static int64_t innobase_log_file_size;
226
179
 
227
180
/** Percentage of the buffer pool to reserve for 'old' blocks.
228
181
Connected to buf_LRU_old_ratio. */
229
 
typedef constrained_check<uint32_t, 95, 5> old_blocks_constraint;
230
 
static old_blocks_constraint innobase_old_blocks_pct;
231
 
 
232
 
static uint32_constraint innodb_sync_spin_loops;
233
 
static uint32_constraint innodb_spin_wait_delay;
234
 
static uint32_constraint innodb_thread_sleep_delay;
235
 
 
236
 
typedef constrained_check<uint32_t, 64, 0> read_ahead_threshold_constraint;
237
 
static read_ahead_threshold_constraint innodb_read_ahead_threshold;
 
182
static uint innobase_old_blocks_pct;
238
183
 
239
184
/* The default values for the following char* start-up parameters
240
185
are determined in innobase_init below: */
241
186
 
242
 
std::string innobase_data_home_dir;
243
 
std::string innobase_data_file_path;
244
 
std::string innobase_log_group_home_dir;
245
 
static string innobase_file_format_name;
246
 
static string innobase_change_buffering;
247
 
 
248
 
/* The highest file format being used in the database. The value can be
249
 
set by user, however, it will be adjusted to the newer file format if
250
 
a table of such format is created/opened. */
251
 
static string innobase_file_format_max;
 
187
static char*  innobase_data_home_dir      = NULL;
 
188
static char*  innobase_data_file_path     = NULL;
 
189
static char*  innobase_log_group_home_dir   = NULL;
 
190
static char*  innobase_file_format_name   = NULL;
 
191
static char*  innobase_change_buffering   = NULL;
 
192
 
 
193
/* Note: This variable can be set to on/off and any of the supported
 
194
file formats in the configuration file, but can only be set to any
 
195
of the supported file formats during runtime. */
 
196
static char*  innobase_file_format_check    = NULL;
 
197
 
 
198
static char*  innobase_file_flush_method   = NULL;
252
199
 
253
200
/* Below we have boolean-valued start-up parameters, and their default
254
201
values */
255
202
 
256
 
typedef constrained_check<uint16_t, 2, 0> trinary_constraint;
257
 
static trinary_constraint innobase_fast_shutdown;
258
 
 
259
 
/* "innobase_file_format_check" decides whether we would continue
260
 
booting the server if the file format stamped on the system
261
 
table space exceeds the maximum file format supported
262
 
by the server. Can be set during server startup at command
263
 
line or configure file, and a read only variable after
264
 
server startup */
265
 
 
266
 
/* If a new file format is introduced, the file format
267
 
name needs to be updated accordingly. Please refer to
268
 
file_format_name_map[] defined in trx0sys.c for the next
269
 
file format name. */
270
 
 
271
 
static my_bool  innobase_file_format_check = TRUE;
 
203
static ulong  innobase_fast_shutdown      = 1;
 
204
#ifdef UNIV_LOG_ARCHIVE
 
205
static my_bool  innobase_log_archive      = FALSE;
 
206
static char*  innobase_log_arch_dir     = NULL;
 
207
#endif /* UNIV_LOG_ARCHIVE */
272
208
static my_bool  innobase_use_doublewrite    = TRUE;
273
209
static my_bool  innobase_use_checksums      = TRUE;
274
210
static my_bool  innobase_rollback_on_timeout    = FALSE;
275
211
static my_bool  innobase_create_status_file   = FALSE;
276
 
static bool innobase_use_replication_log;
277
 
static bool support_xa;
278
 
static bool strict_mode;
279
 
typedef constrained_check<uint32_t, 1024*1024*1024, 1> lock_wait_constraint;
280
 
static lock_wait_constraint lock_wait_timeout;
281
212
 
282
213
static char*  internal_innobase_data_file_path  = NULL;
283
214
 
 
215
static char*  innodb_version_str = (char*) INNODB_VERSION_STR;
 
216
 
284
217
/* The following counter is used to convey information to InnoDB
285
218
about server activity: in selects it is not sensible to call
286
219
srv_active_wake_master_thread after each fetch or search, we only do
298
231
/** Allowed values of innodb_change_buffering */
299
232
static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = {
300
233
  "none",   /* IBUF_USE_NONE */
301
 
  "inserts",    /* IBUF_USE_INSERT */
302
 
  "deletes",    /* IBUF_USE_DELETE_MARK */
303
 
  "changes",    /* IBUF_USE_INSERT_DELETE_MARK */
304
 
  "purges",     /* IBUF_USE_DELETE */
305
 
  "all"         /* IBUF_USE_ALL */
 
234
  "inserts" /* IBUF_USE_INSERT */
306
235
};
307
236
 
308
237
/* "GEN_CLUST_INDEX" is the name reserved for Innodb default
360
289
    }
361
290
    
362
291
    /* These get strdup'd from vm variables */
 
292
    free(innobase_data_home_dir);
 
293
    free(innobase_log_group_home_dir);
363
294
 
364
295
  }
365
296
 
514
445
 
515
446
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
516
447
                             const drizzled::SchemaIdentifier &schema_identifier,
517
 
                             drizzled::TableIdentifier::vector &set_of_identifiers);
 
448
                             drizzled::TableIdentifiers &set_of_identifiers);
518
449
  bool validateCreateTableOption(const std::string &key, const std::string &state);
519
450
  void dropTemporarySchema();
520
451
 
543
474
 
544
475
void InnobaseEngine::doGetTableIdentifiers(drizzled::CachedDirectory &directory,
545
476
                                           const drizzled::SchemaIdentifier &schema_identifier,
546
 
                                           drizzled::TableIdentifier::vector &set_of_identifiers)
 
477
                                           drizzled::TableIdentifiers &set_of_identifiers)
547
478
{
548
479
  CachedDirectory::Entries entries= directory.getEntries();
549
480
 
562
493
    { }
563
494
    else
564
495
    {
565
 
      std::string path;
566
 
      path+= directory.getPath();
567
 
      path+= FN_LIBCHAR;
568
 
      path+= entry->filename;
569
 
 
570
 
      message::Table definition;
571
 
      if (StorageEngine::readTableFile(path, definition))
572
 
      {
573
 
        /* 
574
 
           Using schema_identifier here to stop unused warning, could use
575
 
           definition.schema() instead
576
 
        */
577
 
        TableIdentifier identifier(schema_identifier.getSchemaName(), definition.name());
578
 
        set_of_identifiers.push_back(identifier);
579
 
      }
 
496
      char uname[NAME_LEN + 1];
 
497
      uint32_t file_name_len;
 
498
 
 
499
      file_name_len= TableIdentifier::filename_to_tablename(filename->c_str(), uname, sizeof(uname));
 
500
      // TODO: Remove need for memory copy here
 
501
      uname[file_name_len - sizeof(DEFAULT_FILE_EXTENSION) + 1]= '\0'; // Subtract ending, place NULL 
 
502
 
 
503
      set_of_identifiers.push_back(TableIdentifier(schema_identifier, uname));
580
504
    }
581
505
  }
582
506
}
619
543
  return ENOENT;
620
544
}
621
545
 
 
546
/** @brief Initialize the default value of innodb_commit_concurrency.
 
547
 
 
548
Once InnoDB is running, the innodb_commit_concurrency must not change
 
549
from zero to nonzero. (Bug #42101)
 
550
 
 
551
The initial default value is 0, and without this extra initialization,
 
552
SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter
 
553
to 0, even if it was initially set to nonzero at the command line
 
554
or configuration file. */
 
555
static
 
556
void
 
557
innobase_commit_concurrency_init_default(void);
 
558
/*==========================================*/
622
559
 
623
560
/************************************************************//**
624
561
Validate the file format name and return its corresponding id.
631
568
            name */
632
569
/************************************************************//**
633
570
Validate the file format check config parameters, as a side effect it
634
 
sets the srv_max_file_format_at_startup variable.
 
571
sets the srv_check_file_format_at_startup variable.
 
572
@return true if one of  "on" or "off" */
 
573
static
 
574
bool
 
575
innobase_file_format_check_on_off(
 
576
/*==============================*/
 
577
  const char* format_check);    /*!< in: parameter value */
 
578
/************************************************************//**
 
579
Validate the file format check config parameters, as a side effect it
 
580
sets the srv_check_file_format_at_startup variable.
635
581
@return the format_id if valid config value, otherwise, return -1 */
636
582
static
637
583
int
638
584
innobase_file_format_validate_and_set(
639
585
/*================================*/
640
 
  const char* format_max);    /*!< in: parameter value */
 
586
  const char* format_check);    /*!< in: parameter value */
641
587
 
642
588
static const char innobase_engine_name[]= "InnoDB";
643
589
 
 
590
/*************************************************************//**
 
591
Check for a valid value of innobase_commit_concurrency.
 
592
@return 0 for valid innodb_commit_concurrency */
 
593
static
 
594
int
 
595
innobase_commit_concurrency_validate(
 
596
/*=================================*/
 
597
  Session*      , /*!< in: thread handle */
 
598
  drizzle_sys_var*  , /*!< in: pointer to system
 
599
            variable */
 
600
  void*       save, /*!< out: immediate result
 
601
            for update function */
 
602
  drizzle_value*    value)  /*!< in: incoming string */
 
603
{
 
604
  int64_t   intbuf;
 
605
  ulong   commit_concurrency;
 
606
 
 
607
  if (value->val_int(value, &intbuf)) {
 
608
    /* The value is NULL. That is invalid. */
 
609
    return(1);
 
610
  }
 
611
 
 
612
  *reinterpret_cast<ulong*>(save) = commit_concurrency
 
613
    = static_cast<ulong>(intbuf);
 
614
 
 
615
  /* Allow the value to be updated, as long as it remains zero
 
616
  or nonzero. */
 
617
  return(!(!commit_concurrency == !innobase_commit_concurrency));
 
618
}
 
619
 
 
620
static DRIZZLE_SessionVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG,
 
621
  "Enable InnoDB support for the XA two-phase commit",
 
622
  /* check_func */ NULL, /* update_func */ NULL,
 
623
  /* default */ TRUE);
 
624
 
 
625
static DRIZZLE_SessionVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
 
626
  "Enable InnoDB locking in LOCK TABLES",
 
627
  /* check_func */ NULL, /* update_func */ NULL,
 
628
  /* default */ TRUE);
 
629
 
 
630
static DRIZZLE_SessionVAR_BOOL(strict_mode, PLUGIN_VAR_OPCMDARG,
 
631
  "Use strict mode when evaluating create options.",
 
632
  NULL, NULL, FALSE);
 
633
 
 
634
static DRIZZLE_SessionVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
 
635
  "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
 
636
  NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
 
637
 
644
638
 
645
639
/*****************************************************************//**
646
640
Commits a transaction in an InnoDB database. */
907
901
ibool
908
902
thd_supports_xa(
909
903
/*============*/
910
 
  void* )  /*!< in: thread handle (Session*), or NULL to query
 
904
  void* session)  /*!< in: thread handle (Session*), or NULL to query
911
905
        the global innodb_supports_xa */
912
906
{
913
 
  /* TODO: Add support here for per-session value */
914
 
  return(support_xa);
 
907
  return(SessionVAR((Session*) session, support_xa));
915
908
}
916
909
 
917
910
/******************************************************************//**
921
914
ulong
922
915
thd_lock_wait_timeout(
923
916
/*==================*/
924
 
  void*)  /*!< in: thread handle (Session*), or NULL to query
 
917
  void* session)  /*!< in: thread handle (Session*), or NULL to query
925
918
      the global innodb_lock_wait_timeout */
926
919
{
927
 
  /* TODO: Add support here for per-session value */
928
920
  /* According to <drizzle/plugin.h>, passing session == NULL
929
921
  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
 
        }
 
922
  return(SessionVAR((Session*) session, lock_wait_timeout));
945
923
}
946
924
 
947
925
/********************************************************************//**
956
934
  return *(trx_t**) session->getEngineData(innodb_engine_ptr);
957
935
}
958
936
 
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
937
/********************************************************************//**
979
938
Call this function when mysqld passes control to the client. That is to
980
939
avoid deadlocks on the adaptive hash S-latch possibly held by session. For more
1039
998
  case DB_INTERRUPTED:
1040
999
    my_error(ER_QUERY_INTERRUPTED, MYF(0));
1041
1000
    /* 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
1001
  case DB_ERROR:
1055
1002
  default:
1056
1003
    return(-1); /* unspecified error */
1177
1124
           use the default max length */
1178
1125
{
1179
1126
  Session *session= reinterpret_cast<Session *>(in_session);
1180
 
  drizzled::identifier::User::const_shared_ptr user_identifier(session->user());
1181
 
 
1182
1127
  fprintf(f,
1183
1128
          "Drizzle thread %"PRIu64", query id %"PRIu64", %s, %s, %s ",
1184
1129
          static_cast<uint64_t>(session->getSessionId()),
1185
1130
          static_cast<uint64_t>(session->getQueryId()),
1186
1131
          glob_hostname,
1187
 
          user_identifier->address().c_str(),
1188
 
          user_identifier->username().c_str()
 
1132
          session->getSecurityContext().getIp().c_str(),
 
1133
          session->getSecurityContext().getUser().c_str()
1189
1134
  );
1190
1135
  fprintf(f, "\n%s", session->getQueryString()->c_str());
1191
1136
  putc('\n', f);
1210
1155
  if (cs) {
1211
1156
    *mbminlen = cs->mbminlen;
1212
1157
    *mbmaxlen = cs->mbmaxlen;
1213
 
    ut_ad(*mbminlen < DATA_MBMAX);
1214
 
    ut_ad(*mbmaxlen < DATA_MBMAX);
1215
1158
  } else {
1216
1159
    ut_a(cset == 0);
1217
1160
    *mbminlen = *mbmaxlen = 0;
1301
1244
 
1302
1245
/**********************************************************************//**
1303
1246
Determines the current SQL statement.
1304
 
@return        SQL statement string */
 
1247
@return SQL statement string */
1305
1248
extern "C" UNIV_INTERN
1306
1249
const char*
1307
1250
innobase_get_stmt(
1308
1251
/*==============*/
1309
 
       void*   session,        /*!< in: MySQL thread handle */
1310
 
       size_t* length)         /*!< out: length of the SQL statement */
 
1252
        void*   session,        /*!< in: MySQL thread handle */
 
1253
        size_t* length)         /*!< out: length of the SQL statement */
1311
1254
{
1312
1255
  return static_cast<Session*>(session)->getQueryStringCopy(*length);
1313
1256
}
1818
1761
/*==========*/
1819
1762
        trx_t*  trx)    /*!< in: transaction */
1820
1763
{
1821
 
        return(trx && trx->mysql_thd
1822
 
               && true);
 
1764
  return(trx && trx->mysql_thd && true);
1823
1765
}
1824
1766
 
1825
1767
/**************************************************************//**
1841
1783
  value= value - (value % align_val);
1842
1784
}
1843
1785
 
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
1786
/*********************************************************************//**
2043
1787
Opens an InnoDB database.
2044
1788
@return 0 on success, error code on failure */
2054
1798
  InnobaseEngine *actuall_engine_ptr;
2055
1799
  const module::option_map &vm= context.getOptions();
2056
1800
 
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
1801
  /* Inverted Booleans */
2074
1802
 
2075
1803
  innobase_use_checksums= (vm.count("disable-checksums")) ? false : true;
2076
1804
  innobase_use_doublewrite= (vm.count("disable-doublewrite")) ? false : true;
2077
1805
  srv_adaptive_flushing= (vm.count("disable-adaptive-flushing")) ? false : true;
2078
1806
  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 */
 
1807
  (SessionVAR(NULL,support_xa))= (vm.count("disable-xa")) ? false : true;
 
1808
  (SessionVAR(NULL,table_locks))= (vm.count("disable-table-locks")) ? false : true;
 
1809
 
 
1810
  if (vm.count("io-capacity"))
 
1811
  {
 
1812
    if (srv_io_capacity < 100)
 
1813
    {
 
1814
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for io-capacity\n"));
 
1815
      exit(-1);
 
1816
    }
 
1817
  }
 
1818
 
2084
1819
  if (vm.count("data-home-dir"))
2085
1820
  {
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
 
 
 
1821
    innobase_data_home_dir= strdup(vm["data-home-dir"].as<string>().c_str());
 
1822
  }
 
1823
  else
 
1824
  {
 
1825
    innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
 
1826
  }
 
1827
 
 
1828
  if (vm.count("fast-shutdown"))
 
1829
  {
 
1830
    if (innobase_fast_shutdown > 2)
 
1831
    {
 
1832
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for fast-shutdown\n"));
 
1833
      exit(-1);
 
1834
    }
 
1835
  }
 
1836
 
 
1837
  if (vm.count("file-format-check"))
 
1838
  {
 
1839
    innobase_file_format_check= const_cast<char *>(vm["file-format-check"].as<string>().c_str());
 
1840
  }
 
1841
 
 
1842
  if (vm.count("flush-log-at-trx-commit"))
 
1843
  {
 
1844
    if (srv_flush_log_at_trx_commit > 2)
 
1845
    {
 
1846
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for flush-log-at-trx-commit\n"));
 
1847
      exit(-1);
 
1848
    }
 
1849
  }
 
1850
 
 
1851
  if (vm.count("flush-method"))
 
1852
  {
 
1853
    innobase_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
 
1854
  }
 
1855
  else
 
1856
  {
 
1857
    innobase_file_flush_method= NULL;
 
1858
  }
 
1859
 
 
1860
#ifdef UNIV_LOG_ARCHIVE
 
1861
  if (vm.count("log-arch-dir"))
 
1862
  {
 
1863
    innobase_log_arch_dir= const_cast<char *>(vm["log-arch-dir"].as<string>().c_str());
 
1864
  }
 
1865
 
 
1866
  else
 
1867
  {
 
1868
    innobase_log_arch_dir= NULL;
 
1869
  }
 
1870
#endif /* UNIV_LOG_ARCHIVE */
 
1871
 
 
1872
  if (vm.count("max-dirty-pages-pct"))
 
1873
  {
 
1874
    if (srv_max_buf_pool_modified_pct > 99)
 
1875
    {
 
1876
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-dirty-pages-pct\n"));
 
1877
      exit(-1);
 
1878
    }
 
1879
  }
 
1880
 
 
1881
  if (vm.count("stats-sample-pages"))
 
1882
  {
 
1883
    if (srv_stats_sample_pages < 8)
 
1884
    {
 
1885
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for stats-sample-pages\n"));
 
1886
      exit(-1);
 
1887
    }
 
1888
  }
 
1889
 
 
1890
  if (vm.count("additional-mem-pool-size"))
 
1891
  {
 
1892
    align_value(innobase_additional_mem_pool_size);
 
1893
 
 
1894
    if (innobase_additional_mem_pool_size < 512*1024L)
 
1895
    {
 
1896
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for additional-mem-pool-size\n"));
 
1897
      exit(-1);
 
1898
    }
 
1899
 
 
1900
  }
 
1901
 
 
1902
  if (vm.count("autoextend-increment"))
 
1903
  {
 
1904
    if (srv_auto_extend_increment < 1 || srv_auto_extend_increment > 1000)
 
1905
    {
 
1906
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for autoextend-increment\n"));
 
1907
      exit(-1);
 
1908
    }
 
1909
  }
 
1910
 
 
1911
  if (vm.count("buffer-pool-size"))
 
1912
  {
 
1913
    align_value(innobase_buffer_pool_size, 1024*1024);
 
1914
    if (innobase_buffer_pool_size < 5*1024*1024)
 
1915
    {
 
1916
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer-pool-size\n"));
 
1917
      exit(-1);
 
1918
    }
 
1919
    
 
1920
  }
 
1921
 
 
1922
  if (vm.count("commit-concurrency"))
 
1923
  {
 
1924
    if (srv_replication_delay > 1000)
 
1925
    {
 
1926
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for commit-concurrency\n"));
 
1927
      exit(-1);
 
1928
    }
 
1929
  }
 
1930
 
 
1931
  if (vm.count("concurrency-tickets"))
 
1932
  {
 
1933
    if (srv_n_free_tickets_to_enter < 1)
 
1934
    {
 
1935
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for concurrency-tickets\n"));
 
1936
      exit(-1);
 
1937
    }
 
1938
  }
 
1939
 
 
1940
  if (vm.count("read-io-threads"))
 
1941
  {
 
1942
    if (innobase_read_io_threads < 1 || innobase_read_io_threads > 64)
 
1943
    {
 
1944
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-io-threads\n"));
 
1945
      exit(-1);
 
1946
    }
 
1947
  }
 
1948
 
 
1949
  if (vm.count("write-io-threads"))
 
1950
  {
 
1951
    if (innobase_write_io_threads < 1 || innobase_write_io_threads > 64)
 
1952
    {
 
1953
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write-io-threads\n"));
 
1954
      exit(-1);
 
1955
    }
 
1956
  }
 
1957
 
 
1958
  if (vm.count("force-recovery"))
 
1959
  {
 
1960
    if (innobase_force_recovery > 6)
 
1961
    {
 
1962
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for force-recovery\n"));
 
1963
      exit(-1);
 
1964
    }
 
1965
  }
 
1966
 
 
1967
  if (vm.count("log-buffer-size"))
 
1968
  {
 
1969
    align_value(innobase_log_buffer_size);
 
1970
    if (innobase_log_buffer_size < 256*1024L)
 
1971
    {
 
1972
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
 
1973
      exit(-1);
 
1974
    }
 
1975
  }
 
1976
 
 
1977
  if (vm.count("log-file-size"))
 
1978
  {
 
1979
    align_value(innobase_log_file_size, 1024*1024);
 
1980
    if (innobase_log_file_size < 1*1024*1024L)
 
1981
    {
 
1982
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-file-size\n"));
 
1983
      exit(-1);
 
1984
    }
 
1985
  }
 
1986
 
 
1987
  if (vm.count("log-files-in-group"))
 
1988
  {
 
1989
    if (innobase_log_files_in_group < 2 || innobase_log_files_in_group > 100)
 
1990
    {
 
1991
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for log-files-in-group\n"));
 
1992
      exit(-1);
 
1993
    }
 
1994
  }
 
1995
 
 
1996
  if (vm.count("mirrored-log-groups"))
 
1997
  {
 
1998
    if (innobase_mirrored_log_groups < 1 || innobase_mirrored_log_groups > 10)
 
1999
    {
 
2000
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for mirrored-log-groups\n"));
 
2001
      exit(-1);
 
2002
    }
 
2003
  }
 
2004
 
 
2005
  if (vm.count("open-files"))
 
2006
  {
 
2007
    if (innobase_open_files < 10)
 
2008
    {
 
2009
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for open-files\n"));
 
2010
      exit(-1);
 
2011
    }
 
2012
  }
 
2013
 
 
2014
  if (vm.count("thread-concurrency"))
 
2015
  {
 
2016
    if (srv_thread_concurrency > 1000)
 
2017
    {
 
2018
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for thread-concurrency\n"));
 
2019
      exit(-1);
 
2020
    }
 
2021
  }
2093
2022
 
2094
2023
  if (vm.count("data-file-path"))
2095
2024
  {
2096
 
    innobase_data_file_path= vm["data-file-path"].as<string>();
2097
 
  }
2098
 
 
 
2025
    innobase_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
 
2026
  }
 
2027
  else
 
2028
  {
 
2029
    innobase_data_file_path= NULL;
 
2030
  }
 
2031
 
 
2032
  if (vm.count("version"))
 
2033
  {
 
2034
    innodb_version_str= const_cast<char *>(vm["version"].as<string>().c_str());
 
2035
  }
 
2036
 
 
2037
  if (vm.count("read-ahead-threshold"))
 
2038
  {
 
2039
    if (srv_read_ahead_threshold > 64)
 
2040
    {
 
2041
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read-ahead-threshold\n"));
 
2042
      exit(-1);
 
2043
    }
 
2044
  }
 
2045
 
 
2046
  if (vm.count("strict-mode"))
 
2047
  {
 
2048
    (SessionVAR(NULL,strict_mode))= vm["strict-mode"].as<bool>();
 
2049
  }
 
2050
 
 
2051
  if (vm.count("lock-wait-timeout"))
 
2052
  {
 
2053
    if (vm["lock-wait-timeout"].as<unsigned long>() < 1 || vm["lock-wait-timeout"].as<unsigned long>() > 1024*1024*1024)
 
2054
    {
 
2055
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for lock-wait-timeout\n"));
 
2056
      exit(-1);
 
2057
    }
 
2058
 
 
2059
    (SessionVAR(NULL,lock_wait_timeout))= vm["lock-wait-timeout"].as<unsigned long>();
 
2060
  }
2099
2061
 
2100
2062
  innodb_engine_ptr= actuall_engine_ptr= new InnobaseEngine(innobase_engine_name);
2101
2063
 
2119
2081
  }
2120
2082
#endif /* UNIV_DEBUG */
2121
2083
 
 
2084
  /* Check that values don't overflow on 32-bit systems. */
 
2085
  if (sizeof(ulint) == 4) {
 
2086
    if (innobase_buffer_pool_size > UINT32_MAX) {
 
2087
      errmsg_printf(ERRMSG_LVL_ERROR, 
 
2088
                    "innobase_buffer_pool_size can't be over 4GB"
 
2089
                    " on 32-bit systems");
 
2090
 
 
2091
      goto error;
 
2092
    }
 
2093
 
 
2094
    if (innobase_log_file_size > UINT32_MAX) {
 
2095
      errmsg_printf(ERRMSG_LVL_ERROR, 
 
2096
                    "innobase_log_file_size can't be over 4GB"
 
2097
                    " on 32-bit systems");
 
2098
 
 
2099
      goto error;
 
2100
    }
 
2101
  }
 
2102
 
2122
2103
  os_innodb_umask = (ulint)internal::my_umask;
2123
2104
 
2124
2105
 
2129
2110
 
2130
2111
  /* The default dir for data files is the datadir of MySQL */
2131
2112
 
2132
 
  srv_data_home = (char *)innobase_data_home_dir.c_str();
 
2113
  srv_data_home = (char *)innobase_data_home_dir;
2133
2114
 
2134
2115
  /* Set default InnoDB data file size to 10 MB and let it be
2135
2116
    auto-extending. Thus users can use InnoDB in >= 4.0 without having
2136
2117
    to specify any startup options. */
2137
2118
 
2138
 
  if (innobase_data_file_path.empty()) 
2139
 
  {
2140
 
    innobase_data_file_path= std::string("ibdata1:10M:autoextend");
 
2119
  if (!innobase_data_file_path) {
 
2120
    innobase_data_file_path = (char*) "ibdata1:10M:autoextend";
2141
2121
  }
2142
2122
 
2143
2123
  /* Since InnoDB edits the argument in the next call, we make another
2144
2124
    copy of it: */
2145
2125
 
2146
 
  internal_innobase_data_file_path = strdup(innobase_data_file_path.c_str());
 
2126
  internal_innobase_data_file_path = strdup(innobase_data_file_path);
2147
2127
 
2148
2128
  ret = (bool) srv_parse_data_file_paths_and_sizes(
2149
2129
                                                   internal_innobase_data_file_path);
2163
2143
 
2164
2144
  if (vm.count("log-group-home-dir"))
2165
2145
  {
2166
 
    innobase_log_group_home_dir= vm["log-group-home-dir"].as<string>();
 
2146
    innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str());
2167
2147
  }
2168
2148
  else
2169
2149
  {
2170
 
    innobase_log_group_home_dir= getDataHome().file_string();
 
2150
    innobase_log_group_home_dir = strdup(getDataHome().file_string().c_str());
2171
2151
  }
2172
2152
 
 
2153
#ifdef UNIV_LOG_ARCHIVE
 
2154
  /* Since innodb_log_arch_dir has no relevance under MySQL,
 
2155
    starting from 4.0.6 we always set it the same as
 
2156
innodb_log_group_home_dir: */
 
2157
 
 
2158
  innobase_log_arch_dir = innobase_log_group_home_dir;
 
2159
 
 
2160
  srv_arch_dir = innobase_log_arch_dir;
 
2161
#endif /* UNIG_LOG_ARCHIVE */
 
2162
 
2173
2163
  ret = (bool)
2174
 
    srv_parse_log_group_home_dirs((char *)innobase_log_group_home_dir.c_str());
 
2164
    srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
2175
2165
 
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"));
 
2166
  if (ret == FALSE || innobase_mirrored_log_groups != 1) {
 
2167
    errmsg_printf(ERRMSG_LVL_ERROR, "syntax error in innodb_log_group_home_dir, or a "
 
2168
                  "wrong number of mirrored log groups");
2180
2169
 
2181
2170
    goto mem_free_and_error;
2182
2171
  }
2201
2190
 
2202
2191
  srv_file_format = format_id;
2203
2192
 
2204
 
  innobase_file_format_name =
2205
 
    trx_sys_file_format_id_to_name(format_id);
2206
 
 
2207
 
  /* Check innobase_file_format_check variable */
2208
 
  if (!innobase_file_format_check)
2209
 
  {
2210
 
    /* Set the value to disable checking. */
2211
 
    srv_max_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
2212
 
  } else {
2213
 
    /* Set the value to the lowest supported format. */
2214
 
    srv_max_file_format_at_startup = DICT_TF_FORMAT_MIN;
2215
 
  }
2216
 
 
2217
 
  /* Did the user specify a format name that we support?
2218
 
     As a side effect it will update the variable
2219
 
     srv_max_file_format_at_startup */
2220
 
  if (innobase_file_format_validate_and_set(innobase_file_format_max.c_str()) < 0)
2221
 
  {
2222
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("InnoDB: invalid "
2223
 
                    "innodb_file_format_max value: "
2224
 
                    "should be any value up to %s or its "
2225
 
                    "equivalent numeric id"),
2226
 
                    trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
2227
 
    goto mem_free_and_error;
 
2193
  /* Given the type of innobase_file_format_name we have little
 
2194
    choice but to cast away the constness from the returned name.
 
2195
    innobase_file_format_name is used in the MySQL set variable
 
2196
    interface and so can't be const. */
 
2197
 
 
2198
  innobase_file_format_name = 
 
2199
    (char*) trx_sys_file_format_id_to_name(format_id);
 
2200
 
 
2201
  /* Process innobase_file_format_check variable */
 
2202
  ut_a(innobase_file_format_check != NULL);
 
2203
 
 
2204
  /* As a side effect it will set srv_check_file_format_at_startup
 
2205
    on valid input. First we check for "on"/"off". */
 
2206
  if (!innobase_file_format_check_on_off(innobase_file_format_check)) {
 
2207
 
 
2208
    /* Did the user specify a format name that we support ?
 
2209
      As a side effect it will update the variable
 
2210
      srv_check_file_format_at_startup */
 
2211
    if (innobase_file_format_validate_and_set(
 
2212
                                innobase_file_format_check) < 0) {
 
2213
      errmsg_printf(ERRMSG_LVL_ERROR, "InnoDB: invalid "
 
2214
                    "innodb_file_format_check value: "
 
2215
                    "should be either 'on' or 'off' or "
 
2216
                    "any value up to %s or its "
 
2217
                    "equivalent numeric id",
 
2218
                    trx_sys_file_format_id_to_name(
 
2219
                                                   DICT_TF_FORMAT_MAX));
 
2220
 
 
2221
      goto mem_free_and_error;
 
2222
    }
2228
2223
  }
2229
2224
 
2230
2225
  if (vm.count("change-buffering"))
2235
2230
         use < UT_ARR_SIZE(innobase_change_buffering_values);
2236
2231
         use++) {
2237
2232
      if (!innobase_strcasecmp(
2238
 
                               innobase_change_buffering.c_str(),
 
2233
                               vm["change-buffering"].as<string>().c_str(),
2239
2234
                               innobase_change_buffering_values[use])) {
2240
 
        ibuf_use = static_cast<ibuf_use_t>(use);
 
2235
        ibuf_use = (ibuf_use_t) use;
2241
2236
        goto innobase_change_buffering_inited_ok;
2242
2237
      }
2243
2238
    }
2244
2239
 
2245
2240
    errmsg_printf(ERRMSG_LVL_ERROR,
2246
2241
                  "InnoDB: invalid value "
2247
 
                  "innodb_change_buffering=%s",
 
2242
                  "innodb_file_format_check=%s",
2248
2243
                  vm["change-buffering"].as<string>().c_str());
2249
2244
    goto mem_free_and_error;
2250
2245
  }
2251
2246
 
2252
2247
innobase_change_buffering_inited_ok:
2253
2248
  ut_a((ulint) ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
2254
 
  innobase_change_buffering = innobase_change_buffering_values[ibuf_use];
 
2249
  innobase_change_buffering = (char*)
 
2250
    innobase_change_buffering_values[ibuf_use];
2255
2251
 
2256
2252
  /* --------------------------------------------------*/
2257
2253
 
2258
 
  if (vm.count("flush-method") != 0)
2259
 
  {
2260
 
    srv_file_flush_method_str = (char *)vm["flush-method"].as<string>().c_str();
2261
 
  }
 
2254
  srv_file_flush_method_str = innobase_file_flush_method;
2262
2255
 
2263
2256
  srv_n_log_groups = (ulint) innobase_mirrored_log_groups;
2264
2257
  srv_n_log_files = (ulint) innobase_log_files_in_group;
2265
2258
  srv_log_file_size = (ulint) innobase_log_file_size;
2266
2259
 
 
2260
#ifdef UNIV_LOG_ARCHIVE
 
2261
  srv_log_archive_on = (ulint) innobase_log_archive;
 
2262
#endif /* UNIV_LOG_ARCHIVE */
2267
2263
  srv_log_buffer_size = (ulint) innobase_log_buffer_size;
2268
2264
 
2269
2265
  srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
2270
 
  srv_buf_pool_instances = (ulint) innobase_buffer_pool_instances;
2271
2266
 
2272
2267
  srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
2273
2268
 
2298
2293
 
2299
2294
  data_mysql_default_charset_coll = (ulint)default_charset_info->number;
2300
2295
 
 
2296
  innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct,
 
2297
                                                     FALSE);
 
2298
 
 
2299
  innobase_commit_concurrency_init_default();
 
2300
 
2301
2301
  /* Since we in this module access directly the fields of a trx
2302
2302
    struct, and due to different headers and flags it might happen that
2303
2303
    mutex_t has a different size in this module and in InnoDB
2306
2306
 
2307
2307
  err = innobase_start_or_create_for_mysql();
2308
2308
 
2309
 
  if (err != DB_SUCCESS)
2310
 
  {
2311
 
    goto mem_free_and_error;
2312
 
  }
2313
 
 
2314
 
  err = dict_create_sys_replication_log();
2315
 
 
2316
2309
  if (err != DB_SUCCESS) {
2317
2310
    goto mem_free_and_error;
2318
2311
  }
2319
2312
 
2320
 
 
2321
 
  innobase_old_blocks_pct = buf_LRU_old_ratio_update(innobase_old_blocks_pct.get(),
2322
 
                                                     TRUE);
2323
 
 
2324
2313
  innobase_open_tables = hash_create(200);
2325
2314
  pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
2326
2315
  pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
2358
2347
  innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
2359
2348
  context.add(innodb_lock_waits_tool);
2360
2349
 
2361
 
  innodb_sys_tables_tool= new(std::nothrow)InnodbSysTablesTool();
2362
 
  context.add(innodb_sys_tables_tool);
2363
 
 
2364
 
  innodb_sys_tablestats_tool= new(std::nothrow)InnodbSysTableStatsTool();
2365
 
  context.add(innodb_sys_tablestats_tool);
2366
 
 
2367
 
  innodb_sys_indexes_tool= new(std::nothrow)InnodbSysIndexesTool();
2368
 
  context.add(innodb_sys_indexes_tool);
2369
 
 
2370
 
  innodb_sys_columns_tool= new(std::nothrow)InnodbSysColumnsTool();
2371
 
  context.add(innodb_sys_columns_tool);
2372
 
 
2373
 
  innodb_sys_fields_tool= new(std::nothrow)InnodbSysFieldsTool();
2374
 
  context.add(innodb_sys_fields_tool);
2375
 
 
2376
 
  innodb_sys_foreign_tool= new(std::nothrow)InnodbSysForeignTool();
2377
 
  context.add(innodb_sys_foreign_tool);
2378
 
 
2379
 
  innodb_sys_foreign_cols_tool= new(std::nothrow)InnodbSysForeignColsTool();
2380
 
  context.add(innodb_sys_foreign_cols_tool);
2381
 
 
2382
2350
  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));
 
2351
 
2473
2352
  /* 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);
 
2353
  innobase_file_format_check = (char*) trx_sys_file_format_max_get();
2476
2354
 
2477
2355
  return(FALSE);
2478
2356
error:
2581
2459
    Note, the position is current because of
2582
2460
    prepare_commit_mutex */
2583
2461
retry:
2584
 
    if (innobase_commit_concurrency.get() > 0) {
 
2462
    if (innobase_commit_concurrency > 0) {
2585
2463
      pthread_mutex_lock(&commit_cond_m);
2586
2464
      commit_threads++;
2587
2465
 
2588
 
      if (commit_threads > innobase_commit_concurrency.get()) {
 
2466
      if (commit_threads > innobase_commit_concurrency) {
2589
2467
        commit_threads--;
2590
2468
        pthread_cond_wait(&commit_cond,
2591
2469
          &commit_cond_m);
2610
2488
    innobase_commit_low(trx);
2611
2489
    trx->flush_log_later = FALSE;
2612
2490
 
2613
 
    if (innobase_commit_concurrency.get() > 0) {
 
2491
    if (innobase_commit_concurrency > 0) {
2614
2492
      pthread_mutex_lock(&commit_cond_m);
2615
2493
      commit_threads--;
2616
2494
      pthread_cond_signal(&commit_cond);
2857
2735
  /* Warn if rolling back some things... */
2858
2736
  if (session->getKilled() != Session::NOT_KILLED &&
2859
2737
      trx->conc_state != TRX_NOT_STARTED &&
2860
 
      trx->undo_no > 0 &&
 
2738
      trx->undo_no.low > 0 &&
2861
2739
      global_system_variables.log_warnings)
2862
2740
  {
2863
 
      errmsg_printf(ERRMSG_LVL_WARN,
 
2741
      errmsg_printf(ERRMSG_LVL_WARN, 
2864
2742
      "Drizzle is closing a connection during a KILL operation\n"
2865
 
      "that has an active InnoDB transaction.  %llu row modifications will "
 
2743
      "that has an active InnoDB transaction.  %lu row modifications will "
2866
2744
      "roll back.\n",
2867
 
      (ullint) trx->undo_no);
 
2745
      (ulong) trx->undo_no.low);
2868
2746
  }
2869
2747
 
2870
2748
  innobase_rollback_trx(trx);
3119
2997
        dict_index_t**  index_mapping;
3120
2998
        ibool           ret = TRUE;
3121
2999
 
3122
 
        mutex_enter(&dict_sys->mutex);
3123
 
 
3124
3000
        mysql_num_index = table->getShare()->keys;
3125
3001
        ib_num_index = UT_LIST_GET_LEN(ib_table->indexes);
3126
3002
 
3150
3026
                                                         sizeof(*index_mapping));
3151
3027
 
3152
3028
                if (!index_mapping) {
3153
 
                        /* Report an error if index_mapping continues to be
3154
 
                        NULL and mysql_num_index is a non-zero value */
3155
 
                        errmsg_printf(ERRMSG_LVL_ERROR,
3156
 
                                      "InnoDB: fail to allocate memory for "
3157
 
                                        "index translation table. Number of "
3158
 
                                        "Index:%lu, array size:%lu",
3159
 
                                        mysql_num_index,
3160
 
                                        share->idx_trans_tbl.array_size);
3161
3029
                        ret = FALSE;
3162
3030
                        goto func_exit;
3163
3031
                }
3165
3033
                share->idx_trans_tbl.array_size = mysql_num_index;
3166
3034
        }
3167
3035
 
 
3036
 
3168
3037
        /* For each index in the mysql key_info array, fetch its
3169
3038
        corresponding InnoDB index pointer into index_mapping
3170
3039
        array. */
3210
3079
 
3211
3080
        share->idx_trans_tbl.index_mapping = index_mapping;
3212
3081
 
3213
 
        mutex_exit(&dict_sys->mutex);
3214
 
 
3215
3082
        return(ret);
3216
3083
}
3217
3084
 
3298
3165
    err = row_search_max_autoinc(index, col_name, &read_auto_inc);
3299
3166
 
3300
3167
    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
 
 
 
3168
    case DB_SUCCESS:
3306
3169
      /* 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
 
 
 
3170
         or the offset, so use a default increment of 1. */
 
3171
      auto_inc = read_auto_inc + 1;
3311
3172
      break;
3312
 
    }
 
3173
 
3313
3174
    case DB_RECORD_NOT_FOUND:
3314
3175
      ut_print_timestamp(stderr);
3315
3176
      fprintf(stderr, "  InnoDB: MySQL and InnoDB data "
3582
3443
    /* We update the highest file format in the system table
3583
3444
    space, if this table has higher file format setting. */
3584
3445
 
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,
 
3446
    trx_sys_file_format_max_upgrade(
 
3447
      (const char**) &innobase_file_format_check,
3588
3448
      dict_table_get_format(prebuilt->table));
3589
 
    innobase_file_format_max= changed_file_format_max;
3590
3449
  }
3591
3450
 
 
3451
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
 
3452
 
3592
3453
  /* Only if the table has an AUTOINC column. */
3593
3454
  if (prebuilt->table != NULL && getTable()->found_next_number_field != NULL) {
3594
3455
 
3606
3467
    dict_table_autoinc_unlock(prebuilt->table);
3607
3468
  }
3608
3469
 
3609
 
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
3610
 
 
3611
3470
  return(0);
3612
3471
}
3613
3472
 
3855
3714
  case DRIZZLE_TYPE_DATETIME:
3856
3715
  case DRIZZLE_TYPE_DATE:
3857
3716
  case DRIZZLE_TYPE_TIMESTAMP:
3858
 
  case DRIZZLE_TYPE_ENUM:
3859
3717
    return(DATA_INT);
3860
3718
  case DRIZZLE_TYPE_DOUBLE:
3861
3719
    return(DATA_DOUBLE);
3862
3720
  case DRIZZLE_TYPE_BLOB:
3863
 
    return(DATA_BLOB);
3864
 
  case DRIZZLE_TYPE_UUID:
3865
 
    return(DATA_FIXBINARY);
3866
 
  case DRIZZLE_TYPE_NULL:
 
3721
                return(DATA_BLOB);
 
3722
  default:
3867
3723
    ut_error;
3868
3724
  }
3869
3725
 
4103
3959
      ulint     key_len;
4104
3960
      const unsigned char*    src_start;
4105
3961
      enum_field_types  real_type;
4106
 
      const CHARSET_INFO* cs= field->charset();
4107
3962
 
4108
3963
      key_len = key_part->length;
4109
3964
 
4125
3980
      memcpy(buff, src_start, true_len);
4126
3981
      buff += true_len;
4127
3982
 
4128
 
      /* Pad the unused space with spaces. */
 
3983
      /* Pad the unused space with spaces. Note that no
 
3984
      padding is ever needed for UCS-2 because in MySQL,
 
3985
      all UCS2 characters are 2 bytes, as MySQL does not
 
3986
      support surrogate pairs, which are needed to represent
 
3987
      characters in the range U+10000 to U+10FFFF. */
4129
3988
 
4130
3989
      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 */);
 
3990
        ulint pad_len = key_len - true_len;
 
3991
        memset(buff, ' ', pad_len);
4136
3992
        buff += pad_len;
4137
3993
      }
4138
3994
    }
4240
4096
 
4241
4097
  /* Note that in InnoDB, i is the column number. MySQL calls columns
4242
4098
  'fields'. */
4243
 
  for (i = 0; i < n_fields; i++)
 
4099
  for (i = 0; i < n_fields; i++) 
4244
4100
  {
4245
 
    const dict_col_t *col= &index->table->cols[i];
4246
4101
    templ = prebuilt->mysql_template + n_requested_fields;
4247
4102
    field = table->getField(i);
4248
4103
 
4290
4145
    templ->col_no = i;
4291
4146
 
4292
4147
    if (index == clust_index) {
4293
 
      templ->rec_field_no = dict_col_get_clust_pos(col, index);
 
4148
      templ->rec_field_no = dict_col_get_clust_pos(
 
4149
        &index->table->cols[i], index);
4294
4150
    } else {
4295
4151
      templ->rec_field_no = dict_index_get_nth_col_pos(
4296
4152
                index, i);
4319
4175
      mysql_prefix_len = templ->mysql_col_offset
4320
4176
        + templ->mysql_col_len;
4321
4177
    }
4322
 
    templ->type = col->mtype;
 
4178
    templ->type = index->table->cols[i].mtype;
4323
4179
    templ->mysql_type = (ulint)field->type();
4324
4180
 
4325
4181
    if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
4327
4183
        (((Field_varstring*)field)->pack_length_no_ptr());
4328
4184
    }
4329
4185
 
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;
 
4186
    templ->charset = dtype_get_charset_coll(
 
4187
      index->table->cols[i].prtype);
 
4188
    templ->mbminlen = index->table->cols[i].mbminlen;
 
4189
    templ->mbmaxlen = index->table->cols[i].mbmaxlen;
 
4190
    templ->is_unsigned = index->table->cols[i].prtype
 
4191
              & DATA_UNSIGNED;
4334
4192
    if (templ->type == DATA_BLOB) {
4335
4193
      prebuilt->templ_contains_blob = TRUE;
4336
4194
    }
4548
4406
 
4549
4407
  error = row_insert_for_mysql((byte*) record, prebuilt);
4550
4408
 
4551
 
  user_session->setXaId(trx->id);
 
4409
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4552
4410
 
4553
4411
  /* Handle duplicate key errors */
4554
4412
  if (auto_inc_used) {
4871
4729
 
4872
4730
  error = row_update_for_mysql((byte*) old_row, prebuilt);
4873
4731
 
4874
 
  user_session->setXaId(trx->id);
 
4732
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4875
4733
 
4876
4734
  /* We need to do some special AUTOINC handling for the following case:
4877
4735
 
4963
4821
 
4964
4822
  error = row_update_for_mysql((byte*) record, prebuilt);
4965
4823
 
4966
 
  user_session->setXaId(trx->id);
 
4824
  user_session->setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
4967
4825
 
4968
4826
  innodb_srv_conc_exit_innodb(trx);
4969
4827
 
5223
5081
    return(HA_ERR_CRASHED);
5224
5082
  }
5225
5083
 
5226
 
  if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
5227
 
    return(HA_ERR_TABLE_DEF_CHANGED);
5228
 
  }
5229
5084
 
5230
5085
  /* Note that if the index for which the search template is built is not
5231
5086
  necessarily prebuilt->index, but can also be the clustered index */
5820
5675
 
5821
5676
    col_type = get_innobase_type_from_mysql_type(&unsigned_type,
5822
5677
                  field);
5823
 
 
5824
 
    if (!col_type) {
5825
 
      push_warning_printf(
5826
 
                          (Session*) trx->mysql_thd,
5827
 
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
5828
 
                          ER_CANT_CREATE_TABLE,
5829
 
                          "Error creating table '%s' with "
5830
 
                          "column '%s'. Please check its "
5831
 
                          "column type and try to re-create "
5832
 
                          "the table with an appropriate "
5833
 
                          "column type.",
5834
 
                          table->name, (char*) field->field_name);
5835
 
      goto err_col;
5836
 
    }
5837
 
 
5838
5678
    if (field->null_ptr) {
5839
5679
      nulls_allowed = 0;
5840
5680
    } else {
5892
5732
    if (dict_col_name_is_reserved(field->field_name)){
5893
5733
      my_error(ER_WRONG_COLUMN_NAME, MYF(0), field->field_name);
5894
5734
 
5895
 
  err_col:
5896
5735
      dict_mem_table_free(table);
5897
5736
      trx_commit_for_mysql(trx);
5898
5737
 
6234
6073
# error "DICT_TF_ZSSIZE_MAX < 1"
6235
6074
#endif
6236
6075
 
6237
 
    if (strict_mode)
 
6076
    if (SessionVAR(&session, strict_mode))
6238
6077
    {
6239
6078
      if (! srv_file_per_table)
6240
6079
      {
6281
6120
                          lex_identified_temp_table ? name2 : NULL,
6282
6121
                          iflags);
6283
6122
 
6284
 
  session.setXaId(trx->id);
 
6123
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6285
6124
 
6286
6125
  if (error) {
6287
6126
    goto cleanup;
6362
6201
    /* We update the highest file format in the system table
6363
6202
      space, if this table has higher file format setting. */
6364
6203
 
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;
 
6204
    trx_sys_file_format_max_upgrade((const char**) &innobase_file_format_check,
 
6205
                                    dict_table_get_format(innobase_table));
6370
6206
  }
6371
6207
 
6372
6208
  /* Note: We can't call update_session() as prebuilt will not be
6538
6374
                                   session_sql_command(&session)
6539
6375
                                   == SQLCOM_DROP_DB);
6540
6376
 
6541
 
  session.setXaId(trx->id);
 
6377
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6542
6378
 
6543
6379
  /* Flush the log to reduce probability that the .frm files and
6544
6380
    the InnoDB data dictionary get out-of-sync if the user runs
6760
6596
 
6761
6597
  error = innobase_rename_table(trx, from.getPath().c_str(), to.getPath().c_str(), TRUE);
6762
6598
 
6763
 
  session.setXaId(trx->id);
 
6599
  session.setXaId((ib_uint64_t) ut_conv_dulint_to_longlong(trx->id));
6764
6600
 
6765
6601
  /* Tell the InnoDB server that there might be work for
6766
6602
    utility threads: */
6848
6684
    goto func_exit;
6849
6685
  }
6850
6686
 
6851
 
  if (UNIV_UNLIKELY(!row_merge_is_index_usable(prebuilt->trx, index))) {
6852
 
    n_rows = HA_ERR_TABLE_DEF_CHANGED;
6853
 
    goto func_exit;
6854
 
  }
6855
 
 
6856
6687
  heap = mem_heap_create(2 * (key->key_parts * sizeof(dfield_t)
6857
6688
            + sizeof(dtuple_t)));
6858
6689
 
7049
6880
 
7050
6881
        /* If index does not belong to the table of share structure. Search
7051
6882
        index->table instead */
7052
 
        if (index->table != ib_table) {
7053
 
                i = 0;
7054
 
                ind = dict_table_get_first_index(index->table);
7055
 
 
7056
 
                while (index != ind) {
7057
 
                        ind = dict_table_get_next_index(ind);
7058
 
                        i++;
7059
 
                }
7060
 
 
7061
 
                if (row_table_got_default_clust_index(index->table)) {
7062
 
                        ut_a(i > 0);
7063
 
                        i--;
7064
 
                }
7065
 
 
7066
 
                return(i);
7067
 
        }
7068
 
 
7069
 
        /* If index does not belong to the table of share structure. Search
7070
 
        index->table instead */
7071
 
        if (index->table != ib_table) {
 
6883
        if (index->table != ib_table
 
6884
            && strcmp(index->table->name, share->table_name)) {
7072
6885
                i = 0;
7073
6886
                ind = dict_table_get_first_index(index->table);
7074
6887
 
7132
6945
  dict_index_t* index;
7133
6946
  ha_rows   rec_per_key;
7134
6947
  ib_int64_t  n_rows;
 
6948
  ulong   j;
 
6949
  ulong   i;
7135
6950
  os_file_stat_t  stat_info;
7136
6951
 
7137
6952
  /* If we are forcing recovery at a high level, we will suppress
7138
6953
  statistics calculation on tables, because that may crash the
7139
6954
  server if an index is badly corrupted. */
7140
6955
 
 
6956
  if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
 
6957
 
 
6958
    /* We return success (0) instead of HA_ERR_CRASHED,
 
6959
    because we want MySQL to process this query and not
 
6960
    stop, like it would do if it received the error code
 
6961
    HA_ERR_CRASHED. */
 
6962
 
 
6963
    return(0);
 
6964
  }
 
6965
 
7141
6966
  /* We do not know if MySQL can call this function before calling
7142
6967
  external_lock(). To be safe, update the session of the current table
7143
6968
  handle. */
7229
7054
    acquiring latches inside InnoDB, we do not call it if we
7230
7055
    are asked by MySQL to avoid locking. Another reason to
7231
7056
    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 {
 
7057
    See Bug#38185.
 
7058
    We do not update delete_length if no locking is requested
 
7059
    so the "old" value can remain. delete_length is initialized
 
7060
    to 0 in the ha_statistics' constructor. */
 
7061
    if (!(flag & HA_STATUS_NO_LOCK)) {
 
7062
 
7244
7063
      /* lock the data dictionary to avoid races with
7245
7064
      ibd_file_missing and tablespace_discarded */
7246
7065
      row_mysql_lock_data_dictionary(prebuilt->trx);
7286
7105
  }
7287
7106
 
7288
7107
  if (flag & HA_STATUS_CONST) {
7289
 
    ulong i;
7290
7108
    /* Verify the number of index in InnoDB and MySQL
7291
7109
       matches up. If prebuilt->clust_index_was_generated
7292
7110
       holds, InnoDB defines GEN_CLUST_INDEX internally */
7302
7120
    }
7303
7121
 
7304
7122
    for (i = 0; i < getTable()->getShare()->sizeKeys(); i++) {
7305
 
      ulong j;
7306
7123
      /* We could get index quickly through internal
7307
7124
         index mapping with the index translation table.
7308
7125
         The identity of index (match up index name with
7368
7185
    }
7369
7186
  }
7370
7187
 
7371
 
  if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
7372
 
    goto func_exit;
7373
 
  }
7374
 
 
7375
7188
  if (flag & HA_STATUS_ERRKEY) {
7376
7189
    const dict_index_t* err_index;
7377
7190
 
7393
7206
    stats.auto_increment_value = innobase_peek_autoinc();
7394
7207
  }
7395
7208
 
7396
 
func_exit:
7397
7209
  prebuilt->trx->op_info = (char*)"";
7398
7210
 
7399
7211
  return(0);
8094
7906
{
8095
7907
  trx_t*      trx;
8096
7908
  static const char truncated_msg[] = "... truncated...\n";
8097
 
  const long    MAX_STATUS_SIZE = 1048576;
 
7909
  const long    MAX_STATUS_SIZE = 64000;
8098
7910
  ulint     trx_list_start = ULINT_UNDEFINED;
8099
7911
  ulint     trx_list_end = ULINT_UNDEFINED;
8100
7912
 
8123
7935
 
8124
7936
  if (flen > MAX_STATUS_SIZE) {
8125
7937
    usable_len = MAX_STATUS_SIZE;
8126
 
    srv_truncated_status_writes++;
8127
7938
  } else {
8128
7939
    usable_len = flen;
8129
7940
  }
8159
7970
 
8160
7971
  mutex_exit(&srv_monitor_file_mutex);
8161
7972
 
8162
 
  stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
8163
 
             STRING_WITH_LEN(""), str, flen);
 
7973
  bool result = FALSE;
8164
7974
 
 
7975
  if (stat_print(session, innobase_engine_name, strlen(innobase_engine_name),
 
7976
      STRING_WITH_LEN(""), str, flen)) {
 
7977
    result= TRUE;
 
7978
  }
8165
7979
  free(str);
8166
7980
 
8167
7981
  return(FALSE);
8510
8324
        && (sql_command == SQLCOM_INSERT_SELECT
8511
8325
            || sql_command == SQLCOM_REPLACE_SELECT
8512
8326
            || sql_command == SQLCOM_UPDATE
8513
 
            || sql_command == SQLCOM_CREATE_TABLE
8514
 
            || sql_command == SQLCOM_SET_OPTION)) {
 
8327
            || sql_command == SQLCOM_CREATE_TABLE)) {
8515
8328
 
8516
8329
      /* If we either have innobase_locks_unsafe_for_binlog
8517
8330
      option set or this session is using READ COMMITTED
8519
8332
      is not set to serializable and MySQL is doing
8520
8333
      INSERT INTO...SELECT or REPLACE INTO...SELECT
8521
8334
      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. */
 
8335
      SELECT... without FOR UPDATE or IN SHARE
 
8336
      MODE in select, then we use consistent read
 
8337
      for select. */
8525
8338
 
8526
8339
      prebuilt->select_lock_type = LOCK_NONE;
8527
8340
      prebuilt->stored_select_lock_type = LOCK_NONE;
8609
8422
}
8610
8423
 
8611
8424
/*******************************************************************//**
8612
 
This function reads the global auto-inc counter. It doesn't use the
 
8425
This function reads the global auto-inc counter. It doesn't use the 
8613
8426
AUTOINC lock even if the lock mode is set to TRADITIONAL.
8614
8427
@return the autoinc value */
8615
8428
UNIV_INTERN
8629
8442
 
8630
8443
  auto_inc = dict_table_autoinc_read(innodb_table);
8631
8444
 
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
 
  }
 
8445
  ut_a(auto_inc > 0);
8637
8446
 
8638
8447
  dict_table_autoinc_unlock(innodb_table);
8639
8448
 
9051
8860
uint64_t InnobaseEngine::doGetCurrentTransactionId(Session *session)
9052
8861
{
9053
8862
  trx_t *trx= session_to_trx(session);
9054
 
  return (trx->id);
 
8863
  return (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
9055
8864
}
9056
8865
 
9057
8866
uint64_t InnobaseEngine::doGetNewTransactionId(Session *session)
9069
8878
  trx->id= trx_sys_get_new_trx_id();
9070
8879
  mutex_exit(&kernel_mutex);
9071
8880
 
9072
 
  uint64_t transaction_id= trx->id;
 
8881
  uint64_t transaction_id= (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id);
9073
8882
 
9074
8883
  return transaction_id;
9075
8884
}
9185
8994
}
9186
8995
 
9187
8996
/************************************************************//**
 
8997
Validate the file format check value, is it one of "on" or "off",
 
8998
as a side effect it sets the srv_check_file_format_at_startup variable.
 
8999
@return true if config value one of "on" or  "off" */
 
9000
static
 
9001
bool
 
9002
innobase_file_format_check_on_off(
 
9003
/*==============================*/
 
9004
  const char* format_check) /*!< in: parameter value */
 
9005
{
 
9006
  bool    ret = true;
 
9007
 
 
9008
  if (!innobase_strcasecmp(format_check, "off")) {
 
9009
 
 
9010
    /* Set the value to disable checking. */
 
9011
    srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX + 1;
 
9012
 
 
9013
  } else if (!innobase_strcasecmp(format_check, "on")) {
 
9014
 
 
9015
    /* Set the value to the lowest supported format. */
 
9016
    srv_check_file_format_at_startup = DICT_TF_FORMAT_51;
 
9017
  } else {
 
9018
    ret = FALSE;
 
9019
  }
 
9020
 
 
9021
  return(ret);
 
9022
}
 
9023
 
 
9024
/************************************************************//**
9188
9025
Validate the file format check config parameters, as a side effect it
9189
 
sets the srv_max_file_format_at_startup variable.
 
9026
sets the srv_check_file_format_at_startup variable.
9190
9027
@return the format_id if valid config value, otherwise, return -1 */
9191
9028
static
9192
9029
int
9193
9030
innobase_file_format_validate_and_set(
9194
9031
/*================================*/
9195
 
  const char* format_max) /*!< in: parameter value */
 
9032
  const char* format_check) /*!< in: parameter value */
9196
9033
{
9197
9034
  uint    format_id;
9198
9035
 
9199
 
  format_id = innobase_file_format_name_lookup(format_max);
 
9036
  format_id = innobase_file_format_name_lookup(format_check);
9200
9037
 
9201
9038
  if (format_id < DICT_TF_FORMAT_MAX + 1) {
9202
 
    srv_max_file_format_at_startup = format_id;
 
9039
    srv_check_file_format_at_startup = format_id;
9203
9040
    return((int) format_id);
9204
9041
  } else {
9205
9042
    return(-1);
9206
9043
  }
9207
9044
}
9208
9045
 
9209
 
 
 
9046
/*************************************************************//**
 
9047
Check if it is a valid file format. This function is registered as
 
9048
a callback with MySQL.
 
9049
@return 0 for valid file format */
 
9050
static
 
9051
int
 
9052
innodb_file_format_name_validate(
 
9053
/*=============================*/
 
9054
  Session*      , /*!< in: thread handle */
 
9055
  drizzle_sys_var*  , /*!< in: pointer to system
 
9056
            variable */
 
9057
  void*       save, /*!< out: immediate result
 
9058
            for update function */
 
9059
  drizzle_value*    value)  /*!< in: incoming string */
 
9060
{
 
9061
  const char* file_format_input;
 
9062
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9063
  int   len = sizeof(buff);
 
9064
 
 
9065
  ut_a(save != NULL);
 
9066
  ut_a(value != NULL);
 
9067
 
 
9068
  file_format_input = value->val_str(value, buff, &len);
 
9069
 
 
9070
  if (file_format_input != NULL) {
 
9071
    uint  format_id;
 
9072
 
 
9073
    format_id = innobase_file_format_name_lookup(
 
9074
      file_format_input);
 
9075
 
 
9076
    if (format_id <= DICT_TF_FORMAT_MAX) {
 
9077
      /* Save a pointer to the name in the
 
9078
         'file_format_name_map' constant array. */
 
9079
      *static_cast<const char**>(save) =
 
9080
        trx_sys_file_format_id_to_name(format_id);
 
9081
 
 
9082
      return(0);
 
9083
    }
 
9084
  }
 
9085
 
 
9086
  *static_cast<const char**>(save) = NULL;
 
9087
  return(1);
 
9088
}
 
9089
 
 
9090
/****************************************************************//**
 
9091
Update the system variable innodb_file_format using the "saved"
 
9092
value. This function is registered as a callback with MySQL. */
 
9093
static
 
9094
void
 
9095
innodb_file_format_name_update(
 
9096
/*===========================*/
 
9097
  Session*      ,   /*!< in: thread handle */
 
9098
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9099
              system variable */
 
9100
  void*       var_ptr,  /*!< out: where the
 
9101
              formal string goes */
 
9102
  const void*     save)   /*!< in: immediate result
 
9103
              from check function */
 
9104
{
 
9105
  const char* format_name;
 
9106
 
 
9107
  ut_a(var_ptr != NULL);
 
9108
  ut_a(save != NULL);
 
9109
 
 
9110
  format_name = *static_cast<const char*const*>(save);
 
9111
 
 
9112
  if (format_name) {
 
9113
    uint  format_id;
 
9114
 
 
9115
    format_id = innobase_file_format_name_lookup(format_name);
 
9116
 
 
9117
    if (format_id <= DICT_TF_FORMAT_MAX) {
 
9118
      srv_file_format = format_id;
 
9119
    }
 
9120
  }
 
9121
 
 
9122
  *static_cast<const char**>(var_ptr)
 
9123
    = trx_sys_file_format_id_to_name(srv_file_format);
 
9124
}
 
9125
 
 
9126
/*************************************************************//**
 
9127
Check if valid argument to innodb_file_format_check. This
 
9128
function is registered as a callback with MySQL.
 
9129
@return 0 for valid file format */
 
9130
static
 
9131
int
 
9132
innodb_file_format_check_validate(
 
9133
/*==============================*/
 
9134
  Session*      session, /*!< in: thread handle */
 
9135
  drizzle_sys_var*  , /*!< in: pointer to system
 
9136
            variable */
 
9137
  void*       save, /*!< out: immediate result
 
9138
            for update function */
 
9139
  drizzle_value*    value)  /*!< in: incoming string */
 
9140
{
 
9141
  const char* file_format_input;
 
9142
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9143
  int   len = sizeof(buff);
 
9144
  int   format_id;
 
9145
 
 
9146
  ut_a(save != NULL);
 
9147
  ut_a(value != NULL);
 
9148
 
 
9149
  file_format_input = value->val_str(value, buff, &len);
 
9150
 
 
9151
  if (file_format_input != NULL) {
 
9152
 
 
9153
    /* Check if user set on/off, we want to print a suitable
 
9154
    message if they did so. */
 
9155
 
 
9156
    if (innobase_file_format_check_on_off(file_format_input)) {
 
9157
      push_warning_printf(session,
 
9158
                          DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
9159
                          ER_WRONG_ARGUMENTS,
 
9160
        "InnoDB: invalid innodb_file_format_check "
 
9161
        "value; on/off can only be set at startup or "
 
9162
        "in the configuration file");
 
9163
    } else {
 
9164
      format_id = innobase_file_format_validate_and_set(file_format_input);
 
9165
      if (format_id >= 0) {
 
9166
        /* Save a pointer to the name in the
 
9167
           'file_format_name_map' constant array. */
 
9168
        *static_cast<const char**>(save) =
 
9169
          trx_sys_file_format_id_to_name(
 
9170
                                         (uint)format_id);
 
9171
 
 
9172
        return(0);
 
9173
 
 
9174
      } else {
 
9175
        push_warning_printf(session,
 
9176
                            DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
9177
                            ER_WRONG_ARGUMENTS,
 
9178
                            "InnoDB: invalid innodb_file_format_check "
 
9179
                            "value; can be any format up to %s "
 
9180
                            "or its equivalent numeric id",
 
9181
                            trx_sys_file_format_id_to_name(DICT_TF_FORMAT_MAX));
 
9182
      }
 
9183
    }
 
9184
  }
 
9185
 
 
9186
  *static_cast<const char**>(save) = NULL;
 
9187
  return(1);
 
9188
}
 
9189
 
 
9190
/****************************************************************//**
 
9191
Update the system variable innodb_file_format_check using the "saved"
 
9192
value. This function is registered as a callback with MySQL. */
 
9193
static
 
9194
void
 
9195
innodb_file_format_check_update(
 
9196
/*============================*/
 
9197
  Session*      session,  /*!< in: thread handle */
 
9198
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9199
              system variable */
 
9200
  void*       var_ptr,  /*!< out: where the
 
9201
              formal string goes */
 
9202
  const void*     save)   /*!< in: immediate result
 
9203
              from check function */
 
9204
{
 
9205
  const char* format_name_in;
 
9206
  const char**  format_name_out;
 
9207
  uint    format_id;
 
9208
 
 
9209
  ut_a(save != NULL);
 
9210
  ut_a(var_ptr != NULL);
 
9211
 
 
9212
  format_name_in = *static_cast<const char*const*>(save);
 
9213
 
 
9214
  if (!format_name_in) {
 
9215
 
 
9216
    return;
 
9217
  }
 
9218
 
 
9219
  format_id = innobase_file_format_name_lookup(format_name_in);
 
9220
 
 
9221
  if (format_id > DICT_TF_FORMAT_MAX) {
 
9222
    /* DEFAULT is "on", which is invalid at runtime. */
 
9223
    push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
9224
            ER_WRONG_ARGUMENTS,
 
9225
            "Ignoring SET innodb_file_format=%s",
 
9226
            format_name_in);
 
9227
    return;
 
9228
  }
 
9229
 
 
9230
  format_name_out = static_cast<const char**>(var_ptr);
 
9231
 
 
9232
  /* Update the max format id in the system tablespace. */
 
9233
  if (trx_sys_file_format_max_set(format_id, format_name_out)) {
 
9234
    ut_print_timestamp(stderr);
 
9235
    fprintf(stderr,
 
9236
      " [Info] InnoDB: the file format in the system "
 
9237
      "tablespace is now set to %s.\n", *format_name_out);
 
9238
  }
 
9239
}
 
9240
 
 
9241
/****************************************************************//**
 
9242
Update the system variable innodb_adaptive_hash_index using the "saved"
 
9243
value. This function is registered as a callback with MySQL. */
 
9244
static
 
9245
void
 
9246
innodb_adaptive_hash_index_update(
 
9247
/*==============================*/
 
9248
  Session*      ,   /*!< in: thread handle */
 
9249
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9250
              system variable */
 
9251
  void*       , /*!< out: where the
 
9252
              formal string goes */
 
9253
  const void*     save)   /*!< in: immediate result
 
9254
              from check function */
 
9255
{
 
9256
  if (*(bool*) save) {
 
9257
    btr_search_enable();
 
9258
  } else {
 
9259
    btr_search_disable();
 
9260
  }
 
9261
}
 
9262
 
 
9263
/****************************************************************//**
 
9264
Update the system variable innodb_old_blocks_pct using the "saved"
 
9265
value. This function is registered as a callback with MySQL. */
 
9266
static
 
9267
void
 
9268
innodb_old_blocks_pct_update(
 
9269
/*=========================*/
 
9270
        Session*                        ,       /*!< in: thread handle */
 
9271
        drizzle_sys_var*        ,       /*!< in: pointer to
 
9272
                                                system variable */
 
9273
        void*                           ,/*!< out: where the
 
9274
                                                formal string goes */
 
9275
        const void*                     save)   /*!< in: immediate result
 
9276
                                                from check function */
 
9277
{
 
9278
        innobase_old_blocks_pct = buf_LRU_old_ratio_update(
 
9279
                *static_cast<const uint*>(save), TRUE);
 
9280
}
 
9281
 
 
9282
/*************************************************************//**
 
9283
Check if it is a valid value of innodb_change_buffering.  This function is
 
9284
registered as a callback with MySQL.
 
9285
@return 0 for valid innodb_change_buffering */
 
9286
static
 
9287
int
 
9288
innodb_change_buffering_validate(
 
9289
/*=============================*/
 
9290
  Session*      , /*!< in: thread handle */
 
9291
  drizzle_sys_var*  , /*!< in: pointer to system
 
9292
            variable */
 
9293
  void*       save, /*!< out: immediate result
 
9294
            for update function */
 
9295
  drizzle_value*    value)  /*!< in: incoming string */
 
9296
{
 
9297
  const char* change_buffering_input;
 
9298
  char    buff[STRING_BUFFER_USUAL_SIZE];
 
9299
  int   len = sizeof(buff);
 
9300
 
 
9301
  ut_a(save != NULL);
 
9302
  ut_a(value != NULL);
 
9303
 
 
9304
  change_buffering_input = value->val_str(value, buff, &len);
 
9305
 
 
9306
  if (change_buffering_input != NULL) {
 
9307
    ulint use;
 
9308
 
 
9309
    for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
 
9310
         use++) {
 
9311
      if (!innobase_strcasecmp(
 
9312
            change_buffering_input,
 
9313
            innobase_change_buffering_values[use])) {
 
9314
        *(ibuf_use_t*) save = (ibuf_use_t) use;
 
9315
        return(0);
 
9316
      }
 
9317
    }
 
9318
  }
 
9319
 
 
9320
  return(1);
 
9321
}
 
9322
 
 
9323
/****************************************************************//**
 
9324
Update the system variable innodb_change_buffering using the "saved"
 
9325
value. This function is registered as a callback with MySQL. */
 
9326
static
 
9327
void
 
9328
innodb_change_buffering_update(
 
9329
/*===========================*/
 
9330
  Session*      ,   /*!< in: thread handle */
 
9331
  drizzle_sys_var*  ,   /*!< in: pointer to
 
9332
              system variable */
 
9333
  void*       var_ptr,  /*!< out: where the
 
9334
              formal string goes */
 
9335
  const void*     save)   /*!< in: immediate result
 
9336
              from check function */
 
9337
{
 
9338
  ut_a(var_ptr != NULL);
 
9339
  ut_a(save != NULL);
 
9340
  ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
 
9341
 
 
9342
  ibuf_use = *(const ibuf_use_t*) save;
 
9343
 
 
9344
  *(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
 
9345
}
 
9346
 
 
9347
/* plugin options */
 
9348
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
 
9349
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
9350
  "Enable InnoDB checksums validation (enabled by default). ",
 
9351
  NULL, NULL, TRUE);
 
9352
 
 
9353
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
 
9354
  PLUGIN_VAR_READONLY,
 
9355
  "The common part for InnoDB table spaces.",
 
9356
  NULL, NULL, NULL);
 
9357
 
 
9358
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
 
9359
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
9360
  "Enable InnoDB doublewrite buffer (enabled by default). ",
 
9361
  NULL, NULL, TRUE);
 
9362
 
 
9363
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
 
9364
  PLUGIN_VAR_RQCMDARG,
 
9365
  "Number of IOPs the server can do. Tunes the background IO rate",
 
9366
  NULL, NULL, 200, 100, ~0L, 0);
 
9367
 
 
9368
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
 
9369
  PLUGIN_VAR_OPCMDARG,
 
9370
  "Speeds up the shutdown process of the InnoDB storage engine. Possible "
 
9371
  "values are 0, 1 (faster)"
 
9372
  " or 2 (fastest - crash-like)"
 
9373
  ".",
 
9374
  NULL, NULL, 1, 0, 2, 0);
 
9375
 
 
9376
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
 
9377
  PLUGIN_VAR_NOCMDARG,
 
9378
  "Stores each InnoDB table to an .ibd file in the database dir.",
 
9379
  NULL, NULL, FALSE);
 
9380
 
 
9381
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
 
9382
  PLUGIN_VAR_RQCMDARG,
 
9383
  "File format to use for new tables in .ibd files.",
 
9384
  innodb_file_format_name_validate,
 
9385
  innodb_file_format_name_update, "Antelope");
 
9386
 
 
9387
/* If a new file format is introduced, the file format
 
9388
name needs to be updated accordingly. Please refer to
 
9389
file_format_name_map[] defined in trx0sys.c for the next
 
9390
file format name. */
 
9391
static DRIZZLE_SYSVAR_STR(file_format_check, innobase_file_format_check,
 
9392
  PLUGIN_VAR_OPCMDARG,
 
9393
  "The highest file format in the tablespace.",
 
9394
  innodb_file_format_check_validate,
 
9395
  innodb_file_format_check_update,
 
9396
  "Barracuda");
 
9397
 
 
9398
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
 
9399
  PLUGIN_VAR_OPCMDARG,
 
9400
  "Set to 0 (write and flush once per second),"
 
9401
  " 1 (write and flush at each commit)"
 
9402
  " or 2 (write at commit, flush once per second).",
 
9403
  NULL, NULL, 1, 0, 2, 0);
 
9404
 
 
9405
static DRIZZLE_SYSVAR_STR(flush_method, innobase_file_flush_method,
 
9406
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9407
  "With which method to flush data.", NULL, NULL, NULL);
 
9408
 
 
9409
#ifdef UNIV_LOG_ARCHIVE
 
9410
static DRIZZLE_SYSVAR_STR(log_arch_dir, innobase_log_arch_dir,
 
9411
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9412
  "Where full logs should be archived.", NULL, NULL, NULL);
 
9413
 
 
9414
static DRIZZLE_SYSVAR_BOOL(log_archive, innobase_log_archive,
 
9415
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
9416
  "Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
 
9417
#endif /* UNIV_LOG_ARCHIVE */
 
9418
 
 
9419
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
 
9420
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9421
  "Path to InnoDB log files.", NULL, NULL, NULL);
 
9422
 
 
9423
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
 
9424
  PLUGIN_VAR_RQCMDARG,
 
9425
  "Percentage of dirty pages allowed in bufferpool.",
 
9426
  NULL, NULL, 75, 0, 99, 0);
 
9427
 
 
9428
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
 
9429
  PLUGIN_VAR_NOCMDARG,
 
9430
  "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
 
9431
  NULL, NULL, TRUE);
 
9432
 
 
9433
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
 
9434
  PLUGIN_VAR_RQCMDARG,
 
9435
  "Desired maximum length of the purge queue (0 = no limit)",
 
9436
  NULL, NULL, 0, 0, ~0L, 0);
 
9437
 
 
9438
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
 
9439
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
 
9440
  "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
 
9441
  NULL, NULL, FALSE);
 
9442
 
 
9443
static DRIZZLE_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_sample_pages,
 
9444
  PLUGIN_VAR_RQCMDARG,
 
9445
  "The number of index pages to sample when calculating statistics (default 8)",
 
9446
  NULL, NULL, 8, 1, ~0ULL, 0);
 
9447
 
 
9448
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
 
9449
  PLUGIN_VAR_OPCMDARG,
 
9450
  "Enable InnoDB adaptive hash index (enabled by default).",
 
9451
  NULL, innodb_adaptive_hash_index_update, TRUE);
 
9452
 
 
9453
static DRIZZLE_SYSVAR_ULONG(replication_delay, srv_replication_delay,
 
9454
  PLUGIN_VAR_RQCMDARG,
 
9455
  "Replication thread delay (ms) on the slave server if "
 
9456
  "innodb_thread_concurrency is reached (0 by default)",
 
9457
  NULL, NULL, 0, 0, ~0UL, 0);
 
9458
 
 
9459
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
 
9460
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9461
  "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
 
9462
  NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
 
9463
 
 
9464
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
 
9465
  PLUGIN_VAR_RQCMDARG,
 
9466
  "Data file autoextend increment in megabytes",
 
9467
  NULL, NULL, 8L, 1L, 1000L, 0);
 
9468
 
 
9469
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
 
9470
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9471
  "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
 
9472
  NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
 
9473
 
 
9474
static DRIZZLE_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
 
9475
  PLUGIN_VAR_RQCMDARG,
 
9476
  "Helps in performance tuning in heavily concurrent environments.",
 
9477
  innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0);
 
9478
 
 
9479
static DRIZZLE_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter,
 
9480
  PLUGIN_VAR_RQCMDARG,
 
9481
  "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket",
 
9482
  NULL, NULL, 500L, 1L, ~0L, 0);
 
9483
 
 
9484
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
 
9485
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9486
  "Number of background read I/O threads in InnoDB.",
 
9487
  NULL, NULL, 4, 1, 64, 0);
 
9488
 
 
9489
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
 
9490
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9491
  "Number of background write I/O threads in InnoDB.",
 
9492
  NULL, NULL, 4, 1, 64, 0);
 
9493
 
 
9494
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
 
9495
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9496
  "Helps to save your data in case the disk image of the database becomes corrupt.",
 
9497
  NULL, NULL, 0, 0, 6, 0);
 
9498
 
 
9499
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
 
9500
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9501
  "The size of the buffer which InnoDB uses to write log to the log files on disk.",
 
9502
  NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
 
9503
 
 
9504
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
 
9505
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9506
  "Size of each log file in a log group.",
 
9507
  NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
 
9508
 
 
9509
static DRIZZLE_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
 
9510
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9511
  "Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.",
 
9512
  NULL, NULL, 2, 2, 100, 0);
 
9513
 
 
9514
static DRIZZLE_SYSVAR_LONG(mirrored_log_groups, innobase_mirrored_log_groups,
 
9515
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9516
  "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
 
9517
  NULL, NULL, 1, 1, 10, 0);
 
9518
 
 
9519
static DRIZZLE_SYSVAR_UINT(old_blocks_pct, innobase_old_blocks_pct,
 
9520
  PLUGIN_VAR_RQCMDARG,
 
9521
  "Percentage of the buffer pool to reserve for 'old' blocks.",
 
9522
  NULL, innodb_old_blocks_pct_update, 100 * 3 / 8, 5, 95, 0);
 
9523
 
 
9524
static DRIZZLE_SYSVAR_UINT(old_blocks_time, buf_LRU_old_threshold_ms,
 
9525
  PLUGIN_VAR_RQCMDARG,
 
9526
  "Move blocks to the 'new' end of the buffer pool if the first access"
 
9527
  " was at least this many milliseconds ago."
 
9528
  " The timeout is disabled if 0 (the default).",
 
9529
  NULL, NULL, 0, 0, UINT32_MAX, 0);
 
9530
 
 
9531
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
 
9532
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9533
  "How many files at the maximum InnoDB keeps open at the same time.",
 
9534
  NULL, NULL, 300L, 10L, LONG_MAX, 0);
 
9535
 
 
9536
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
 
9537
  PLUGIN_VAR_RQCMDARG,
 
9538
  "Count of spin-loop rounds in InnoDB mutexes (30 by default)",
 
9539
  NULL, NULL, 30L, 0L, ~0L, 0);
 
9540
 
 
9541
static DRIZZLE_SYSVAR_ULONG(spin_wait_delay, srv_spin_wait_delay,
 
9542
  PLUGIN_VAR_OPCMDARG,
 
9543
  "Maximum delay between polling for a spin lock (6 by default)",
 
9544
  NULL, NULL, 6L, 0L, ~0L, 0);
 
9545
 
 
9546
static DRIZZLE_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency,
 
9547
  PLUGIN_VAR_RQCMDARG,
 
9548
  "Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
 
9549
  NULL, NULL, 0, 0, 1000, 0);
 
9550
 
 
9551
static DRIZZLE_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
 
9552
  PLUGIN_VAR_RQCMDARG,
 
9553
  "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep",
 
9554
  NULL, NULL, 10000L, 0L, ~0L, 0);
 
9555
 
 
9556
static DRIZZLE_SYSVAR_STR(data_file_path, innobase_data_file_path,
 
9557
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
9558
  "Path to individual files and their sizes.",
 
9559
  NULL, NULL, NULL);
 
9560
 
 
9561
static DRIZZLE_SYSVAR_STR(version, innodb_version_str,
 
9562
  PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
 
9563
  "InnoDB version", NULL, NULL, INNODB_VERSION_STR);
 
9564
 
 
9565
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
 
9566
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
9567
  "Use OS memory allocator instead of InnoDB's internal memory allocator",
 
9568
  NULL, NULL, TRUE);
 
9569
 
 
9570
static DRIZZLE_SYSVAR_STR(change_buffering, innobase_change_buffering,
 
9571
  PLUGIN_VAR_RQCMDARG,
 
9572
  "Buffer changes to reduce random access: "
 
9573
  "OFF, ON, none, inserts.",
 
9574
  innodb_change_buffering_validate,
 
9575
  innodb_change_buffering_update, NULL);
 
9576
 
 
9577
static DRIZZLE_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
 
9578
  PLUGIN_VAR_RQCMDARG,
 
9579
  "Number of pages that must be accessed sequentially for InnoDB to "
 
9580
  "trigger a readahead.",
 
9581
  NULL, NULL, 56, 0, 64, 0);
9210
9582
 
9211
9583
static void init_options(drizzled::module::option_context &context)
9212
9584
{
9218
9590
  context("disable-doublewrite",
9219
9591
          "Disable InnoDB doublewrite buffer.");
9220
9592
  context("io-capacity",
9221
 
          po::value<io_capacity_constraint>(&innodb_io_capacity)->default_value(200),
 
9593
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
9222
9594
          "Number of IOPs the server can do. Tunes the background IO rate");
9223
9595
  context("fast-shutdown",
9224
 
          po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1), 
 
9596
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1), 
9225
9597
          "Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like).");
9226
 
  context("purge-batch-size",
9227
 
          po::value<purge_batch_constraint>(&innodb_purge_batch_size)->default_value(20),
9228
 
          "Number of UNDO logs to purge in one batch from the history list. "
9229
 
          "Default is 20.");
9230
 
  context("purge-threads",
9231
 
          po::value<purge_threads_constraint>(&innodb_n_purge_threads)->default_value(0),
9232
 
          "Purge threads can be either 0 or 1. Defalut is 0.");
9233
9598
  context("file-per-table",
9234
9599
          po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
9235
9600
          "Stores each InnoDB table to an .ibd file in the database dir.");
9236
9601
  context("file-format",
9237
 
          po::value<string>(&innobase_file_format_name)->default_value("Antelope"),
 
9602
          po::value<string>()->default_value("Antelope"),
9238
9603
          "File format to use for new tables in .ibd files.");
9239
 
  context("file-format-max",
9240
 
          po::value<string>(&innobase_file_format_max)->default_value("Antelope"),
 
9604
  context("file-format-check",
 
9605
          po::value<string>()->default_value("on"),
9241
9606
          "The highest file format in the tablespace.");
9242
 
  context("file-format-check",
9243
 
          po::value<bool>(&innobase_file_format_check)->default_value(true)->zero_tokens(),
9244
 
          "Whether to perform system file format check.");
9245
9607
  context("flush-log-at-trx-commit",
9246
 
          po::value<trinary_constraint>(&innodb_flush_log_at_trx_commit)->default_value(1),
 
9608
          po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
9247
9609
          "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
9610
  context("flush-method",
9249
9611
          po::value<string>(),
9250
9612
          "With which method to flush data.");
 
9613
#ifdef UNIV_LOG_ARCHIVE
 
9614
  context("log-arch-dir",
 
9615
          po::value<string>(),
 
9616
          "Where full logs should be archived.");
 
9617
  context("log-archive",
 
9618
          po::value<bool>(&innobase_log_archive)->default_value(false)->zero_tokens(),
 
9619
          "Set to 1 if you want to have logs archived.");
 
9620
#endif /* UNIV_LOG_ARCHIVE */
9251
9621
  context("log-group-home-dir",
9252
9622
          po::value<string>(),
9253
9623
          "Path to InnoDB log files.");
9254
9624
  context("max-dirty-pages-pct",
9255
 
          po::value<max_dirty_pages_constraint>(&innodb_max_dirty_pages_pct)->default_value(75),
 
9625
          po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
9256
9626
          "Percentage of dirty pages allowed in bufferpool.");
9257
9627
  context("disable-adaptive-flushing",
9258
9628
          "Do not attempt flushing dirty pages to avoid IO bursts at checkpoints.");
9259
9629
  context("max-purge-lag",
9260
 
          po::value<uint64_constraint>(&innodb_max_purge_lag)->default_value(0),
 
9630
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
9261
9631
          "Desired maximum length of the purge queue (0 = no limit)");
9262
9632
  context("status-file",
9263
9633
          po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
9265
9635
  context("disable-stats-on-metadata",
9266
9636
          "Disable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)");
9267
9637
  context("stats-sample-pages",
9268
 
          po::value<uint64_nonzero_constraint>(&innodb_stats_sample_pages)->default_value(8),
 
9638
          po::value<uint64_t>(&srv_stats_sample_pages)->default_value(8),
9269
9639
          "The number of index pages to sample when calculating statistics (default 8)");
9270
9640
  context("disable-adaptive-hash-index",
9271
9641
          "Enable InnoDB adaptive hash index (enabled by default)");
9272
9642
  context("replication-delay",
9273
 
          po::value<uint64_constraint>(&innodb_replication_delay)->default_value(0),
 
9643
          po::value<unsigned long>(&srv_replication_delay)->default_value(0),
9274
9644
          "Replication thread delay (ms) on the slave server if innodb_thread_concurrency is reached (0 by default)");
9275
9645
  context("additional-mem-pool-size",
9276
 
          po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
9646
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
9277
9647
          "Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.");
9278
9648
  context("autoextend-increment",
9279
 
          po::value<autoextend_constraint>(&innodb_auto_extend_increment)->default_value(8L),
 
9649
          po::value<uint32_t>(&srv_auto_extend_increment)->default_value(8L),
9280
9650
          "Data file autoextend increment in megabytes");
9281
9651
  context("buffer-pool-size",
9282
 
          po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
9652
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
9283
9653
          "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.");
9284
 
  context("buffer-pool-instances",
9285
 
          po::value<buffer_pool_instances_constraint>(&innobase_buffer_pool_instances)->default_value(1),
9286
 
          "Number of buffer pool instances, set to higher value on high-end machines to increase scalability");
9287
 
 
9288
9654
  context("commit-concurrency",
9289
 
          po::value<concurrency_constraint>(&innobase_commit_concurrency)->default_value(0),
 
9655
          po::value<unsigned long>(&innobase_commit_concurrency)->default_value(0),
9290
9656
          "Helps in performance tuning in heavily concurrent environments.");
9291
9657
  context("concurrency-tickets",
9292
 
          po::value<uint32_nonzero_constraint>(&innodb_concurrency_tickets)->default_value(500L),
 
9658
          po::value<unsigned long>(&srv_n_free_tickets_to_enter)->default_value(500L),
9293
9659
          "Number of times a thread is allowed to enter InnoDB within the same SQL query after it has once got the ticket");
9294
9660
  context("read-io-threads",
9295
 
          po::value<io_threads_constraint>(&innobase_read_io_threads)->default_value(4),
 
9661
          po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
9296
9662
          "Number of background read I/O threads in InnoDB.");
9297
9663
  context("write-io-threads",
9298
 
          po::value<io_threads_constraint>(&innobase_write_io_threads)->default_value(4),
 
9664
          po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
9299
9665
          "Number of background write I/O threads in InnoDB.");
9300
9666
  context("force-recovery",
9301
 
          po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
 
9667
          po::value<long>(&innobase_force_recovery)->default_value(0),
9302
9668
          "Helps to save your data in case the disk image of the database becomes corrupt.");
9303
9669
  context("log-buffer-size",
9304
 
          po::value<log_buffer_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
 
9670
          po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
9305
9671
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9306
9672
  context("log-file-size",
9307
 
          po::value<log_file_constraint>(&innobase_log_file_size)->default_value(20*1024*1024L),
 
9673
          po::value<int64_t>(&innobase_log_file_size)->default_value(20*1024*1024L),
9308
9674
          "The size of the buffer which InnoDB uses to write log to the log files on disk.");
9309
9675
  context("log-files-in-group",
9310
 
          po::value<log_files_in_group_constraint>(&innobase_log_files_in_group)->default_value(2),
 
9676
          po::value<long>(&innobase_log_files_in_group)->default_value(2),
9311
9677
          "Number of log files in the log group. InnoDB writes to the files in a circular fashion.");
9312
9678
  context("mirrored-log-groups",
9313
 
          po::value<mirrored_log_groups_constraint>(&innobase_mirrored_log_groups)->default_value(1),
 
9679
          po::value<long>(&innobase_mirrored_log_groups)->default_value(1),
9314
9680
          "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.");
9315
9681
  context("open-files",
9316
 
          po::value<open_files_constraint>(&innobase_open_files)->default_value(300L),
 
9682
          po::value<long>(&innobase_open_files)->default_value(300L),
9317
9683
          "How many files at the maximum InnoDB keeps open at the same time.");
9318
9684
  context("sync-spin-loops",
9319
 
          po::value<uint32_constraint>(&innodb_sync_spin_loops)->default_value(30L),
 
9685
          po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
9320
9686
          "Count of spin-loop rounds in InnoDB mutexes (30 by default)");
9321
9687
  context("spin-wait-delay",
9322
 
          po::value<uint32_constraint>(&innodb_spin_wait_delay)->default_value(6L),
 
9688
          po::value<unsigned long>(&srv_spin_wait_delay)->default_value(6L),
9323
9689
          "Maximum delay between polling for a spin lock (6 by default)");
9324
9690
  context("thread-concurrency",
9325
 
          po::value<concurrency_constraint>(&innobase_thread_concurrency)->default_value(0),
 
9691
          po::value<unsigned long>(&srv_thread_concurrency)->default_value(0),
9326
9692
          "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
9693
  context("thread-sleep-delay",
9328
 
          po::value<uint32_constraint>(&innodb_thread_sleep_delay)->default_value(10000L),
 
9694
          po::value<unsigned long>(&srv_thread_sleep_delay)->default_value(10000L),
9329
9695
          "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep");
9330
9696
  context("data-file-path",
9331
9697
          po::value<string>(),
9336
9702
  context("use-internal-malloc",
9337
9703
          "Use InnoDB's internal memory allocator instal of the OS memory allocator.");
9338
9704
  context("change-buffering",
9339
 
          po::value<string>(&innobase_change_buffering),
 
9705
          po::value<string>(),
9340
9706
          "Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.");
9341
9707
  context("read-ahead-threshold",
9342
 
          po::value<read_ahead_threshold_constraint>(&innodb_read_ahead_threshold)->default_value(56),
 
9708
          po::value<unsigned long>(&srv_read_ahead_threshold)->default_value(56),
9343
9709
          "Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.");
9344
9710
  context("disable-xa",
9345
9711
          "Disable InnoDB support for the XA two-phase commit");
9346
9712
  context("disable-table-locks",
9347
9713
          "Disable InnoDB locking in LOCK TABLES");
9348
9714
  context("strict-mode",
9349
 
          po::value<bool>(&strict_mode)->default_value(false)->zero_tokens(),
 
9715
          po::value<bool>()->default_value(false)->zero_tokens(),
9350
9716
          "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
9717
  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)."));
 
9718
          po::value<unsigned long>()->default_value(50),
 
9719
          "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");
9365
9720
}
9366
9721
 
9367
 
 
 
9722
static drizzle_sys_var* innobase_system_variables[]= {
 
9723
  DRIZZLE_SYSVAR(additional_mem_pool_size),
 
9724
  DRIZZLE_SYSVAR(autoextend_increment),
 
9725
  DRIZZLE_SYSVAR(buffer_pool_size),
 
9726
  DRIZZLE_SYSVAR(checksums),
 
9727
  DRIZZLE_SYSVAR(commit_concurrency),
 
9728
  DRIZZLE_SYSVAR(concurrency_tickets),
 
9729
  DRIZZLE_SYSVAR(data_file_path),
 
9730
  DRIZZLE_SYSVAR(data_home_dir),
 
9731
  DRIZZLE_SYSVAR(doublewrite),
 
9732
  DRIZZLE_SYSVAR(fast_shutdown),
 
9733
  DRIZZLE_SYSVAR(read_io_threads),
 
9734
  DRIZZLE_SYSVAR(write_io_threads),
 
9735
  DRIZZLE_SYSVAR(file_per_table),
 
9736
  DRIZZLE_SYSVAR(file_format),
 
9737
  DRIZZLE_SYSVAR(file_format_check),
 
9738
  DRIZZLE_SYSVAR(flush_log_at_trx_commit),
 
9739
  DRIZZLE_SYSVAR(flush_method),
 
9740
  DRIZZLE_SYSVAR(force_recovery),
 
9741
  DRIZZLE_SYSVAR(lock_wait_timeout),
 
9742
#ifdef UNIV_LOG_ARCHIVE
 
9743
  DRIZZLE_SYSVAR(log_arch_dir),
 
9744
  DRIZZLE_SYSVAR(log_archive),
 
9745
#endif /* UNIV_LOG_ARCHIVE */
 
9746
  DRIZZLE_SYSVAR(log_buffer_size),
 
9747
  DRIZZLE_SYSVAR(log_file_size),
 
9748
  DRIZZLE_SYSVAR(log_files_in_group),
 
9749
  DRIZZLE_SYSVAR(log_group_home_dir),
 
9750
  DRIZZLE_SYSVAR(max_dirty_pages_pct),
 
9751
  DRIZZLE_SYSVAR(max_purge_lag),
 
9752
  DRIZZLE_SYSVAR(adaptive_flushing),
 
9753
  DRIZZLE_SYSVAR(mirrored_log_groups),
 
9754
  DRIZZLE_SYSVAR(old_blocks_pct),
 
9755
  DRIZZLE_SYSVAR(old_blocks_time),
 
9756
  DRIZZLE_SYSVAR(open_files),
 
9757
  DRIZZLE_SYSVAR(stats_sample_pages),
 
9758
  DRIZZLE_SYSVAR(adaptive_hash_index),
 
9759
  DRIZZLE_SYSVAR(replication_delay),
 
9760
  DRIZZLE_SYSVAR(status_file),
 
9761
  DRIZZLE_SYSVAR(strict_mode),
 
9762
  DRIZZLE_SYSVAR(support_xa),
 
9763
  DRIZZLE_SYSVAR(sync_spin_loops),
 
9764
  DRIZZLE_SYSVAR(spin_wait_delay),
 
9765
  DRIZZLE_SYSVAR(table_locks),
 
9766
  DRIZZLE_SYSVAR(thread_concurrency),
 
9767
  DRIZZLE_SYSVAR(thread_sleep_delay),
 
9768
  DRIZZLE_SYSVAR(version),
 
9769
  DRIZZLE_SYSVAR(use_sys_malloc),
 
9770
  DRIZZLE_SYSVAR(change_buffering),
 
9771
  DRIZZLE_SYSVAR(read_ahead_threshold),
 
9772
  DRIZZLE_SYSVAR(io_capacity),
 
9773
  NULL
 
9774
};
9368
9775
 
9369
9776
DRIZZLE_DECLARE_PLUGIN
9370
9777
{
9375
9782
  "Supports transactions, row-level locking, and foreign keys",
9376
9783
  PLUGIN_LICENSE_GPL,
9377
9784
  innobase_init, /* Plugin Init */
9378
 
  NULL, /* system variables */
 
9785
  innobase_system_variables, /* system variables */
9379
9786
  init_options /* reserved */
9380
9787
}
9381
9788
DRIZZLE_DECLARE_PLUGIN_END;
9403
9810
  return res;
9404
9811
}
9405
9812
 
 
9813
/** @brief Initialize the default value of innodb_commit_concurrency.
 
9814
 
 
9815
Once InnoDB is running, the innodb_commit_concurrency must not change
 
9816
from zero to nonzero. (Bug #42101)
 
9817
 
 
9818
The initial default value is 0, and without this extra initialization,
 
9819
SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter
 
9820
to 0, even if it was initially set to nonzero at the command line
 
9821
or configuration file. */
 
9822
static
 
9823
void
 
9824
innobase_commit_concurrency_init_default(void)
 
9825
/*==========================================*/
 
9826
{
 
9827
  DRIZZLE_SYSVAR_NAME(commit_concurrency).def_val
 
9828
    = innobase_commit_concurrency;
 
9829
}
 
9830
 
9406
9831
/***********************************************************************
9407
9832
This function checks each index name for a table against reserved
9408
9833
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,