1487
1492
return (uint)file->state->checksum;
1495
static MyisamEngine *engine= NULL;
1490
1497
static int myisam_init(module::Context &context)
1492
context.add(new MyisamEngine(engine_name));
1493
context.registerVariable(new sys_var_constrained_value<size_t>("sort-buffer-size",
1495
context.registerVariable(new sys_var_uint64_t_ptr("max_sort_file_size",
1496
&max_sort_file_size,
1497
context.getOptions()["max-sort-file-size"].as<uint64_t>()));
1499
engine= new MyisamEngine(engine_name);
1500
context.add(engine);
1502
/* call ha_init_key_cache() on all key caches to init them */
1503
int error= init_key_cache(dflt_key_cache,
1504
myisam_key_cache_block_size,
1505
myisam_key_cache_size,
1506
myisam_key_cache_division_limit,
1507
myisam_key_cache_age_threshold);
1510
exit(1); /* Memory Allocation Failure */
1503
static void init_options(drizzled::module::option_context &context)
1505
context("max-sort-file-size",
1506
po::value<uint64_t>(&max_sort_file_size)->default_value(INT32_MAX),
1507
N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."));
1508
context("sort-buffer-size",
1509
po::value<sort_buffer_constraint>(&sort_buffer_size)->default_value(8192*1024),
1510
N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."));
1516
static void sys_var_key_cache_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1518
uint32_t tmp= *static_cast<const uint32_t *>(save);
1521
struct option option_limits;
1522
plugin_opt_set_limits(&option_limits, var);
1523
option_limits.name= "myisam_key_cache_size";
1525
if (dflt_key_cache->in_init)
1528
myisam_key_cache_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1530
/* If key cache didn't existed initialize it, else resize it */
1531
dflt_key_cache->in_init= 1;
1533
error= ! resize_key_cache(dflt_key_cache,
1534
myisam_key_cache_block_size,
1535
myisam_key_cache_size,
1536
myisam_key_cache_division_limit,
1537
myisam_key_cache_age_threshold);
1538
dflt_key_cache->in_init= 0;
1541
static void sys_var_key_cache_block_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1543
uint32_t tmp= *static_cast<const uint32_t *>(save);
1546
struct option option_limits;
1547
plugin_opt_set_limits(&option_limits, var);
1548
option_limits.name= "myisam_key_cache_block_size";
1550
if (dflt_key_cache->in_init)
1553
myisam_key_cache_block_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1555
dflt_key_cache->in_init= 1;
1557
error= ! resize_key_cache(dflt_key_cache,
1558
myisam_key_cache_block_size,
1559
myisam_key_cache_size,
1560
myisam_key_cache_division_limit,
1561
myisam_key_cache_age_threshold);
1563
dflt_key_cache->in_init= 0;
1566
static void sys_var_key_cache_division_limit_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1568
uint32_t tmp= *static_cast<const uint32_t *>(save);
1571
struct option option_limits;
1572
plugin_opt_set_limits(&option_limits, var);
1573
option_limits.name= "myisam_key_cache_division_limit";
1575
if (dflt_key_cache->in_init)
1578
myisam_key_cache_division_limit= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1580
dflt_key_cache->in_init= 1;
1582
error= ! resize_key_cache(dflt_key_cache,
1583
myisam_key_cache_block_size,
1584
myisam_key_cache_size,
1585
myisam_key_cache_division_limit,
1586
myisam_key_cache_age_threshold);
1588
dflt_key_cache->in_init= 0;
1591
static void sys_var_key_cache_age_threshold_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1593
uint32_t tmp= *static_cast<const uint32_t *>(save);
1596
struct option option_limits;
1597
plugin_opt_set_limits(&option_limits, var);
1598
option_limits.name= "myisam_key_cache_age_threshold";
1600
if (dflt_key_cache->in_init)
1603
myisam_key_cache_age_threshold= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1605
dflt_key_cache->in_init= 1;
1607
error= ! resize_key_cache(dflt_key_cache,
1608
myisam_key_cache_block_size,
1609
myisam_key_cache_size,
1610
myisam_key_cache_division_limit,
1611
myisam_key_cache_age_threshold);
1613
dflt_key_cache->in_init= 0;
1616
static DRIZZLE_SYSVAR_UINT(key_cache_block_size,
1617
myisam_key_cache_block_size,
1618
PLUGIN_VAR_RQCMDARG,
1619
N_("Block size to be used for MyISAM index pages."),
1621
sys_var_key_cache_block_size_update,
1622
KEY_CACHE_BLOCK_SIZE,
1627
static DRIZZLE_SYSVAR_UINT(key_cache_age_threshold, myisam_key_cache_age_threshold,
1628
PLUGIN_VAR_RQCMDARG,
1629
N_("This characterizes the number of hits a hot block has to be untouched "
1630
"until it is considered aged enough to be downgraded to a warm block. "
1631
"This specifies the percentage ratio of that number of hits to the "
1632
"total number of blocks in key cache"),
1634
sys_var_key_cache_age_threshold_update,
1640
static DRIZZLE_SYSVAR_UINT(key_cache_division_limit, myisam_key_cache_division_limit,
1641
PLUGIN_VAR_RQCMDARG,
1642
N_("The minimum percentage of warm blocks in key cache"),
1644
sys_var_key_cache_division_limit_update,
1650
static DRIZZLE_SYSVAR_UINT(key_cache_size,
1651
myisam_key_cache_size,
1652
PLUGIN_VAR_RQCMDARG,
1653
N_("The size of the buffer used for index blocks for MyISAM tables. "
1654
"Increase this to get better index handling (for all reads and multiple "
1655
"writes) to as much as you can afford;"),
1657
sys_var_key_cache_size_update,
1663
static DRIZZLE_SYSVAR_UINT(repair_threads, repair_threads,
1664
PLUGIN_VAR_RQCMDARG,
1665
N_("Number of threads to use when repairing MyISAM tables. The value of "
1666
"1 disables parallel repair."),
1667
NULL, NULL, 1, 1, UINT32_MAX, 0);
1669
static DRIZZLE_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size,
1670
PLUGIN_VAR_RQCMDARG,
1671
N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."),
1672
NULL, NULL, INT32_MAX, 0, UINT64_MAX, 0);
1674
static DRIZZLE_SYSVAR_ULONGLONG(sort_buffer_size, sort_buffer_size,
1675
PLUGIN_VAR_RQCMDARG,
1676
N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
1677
NULL, NULL, 8192*1024, 1024, SIZE_MAX, 0);
1679
extern uint32_t data_pointer_size;
1680
static DRIZZLE_SYSVAR_UINT(data_pointer_size, data_pointer_size,
1681
PLUGIN_VAR_RQCMDARG,
1682
N_("Default pointer size to be used for MyISAM tables."),
1683
NULL, NULL, 6, 2, 7, 0);
1685
static drizzle_sys_var* sys_variables[]= {
1686
DRIZZLE_SYSVAR(key_cache_block_size),
1687
DRIZZLE_SYSVAR(key_cache_size),
1688
DRIZZLE_SYSVAR(key_cache_division_limit),
1689
DRIZZLE_SYSVAR(key_cache_age_threshold),
1690
DRIZZLE_SYSVAR(repair_threads),
1691
DRIZZLE_SYSVAR(max_sort_file_size),
1692
DRIZZLE_SYSVAR(sort_buffer_size),
1693
DRIZZLE_SYSVAR(data_pointer_size),
1514
1698
DRIZZLE_DECLARE_PLUGIN
1516
1700
DRIZZLE_VERSION_ID,
1520
1704
"Default engine as of MySQL 3.23 with great performance",
1521
1705
PLUGIN_LICENSE_GPL,
1522
1706
myisam_init, /* Plugin Init */
1523
NULL, /* system variables */
1524
init_options /* config options */
1707
sys_variables, /* system variables */
1708
NULL /* config options */
1526
1710
DRIZZLE_DECLARE_PLUGIN_END;