~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
*/
40
40
 
41
 
#include <config.h>
42
 
#include <drizzled/option.h>
43
 
#include <drizzled/error.h>
44
 
#include <drizzled/gettext.h>
45
 
#include <drizzled/tztime.h>
46
 
#include <drizzled/data_home.h>
47
 
#include <drizzled/set_var.h>
48
 
#include <drizzled/session.h>
49
 
#include <drizzled/sql_base.h>
50
 
#include <drizzled/lock.h>
51
 
#include <drizzled/item/uint.h>
52
 
#include <drizzled/item/null.h>
53
 
#include <drizzled/item/float.h>
54
 
#include <drizzled/item/string.h>
55
 
#include <drizzled/plugin.h>
56
 
#include <drizzled/version.h>
57
 
#include <drizzled/strfunc.h>
58
 
#include <drizzled/internal/m_string.h>
59
 
#include <drizzled/pthread_globals.h>
60
 
#include <drizzled/charset.h>
61
 
#include <drizzled/transaction_services.h>
62
 
#include <drizzled/constrained_value.h>
63
 
#include <drizzled/visibility.h>
64
 
#include <drizzled/typelib.h>
65
 
#include <drizzled/plugin/storage_engine.h>
 
41
#include "config.h"
 
42
#include "drizzled/option.h"
 
43
#include "drizzled/error.h"
 
44
#include "drizzled/gettext.h"
 
45
#include "drizzled/tztime.h"
 
46
#include "drizzled/data_home.h"
 
47
#include "drizzled/set_var.h"
 
48
#include "drizzled/session.h"
 
49
#include "drizzled/sql_base.h"
 
50
#include "drizzled/lock.h"
 
51
#include "drizzled/item/uint.h"
 
52
#include "drizzled/item/null.h"
 
53
#include "drizzled/item/float.h"
 
54
#include "drizzled/item/string.h"
 
55
#include "drizzled/plugin.h"
 
56
#include "drizzled/version.h"
 
57
#include "drizzled/strfunc.h"
 
58
#include "drizzled/internal/m_string.h"
 
59
#include "drizzled/pthread_globals.h"
 
60
#include "drizzled/charset.h"
 
61
#include "drizzled/transaction_services.h"
 
62
#include "drizzled/constrained_value.h"
66
63
 
67
64
#include <cstdio>
68
65
#include <map>
92
89
 
93
90
extern TYPELIB tx_isolation_typelib;
94
91
 
95
 
namespace
96
 
{
97
 
static size_t revno= DRIZZLE7_VC_REVNO;
98
 
static size_t release_id= DRIZZLE7_RELEASE_ID;
99
 
}
100
 
 
101
92
const char *bool_type_names[]= { "OFF", "ON", NULL };
102
93
TYPELIB bool_typelib=
103
94
{
220
211
static sys_var_session_size_t   sys_sort_buffer("sort_buffer_size",
221
212
                                                &drizzle_system_variables::sortbuff_size);
222
213
 
223
 
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold",
224
 
                                                                &transaction_message_threshold);
 
214
static sys_var_session_size_t sys_transaction_message_threshold("transaction_message_threshold",
 
215
                                                                &drizzle_system_variables::transaction_message_threshold);
225
216
 
226
217
static sys_var_session_storage_engine sys_storage_engine("storage_engine",
227
218
                                       &drizzle_system_variables::storage_engine);
 
219
static sys_var_const_str        sys_system_time_zone("system_time_zone",
 
220
                                             system_time_zone);
228
221
static sys_var_size_t_ptr       sys_table_def_size("table_definition_cache",
229
222
                                             &table_def_size);
