~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

  • Committer: Olaf van der Spek
  • Date: 2011-04-05 12:26:58 UTC
  • mto: (2278.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2272.
  • Revision ID: olafvdspek@gmail.com-20110405122658-xxrvmobwwwwf3oct
Refactor Open_tables_state

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
#include <drizzled/item/string.h>
55
55
#include <drizzled/plugin.h>
56
56
#include <drizzled/version.h>
57
 
#include <drizzled/strfunc.h>
58
57
#include <drizzled/internal/m_string.h>
59
58
#include <drizzled/pthread_globals.h>
60
59
#include <drizzled/charset.h>
63
62
#include <drizzled/visibility.h>
64
63
#include <drizzled/typelib.h>
65
64
#include <drizzled/plugin/storage_engine.h>
 
65
#include <drizzled/system_variables.h>
 
66
#include <drizzled/catalog/instance.h>
66
67
 
67
68
#include <cstdio>
68
69
#include <map>
71
72
 
72
73
using namespace std;
73
74
 
74
 
namespace drizzled
75
 
{
 
75
namespace drizzled {
76
76
 
77
77
namespace internal
78
78
{
79
 
extern bool timed_mutexes;
 
79
        extern bool timed_mutexes;
80
80
}
81
81
 
82
82
extern plugin::StorageEngine *myisam_engine;
83
83
extern bool timed_mutexes;
84
84
 
85
85
extern struct option my_long_options[];
86
 
extern const CHARSET_INFO *character_set_filesystem;
 
86
extern const charset_info_st *character_set_filesystem;
87
87
extern size_t my_thread_stack_size;
88
88
 
89
89
typedef map<string, sys_var *> SystemVariableMap;
1066
1066
 
1067
1067
bool sys_var_collation_sv::update(Session *session, set_var *var)
1068
1068
{
1069
 
  const CHARSET_INFO *tmp;
 
1069
  const charset_info_st *tmp;
1070
1070
 
1071
1071
  if (var->value->result_type() == STRING_RESULT)
1072
1072
  {
1120
1120
                                               sql_var_t type,
1121
1121
                                               const LEX_STRING *)
1122
1122
{
1123
 
  const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
 
1123
  const charset_info_st *cs= ((type == OPT_GLOBAL) ?
1124
1124
                           global_system_variables.*offset :
1125
1125
                           session->variables.*offset);
1126
1126
  return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1427
1427
  if (result)
1428
1428
  {
1429
1429
    drizzle_show_var *show= result;
1430
 
 
1431
 
    SystemVariableMap::const_iterator iter= system_variable_map.begin();
1432
 
    while (iter != system_variable_map.end())
 
1430
    BOOST_FOREACH(SystemVariableMap::const_reference iter, system_variable_map)
1433
1431
    {
1434
 
      sys_var *var= (*iter).second;
 
1432
      sys_var *var= iter.second;
1435
1433
      show->name= var->getName().c_str();
1436
1434
      show->value= (char*) var;
1437
1435
      show->type= SHOW_SYS;
1438
1436
      ++show;
1439
 
      ++iter;
1440
1437
    }
1441
1438
 
1442
1439
    /* make last element empty */
1445
1442
  return result;
1446
1443
}
1447
1444
 
1448
 
 
1449
 
 
1450
1445
void add_sys_var_to_list(sys_var *var)
1451
1446
{
1452
1447
  string lower_name(var->getName());
1453
 
  transform(lower_name.begin(), lower_name.end(),
1454
 
            lower_name.begin(), ::tolower);
 
1448
  transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
1455
1449
 
1456
1450
  /* this fails if there is a conflicting variable name. */
1457
 
  if (system_variable_map.find(lower_name) != system_variable_map.end())
 
1451
  if (system_variable_map.count(lower_name))
1458
1452
  {
1459
1453
    errmsg_printf(error::ERROR, _("Variable named %s already exists!\n"),
1460
1454
                  var->getName().c_str());
1586
1580
sys_var *find_sys_var(const std::string &name)
1587
1581
{
1588
1582
  string lower_name(name);
1589
 
  transform(lower_name.begin(), lower_name.end(),
1590
 
            lower_name.begin(), ::tolower);
 
1583
  transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
1591
1584
 
1592
1585
  sys_var *result= NULL;
1593
1586
 
1594
 
  SystemVariableMap::iterator iter= system_variable_map.find(lower_name);
1595
 
  if (iter != system_variable_map.end())
1596
 
  {
1597
 
    result= (*iter).second;
1598
 
  } 
 
1587
  if (SystemVariableMap::mapped_type* ptr= find_ptr(system_variable_map, lower_name))
 
1588
    result= *ptr;
1599
1589
 
1600
1590
  if (result == NULL)
1601
1591
  {
1629
1619
 
1630
1620
void sys_var_session_storage_engine::set_default(Session *session, sql_var_t type)
1631
1621
{
1632
 
  plugin::StorageEngine *old_value, *new_value, **value;
 
1622
  plugin::StorageEngine *new_value, **value;
1633
1623
  if (type == OPT_GLOBAL)
1634
1624
  {
1635
1625
    value= &(global_system_variables.*offset);
1641
1631
    new_value= global_system_variables.*offset;
1642
1632
  }
1643
1633
  assert(new_value);
1644
 
  old_value= *value;
1645
1634
  *value= new_value;
1646
1635
}
1647
1636