~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

Merge of Keycache gutting code. (this is a test).

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
static uint64_t max_sort_file_size;
63
63
static uint64_t sort_buffer_size;
64
64
 
 
65
void st_mi_isam_share::setKeyCache()
 
66
{
 
67
  (void)init_key_cache(&key_cache,
 
68
                       myisam_key_cache_block_size,
 
69
                       myisam_key_cache_size,
 
70
                       myisam_key_cache_division_limit, 
 
71
                       myisam_key_cache_age_threshold);
 
72
}
 
73
 
65
74
/*****************************************************************************
66
75
** MyISAM tables
67
76
*****************************************************************************/
95
104
  virtual ~MyisamEngine()
96
105
  { 
97
106
    pthread_mutex_destroy(&THR_LOCK_myisam);
98
 
    end_key_cache(dflt_key_cache, 1);           // Can never fail
99
107
 
100
108
    mi_panic(HA_PANIC_CLOSE);
101
109
  }
1560
1568
  engine= new MyisamEngine(engine_name);
1561
1569
  context.add(engine);
1562
1570
 
1563
 
  /* call ha_init_key_cache() on all key caches to init them */
1564
 
  int error= init_key_cache(dflt_key_cache,
1565
 
                            myisam_key_cache_block_size,
1566
 
                            myisam_key_cache_size,
1567
 
                            myisam_key_cache_division_limit, 
1568
 
                            myisam_key_cache_age_threshold);
1569
 
 
1570
 
  if (error == 0)
1571
 
    exit(1); /* Memory Allocation Failure */
1572
 
 
1573
1571
  return 0;
1574
1572
}
1575
1573
 
1577
1575
static void sys_var_key_cache_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
1578
1576
{
1579
1577
  uint32_t tmp= *static_cast<const uint32_t *>(save);
1580
 
  bool error= 0;
1581
1578
 
1582
1579
        struct option option_limits;
1583
1580
  plugin_opt_set_limits(&option_limits, var);
1584
1581
        option_limits.name= "myisam_key_cache_size";
1585
1582
 
1586
 
  if (dflt_key_cache->in_init)
1587
 
    return;
1588
 
 
1589
1583
  myisam_key_cache_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1590
1584
 
1591
 
  /* If key cache didn't existed initialize it, else resize it */
1592
 
  dflt_key_cache->in_init= 1;
1593
 
 
1594
 
  error= ! resize_key_cache(dflt_key_cache,
1595
 
                                                                                                                myisam_key_cache_block_size,
1596
 
                            myisam_key_cache_size,
1597
 
                            myisam_key_cache_division_limit,
1598
 
                                                                                                          myisam_key_cache_age_threshold);
1599
 
  dflt_key_cache->in_init= 0;
1600
1585
}
1601
1586
 
1602
 
static void sys_var_key_cache_block_size_update(Session *session, drizzle_sys_var *var, void *, const void *save)
 
1587
static void sys_var_key_cache_block_size_update(Session *, drizzle_sys_var *var, void *, const void *)
1603
1588
{
1604
 
  uint32_t tmp= *static_cast<const uint32_t *>(save);
1605
 
  bool error= 0;
1606
 
 
1607
1589
        struct option option_limits;
1608
1590
  plugin_opt_set_limits(&option_limits, var);
1609
1591
        option_limits.name= "myisam_key_cache_block_size";
1610
1592
 
1611
 
  if (dflt_key_cache->in_init)
1612
 
    return;
1613
 
 
1614
 
  myisam_key_cache_block_size= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1615
 
 
1616
 
  dflt_key_cache->in_init= 1;
1617
 
 
1618
 
  error= ! resize_key_cache(dflt_key_cache,
1619
 
                                                                                                                myisam_key_cache_block_size,
1620
 
                            myisam_key_cache_size,
1621
 
                            myisam_key_cache_division_limit,
1622
 
                                                                                                          myisam_key_cache_age_threshold);
1623
 
 
1624
 
  dflt_key_cache->in_init= 0;
1625
1593
}
1626
1594
 
1627
 
static void sys_var_key_cache_division_limit_update(Session *session, drizzle_sys_var *var, void *, const void *save)
 
1595
static void sys_var_key_cache_division_limit_update(Session *, drizzle_sys_var *var, void *, const void *)
1628
1596
{
1629
 
  uint32_t tmp= *static_cast<const uint32_t *>(save);
1630
 
  bool error= 0;
1631
 
 
1632
1597
        struct option option_limits;
1633
1598
  plugin_opt_set_limits(&option_limits, var);
1634
1599
        option_limits.name= "myisam_key_cache_division_limit";
1635
1600
 
1636
 
  if (dflt_key_cache->in_init)
1637
 
    return;
1638
 
 
1639
 
  myisam_key_cache_division_limit= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1640
 
 
1641
 
  dflt_key_cache->in_init= 1;
1642
 
 
1643
 
  error= ! resize_key_cache(dflt_key_cache,
1644
 
                                                                                                                myisam_key_cache_block_size,
1645
 
                            myisam_key_cache_size,
1646
 
                            myisam_key_cache_division_limit,
1647
 
                                                                                                          myisam_key_cache_age_threshold);
1648
 
 
1649
 
  dflt_key_cache->in_init= 0;
1650
1601
}
1651
1602
 
1652
 
static void sys_var_key_cache_age_threshold_update(Session *session, drizzle_sys_var *var, void *, const void *save)
 
1603
static void sys_var_key_cache_age_threshold_update(Session *, drizzle_sys_var *var, void *, const void *)
1653
1604
{
1654
 
  uint32_t tmp= *static_cast<const uint32_t *>(save);
1655
 
  bool error= 0;
1656
 
 
1657
 
        struct option option_limits;
 
1605
  struct option option_limits;
1658
1606
  plugin_opt_set_limits(&option_limits, var);
1659
 
        option_limits.name= "myisam_key_cache_age_threshold";
1660
 
 
1661
 
  if (dflt_key_cache->in_init)
1662
 
    return;
1663
 
 
1664
 
  myisam_key_cache_age_threshold= static_cast<uint32_t>(fix_unsigned(session, static_cast<uint64_t>(tmp), &option_limits));
1665
 
 
1666
 
  dflt_key_cache->in_init= 1;
1667
 
 
1668
 
  error= ! resize_key_cache(dflt_key_cache,
1669
 
                                                                                                                myisam_key_cache_block_size,
1670
 
                            myisam_key_cache_size,
1671
 
                            myisam_key_cache_division_limit,
1672
 
                                                                                                          myisam_key_cache_age_threshold);
1673
 
 
1674
 
  dflt_key_cache->in_init= 0;
 
1607
  option_limits.name= "myisam_key_cache_age_threshold";
1675
1608
}
1676
1609
 
1677
1610
static DRIZZLE_SYSVAR_UINT(key_cache_block_size,