230
223
static sys_var_uint64_t_ptr     sys_table_cache_size("table_open_cache",
313
306
sys_var_session_uint64_t sys_group_concat_max_len("group_concat_max_len",
314
307
                                                  &drizzle_system_variables::group_concat_max_len);
315
308
 
 
309
sys_var_session_time_zone sys_time_zone("time_zone");
 
310
 
316
311
/* Global read-only variable containing hostname */
317
 
static sys_var_const_string sys_hostname("hostname", getServerHostname());
318
 
 
319
 
static sys_var_const_str sys_revid("vc_revid", DRIZZLE7_VC_REVID);
320
 
static sys_var_const_str sys_branch("vc_branch", DRIZZLE7_VC_BRANCH);
321
 
static sys_var_size_t_ptr_readonly sys_revno("vc_revno", &revno);
322
 
static sys_var_size_t_ptr_readonly sys_release_id("vc_release_id", &release_id);
 
312
static sys_var_const_str        sys_hostname("hostname", glob_hostname);
323
313
 
324
314
bool sys_var::check(Session *session, set_var *var)
325
315
{
440
430
{
441
431
  if (fixed)
442
432
  {
443
 
    char buf[DECIMAL_LONGLONG_DIGITS];
 
433
    char buf[22];
444
434
 
445
435
    if (unsignd)
446
436
      internal::ullstr((uint64_t) val, buf);
484
474
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
485
475
{
486
476
  uint64_t tmp= var->getInteger();
487
 
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
488
 
 
 
477
  LOCK_global_system_variables.lock();
489
478
  if (option_limits)
490
479
  {
491
480
    uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
493
482
      *value= newvalue;
494
483
  }
495
484
  else
496
 
  {
497
485
    *value= static_cast<uint32_t>(tmp);
498
 
  }
499
 
 
 
486
  LOCK_global_system_variables.unlock();
500
487
  return 0;
501
488
}
502
489
 
503
490
 
504
 
void sys_var_uint32_t_ptr::set_default(Session *session, sql_var_t)
 
491
void sys_var_uint32_t_ptr::set_default(Session *, sql_var_t)
505
492
{
506
493
  bool not_used;
507
 
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
494
  LOCK_global_system_variables.lock();
508
495
  *value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
509
496
                                           option_limits, &not_used);
 
497
  LOCK_global_system_variables.unlock();
510
498
}
511
499
 
512
500
 
513
501
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
514
502
{
515
503
  uint64_t tmp= var->getInteger();
516
 
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
517
 
 
 
504
  LOCK_global_system_variables.lock();
518
505
  if (option_limits)
519
506
  {
520
507
    uint64_t newvalue= fix_unsigned(session, tmp, option_limits);
522
509
      *value= newvalue;
523
510
  }
524
511
  else
525
 
  {
526
512
    *value= tmp;
527
 
  }
528
 
 
 
513
  LOCK_global_system_variables.unlock();
529
514
  return 0;
530
515
}
531
516
 
532
517
 
533
 
void sys_var_uint64_t_ptr::set_default(Session *session, sql_var_t)
 
518
void sys_var_uint64_t_ptr::set_default(Session *, sql_var_t)
534
519
{
535
520
  if (have_default_value)
536
521
  {
539
524
  else
540
525
  {
541
526
    bool not_used;
542
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
527
    LOCK_global_system_variables.lock();
543
528
    *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
544
529
                                   option_limits, &not_used);
 
530
    LOCK_global_system_variables.unlock();
545
531
  }
546
532
}
547
533
 
549
535
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
550
536
{
551
537
  size_t tmp= size_t(var->getInteger());
552
 
 
553
 
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
554
 
 
 
538
  LOCK_global_system_variables.lock();
555
539
  if (option_limits)
556
540
    *value= fix_size_t(session, tmp, option_limits);
557
541
  else
558
542
    *value= tmp;
559
 
 
 
543
  LOCK_global_system_variables.unlock();
560
544
  return 0;
561
545
}
562
546
 
563
547
 
564
 
void sys_var_size_t_ptr::set_default(Session *session, sql_var_t)
 
548
void sys_var_size_t_ptr::set_default(Session *, sql_var_t)
565
549
{
566
550
  bool not_used;
567
 
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
551
  LOCK_global_system_variables.lock();
568
552
  *value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
569
553
                                         option_limits, &not_used);
570
 
}
571
 
 
572
 
bool sys_var_bool_ptr::check(Session *session, set_var *var)
573
 
{
574
 
  return check_enum(session, var, &bool_typelib);
 
554
  LOCK_global_system_variables.unlock();
575
555
}
576
556
 
577
557
bool sys_var_bool_ptr::update(Session *, set_var *var)
662
642
  if (var->type == OPT_GLOBAL)
663
643
  {
664
644
    /* Lock is needed to make things safe on 32 bit systems */
665
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
645
    LOCK_global_system_variables.lock();
666
646
    global_system_variables.*offset= (ha_rows) tmp;
 
647
    LOCK_global_system_variables.unlock();
667
648
  }
668
649
  else
669
 
  {
670
650
    session->variables.*offset= (ha_rows) tmp;
671
 
  }
672
 
 
673
651
  return 0;
674
652
}
675
653
 
680
658
  {
681
659
    bool not_used;
682
660
    /* We will not come here if option_limits is not set */
683
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
661
    LOCK_global_system_variables.lock();
684
662
    global_system_variables.*offset=
685
663
      (ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
686
664
                                       option_limits, &not_used);
 
665
    LOCK_global_system_variables.unlock();
687
666
  }
688
667
  else
689
 
  {
690
668
    session->variables.*offset= global_system_variables.*offset;
691
 
  }
692
669
}
693
670
 
