~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

  • Committer: Lee Bieber
  • Date: 2011-01-26 04:38:57 UTC
  • mfrom: (2115.1.2 drizzle-build)
  • Revision ID: kalebral@gmail.com-20110126043857-d5oegxrszux47793
Merge Brian - Merge in latest catalog changes
Merge Brian remove error numbers in tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
474
474
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
475
475
{
476
476
  uint64_t tmp= var->getInteger();
477
 
  LOCK_global_system_variables.lock();
 
477
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
478
 
478
479
  if (option_limits)
479
480
  {
480
481
    uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
482
483
      *value= newvalue;
483
484
  }
484
485
  else
 
486
  {
485
487
    *value= static_cast<uint32_t>(tmp);
486
 
  LOCK_global_system_variables.unlock();
 
488
  }
 
489
 
487
490
  return 0;
488
491
}
489
492
 
490
493
 
491
 
void sys_var_uint32_t_ptr::set_default(Session *, sql_var_t)
 
494
void sys_var_uint32_t_ptr::set_default(Session *session, sql_var_t)
492
495
{
493
496
  bool not_used;
494
 
  LOCK_global_system_variables.lock();
 
497
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
495
498
  *value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
496
499
                                           option_limits, &not_used);
497
 
  LOCK_global_system_variables.unlock();
498
500
}
499
501
 
500
502
 
501
503
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
502
504
{
503
505
  uint64_t tmp= var->getInteger();
504
 
  LOCK_global_system_variables.lock();
 
506
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
507
 
505
508
  if (option_limits)
506
509
  {
507
510
    uint64_t newvalue= fix_unsigned(session, tmp, option_limits);
509
512
      *value= newvalue;
510
513
  }
511
514
  else
 
515
  {
512
516
    *value= tmp;
513
 
  LOCK_global_system_variables.unlock();
 
517
  }
 
518
 
514
519
  return 0;
515
520
}
516
521
 
517
522
 
518
 
void sys_var_uint64_t_ptr::set_default(Session *, sql_var_t)
 
523
void sys_var_uint64_t_ptr::set_default(Session *session, sql_var_t)
519
524
{
520
525
  if (have_default_value)
521
526
  {
524
529
  else
525
530
  {
526
531
    bool not_used;
527
 
    LOCK_global_system_variables.lock();
 
532
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
528
533
    *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
529
534
                                   option_limits, &not_used);
530
 
    LOCK_global_system_variables.unlock();
531
535
  }
532
536
}
533
537
 
535
539
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
536
540
{
537
541
  size_t tmp= size_t(var->getInteger());
538
 
  LOCK_global_system_variables.lock();
 
542
 
 
543
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
544
 
539
545
  if (option_limits)
540
546
    *value= fix_size_t(session, tmp, option_limits);
541
547
  else
542
548
    *value= tmp;
543
 
  LOCK_global_system_variables.unlock();
 
549
 
544
550
  return 0;
545
551
}
546
552
 
547
553
 
548
 
void sys_var_size_t_ptr::set_default(Session *, sql_var_t)
 
554
void sys_var_size_t_ptr::set_default(Session *session, sql_var_t)
549
555
{
550
556
  bool not_used;
551
 
  LOCK_global_system_variables.lock();
 
557
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
552
558
  *value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
553
559
                                         option_limits, &not_used);
554
 
  LOCK_global_system_variables.unlock();
555
560
}
556
561
 
557
562
bool sys_var_bool_ptr::update(Session *, set_var *var)
642
647
  if (var->type == OPT_GLOBAL)
643
648
  {
644
649
    /* Lock is needed to make things safe on 32 bit systems */
645
 
    LOCK_global_system_variables.lock();
 
650
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
646
651
    global_system_variables.*offset= (ha_rows) tmp;
647
 
    LOCK_global_system_variables.unlock();
648
652
  }
649
653
  else
 
654
  {
650
655
    session->variables.*offset= (ha_rows) tmp;
 
656
  }
 
657
 
651
658
  return 0;
652
659
}
653
660
 
