~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: lbieber
  • Date: 2010-08-06 21:05:10 UTC
  • mfrom: (1689.2.1 rollup)
  • mto: This revision was merged to the branch mainline in revision 1691.
  • Revision ID: lbieber@orisndriz03-20100806210510-4u7671cxzypyiboe
Merge Brian - Convert LOCK_global_system_variables to boost

Show diffs side-by-side

added added

removed removed

Lines of Context:
504
504
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
505
505
{
506
506
  uint32_t tmp= var->save_result.uint32_t_value;
507
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
507
  LOCK_global_system_variables.lock();
508
508
  if (option_limits)
509
509
  {
510
510
    uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
513
513
  }
514
514
  else
515
515
    *value= (uint32_t) tmp;
516
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
516
  LOCK_global_system_variables.unlock();
517
517
  return 0;
518
518
}
519
519
 
521
521
void sys_var_uint32_t_ptr::set_default(Session *, sql_var_t)
522
522
{
523
523
  bool not_used;
524
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
524
  LOCK_global_system_variables.lock();
525
525
  *value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
526
526
                                           option_limits, &not_used);
527
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
527
  LOCK_global_system_variables.unlock();
528
528
}
529
529
 
530
530
 
531
531
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
532
532
{
533
533
  uint64_t tmp= var->save_result.uint64_t_value;
534
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
534
  LOCK_global_system_variables.lock();
535
535
  if (option_limits)
536
536
  {
537
537
    uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits);
540
540
  }
541
541
  else
542
542
    *value= (uint64_t) tmp;
543
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
543
  LOCK_global_system_variables.unlock();
544
544
  return 0;
545
545
}
546
546
 
548
548
void sys_var_uint64_t_ptr::set_default(Session *, sql_var_t)
549
549
{
550
550
  bool not_used;
551
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
551
  LOCK_global_system_variables.lock();
552
552
  *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
553
553
                                 option_limits, &not_used);
554
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
554
  LOCK_global_system_variables.unlock();
555
555
}
556
556
 
557
557
 
558
558
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
559
559
{
560
560
  size_t tmp= var->save_result.size_t_value;
561
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
561
  LOCK_global_system_variables.lock();
562
562
  if (option_limits)
563
563
    *value= fix_size_t(session, tmp, option_limits);
564
564
  else
565
565
    *value= tmp;
566
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
566
  LOCK_global_system_variables.unlock();
567
567
  return 0;
568
568
}
569
569
 
571
571
void sys_var_size_t_ptr::set_default(Session *, sql_var_t)
572
572
{
573
573
  bool not_used;
574
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
574
  LOCK_global_system_variables.lock();
575
575
  *value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
576
576
                                         option_limits, &not_used);
577
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
577
  LOCK_global_system_variables.unlock();
578
578
}
579
579
 
580
580
bool sys_var_bool_ptr::update(Session *, set_var *var)
665
665
  if (var->type == OPT_GLOBAL)
666
666
  {
667
667
    /* Lock is needed to make things safe on 32 bit systems */
668
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
668
    LOCK_global_system_variables.lock();
669
669
    global_system_variables.*offset= (ha_rows) tmp;
670
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
670
    LOCK_global_system_variables.unlock();
671
671
  }
672
672
  else
673
673
    session->variables.*offset= (ha_rows) tmp;
681
681
  {
682
682
    bool not_used;
683
683
    /* We will not come here if option_limits is not set */
684
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
684
    LOCK_global_system_variables.lock();
685
685
    global_system_variables.*offset=
686
686
      (ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
687
687
                                       option_limits, &not_used);
688
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
688
    LOCK_global_system_variables.unlock();
689
689
  }
690
690
  else
691
691
    session->variables.*offset= global_system_variables.*offset;
722
722
  if (var->type == OPT_GLOBAL)
723
723
  {
724
724
    /* Lock is needed to make things safe on 32 bit systems */
725
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
725
    LOCK_global_system_variables.lock();
726
726
    global_system_variables.*offset= (uint64_t) tmp;
727
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
727
    LOCK_global_system_variables.unlock();
728
728
  }
729
729
  else
730
730
    session->variables.*offset= (uint64_t) tmp;
737
737
  if (type == OPT_GLOBAL)
738
738
  {
739
739
    bool not_used;
740
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
740
    LOCK_global_system_variables.lock();
741
741
    global_system_variables.*offset=
742
742
      getopt_ull_limit_value((uint64_t) option_limits->def_value,
743
743
                             option_limits, &not_used);
744
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
744
    LOCK_global_system_variables.unlock();
745
745
  }
746
746
  else
747
747
    session->variables.*offset= global_system_variables.*offset;
775
775
  if (var->type == OPT_GLOBAL)
776
776
  {
777
777
    /* Lock is needed to make things safe on 32 bit systems */
778
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
778
    LOCK_global_system_variables.lock();
779
779
    global_system_variables.*offset= tmp;
780
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
780
    LOCK_global_system_variables.unlock();
781
781
  }
782
782
  else
783
783
    session->variables.*offset= tmp;
790
790
  if (type == OPT_GLOBAL)
791
791
  {
792
792
    bool not_used;
793
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
793
    LOCK_global_system_variables.lock();
794
794
    global_system_variables.*offset=
795
795
      (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
796
796
                                     option_limits, &not_used);
797
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
797
    LOCK_global_system_variables.unlock();
798
798
  }
