~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Brian Aker
  • Date: 2010-08-18 16:12:58 UTC
  • mto: This revision was merged to the branch mainline in revision 1720.
  • Revision ID: brian@tangent.org-20100818161258-1vm71da888dfvwsx
Remove the code surrounding stack trace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
#include "drizzled/charset.h"
65
65
#include "drizzled/transaction_services.h"
66
66
 
 
67
#include <cstdio>
67
68
#include <map>
68
69
#include <algorithm>
69
70
 
143
144
                                                    fix_completion_type);
144
145
static sys_var_collation_sv
145
146
sys_collation_server(&vars, "collation_server", &system_variables::collation_server, &default_charset_info);
146
 
static sys_var_const_str       sys_datadir(&vars, "datadir", drizzle_real_data_home);
 
147
static sys_var_const_str       sys_datadir(&vars, "datadir", data_home_real);
147
148
 
148
149
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
149
150
                                                     &system_variables::join_buff_size);
199
200
 
200
201
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
201
202
                                             &opt_secure_file_priv);
 
203
 
 
204
static sys_var_const_str_ptr sys_scheduler(&vars, "scheduler",
 
205
                                           &opt_scheduler);
 
206
 
202
207
static sys_var_uint32_t_ptr  sys_server_id(&vars, "server_id", &server_id,
203
208
                                           fix_server_id);
204
209
 
399
404
static void fix_session_mem_root(Session *session, sql_var_t type)
400
405
{
401
406
  if (type != OPT_GLOBAL)
402
 
    reset_root_defaults(session->mem_root,
403
 
                        session->variables.query_alloc_block_size,
404
 
                        session->variables.query_prealloc_size);
 
407
    session->mem_root->reset_root_defaults(session->variables.query_alloc_block_size,
 
408
                                           session->variables.query_prealloc_size);
405
409
}
406
410
 
407
411
 
500
504
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
501
505
{
502
506
  uint32_t tmp= var->save_result.uint32_t_value;
503
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
507
  LOCK_global_system_variables.lock();
504
508
  if (option_limits)
505
509
  {
506
510
    uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
509
513
  }
510
514
  else
511
515
    *value= (uint32_t) tmp;
512
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
516
  LOCK_global_system_variables.unlock();
513
517
  return 0;
514
518
}
515
519
 
517
521
void sys_var_uint32_t_ptr::set_default(Session *, sql_var_t)
518
522
{
519
523
  bool not_used;
520
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
524
  LOCK_global_system_variables.lock();
521
525
  *value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
522
526
                                           option_limits, &not_used);
523
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
527
  LOCK_global_system_variables.unlock();
524
528
}
525
529
 
526
530
 
527
531
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
528
532
{
529
533
  uint64_t tmp= var->save_result.uint64_t_value;
530
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
534
  LOCK_global_system_variables.lock();
531
535
  if (option_limits)
532
536
  {
533
537
    uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits);
536
540
  }
537
541
  else
538
542
    *value= (uint64_t) tmp;
539
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
543
  LOCK_global_system_variables.unlock();
540
544
  return 0;
541
545
}
542
546
 
544
548
void sys_var_uint64_t_ptr::set_default(Session *, sql_var_t)
545
549
{
546
550
  bool not_used;
547
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
551
  LOCK_global_system_variables.lock();
548
552
  *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
549
553
                                 option_limits, &not_used);
550
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
554
  LOCK_global_system_variables.unlock();
551
555
}
552
556
 
553
557
 
554
558
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
555
559
{
556
560
  size_t tmp= var->save_result.size_t_value;
557
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
561
  LOCK_global_system_variables.lock();
558
562
  if (option_limits)
559
563
    *value= fix_size_t(session, tmp, option_limits);
560
564
  else
561
565
    *value= tmp;
562
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
566
  LOCK_global_system_variables.unlock();
563
567
  return 0;
564
568
}
565
569
 
567
571
void sys_var_size_t_ptr::set_default(Session *, sql_var_t)
568
572
{
569
573
  bool not_used;
570
 
  pthread_mutex_lock(&LOCK_global_system_variables);
 
574
  LOCK_global_system_variables.lock();
571
575
  *value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
572
576
                                         option_limits, &not_used);
573
 
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
577
  LOCK_global_system_variables.unlock();
574
578
}
575
579
 
576
580
bool sys_var_bool_ptr::update(Session *, set_var *var)
661
665
  if (var->type == OPT_GLOBAL)