658
665
  {
659
666
    bool not_used;
660
667
    /* We will not come here if option_limits is not set */
661
 
    LOCK_global_system_variables.lock();
 
668
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
662
669
    global_system_variables.*offset=
663
670
      (ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
664
671
                                       option_limits, &not_used);
665
 
    LOCK_global_system_variables.unlock();
666
672
  }
667
673
  else
 
674
  {
668
675
    session->variables.*offset= global_system_variables.*offset;
 
676
  }
669
677
}
670
678
 
671
679
 
699
707
  if (var->type == OPT_GLOBAL)
700
708
  {
701
709
    /* Lock is needed to make things safe on 32 bit systems */
702
 
    LOCK_global_system_variables.lock();
 
710
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
703
711
    global_system_variables.*offset= (uint64_t) tmp;
704
 
    LOCK_global_system_variables.unlock();
705
712
  }
706
713
  else
 
714
  {
707
715
    session->variables.*offset= (uint64_t) tmp;
 
716
  }
 
717
 
708
718
  return 0;
709
719
}
710
720
 
714
724
  if (type == OPT_GLOBAL)
715
725
  {
716
726
    bool not_used;
717
 
    LOCK_global_system_variables.lock();
 
727
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
718
728
    global_system_variables.*offset=
719
729
      getopt_ull_limit_value((uint64_t) option_limits->def_value,
720
730
                             option_limits, &not_used);
721
 
    LOCK_global_system_variables.unlock();
722
731
  }
723
732
  else
 
733
  {
724
734
    session->variables.*offset= global_system_variables.*offset;
 
735
  }
725
736
}
726
737
 
727
738
 
752
763
  if (var->type == OPT_GLOBAL)
753
764
  {
754
765
    /* Lock is needed to make things safe on 32 bit systems */
755
 
    LOCK_global_system_variables.lock();
 
766
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
756
767
    global_system_variables.*offset= tmp;
757
 
    LOCK_global_system_variables.unlock();
758
768
  }
759
769
  else
 
770
  {
760
771
    session->variables.*offset= tmp;
 
772
  }
 
773
 
761
774
  return 0;
762
775
}
763
776
 
767
780
  if (type == OPT_GLOBAL)
768
781
  {
769
782
    bool not_used;
770
 
    LOCK_global_system_variables.lock();
 
783
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
771
784
    global_system_variables.*offset=
772
785
      (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
773
786
                                     option_limits, &not_used);
774
 
    LOCK_global_system_variables.unlock();
775
787
  }
776
788
  else
 
789
  {
777
790
    session->variables.*offset= global_system_variables.*offset;
 
791
  }
778
792
}
779
793
 
780
794
 
794
808
    global_system_variables.*offset= bool(var->getInteger());
795
809
  else
796
810
    session->variables.*offset= bool(var->getInteger());
 
811
 
797
812
  return 0;
798
813
}
799
814
 
886
901
  case SHOW_INT:
887
902
  {
888
903
    uint32_t value;
889
 
    LOCK_global_system_variables.lock();
 
904
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
890
905
    value= *(uint*) value_ptr(session, var_type, base);
891
 
    LOCK_global_system_variables.unlock();
 
906
 
892
907
    return new Item_uint((uint64_t) value);
893
908
  }
894
909
  case SHOW_LONGLONG:
895
910
  {
896
911
    int64_t value;
897
 
    LOCK_global_system_variables.lock();
 
912
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
898
913
    value= *(int64_t*) value_ptr(session, var_type, base);
899
 
    LOCK_global_system_variables.unlock();
 
914
 
900
915
    return new Item_int(value);
901
916
  }
902
917
  case SHOW_DOUBLE:
903
918
  {
904
919
    double value;
905
 
    LOCK_global_system_variables.lock();
906
 
    value= *(double*) value_ptr(session, var_type, base);
907
 
    LOCK_global_system_variables.unlock();
 
920
    {
 
921
      boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
922
      value= *(double*) value_ptr(session, var_type, base);
 
923
    }
 
924
 
908
925
    /* 6, as this is for now only used with microseconds */
909
926
    return new Item_float(value, 6);
910
927
  }
911
928
  case SHOW_HA_ROWS:
