1487
1505
return (uint)file->state->checksum;
1508
static MyisamEngine *engine= NULL;
1490
1510
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>()));
1512
engine= new MyisamEngine(engine_name);
1513
context.add(engine);
1515
/* call ha_init_key_cache() on all key caches to init them */
1516
int error= init_key_cache(dflt_key_cache,
1517
myisam_key_cache_block_size,
1518
myisam_key_cache_size,
1519
myisam_key_cache_division_limit,
1520
myisam_key_cache_age_threshold);
1523
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."));
1529
static void sys_var_key_cache_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1531
uint32_t tmp= *static_cast<const uint32_t *>(save);
1534
struct option option_limits;
1535
plugin_opt_set_limits(&option_limits, var);
1536
option_limits.name= "myisam_key_cache_size";
1538
if (dflt_key_cache->in_init)
1541
myisam_key_cache_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1543
/* If key cache didn't existed initialize it, else resize it */
1544
dflt_key_cache->in_init= 1;
1546
error= ! resize_key_cache(dflt_key_cache,
1547
myisam_key_cache_block_size,
1548
myisam_key_cache_size,
1549
myisam_key_cache_division_limit,
1550
myisam_key_cache_age_threshold);
1551
dflt_key_cache->in_init= 0;
1554
static void sys_var_key_cache_block_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1556
uint32_t tmp= *static_cast<const uint32_t *>(save);
1559
struct option option_limits;
1560
plugin_opt_set_limits(&option_limits, var);
1561
option_limits.name= "myisam_key_cache_block_size";
1563
if (dflt_key_cache->in_init)
1566
myisam_key_cache_block_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1568
dflt_key_cache->in_init= 1;
1570
error= ! resize_key_cache(dflt_key_cache,
1571
myisam_key_cache_block_size,
1572
myisam_key_cache_size,
1573
myisam_key_cache_division_limit,
1574
myisam_key_cache_age_threshold);
1576
dflt_key_cache->in_init= 0;
1579
static void sys_var_key_cache_division_limit_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1581
uint32_t tmp= *static_cast<const uint32_t *>(save);
1584
struct option option_limits;
1585
plugin_opt_set_limits(&option_limits, var);
1586
option_limits.name= "myisam_key_cache_division_limit";
1588
if (dflt_key_cache->in_init)
1591
myisam_key_cache_division_limit= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1593
dflt_key_cache->in_init= 1;
1595
error= ! resize_key_cache(dflt_key_cache,
1596
myisam_key_cache_block_size,
1597
myisam_key_cache_size,
1598
myisam_key_cache_division_limit,
1599
myisam_key_cache_age_threshold);
1601
dflt_key_cache->in_init= 0;
1604
static void sys_var_key_cache_age_threshold_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1606
uint32_t tmp= *static_cast<const uint32_t *>(save);
1609
struct option option_limits;
1610
plugin_opt_set_limits(&option_limits, var);
1611
option_limits.name= "myisam_key_cache_age_threshold";
1613
if (dflt_key_cache->in_init)
1616
myisam_key_cache_age_threshold= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1618
dflt_key_cache->in_init= 1;
1620
error= ! resize_key_cache(dflt_key_cache,
1621
myisam_key_cache_block_size,
1622
myisam_key_cache_size,
1623
myisam_key_cache_division_limit,
1624
myisam_key_cache_age_threshold);
1626
dflt_key_cache->in_init= 0;
1629
static DRIZZLE_SYSVAR_UINT(key_cache_block_size,
1630
myisam_key_cache_block_size,
1631
PLUGIN_VAR_RQCMDARG,
1632
N_("Block size to be used for MyISAM index pages."),
1634
sys_var_key_cache_block_size_update,
1635
KEY_CACHE_BLOCK_SIZE,
1640
static DRIZZLE_SYSVAR_UINT(key_cache_age_threshold, myisam_key_cache_age_threshold,
1641
PLUGIN_VAR_RQCMDARG,
1642
N_("This characterizes the number of hits a hot block has to be untouched "
1643
"until it is considered aged enough to be downgraded to a warm block. "
1644
"This specifies the percentage ratio of that number of hits to the "
1645
"total number of blocks in key cache"),
1647
sys_var_key_cache_age_threshold_update,
1653
static DRIZZLE_SYSVAR_UINT(key_cache_division_limit, myisam_key_cache_division_limit,
1654
PLUGIN_VAR_RQCMDARG,
1655
N_("The minimum percentage of warm blocks in key cache"),
1657
sys_var_key_cache_division_limit_update,
1663
static DRIZZLE_SYSVAR_UINT(key_cache_size,
1664
myisam_key_cache_size,
1665
PLUGIN_VAR_RQCMDARG,
1666
N_("The size of the buffer used for index blocks for MyISAM tables. "
1667
"Increase this to get better index handling (for all reads and multiple "
1668
"writes) to as much as you can afford;"),
1670
sys_var_key_cache_size_update,
1676
static DRIZZLE_SYSVAR_UINT(repair_threads, repair_threads,
1677
PLUGIN_VAR_RQCMDARG,
1678
N_("Number of threads to use when repairing MyISAM tables. The value of "
1679
"1 disables parallel repair."),
1680
NULL, NULL, 1, 1, UINT32_MAX, 0);
1682
static DRIZZLE_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size,
1683
PLUGIN_VAR_RQCMDARG,
1684
N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."),
1685
NULL, NULL, INT32_MAX, 0, UINT64_MAX, 0);
1687
static DRIZZLE_SYSVAR_ULONGLONG(sort_buffer_size, sort_buffer_size,
1688
PLUGIN_VAR_RQCMDARG,
1689
N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
1690
NULL, NULL, 8192*1024, 1024, SIZE_MAX, 0);
1692
extern uint32_t data_pointer_size;
1693
static DRIZZLE_SYSVAR_UINT(data_pointer_size, data_pointer_size,
1694
PLUGIN_VAR_RQCMDARG,
1695
N_("Default pointer size to be used for MyISAM tables."),
1696
NULL, NULL, 6, 2, 7, 0);
1698
static drizzle_sys_var* sys_variables[]= {
1699
DRIZZLE_SYSVAR(key_cache_block_size),
1700
DRIZZLE_SYSVAR(key_cache_size),
1701
DRIZZLE_SYSVAR(key_cache_division_limit),
1702
DRIZZLE_SYSVAR(key_cache_age_threshold),
1703
DRIZZLE_SYSVAR(repair_threads),
1704
DRIZZLE_SYSVAR(max_sort_file_size),
1705
DRIZZLE_SYSVAR(sort_buffer_size),
1706
DRIZZLE_SYSVAR(data_pointer_size),
1514
1711
DRIZZLE_DECLARE_PLUGIN
1516
1713
DRIZZLE_VERSION_ID,
1520
1717
"Default engine as of MySQL 3.23 with great performance",
1521
1718
PLUGIN_LICENSE_GPL,
1522
1719
myisam_init, /* Plugin Init */
1523
NULL, /* system variables */
1524
init_options /* config options */
1720
sys_variables, /* system variables */
1721
NULL /* config options */
1526
1723
DRIZZLE_DECLARE_PLUGIN_END;