694
671
 
722
699
  if (var->type == OPT_GLOBAL)
723
700
  {
724
701
    /* Lock is needed to make things safe on 32 bit systems */
725
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
702
    LOCK_global_system_variables.lock();
726
703
    global_system_variables.*offset= (uint64_t) tmp;
 
704
    LOCK_global_system_variables.unlock();
727
705
  }
728
706
  else
729
 
  {
730
707
    session->variables.*offset= (uint64_t) tmp;
731
 
  }
732
 
 
733
708
  return 0;
734
709
}
735
710
 
739
714
  if (type == OPT_GLOBAL)
740
715
  {
741
716
    bool not_used;
742
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
717
    LOCK_global_system_variables.lock();
743
718
    global_system_variables.*offset=
744
719
      getopt_ull_limit_value((uint64_t) option_limits->def_value,
745
720
                             option_limits, &not_used);
 
721
    LOCK_global_system_variables.unlock();
746
722
  }
747
723
  else
748
 
  {
749
724
    session->variables.*offset= global_system_variables.*offset;
750
 
  }
751
725
}
752
726
 
753
727
 
778
752
  if (var->type == OPT_GLOBAL)
779
753
  {
780
754
    /* Lock is needed to make things safe on 32 bit systems */
781
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
755
    LOCK_global_system_variables.lock();
782
756
    global_system_variables.*offset= tmp;
 
757
    LOCK_global_system_variables.unlock();
783
758
  }
784
759
  else
785
 
  {
786
760
    session->variables.*offset= tmp;
787
 
  }
788
 
 
789
761
  return 0;
790
762
}
791
763
 
795
767
  if (type == OPT_GLOBAL)
796
768
  {
797
769
    bool not_used;
798
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
770
    LOCK_global_system_variables.lock();
799
771
    global_system_variables.*offset=
800
772
      (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
801
773
                                     option_limits, &not_used);
 
774
    LOCK_global_system_variables.unlock();
802
775
  }
803
776
  else
804
 
  {
805
777
    session->variables.*offset= global_system_variables.*offset;
806
 
  }
807
778
}
808
779
 
809
780
 
816
787
  return (unsigned char*) &(session->variables.*offset);
817
788
}
818
789
 
819
 
bool sys_var_session_bool::check(Session *session, set_var *var)
820
 
{
821
 
  return check_enum(session, var, &bool_typelib);
822
 
}
823
790
 
824
791
bool sys_var_session_bool::update(Session *session,  set_var *var)
825
792
{
827
794
    global_system_variables.*offset= bool(var->getInteger());
828
795
  else
829
796
    session->variables.*offset= bool(var->getInteger());
830
 
 
831
797
  return 0;
832
798
}
833
799
 
867
833
      goto err;
868
834
    }
869
835
 
870
 
    uint64_t tmp_val= enum_names->find_type(res->ptr(), res->length(), true);
 
836
    uint64_t tmp_val= find_type(enum_names, res->ptr(), res->length(),1);
871
837
    if (tmp_val == 0)
