~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

  • Committer: Brian Aker
  • Date: 2010-11-11 04:18:45 UTC
  • mfrom: (1897.4.20 rip-plugin-sysvar)
  • Revision ID: brian@tangent.org-20101111041845-b7td4vnx4wu01ga1
Merge in changes from Monty for sys var.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
62
63
 
63
64
void st_mi_isam_share::setKeyCache()
64
65
{
700
701
  param.using_global_keycache = 1;
701
702
  param.session= session;
702
703
  param.out_flag= 0;
703
 
  param.sort_buffer_length= (size_t)sort_buffer_size;
 
704
  param.sort_buffer_length= static_cast<size_t>(sort_buffer_size);
704
705
  strcpy(fixed_name,file->filename);
705
706
 
706
707
  // Don't lock tables if we have used LOCK Table
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)
916
917
    {
1483
1484
  return (uint)file->state->checksum;
1484
1485
}
1485
1486
 
1486
 
static MyisamEngine *engine= NULL;
1487
 
 
1488
1487
static int myisam_init(module::Context &context)
1489
1488
1490
 
  const module::option_map &vm= context.getOptions();
1491
 
 
1492
 
  if (vm.count("max-sort-file-size"))
1493
 
  {
1494
 
    if (max_sort_file_size > UINT64_MAX)
1495
 
    {
1496
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-sort-file-size\n"));
1497
 
      exit(-1);
1498
 
    }
1499
 
  }
1500
 
 
1501
 
  if (vm.count("sort-buffer-size"))
1502
 
  {
1503
 
    if (sort_buffer_size < 1024 || sort_buffer_size > SIZE_MAX)
1504
 
    {
1505
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for sort-buffer-size\n"));
1506
 
      exit(-1);
1507
 
    }
1508
 
  }
1509
 
 
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",
 
1491
                                                                 sort_buffer_size,
 
1492
                                                                 8196*1024));
 
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>()));
1512
1496
 
1513
1497
  return 0;
1514
1498
}
1515
1499
 
1516
1500
 
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);
1521
 
 
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);
1526
 
 
1527
1501
static void init_options(drizzled::module::option_context &context)
1528
1502
{
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."));
1535
1509
}
1536
1510
 
1537
 
static drizzle_sys_var* sys_variables[]= {
1538
 
  DRIZZLE_SYSVAR(max_sort_file_size),
1539
 
  DRIZZLE_SYSVAR(sort_buffer_size),
1540
 
  NULL
1541
 
};
1542
 
 
1543
1511
 
1544
1512
DRIZZLE_DECLARE_PLUGIN
1545
1513
{
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                  */
1555
1523
}
1556
1524
DRIZZLE_DECLARE_PLUGIN_END;