~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

updating to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
#include "drizzled/transaction_services.h"
62
62
#include "drizzled/constrained_value.h"
63
63
#include "drizzled/visibility.h"
 
64
#include "drizzled/typelib.h"
64
65
#include "drizzled/plugin/storage_engine.h"
65
66
 
66
67
#include <cstdio>
218
219
 
219
220
static sys_var_session_storage_engine sys_storage_engine("storage_engine",
220
221
                                       &drizzle_system_variables::storage_engine);
221
 
static sys_var_const_str        sys_system_time_zone("system_time_zone",
222
 
                                             system_time_zone);
223
222
static sys_var_size_t_ptr       sys_table_def_size("table_definition_cache",
224
223
                                             &table_def_size);
225
224
static sys_var_uint64_t_ptr     sys_table_cache_size("table_open_cache",
308
307
sys_var_session_uint64_t sys_group_concat_max_len("group_concat_max_len",
309
308
                                                  &drizzle_system_variables::group_concat_max_len);
310
309
 
311
 
sys_var_session_time_zone sys_time_zone("time_zone");
312
 
 
313
310
/* Global read-only variable containing hostname */
314
311
static sys_var_const_str        sys_hostname("hostname", glob_hostname);
315
312
 
859
856
      goto err;
860
857
    }
861
858
 
862
 
    uint64_t tmp_val= find_type(enum_names, res->ptr(), res->length(),1);
 
859
    uint64_t tmp_val= enum_names->find_type(res->ptr(), res->length(), true);
863
860
    if (tmp_val == 0)
864
861
    {
865
862
      value= res->c_ptr();
1161
1158
  return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1162
1159
}
1163
1160
 
1164
 
 
1165
 
bool sys_var_session_time_zone::update(Session *session, set_var *var)
1166
 
{
1167
 
  char buff[MAX_TIME_ZONE_NAME_LENGTH];
1168
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
1169
 
  String *res= var->value->val_str(&str);
1170
 
 
1171
 
  Time_zone *tmp= my_tz_find(session, res);
1172
 
  if (tmp == NULL)
1173
 
  {
1174
 
    boost::throw_exception(invalid_option_value(var->var->getName()) << invalid_value(std::string(res ? res->c_ptr() : "NULL")));
1175
 
    return 1;
1176
 
  }
1177
 
  /* We are using Time_zone object found during check() phase. */
1178
 
  if (var->type == OPT_GLOBAL)
1179
 
  {
1180
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1181
 
    global_system_variables.time_zone= tmp;
1182
 
  }
1183
 
  else
1184
 
  {
1185
 
    session->variables.time_zone= tmp;
1186
 
  }
1187
 
 
1188
 
  return 0;
1189
 
}
1190
 
 
1191
 
 
1192
 
unsigned char *sys_var_session_time_zone::value_ptr(Session *session,
1193
 
                                                    sql_var_t type,
1194
 
                                                    const LEX_STRING *)
1195
 
{
1196
 
  /*
1197
 
    We can use ptr() instead of c_ptr() here because String contaning
1198
 
    time zone name is guaranteed to be zero ended.
1199
 
  */
1200
 
  if (type == OPT_GLOBAL)
1201
 
    return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
1202
 
  else
1203
 
  {
1204
 
    /*
1205
 
      This is an ugly fix for replication: we don't replicate properly queries
1206
 
      invoking system variables' values to update tables; but
1207
 
      CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
1208
 
      replicable (i.e. we tell the binlog code to store the session
1209
 
      timezone). If it's the global value which was used we can't replicate
1210
 
      (binlog code stores session value only).
1211
 
    */
1212
 
    return (unsigned char *)(session->variables.time_zone->get_name()->ptr());
1213
 
  }
1214
 
}
1215
 
 
1216
 
 
1217
 
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
1218
 
{
1219
 
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1220
 
  if (type == OPT_GLOBAL)
1221
 
  {
1222
 
    if (default_tz_name)
1223
 
    {
1224
 
      String str(default_tz_name, &my_charset_utf8_general_ci);
1225
 
      /*
1226
 
        We are guaranteed to find this time zone since its existence
1227
 
        is checked during start-up.
1228
 
      */
1229
 
      global_system_variables.time_zone= my_tz_find(session, &str);
1230
 
    }
1231
 
    else
1232
 
      global_system_variables.time_zone= my_tz_SYSTEM;
1233
 
  }
1234
 
  else
1235
 
    session->variables.time_zone= global_system_variables.time_zone;
1236
 
}
1237
 
 
1238
 
 
1239
 
 
1240
1161
bool sys_var_session_lc_time_names::update(Session *session, set_var *var)
1241
1162
{
1242
1163
  MY_LOCALE *locale_match;
1609
1530
    add_sys_var_to_list(&sys_sql_notes, my_long_options);
1610
1531
    add_sys_var_to_list(&sys_sql_warnings, my_long_options);
1611
1532
    add_sys_var_to_list(&sys_storage_engine, my_long_options);
1612
 
    add_sys_var_to_list(&sys_system_time_zone, my_long_options);
1613
1533
    add_sys_var_to_list(&sys_table_cache_size, my_long_options);
1614
1534
    add_sys_var_to_list(&sys_table_def_size, my_long_options);
1615
1535
    add_sys_var_to_list(&sys_table_lock_wait_timeout, my_long_options);
1616
1536
    add_sys_var_to_list(&sys_thread_stack_size, my_long_options);
1617
 
    add_sys_var_to_list(&sys_time_zone, my_long_options);
1618
1537
    add_sys_var_to_list(&sys_timed_mutexes, my_long_options);
1619
1538
    add_sys_var_to_list(&sys_timestamp, my_long_options);
1620
1539
    add_sys_var_to_list(&sys_tmp_table_size, my_long_options);