58
58
static uint32_t myisam_key_cache_division_limit;
59
59
static uint32_t myisam_key_cache_age_threshold;
60
60
static uint64_t max_sort_file_size;
61
static uint64_t sort_buffer_size;
61
typedef constrained_check<size_t, SIZE_MAX, 1024, 1024> sort_buffer_constraint;
62
static sort_buffer_constraint sort_buffer_size;
63
64
void st_mi_isam_share::setKeyCache()
910
911
param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
911
912
T_CREATE_MISSING_KEYS);
912
913
param.myf_rw&= ~MY_WAIT_IF_FULL;
913
param.sort_buffer_length= (size_t)sort_buffer_size;
914
param.sort_buffer_length= static_cast<size_t>(sort_buffer_size);
914
915
param.stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
915
916
if ((error= (repair(session,param,0) != HA_ADMIN_OK)) && param.retry_repair)
1483
1484
return (uint)file->state->checksum;
1486
static MyisamEngine *engine= NULL;
1488
1487
static int myisam_init(module::Context &context)
1490
const module::option_map &vm= context.getOptions();
1492
if (vm.count("max-sort-file-size"))
1494
if (max_sort_file_size > UINT64_MAX)
1496
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-sort-file-size\n"));
1501
if (vm.count("sort-buffer-size"))
1503
if (sort_buffer_size < 1024 || sort_buffer_size > SIZE_MAX)
1505
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for sort-buffer-size\n"));
1510
engine= new MyisamEngine(engine_name);
1511
context.add(engine);
1489
context.add(new MyisamEngine(engine_name));
1490
context.registerVariable(new sys_var_constrained_value<size_t>("sort-buffer-size",
1493
context.registerVariable(new sys_var_uint64_t_ptr("max_sort_file_size",
1494
&max_sort_file_size,
1495
context.getOptions()["max-sort-file-size"].as<uint64_t>()));
1517
static DRIZZLE_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size,
1518
PLUGIN_VAR_RQCMDARG,
1519
N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."),
1520
NULL, NULL, INT32_MAX, 0, UINT64_MAX, 0);
1522
static DRIZZLE_SYSVAR_ULONGLONG(sort_buffer_size, sort_buffer_size,
1523
PLUGIN_VAR_RQCMDARG,
1524
N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
1525
NULL, NULL, 8192*1024, 1024, SIZE_MAX, 0);
1527
1501
static void init_options(drizzled::module::option_context &context)
1529
1503
context("max-sort-file-size",
1530
1504
po::value<uint64_t>(&max_sort_file_size)->default_value(INT32_MAX),
1531
1505
N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."));
1532
1506
context("sort-buffer-size",
1533
po::value<uint64_t>(&sort_buffer_size)->default_value(8192*1024),
1507
po::value<sort_buffer_constraint>(&sort_buffer_size)->default_value(8192*1024),
1534
1508
N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."));
1537
static drizzle_sys_var* sys_variables[]= {
1538
DRIZZLE_SYSVAR(max_sort_file_size),
1539
DRIZZLE_SYSVAR(sort_buffer_size),
1544
1512
DRIZZLE_DECLARE_PLUGIN
1550
1518
"Default engine as of MySQL 3.23 with great performance",
1551
1519
PLUGIN_LICENSE_GPL,
1552
1520
myisam_init, /* Plugin Init */
1553
sys_variables, /* system variables */
1521
NULL, /* system variables */
1554
1522
init_options /* config options */
1556
1524
DRIZZLE_DECLARE_PLUGIN_END;