799
799
  else
800
800
    session->variables.*offset= global_system_variables.*offset;
904
904
  case SHOW_INT:
905
905
  {
906
906
    uint32_t value;
907
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
907
    LOCK_global_system_variables.lock();
908
908
    value= *(uint*) value_ptr(session, var_type, base);
909
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
909
    LOCK_global_system_variables.unlock();
910
910
    return new Item_uint((uint64_t) value);
911
911
  }
912
912
  case SHOW_LONGLONG:
913
913
  {
914
914
    int64_t value;
915
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
915
    LOCK_global_system_variables.lock();
916
916
    value= *(int64_t*) value_ptr(session, var_type, base);
917
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
917
    LOCK_global_system_variables.unlock();
918
918
    return new Item_int(value);
919
919
  }
920
920
  case SHOW_DOUBLE:
921
921
  {
922
922
    double value;
923
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
923
    LOCK_global_system_variables.lock();
924
924
    value= *(double*) value_ptr(session, var_type, base);
925
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
925
    LOCK_global_system_variables.unlock();
926
926
    /* 6, as this is for now only used with microseconds */
927
927
    return new Item_float(value, 6);
928
928
  }
929
929
  case SHOW_HA_ROWS:
930
930
  {
931
931
    ha_rows value;
932
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
932
    LOCK_global_system_variables.lock();
933
933
    value= *(ha_rows*) value_ptr(session, var_type, base);
934
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
934
    LOCK_global_system_variables.unlock();
935
935
    return new Item_int((uint64_t) value);
936
936
  }
937
937
  case SHOW_SIZE:
938
938
  {
939
939
    size_t value;
940
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
940
    LOCK_global_system_variables.lock();
941
941
    value= *(size_t*) value_ptr(session, var_type, base);
942
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
942
    LOCK_global_system_variables.unlock();
943
943
    return new Item_int((uint64_t) value);
944
944
  }
945
945
  case SHOW_MY_BOOL:
946
946
  {
947
947
    int32_t value;
948
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
948
    LOCK_global_system_variables.lock();
949
949
    value= *(bool*) value_ptr(session, var_type, base);
950
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
950
    LOCK_global_system_variables.unlock();
951
951
    return new Item_int(value,1);
952
952
  }
953
953
  case SHOW_CHAR_PTR:
954
954
  {
955
955
    Item *tmp;
956
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
956
    LOCK_global_system_variables.lock();
957
957
    char *str= *(char**) value_ptr(session, var_type, base);
958
958
    if (str)
959
959
    {
966
966
      tmp= new Item_null();
967
967
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
968
968
    }
969
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
969
    LOCK_global_system_variables.unlock();
970
970
    return tmp;
971
971
  }
972
972
  case SHOW_CHAR:
973
973
  {
974
974
    Item *tmp;
975
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
975
    LOCK_global_system_variables.lock();
976
976
    char *str= (char*) value_ptr(session, var_type, base);
977
977
    if (str)
978
978
      tmp= new Item_string(str, strlen(str),
982
982
      tmp= new Item_null();
983
983
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
984
984
    }
985
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
985
    LOCK_global_system_variables.unlock();
986
986
    return tmp;
987
987
  }
988
988
  default:
1185
1185
  /* We are using Time_zone object found during check() phase. */
1186
1186
  if (var->type == OPT_GLOBAL)
1187
1187
  {
1188
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1188
    LOCK_global_system_variables.lock();
1189
1189
    global_system_variables.time_zone= var->save_result.time_zone;
1190
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1190
    LOCK_global_system_variables.unlock();
1191
1191
  }
1192
1192
  else
1193
1193
    session->variables.time_zone= var->save_result.time_zone;
1222
1222
 
1223
1223
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
1224
1224
{
1225
 
 pthread_mutex_lock(&LOCK_global_system_variables);
 
1225
 LOCK_global_system_variables.lock();
1226
1226
 if (type == OPT_GLOBAL)
1227
1227
 {
1228
1228
   if (default_tz_name)
1239
1239
 }
1240
1240
 else
1241
1241
   session->variables.time_zone= global_system_variables.time_zone;
1242
 
 pthread_mutex_unlock(&LOCK_global_system_variables);
 
1242
 LOCK_global_system_variables.unlock();
1243
1243
}
1244
1244
 
1245
1245
 
1328
1328
  microseconds= (int64_t) (num * 1000000.0 + 0.5);
1329
1329
  if (var->type == OPT_GLOBAL)
1330
1330
  {
1331
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1331
    LOCK_global_system_variables.lock();
1332
1332
    (global_system_variables.*offset)= microseconds;
1333
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1333
    LOCK_global_system_variables.unlock();
1334
1334
  }
1335
1335
  else
1336
1336
    session->variables.*offset= microseconds;
1343
1343
  int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
1344
1344
  if (type == OPT_GLOBAL)
1345
1345
  {
1346
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1346
    LOCK_global_system_variables.lock();
1347
1347
    global_system_variables.*offset= microseconds;
1348
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1348
    LOCK_global_system_variables.unlock();
1349
1349
  }
1350
1350
  else
1351
1351
    session->variables.*offset= microseconds;