662
666
  {
663
667
    /* Lock is needed to make things safe on 32 bit systems */
664
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
668
    LOCK_global_system_variables.lock();
665
669
    global_system_variables.*offset= (ha_rows) tmp;
666
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
670
    LOCK_global_system_variables.unlock();
667
671
  }
668
672
  else
669
673
    session->variables.*offset= (ha_rows) tmp;
677
681
  {
678
682
    bool not_used;
679
683
    /* We will not come here if option_limits is not set */
680
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
684
    LOCK_global_system_variables.lock();
681
685
    global_system_variables.*offset=
682
686
      (ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
683
687
                                       option_limits, &not_used);
684
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
688
    LOCK_global_system_variables.unlock();
685
689
  }
686
690
  else
687
691
    session->variables.*offset= global_system_variables.*offset;
718
722
  if (var->type == OPT_GLOBAL)
719
723
  {
720
724
    /* Lock is needed to make things safe on 32 bit systems */
721
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
725
    LOCK_global_system_variables.lock();
722
726
    global_system_variables.*offset= (uint64_t) tmp;
723
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
727
    LOCK_global_system_variables.unlock();
724
728
  }
725
729
  else
726
730
    session->variables.*offset= (uint64_t) tmp;
733
737
  if (type == OPT_GLOBAL)
734
738
  {
735
739
    bool not_used;
736
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
740
    LOCK_global_system_variables.lock();
737
741
    global_system_variables.*offset=
738
742
      getopt_ull_limit_value((uint64_t) option_limits->def_value,
739
743
                             option_limits, &not_used);
740
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
744
    LOCK_global_system_variables.unlock();
741
745
  }
742
746
  else
743
747
    session->variables.*offset= global_system_variables.*offset;
771
775
  if (var->type == OPT_GLOBAL)
772
776
  {
773
777
    /* Lock is needed to make things safe on 32 bit systems */
774
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
778
    LOCK_global_system_variables.lock();
775
779
    global_system_variables.*offset= tmp;
776
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
780
    LOCK_global_system_variables.unlock();
777
781
  }
778
782
  else
779
783
    session->variables.*offset= tmp;
786
790
  if (type == OPT_GLOBAL)
787
791
  {
788
792
    bool not_used;
789
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
793
    LOCK_global_system_variables.lock();
790
794
    global_system_variables.*offset=
791
795
      (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
792
796
                                     option_limits, &not_used);
793
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
797
    LOCK_global_system_variables.unlock();
794
798
  }
795
799
  else
796
800
    session->variables.*offset= global_system_variables.*offset;
900
904
  case SHOW_INT:
901
905
  {
902
906
    uint32_t value;
903
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
907
    LOCK_global_system_variables.lock();
904
908
    value= *(uint*) value_ptr(session, var_type, base);
905
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
909
    LOCK_global_system_variables.unlock();
906
910
    return new Item_uint((uint64_t) value);
907
911
  }
908
912
  case SHOW_LONGLONG:
909
913
  {
910
914
    int64_t value;
911
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
915
    LOCK_global_system_variables.lock();
912
916
    value= *(int64_t*) value_ptr(session, var_type, base);
913
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
917
    LOCK_global_system_variables.unlock();
914
918
    return new Item_int(value);
915
919
  }
916
920
  case SHOW_DOUBLE:
917
921
  {
918
922
    double value;
919
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
923
    LOCK_global_system_variables.lock();
920
924
    value= *(double*) value_ptr(session, var_type, base);
921
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
925
    LOCK_global_system_variables.unlock();
922
926
    /* 6, as this is for now only used with microseconds */
923
927
    return new Item_float(value, 6);
924
928
  }
925
929
  case SHOW_HA_ROWS:
926
930
  {
927
931
    ha_rows value;
928
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
932
    LOCK_global_system_variables.lock();
929
933
    value= *(ha_rows*) value_ptr(session, var_type, base);
930
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
934
    LOCK_global_system_variables.unlock();
931
935
    return new Item_int((uint64_t) value);
932
936
  }
933
937
  case SHOW_SIZE:
934
938
  {
935
939
    size_t value;
936
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
940
    LOCK_global_system_variables.lock();
937
941
    value= *(size_t*) value_ptr(session, var_type, base);
938
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
942
    LOCK_global_system_variables.unlock();
939
943
    return new Item_int((uint64_t) value);
940
944
  }
941
945
  case SHOW_MY_BOOL:
942
946
  {
943
947
    int32_t value;
944
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
948
    LOCK_global_system_variables.lock();
945
949
    value= *(bool*) value_ptr(session, var_type, base);
946
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
950
    LOCK_global_system_variables.unlock();
947
951
    return new Item_int(value,1);
948
952
  }
949
953
  case SHOW_CHAR_PTR:
950
954
  {
951
955
    Item *tmp;
952
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
956
    LOCK_global_system_variables.lock();
953
957
    char *str= *(char**) value_ptr(session, var_type, base);
954
958
    if (str)
955
959
    {
962
966
      tmp= new Item_null();
963
967
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
964
968
    }
965
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
969
    LOCK_global_system_variables.unlock();
966
970
    return tmp;
967
971
  }
968
972
  case SHOW_CHAR:
969
973
  {
970
974
    Item *tmp;
971
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
975
    LOCK_global_system_variables.lock();
972
976
    char *str= (char*) value_ptr(session, var_type, base);
973
977
    if (str)
974
978
      tmp= new Item_string(str, strlen(str),
978
982
      tmp= new Item_null();
979
983
      tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
980
984
    }
981
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
985
    LOCK_global_system_variables.unlock();
982
986
    return tmp;
983
987
  }
984
988
  default:
1181
1185
  /* We are using Time_zone object found during check() phase. */
1182
1186
  if (var->type == OPT_GLOBAL)
1183
1187
  {
1184
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1188
    LOCK_global_system_variables.lock();
1185
1189
    global_system_variables.time_zone= var->save_result.time_zone;
1186
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1190
    LOCK_global_system_variables.unlock();
1187
1191
  }
1188
1192
  else
1189
1193
    session->variables.time_zone= var->save_result.time_zone;
1218
1222
 
1219
1223
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
1220
1224
{
1221
 
 pthread_mutex_lock(&LOCK_global_system_variables);
 
1225
 LOCK_global_system_variables.lock();
1222
1226
 if (type == OPT_GLOBAL)
1223
1227
 {
1224
1228
   if (default_tz_name)
1235
1239
 }
1236
1240
 else
1237
1241
   session->variables.time_zone= global_system_variables.time_zone;
1238
 
 pthread_mutex_unlock(&LOCK_global_system_variables);
 
1242
 LOCK_global_system_variables.unlock();
1239
1243
}
1240
1244
 
1241
1245
 
1324
1328
  microseconds= (int64_t) (num * 1000000.0 + 0.5);
1325
1329
  if (var->type == OPT_GLOBAL)
1326
1330
  {
1327
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1331
    LOCK_global_system_variables.lock();
1328
1332
    (global_system_variables.*offset)= microseconds;
1329
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1333
    LOCK_global_system_variables.unlock();
1330
1334
  }
1331
1335
  else
1332
1336
    session->variables.*offset= microseconds;
1339
1343
  int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
1340
1344
  if (type == OPT_GLOBAL)
1341
1345
  {
1342
 
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1346
    LOCK_global_system_variables.lock();
1343
1347
    global_system_variables.*offset= microseconds;
1344
 
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1348
    LOCK_global_system_variables.unlock();
1345
1349
  }
1346
1350
  else
1347
1351
    session->variables.*offset= microseconds;
1381
1385
      session->options&= ~(uint64_t) (OPTION_BEGIN);
1382
1386
      session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1383
1387
      TransactionServices &transaction_services= TransactionServices::singleton();
1384
 
      if (transaction_services.ha_commit_trans(session, true))
 
1388
      if (transaction_services.commitTransaction(session, true))
1385
1389
        return 1;
1386
1390
    }
1387
1391
    else
1431
1435
*/
1432
1436
static unsigned char *get_tmpdir(Session *)
1433
1437
{
1434
 
  assert(drizzle_tmpdir);
1435
 
  return (unsigned char*)drizzle_tmpdir;
 
1438
  assert(drizzle_tmpdir.size());
 
1439
  return (unsigned char*)drizzle_tmpdir.c_str();
1436
1440
}
1437
1441
 
1438
1442
/****************************************************************************
1491
1495
int mysql_add_sys_var_chain(sys_var *first, struct option *long_options)
1492
1496
{
1493
1497
  sys_var *var;
1494
 
  /* A write lock should be held on LOCK_system_variables_hash */
 
1498
  /* @todo for future A write lock should be held on LOCK_system_variables_hash */
1495
1499
 
1496
1500
  for (var= first; var; var= var->getNext())
1497
1501
  {