872
838
    {
873
839
      value= res->c_ptr();
920
886
  case SHOW_INT:
921
887
  {
922
888
    uint32_t value;
923
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
889
    LOCK_global_system_variables.lock();
924
890
    value= *(uint*) value_ptr(session, var_type, base);
925
 
 
 
891
    LOCK_global_system_variables.unlock();
926
892
    return new Item_uint((uint64_t) value);
927
893
  }
928
894
  case SHOW_LONGLONG:
929
895
  {
930
896
    int64_t value;
931
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
897
    LOCK_global_system_variables.lock();
932
898
    value= *(int64_t*) value_ptr(session, var_type, base);
933
 
 
 
899
    LOCK_global_system_variables.unlock();
934
900
    return new Item_int(value);
935
901
  }
936
902
  case SHOW_DOUBLE:
937
903
  {
938
904
    double value;
939
 
    {
940
 
      boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
941
 
      value= *(double*) value_ptr(session, var_type, base);
942
 
    }
943
 
 
 
905
    LOCK_global_system_variables.lock();
 
906
    value= *(double*) value_ptr(session, var_type, base);
 
907
    LOCK_global_system_variables.unlock();
944
908
    /* 6, as this is for now only used with microseconds */
945
909
    return new Item_float(value, 6);
946
910
  }
947
911
  case SHOW_HA_ROWS:
948
912
  {
949
913
    ha_rows value;
950
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
914
    LOCK_global_system_variables.lock();
951
915
    value= *(ha_rows*) value_ptr(session, var_type, base);
952
 
 
 
916
    LOCK_global_system_variables.unlock();
953
917
    return new Item_int((uint64_t) value);
954
918
  }
955
919
  case SHOW_SIZE:
956
920
  {
957
921
    size_t value;
958
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
922
    LOCK_global_system_variables.lock();
959
923
    value= *(size_t*) value_ptr(session, var_type, base);
960
 
 
 
924
    LOCK_global_system_variables.unlock();
961
925
    return new Item_int((uint64_t) value);
962
926
  }
963
927
  case SHOW_MY_BOOL:
964
928
  {
965
929
    int32_t value;
966
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
930
    LOCK_global_system_variables.lock();
967
931
    value= *(bool*) value_ptr(session, var_type, base);
 
932
    LOCK_global_system_variables.unlock();
968
933
    return new Item_int(value,1);
969
934
  }
970
935
  case SHOW_CHAR_PTR:
971
936
  {
972
937
    Item *tmp;
973
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
938
    LOCK_global_system_variables.lock();
974
939
    char *str= *(char**) value_ptr(session, var_type, base);
975
940
    if (str)
976
941
    {
983
948
      tmp= new Item_null();
984
949
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
985
950
    }
986
 
 
 
951
    LOCK_global_system_variables.unlock();
987
952
    return tmp;
988
953
  }
989
954
  case SHOW_CHAR:
990
955
  {
991
956
    Item *tmp;
992
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
957
    LOCK_global_system_variables.lock();
993
958
    char *str= (char*) value_ptr(session, var_type, base);
994
959
    if (str)
995
960
      tmp= new Item_string(str, strlen(str),
999
964
      tmp= new Item_null();
1000
965
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
1001
966
    }
1002
 
 
 
967
    LOCK_global_system_variables.unlock();
1003
968
    return tmp;
1004
969
  }
1005
970
  default:
1169
1134
  return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1170
1135
}
1171
1136
 
 
1137
 
 
1138
bool sys_var_session_time_zone::update(Session *session, set_var *var)
 
1139
{
 
1140
  char buff[MAX_TIME_ZONE_NAME_LENGTH];
 
1141
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
1142
  String *res= var->value->val_str(&str);
 
1143
 
 
1144
  Time_zone *tmp= my_tz_find(session, res);
 
1145
  if (tmp == NULL)
 
1146
  {
 
1147
    boost::throw_exception(invalid_option_value(var->var->getName()) << invalid_value(std::string(res ? res->c_ptr() : "NULL")));
 
1148
    return 1;
 
1149
  }
 
1150
  /* We are using Time_zone object found during check() phase. */
 
1151
  if (var->type == OPT_GLOBAL)
 
1152
  {
 
1153
    LOCK_global_system_variables.lock();
 
1154
    global_system_variables.time_zone= tmp;
 
1155
    LOCK_global_system_variables.unlock();
 
1156
  }
 
1157
  else
 
1158
    session->variables.time_zone= tmp;
 
1159
  return 0;
 
1160
}
 
1161
 
 
1162
 
 
1163
unsigned char *sys_var_session_time_zone::value_ptr(Session *session,
 
1164
                                                    sql_var_t type,
 
1165
                                                    const LEX_STRING *)
 
1166
{
 
1167
  /*
 
1168
    We can use ptr() instead of c_ptr() here because String contaning
 
1169
    time zone name is guaranteed to be zero ended.
 
1170
  */
 
1171
  if (type == OPT_GLOBAL)
 
1172
    return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
 
1173
  else
 
1174
  {
 
1175
    /*
 
1176
      This is an ugly fix for replication: we don't replicate properly queries
 
1177
      invoking system variables' values to update tables; but
 
1178
      CONVERT_TZ(,,@@session.time_zone) is so popular that we make it
 
1179
      replicable (i.e. we tell the binlog code to store the session
 
1180
      timezone). If it's the global value which was used we can't replicate
 
1181
      (binlog code stores session value only).
 
1182
    */
 
1183
    return (unsigned char *)(session->variables.time_zone->get_name()->ptr());
 
1184
  }
 
1185
}
 
