1487
1489
return (uint)file->state->checksum;
1492
static MyisamEngine *engine= NULL;
1490
1494
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>()));
1496
engine= new MyisamEngine(engine_name);
1497
context.add(engine);
1499
/* call ha_init_key_cache() on all key caches to init them */
1500
int error= init_key_cache(dflt_key_cache,
1501
myisam_key_cache_block_size,
1502
myisam_key_cache_size,
1503
myisam_key_cache_division_limit,
1504
myisam_key_cache_age_threshold);
1507
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."));
1513
static void sys_var_key_cache_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1515
uint32_t tmp= *static_cast<const uint32_t *>(save);
1518
struct option option_limits;
1519
plugin_opt_set_limits(&option_limits, var);
1520
option_limits.name= "myisam_key_cache_size";
1522
if (dflt_key_cache->in_init)
1525
myisam_key_cache_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1527
/* If key cache didn't existed initialize it, else resize it */
1528
dflt_key_cache->in_init= 1;
1530
error= ! resize_key_cache(dflt_key_cache,
1531
myisam_key_cache_block_size,
1532
myisam_key_cache_size,
1533
myisam_key_cache_division_limit,
1534
myisam_key_cache_age_threshold);
1535
dflt_key_cache->in_init= 0;
1538
static void sys_var_key_cache_block_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1540
uint32_t tmp= *static_cast<const uint32_t *>(save);
1543
struct option option_limits;
1544
plugin_opt_set_limits(&option_limits, var);
1545
option_limits.name= "myisam_key_cache_block_size";
1547
if (dflt_key_cache->in_init)
1550
myisam_key_cache_block_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1552
dflt_key_cache->in_init= 1;
1554
error= ! resize_key_cache(dflt_key_cache,
1555
myisam_key_cache_block_size,
1556
myisam_key_cache_size,
1557
myisam_key_cache_division_limit,
1558
myisam_key_cache_age_threshold);
1560
dflt_key_cache->in_init= 0;
1563
static void sys_var_key_cache_division_limit_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1565
uint32_t tmp= *static_cast<const uint32_t *>(save);
1568
struct option option_limits;
1569
plugin_opt_set_limits(&option_limits, var);
1570
option_limits.name= "myisam_key_cache_division_limit";
1572
if (dflt_key_cache->in_init)
1575
myisam_key_cache_division_limit= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1577
dflt_key_cache->in_init= 1;
1579
error= ! resize_key_cache(dflt_key_cache,
1580
myisam_key_cache_block_size,
1581
myisam_key_cache_size,
1582
myisam_key_cache_division_limit,
1583
myisam_key_cache_age_threshold);
1585
dflt_key_cache->in_init= 0;
1588
static void sys_var_key_cache_age_threshold_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1590
uint32_t tmp= *static_cast<const uint32_t *>(save);
1593
struct option option_limits;
1594
plugin_opt_set_limits(&option_limits, var);
1595
option_limits.name= "myisam_key_cache_age_threshold";
1597
if (dflt_key_cache->in_init)
1600
myisam_key_cache_age_threshold= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1602
dflt_key_cache->in_init= 1;
1604
error= ! resize_key_cache(dflt_key_cache,
1605
myisam_key_cache_block_size,
1606
myisam_key_cache_size,
1607
myisam_key_cache_division_limit,
1608
myisam_key_cache_age_threshold);
1610
dflt_key_cache->in_init= 0;
1613
static DRIZZLE_SYSVAR_UINT(key_cache_block_size,
1614
myisam_key_cache_block_size,
1615
PLUGIN_VAR_RQCMDARG,
1616
N_("Block size to be used for MyISAM index pages."),
1618
sys_var_key_cache_block_size_update,
1619
KEY_CACHE_BLOCK_SIZE,
1624
static DRIZZLE_SYSVAR_UINT(key_cache_age_threshold, myisam_key_cache_age_threshold,
1625
PLUGIN_VAR_RQCMDARG,
1626
N_("This characterizes the number of hits a hot block has to be untouched "
1627
"until it is considered aged enough to be downgraded to a warm block. "
1628
"This specifies the percentage ratio of that number of hits to the "
1629
"total number of blocks in key cache"),
1631
sys_var_key_cache_age_threshold_update,
1637
static DRIZZLE_SYSVAR_UINT(key_cache_division_limit, myisam_key_cache_division_limit,
1638
PLUGIN_VAR_RQCMDARG,
1639
N_("The minimum percentage of warm blocks in key cache"),
1641
sys_var_key_cache_division_limit_update,
1647
static DRIZZLE_SYSVAR_UINT(key_cache_size,
1648
myisam_key_cache_size,
1649
PLUGIN_VAR_RQCMDARG,
1650
N_("The size of the buffer used for index blocks for MyISAM tables. "
1651
"Increase this to get better index handling (for all reads and multiple "
1652
"writes) to as much as you can afford;"),
1654
sys_var_key_cache_size_update,
1660
static DRIZZLE_SYSVAR_UINT(repair_threads, repair_threads,
1661
PLUGIN_VAR_RQCMDARG,
1662
N_("Number of threads to use when repairing MyISAM tables. The value of "
1663
"1 disables parallel repair."),
1664
NULL, NULL, 1, 1, UINT32_MAX, 0);
1666
static DRIZZLE_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size,
1667
PLUGIN_VAR_RQCMDARG,
1668
N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."),
1669
NULL, NULL, INT32_MAX, 0, UINT64_MAX, 0);
1671
static DRIZZLE_SYSVAR_ULONGLONG(sort_buffer_size, sort_buffer_size,
1672
PLUGIN_VAR_RQCMDARG,
1673
N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
1674
NULL, NULL, 8192*1024, 1024, SIZE_MAX, 0);
1676
extern uint32_t data_pointer_size;
1677
static DRIZZLE_SYSVAR_UINT(data_pointer_size, data_pointer_size,
1678
PLUGIN_VAR_RQCMDARG,
1679
N_("Default pointer size to be used for MyISAM tables."),
1680
NULL, NULL, 6, 2, 7, 0);
1682
static drizzle_sys_var* sys_variables[]= {
1683
DRIZZLE_SYSVAR(key_cache_block_size),
1684
DRIZZLE_SYSVAR(key_cache_size),
1685
DRIZZLE_SYSVAR(key_cache_division_limit),
1686
DRIZZLE_SYSVAR(key_cache_age_threshold),
1687
DRIZZLE_SYSVAR(repair_threads),
1688
DRIZZLE_SYSVAR(max_sort_file_size),
1689
DRIZZLE_SYSVAR(sort_buffer_size),
1690
DRIZZLE_SYSVAR(data_pointer_size),
1514
1695
DRIZZLE_DECLARE_PLUGIN
1516
1697
DRIZZLE_VERSION_ID,
1520
1701
"Default engine as of MySQL 3.23 with great performance",
1521
1702
PLUGIN_LICENSE_GPL,
1522
1703
myisam_init, /* Plugin Init */
1523
NULL, /* system variables */
1524
init_options /* config options */
1704
sys_variables, /* system variables */
1705
NULL /* config options */
1526
1707
DRIZZLE_DECLARE_PLUGIN_END;