151
149
&drizzle_system_variables::join_buff_size);
152
150
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet",
153
151
&drizzle_system_variables::max_allowed_packet);
152
static sys_var_uint64_t_ptr sys_max_connect_errors("max_connect_errors",
153
&max_connect_errors);
154
154
static sys_var_session_uint64_t sys_max_error_count("max_error_count",
155
155
&drizzle_system_variables::max_error_count);
156
156
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size",
213
213
static sys_var_session_size_t sys_sort_buffer("sort_buffer_size",
214
214
&drizzle_system_variables::sortbuff_size);
216
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold",
217
&transaction_message_threshold);
216
static sys_var_session_size_t sys_transaction_message_threshold("transaction_message_threshold",
217
&drizzle_system_variables::transaction_message_threshold);
219
219
static sys_var_session_storage_engine sys_storage_engine("storage_engine",
220
220
&drizzle_system_variables::storage_engine);
476
476
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
478
478
uint64_t tmp= var->getInteger();
479
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
479
LOCK_global_system_variables.lock();
481
480
if (option_limits)
483
482
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
485
484
*value= newvalue;
489
487
*value= static_cast<uint32_t>(tmp);
488
LOCK_global_system_variables.unlock();
496
void sys_var_uint32_t_ptr::set_default(Session *session, sql_var_t)
493
void sys_var_uint32_t_ptr::set_default(Session *, sql_var_t)
499
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
496
LOCK_global_system_variables.lock();
500
497
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
501
498
option_limits, ¬_used);
499
LOCK_global_system_variables.unlock();
505
503
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
507
505
uint64_t tmp= var->getInteger();
508
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
506
LOCK_global_system_variables.lock();
510
507
if (option_limits)
512
509
uint64_t newvalue= fix_unsigned(session, tmp, option_limits);
534
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
529
LOCK_global_system_variables.lock();
535
530
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
536
531
option_limits, ¬_used);
532
LOCK_global_system_variables.unlock();
541
537
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
543
539
size_t tmp= size_t(var->getInteger());
545
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
540
LOCK_global_system_variables.lock();
547
541
if (option_limits)
548
542
*value= fix_size_t(session, tmp, option_limits);
545
LOCK_global_system_variables.unlock();
556
void sys_var_size_t_ptr::set_default(Session *session, sql_var_t)
550
void sys_var_size_t_ptr::set_default(Session *, sql_var_t)
559
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
553
LOCK_global_system_variables.lock();
560
554
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
561
555
option_limits, ¬_used);
564
bool sys_var_bool_ptr::check(Session *session, set_var *var)
566
return check_enum(session, var, &bool_typelib);
556
LOCK_global_system_variables.unlock();
569
559
bool sys_var_bool_ptr::update(Session *, set_var *var)
654
644
if (var->type == OPT_GLOBAL)
656
646
/* Lock is needed to make things safe on 32 bit systems */
657
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
647
LOCK_global_system_variables.lock();
658
648
global_system_variables.*offset= (ha_rows) tmp;
649
LOCK_global_system_variables.unlock();
662
652
session->variables.*offset= (ha_rows) tmp;
674
662
/* We will not come here if option_limits is not set */
675
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
663
LOCK_global_system_variables.lock();
676
664
global_system_variables.*offset=
677
665
(ha_rows) getopt_ull_limit_value((ha_rows) option_limits->def_value,
678
666
option_limits, ¬_used);
667
LOCK_global_system_variables.unlock();
682
670
session->variables.*offset= global_system_variables.*offset;
714
701
if (var->type == OPT_GLOBAL)
716
703
/* Lock is needed to make things safe on 32 bit systems */
717
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
704
LOCK_global_system_variables.lock();
718
705
global_system_variables.*offset= (uint64_t) tmp;
706
LOCK_global_system_variables.unlock();
722
709
session->variables.*offset= (uint64_t) tmp;
731
716
if (type == OPT_GLOBAL)
734
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
719
LOCK_global_system_variables.lock();
735
720
global_system_variables.*offset=
736
721
getopt_ull_limit_value((uint64_t) option_limits->def_value,
737
722
option_limits, ¬_used);
723
LOCK_global_system_variables.unlock();
741
726
session->variables.*offset= global_system_variables.*offset;
770
754
if (var->type == OPT_GLOBAL)
772
756
/* Lock is needed to make things safe on 32 bit systems */
773
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
757
LOCK_global_system_variables.lock();
774
758
global_system_variables.*offset= tmp;
759
LOCK_global_system_variables.unlock();
778
762
session->variables.*offset= tmp;
787
769
if (type == OPT_GLOBAL)
790
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
772
LOCK_global_system_variables.lock();
791
773
global_system_variables.*offset=
792
774
(size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
793
775
option_limits, ¬_used);
776
LOCK_global_system_variables.unlock();
797
779
session->variables.*offset= global_system_variables.*offset;
808
789
return (unsigned char*) &(session->variables.*offset);
811
bool sys_var_session_bool::check(Session *session, set_var *var)
813
return check_enum(session, var, &bool_typelib);
816
793
bool sys_var_session_bool::update(Session *session, set_var *var)
915
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
891
LOCK_global_system_variables.lock();
916
892
value= *(uint*) value_ptr(session, var_type, base);
893
LOCK_global_system_variables.unlock();
918
894
return new Item_uint((uint64_t) value);
920
896
case SHOW_LONGLONG:
923
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
899
LOCK_global_system_variables.lock();
924
900
value= *(int64_t*) value_ptr(session, var_type, base);
901
LOCK_global_system_variables.unlock();
926
902
return new Item_int(value);
928
904
case SHOW_DOUBLE:
932
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
933
value= *(double*) value_ptr(session, var_type, base);
907
LOCK_global_system_variables.lock();
908
value= *(double*) value_ptr(session, var_type, base);
909
LOCK_global_system_variables.unlock();
936
910
/* 6, as this is for now only used with microseconds */
937
911
return new Item_float(value, 6);
939
913
case SHOW_HA_ROWS:
942
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
916
LOCK_global_system_variables.lock();
943
917
value= *(ha_rows*) value_ptr(session, var_type, base);
918
LOCK_global_system_variables.unlock();
945
919
return new Item_int((uint64_t) value);
950
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
924
LOCK_global_system_variables.lock();
951
925
value= *(size_t*) value_ptr(session, var_type, base);
926
LOCK_global_system_variables.unlock();
953
927
return new Item_int((uint64_t) value);
955
929
case SHOW_MY_BOOL:
958
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
932
LOCK_global_system_variables.lock();
959
933
value= *(bool*) value_ptr(session, var_type, base);
934
LOCK_global_system_variables.unlock();
960
935
return new Item_int(value,1);
962
937
case SHOW_CHAR_PTR:
965
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
940
LOCK_global_system_variables.lock();
966
941
char *str= *(char**) value_ptr(session, var_type, base);
975
950
tmp= new Item_null();
976
951
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
953
LOCK_global_system_variables.unlock();
984
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
959
LOCK_global_system_variables.lock();
985
960
char *str= (char*) value_ptr(session, var_type, base);
987
962
tmp= new Item_string(str, strlen(str),
1177
1152
/* We are using Time_zone object found during check() phase. */
1178
1153
if (var->type == OPT_GLOBAL)
1180
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1155
LOCK_global_system_variables.lock();
1181
1156
global_system_variables.time_zone= tmp;
1157
LOCK_global_system_variables.unlock();
1185
1160
session->variables.time_zone= tmp;
1217
1190
void sys_var_session_time_zone::set_default(Session *session, sql_var_t type)
1219
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1220
if (type == OPT_GLOBAL)
1222
if (default_tz_name)
1224
String str(default_tz_name, &my_charset_utf8_general_ci);
1226
We are guaranteed to find this time zone since its existence
1227
is checked during start-up.
1229
global_system_variables.time_zone= my_tz_find(session, &str);
1232
global_system_variables.time_zone= my_tz_SYSTEM;
1235
session->variables.time_zone= global_system_variables.time_zone;
1192
LOCK_global_system_variables.lock();
1193
if (type == OPT_GLOBAL)
1195
if (default_tz_name)
1197
String str(default_tz_name, &my_charset_utf8_general_ci);
1199
We are guaranteed to find this time zone since its existence
1200
is checked during start-up.
1202
global_system_variables.time_zone= my_tz_find(session, &str);
1205
global_system_variables.time_zone= my_tz_SYSTEM;
1208
session->variables.time_zone= global_system_variables.time_zone;
1209
LOCK_global_system_variables.unlock();
1246
1220
if (!(locale_match= my_locale_by_number((uint32_t) var->value->val_int())))
1248
char buf[DECIMAL_LONGLONG_DIGITS];
1249
1223
internal::int10_to_str((int) var->value->val_int(), buf, -10);
1250
1224
my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf);
1315
1289
microseconds= (int64_t) (num * 1000000.0 + 0.5);
1316
1290
if (var->type == OPT_GLOBAL)
1318
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1292
LOCK_global_system_variables.lock();
1319
1293
(global_system_variables.*offset)= microseconds;
1294
LOCK_global_system_variables.unlock();
1322
1297
session->variables.*offset= microseconds;
1329
1304
int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
1330
1305
if (type == OPT_GLOBAL)
1332
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
1307
LOCK_global_system_variables.lock();
1333
1308
global_system_variables.*offset= microseconds;
1309
LOCK_global_system_variables.unlock();
1336
1312
session->variables.*offset= microseconds;
1354
1330
static bool set_option_autocommit(Session *session, set_var *var)
1357
1332
/* The test is negative as the flag we use is NOT autocommit */
1359
1334
uint64_t org_options= session->options;
1360
uint64_t new_options= session->options;
1362
1336
if (var->getInteger() != 0)
1363
new_options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1337
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1365
new_options|= ((sys_var_session_bit*) var->var)->bit_flag;
1339
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
1367
if ((org_options ^ new_options) & OPTION_NOT_AUTOCOMMIT)
1341
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
1369
1343
if ((org_options & OPTION_NOT_AUTOCOMMIT))
1371
success= session->endActiveTransaction();
1372
1345
/* We changed to auto_commit mode */
1373
1346
session->options&= ~(uint64_t) (OPTION_BEGIN);
1374
1347
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1348
TransactionServices &transaction_services= TransactionServices::singleton();
1349
if (transaction_services.commitTransaction(session, true))
1378
1354
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1382
if (var->getInteger() != 0)
1383
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
1385
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
1524
1491
/* this fails if there is a conflicting variable name. */
1525
1492
if (system_variable_map.find(lower_name) != system_variable_map.end())
1527
errmsg_printf(error::ERROR, _("Variable named %s already exists!\n"),
1494
errmsg_printf(ERRMSG_LVL_ERROR, _("Variable named %s already exists!\n"),
1528
1495
var->getName().c_str());
1529
1496
throw exception();
1581
1548
add_sys_var_to_list(&sys_last_insert_id, my_long_options);
1582
1549
add_sys_var_to_list(&sys_lc_time_names, my_long_options);
1583
1550
add_sys_var_to_list(&sys_max_allowed_packet, my_long_options);
1551
add_sys_var_to_list(&sys_max_connect_errors, my_long_options);
1584
1552
add_sys_var_to_list(&sys_max_error_count, my_long_options);
1585
1553
add_sys_var_to_list(&sys_max_heap_table_size, my_long_options);
1586
1554
add_sys_var_to_list(&sys_max_join_size, my_long_options);