1186
 
 
1187
 
 
1188
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
 
1189
{
 
1190
 LOCK_global_system_variables.lock();
 
1191
 if (type == OPT_GLOBAL)
 
1192
 {
 
1193
   if (default_tz_name)
 
1194
   {
 
1195
     String str(default_tz_name, &my_charset_utf8_general_ci);
 
1196
     /*
 
1197
       We are guaranteed to find this time zone since its existence
 
1198
       is checked during start-up.
 
1199
     */
 
1200
     global_system_variables.time_zone= my_tz_find(session, &str);
 
1201
   }
 
1202
   else
 
1203
     global_system_variables.time_zone= my_tz_SYSTEM;
 
1204
 }
 
1205
 else
 
1206
   session->variables.time_zone= global_system_variables.time_zone;
 
1207
 LOCK_global_system_variables.unlock();
 
1208
}
 
1209
 
 
1210
 
 
1211
 
1172
1212
bool sys_var_session_lc_time_names::update(Session *session, set_var *var)
1173
1213
{
1174
1214
  MY_LOCALE *locale_match;
1177
1217
  {
1178
1218
    if (!(locale_match= my_locale_by_number((uint32_t) var->value->val_int())))
1179
1219
    {
1180
 
      char buf[DECIMAL_LONGLONG_DIGITS];
 
1220
      char buf[20];
1181
1221
      internal::int10_to_str((int) var->value->val_int(), buf, -10);
1182
1222
      my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf);
1183
1223
      return 1;
1247
1287
  microseconds= (int64_t) (num * 1000000.0 + 0.5);
1248
1288
  if (var->type == OPT_GLOBAL)
1249
1289
  {
1250
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
1290
    LOCK_global_system_variables.lock();
1251
1291
    (global_system_variables.*offset)= microseconds;
 
1292
    LOCK_global_system_variables.unlock();
1252
1293
  }
1253
1294
  else
1254
1295
    session->variables.*offset= microseconds;
1261
1302
  int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
1262
1303
  if (type == OPT_GLOBAL)
1263
1304
  {
1264
 
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
1305
    LOCK_global_system_variables.lock();
1265
1306
    global_system_variables.*offset= microseconds;
 
1307
    LOCK_global_system_variables.unlock();
1266
1308
  }
1267
1309
  else
1268
1310
    session->variables.*offset= microseconds;
1285
1327
 
1286
1328
static bool set_option_autocommit(Session *session, set_var *var)
1287
1329
{
1288
 
  bool success= true;
1289
1330
  /* The test is negative as the flag we use is NOT autocommit */
1290
1331
 
1291
1332
  uint64_t org_options= session->options;
1292
 
  uint64_t new_options= session->options;
1293
1333
 
1294
1334
  if (var->getInteger() != 0)
1295
 
    new_options&= ~((sys_var_session_bit*) var->var)->bit_flag;
 
1335
    session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1296
1336
  else
1297
 
    new_options|= ((sys_var_session_bit*) var->var)->bit_flag;
 
1337
    session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
1298
1338
 
1299
 
  if ((org_options ^ new_options) & OPTION_NOT_AUTOCOMMIT)
 
1339
  if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
1300
1340
  {
1301
1341
    if ((org_options & OPTION_NOT_AUTOCOMMIT))
1302
1342
    {
1303
 
      success= session->endActiveTransaction();
1304
1343
      /* We changed to auto_commit mode */
1305
1344
      session->options&= ~(uint64_t) (OPTION_BEGIN);
1306
1345
      session->server_status|= SERVER_STATUS_AUTOCOMMIT;
 
1346
      TransactionServices &transaction_services= TransactionServices::singleton();
 
1347
      if (transaction_services.commitTransaction(session, true))
 
1348
        return 1;
1307
1349
    }
1308
1350
    else
1309
1351
    {
1310
1352
      session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1311
1353
    }
1312
1354
  }
1313
 
 
1314
 
  if (var->getInteger() != 0)
1315
 
    session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1316
 
  else
1317
 
    session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
1318
 
 
1319
 
  if (not success)
1320
 
    return true;
1321
 
 
1322
1355
  return 0;
1323
1356
}
1324
1357
 
1422
1455
drizzle_show_var* enumerate_sys_vars(Session *session)
1423
1456
{
1424
1457
  int size= sizeof(drizzle_show_var) * (system_variable_map.size() + 1);
1425
 
  drizzle_show_var *result= (drizzle_show_var*) session->getMemRoot()->allocate(size);
 
1458
  drizzle_show_var *result= (drizzle_show_var*) session->alloc(size);
1426
1459
 
1427
1460
  if (result)
1428
1461
  {
1456
1489
  /* this fails if there is a conflicting variable name. */
1457
1490
  if (system_variable_map.find(lower_name) != system_variable_map.end())
1458
1491
  {
1459
 
    errmsg_printf(error::ERROR, _("Variable named %s already exists!\n"),
 
1492
    errmsg_printf(ERRMSG_LVL_ERROR, _("Variable named %s already exists!\n"),
1460
1493
                  var->getName().c_str());
1461
1494
    throw exception();
1462
1495
  } 
1465
1498
    system_variable_map.insert(make_pair(lower_name, var));
1466
1499
  if (ret.second == false)
1467
1500
  {
1468
 
    errmsg_printf(error::ERROR, _("Could not add Variable: %s\n"),
 
1501
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not add Variable: %s\n"),
1469
1502
                  var->getName().c_str());
1470
1503
    throw exception();
1471
1504
  }
1498
1531
    add_sys_var_to_list(&sys_back_log, my_long_options);
1499
1532
    add_sys_var_to_list(&sys_basedir, my_long_options);
1500
1533
    add_sys_var_to_list(&sys_big_selects, my_long_options);
1501
 
    add_sys_var_to_list(&sys_branch, my_long_options);
1502
1534
    add_sys_var_to_list(&sys_buffer_results, my_long_options);
1503
1535
    add_sys_var_to_list(&sys_bulk_insert_buff_size, my_long_options);
1504
1536
    add_sys_var_to_list(&sys_collation_server, my_long_options);
1533
1565
    add_sys_var_to_list(&sys_range_alloc_block_size, my_long_options);
1534
1566
    add_sys_var_to_list(&sys_read_buff_size, my_long_options);
1535
1567
    add_sys_var_to_list(&sys_read_rnd_buff_size, my_long_options);
1536
 
    add_sys_var_to_list(&sys_release_id, my_long_options);
1537
1568
    add_sys_var_to_list(&sys_replicate_query, my_long_options);
1538
 
    add_sys_var_to_list(&sys_revid, my_long_options);
1539
 
    add_sys_var_to_list(&sys_revno, my_long_options);
1540
1569
    add_sys_var_to_list(&sys_scheduler, my_long_options);
1541
1570
    add_sys_var_to_list(&sys_secure_file_priv, my_long_options);
1542
1571
    add_sys_var_to_list(&sys_select_limit, my_long_options);
1545
1574
    add_sys_var_to_list(&sys_sql_notes, my_long_options);
1546
1575
    add_sys_var_to_list(&sys_sql_warnings, my_long_options);
1547
1576
    add_sys_var_to_list(&sys_storage_engine, my_long_options);
 
1577
    add_sys_var_to_list(&sys_system_time_zone, my_long_options);
1548
1578
    add_sys_var_to_list(&sys_table_cache_size, my_long_options);
1549
1579
    add_sys_var_to_list(&sys_table_def_size, my_long_options);
1550
1580
    add_sys_var_to_list(&sys_table_lock_wait_timeout, my_long_options);
1551
1581
    add_sys_var_to_list(&sys_thread_stack_size, my_long_options);
 
1582
    add_sys_var_to_list(&sys_time_zone, my_long_options);
1552
1583
    add_sys_var_to_list(&sys_timed_mutexes, my_long_options);
1553
1584
    add_sys_var_to_list(&sys_timestamp, my_long_options);
1554
1585
    add_sys_var_to_list(&sys_tmp_table_size, my_long_options);
1565
1596
  }
1566
1597
  catch (std::exception&)
1567
1598
  {
1568
 
    errmsg_printf(error::ERROR, _("Failed to initialize system variables"));
 
1599
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize system variables"));
1569
1600
    return(1);
1570
1601
  }
1571
1602
  return(0);