912
929
  {
913
930
    ha_rows value;
914
 
    LOCK_global_system_variables.lock();
 
931
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
915
932
    value= *(ha_rows*) value_ptr(session, var_type, base);
916
 
    LOCK_global_system_variables.unlock();
 
933
 
917
934
    return new Item_int((uint64_t) value);
918
935
  }
919
936
  case SHOW_SIZE:
920
937
  {
921
938
    size_t value;
922
 
    LOCK_global_system_variables.lock();
 
939
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
923
940
    value= *(size_t*) value_ptr(session, var_type, base);
924
 
    LOCK_global_system_variables.unlock();
 
941
 
925
942
    return new Item_int((uint64_t) value);
926
943
  }
927
944
  case SHOW_MY_BOOL:
928
945
  {
929
946
    int32_t value;
930
 
    LOCK_global_system_variables.lock();
 
947
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
931
948
    value= *(bool*) value_ptr(session, var_type, base);
932
 
    LOCK_global_system_variables.unlock();
933
949
    return new Item_int(value,1);
934
950
  }
935
951
  case SHOW_CHAR_PTR:
936
952
  {
937
953
    Item *tmp;
938
 
    LOCK_global_system_variables.lock();
 
954
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
939
955
    char *str= *(char**) value_ptr(session, var_type, base);
940
956
    if (str)
941
957
    {
948
964
      tmp= new Item_null();
949
965
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
950
966
    }
951
 
    LOCK_global_system_variables.unlock();
 
967
 
952
968
    return tmp;
953
969
  }
954
970
  case SHOW_CHAR:
955
971
  {
956
972
    Item *tmp;
957
 
    LOCK_global_system_variables.lock();
 
973
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
958
974
    char *str= (char*) value_ptr(session, var_type, base);
959
975
    if (str)
960
976
      tmp= new Item_string(str, strlen(str),
964
980
      tmp= new Item_null();
965
981
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
966
982
    }
967
 
    LOCK_global_system_variables.unlock();
 
983
 
968
984
    return tmp;
969
985
  }
970
986
  default:
1150
1166
  /* We are using Time_zone object found during check() phase. */
1151
1167
  if (var->type == OPT_GLOBAL)
1152
1168
  {
1153
 
    LOCK_global_system_variables.lock();
 
1169
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1154
1170
    global_system_variables.time_zone= tmp;
1155
 
    LOCK_global_system_variables.unlock();
1156
1171
  }
1157
1172
  else
 
1173
  {
1158
1174
    session->variables.time_zone= tmp;
 
1175
  }
 
1176
 
1159
1177
  return 0;
1160
1178
}
1161
1179
 
1187
1205
 
1188
1206
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
1189
1207
{
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
  boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
 
1209
  if (type == OPT_GLOBAL)
 
1210
  {
 
1211
    if (default_tz_name)
 
1212
    {
 
1213
      String str(default_tz_name, &my_charset_utf8_general_ci);
 
1214
      /*
 
1215
        We are guaranteed to find this time zone since its existence
 
1216
        is checked during start-up.
 
1217
      */
 
1218
      global_system_variables.time_zone= my_tz_find(session, &str);
 
1219
    }
 
1220
    else
 
1221
      global_system_variables.time_zone= my_tz_SYSTEM;
 
1222
  }
 
1223
  else
 
1224
    session->variables.time_zone= global_system_variables.time_zone;
1208
1225
}
1209
1226
 
1210
1227
 
1287
1304
  microseconds= (int64_t) (num * 1000000.0 + 0.5);
1288
1305
  if (var->type == OPT_GLOBAL)
1289
1306
  {
1290
 
    LOCK_global_system_variables.lock();
 
1307
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1291
1308
    (global_system_variables.*offset)= microseconds;
1292
 
    LOCK_global_system_variables.unlock();
1293
1309
  }
1294
1310
  else
1295
1311
    session->variables.*offset= microseconds;
1302
1318
  int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
1303
1319
  if (type == OPT_GLOBAL)
1304
1320
  {
1305
 
    LOCK_global_system_variables.lock();
 
1321
    boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1306
1322
    global_system_variables.*offset= microseconds;
1307
 
    LOCK_global_system_variables.unlock();
1308
1323
  }
1309
1324
  else
1310
1325
    session->variables.*offset= microseconds;