44
44
Be careful with var->save_result: sys_var::check() only updates
45
uint64_t_value; so other members of the union are garbage then; to use
45
ulonglong_value; so other members of the union are garbage then; to use
46
46
them you must first assign a value to them (in specific ::check() for
49
#include <drizzled/server_includes.h>
50
#ifdef USE_PRAGMA_IMPLEMENTATION
51
#pragma implementation // gcc: Class implementation
54
#include "mysql_priv.h"
50
56
#include "rpl_mi.h"
51
#include <mysys/my_getopt.h>
52
#include <mysys/thr_alarm.h>
53
#include <storage/myisam/myisam.h>
54
#include <drizzled/drizzled_error_messages.h>
55
#include <libdrizzle/gettext.h>
57
#include <my_getopt.h>
58
#include <thr_alarm.h>
57
extern const CHARSET_INFO *character_set_filesystem;
62
extern CHARSET_INFO *character_set_filesystem;
60
65
static DYNAMIC_ARRAY fixed_show_vars;
61
66
static HASH system_variable_hash;
63
const char *bool_type_names[]= { "OFF", "ON", NULL };
68
const char *bool_type_names[]= { "OFF", "ON", NullS };
64
69
TYPELIB bool_typelib=
66
71
array_elements(bool_type_names)-1, "", bool_type_names, NULL
69
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL };
74
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
70
75
TYPELIB delay_key_write_typelib=
72
77
array_elements(delay_key_write_type_names)-1, "",
90
95
static bool set_option_bit(THD *thd, set_var *var);
91
96
static bool set_option_autocommit(THD *thd, set_var *var);
92
97
static int check_log_update(THD *thd, set_var *var);
98
static bool set_log_update(THD *thd, set_var *var);
93
99
static int check_pseudo_thread_id(THD *thd, set_var *var);
94
100
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
101
static int check_tx_isolation(THD *thd, set_var *var);
107
113
static void fix_thd_mem_root(THD *thd, enum_var_type type);
108
114
static void fix_trans_mem_root(THD *thd, enum_var_type type);
109
115
static void fix_server_id(THD *thd, enum_var_type type);
110
static uint64_t fix_unsigned(THD *, uint64_t, const struct my_option *);
116
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
111
117
static bool get_unsigned(THD *thd, set_var *var);
112
118
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
113
const char *name, int64_t val);
114
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
115
static unsigned char *get_error_count(THD *thd);
116
static unsigned char *get_warning_count(THD *thd);
117
static unsigned char *get_tmpdir(THD *thd);
119
const char *name, longlong val);
120
static KEY_CACHE *create_key_cache(const char *name, uint length);
121
static uchar *get_error_count(THD *thd);
122
static uchar *get_warning_count(THD *thd);
123
static uchar *get_tmpdir(THD *thd);
124
static int sys_check_log_path(THD *thd, set_var *var);
125
static bool sys_update_general_log_path(THD *thd, set_var * var);
126
static void sys_default_general_log_path(THD *thd, enum_var_type type);
127
static bool sys_update_slow_log_path(THD *thd, set_var * var);
128
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
120
131
Variable definition list
185
196
sys_collation_server(&vars, "collation_server", &SV::collation_server,
186
197
&default_charset_info,
187
198
sys_var::SESSION_VARIABLE_IN_BINLOG);
199
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
200
&myisam_concurrent_insert);
188
201
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
189
202
&connect_timeout);
190
203
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
196
209
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
197
210
&expire_logs_days);
198
211
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
212
static sys_var_long_ptr sys_flush_time(&vars, "flush_time", &flush_time);
199
213
sys_var_str sys_init_connect(&vars, "init_connect", 0,
200
214
sys_update_init_connect,
201
215
sys_default_init_connect,0);
218
232
param_age_threshold));
219
233
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
220
234
&opt_local_infile);
235
static sys_var_bool_ptr
236
sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
237
&opt_log_queries_not_using_indexes);
238
static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
239
static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time",
240
&SV::long_query_time);
221
241
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
222
242
&SV::low_priority_updates,
223
243
fix_low_priority_updates);
265
290
&max_write_lock_count);
266
291
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
267
292
&SV::min_examined_row_limit);
268
static sys_var_thd_uint64_t sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
293
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
294
&myisam_data_pointer_size);
295
static sys_var_thd_ulonglong sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
269
296
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
270
297
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
295
322
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
296
323
&SV::optimizer_search_depth);
298
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
325
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
299
326
TYPELIB optimizer_use_mrr_typelib= {
300
327
array_elements(optimizer_use_mrr_names) - 1, "",
301
328
optimizer_use_mrr_names, NULL
360
389
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
361
390
&SV::optimizer_switch);
391
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
392
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
393
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
394
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
395
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
363
397
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
364
398
&SV::table_plugin);
399
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
365
400
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
366
401
system_time_zone);
367
402
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
379
414
&tx_isolation_typelib,
380
415
fix_tx_isolation,
381
416
check_tx_isolation);
382
static sys_var_thd_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
417
static sys_var_thd_ulonglong sys_tmp_table_size(&vars, "tmp_table_size",
383
418
&SV::tmp_table_size);
384
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
419
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes",
385
421
static sys_var_const_str sys_version(&vars, "version", server_version);
386
422
static sys_var_const_str sys_version_comment(&vars, "version_comment",
387
DRIZZLE_COMPILATION_COMMENT);
423
MYSQL_COMPILATION_COMMENT);
388
424
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
390
426
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
523
571
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
524
572
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
526
static unsigned char *slave_get_report_port(THD *thd)
574
static uchar *slave_get_report_port(THD *thd)
528
576
thd->sys_var_tmp.long_value= report_port;
529
return (unsigned char*) &thd->sys_var_tmp.long_value;
577
return (uchar*) &thd->sys_var_tmp.long_value;
532
580
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
536
584
/* Read only variables */
538
586
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
587
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
588
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
589
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
590
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
539
591
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
592
/* Global read-only variable describing server license */
593
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
594
/* Global variables which enable|disable logging */
595
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
597
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
598
static sys_var_log_state sys_var_log(&vars, "log", &opt_log,
600
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
602
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
603
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
604
&opt_slow_log, QUERY_LOG_SLOW);
605
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
606
sys_update_general_log_path,
607
sys_default_general_log_path,
609
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
610
sys_update_slow_log_path,
611
sys_default_slow_log_path,
613
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
614
&log_output_typelib, 0);
541
618
Additional variables (not derived from sys_var class, not accessible as
542
619
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
547
624
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
548
625
static SHOW_VAR fixed_vars[]= {
549
626
{"back_log", (char*) &back_log, SHOW_LONG},
627
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
550
628
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
551
629
{"language", language, SHOW_CHAR},
552
630
#ifdef HAVE_MLOCKALL
555
633
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
556
634
{"log_error", (char*) log_error_file, SHOW_CHAR},
635
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
636
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
557
637
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
558
638
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
559
639
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
560
640
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
561
641
{"port", (char*) &mysqld_port, SHOW_INT},
562
642
{"protocol_version", (char*) &protocol_version, SHOW_INT},
643
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
644
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
645
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
563
646
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
567
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
650
bool sys_var::check(THD *thd __attribute__((__unused__)), set_var *var)
569
var->save_result.uint64_t_value= var->value->val_int();
652
var->save_result.ulonglong_value= var->value->val_int();
613
696
var_str->value= res;
614
697
var_str->value_length= new_length;
615
698
rw_unlock(var_mutex);
699
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
621
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
704
static bool sys_update_init_connect(THD *thd __attribute__((__unused__)), set_var *var)
623
706
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
627
static void sys_default_init_connect(THD* thd __attribute__((unused)),
628
enum_var_type type __attribute__((unused)))
710
static void sys_default_init_connect(THD* thd __attribute__((__unused__)),
711
enum_var_type type __attribute__((__unused__)))
630
713
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
634
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
717
static bool sys_update_init_slave(THD *thd __attribute__((__unused__)),
637
720
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
641
static void sys_default_init_slave(THD* thd __attribute__((unused)),
642
enum_var_type type __attribute__((unused)))
724
static void sys_default_init_slave(THD* thd __attribute__((__unused__)),
725
enum_var_type type __attribute__((__unused__)))
644
727
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
750
834
if (type != OPT_GLOBAL)
751
835
thd->net.retry_count=thd->variables.net_retry_count;
755
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
756
enum_var_type type __attribute__((unused)))
837
#else /* HAVE_REPLICATION */
838
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
839
enum_var_type type __attribute__((unused)))
841
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
842
enum_var_type type __attribute__((unused)))
844
static void fix_net_retry_count(THD *thd __attribute__((unused)),
845
enum_var_type type __attribute__((unused)))
847
#endif /* HAVE_REPLICATION */
850
extern void fix_delay_key_write(THD *thd __attribute__((__unused__)),
851
enum_var_type type __attribute__((__unused__)))
758
853
switch ((enum_delay_key_write) delay_key_write_options) {
759
854
case DELAY_KEY_WRITE_NONE:
772
bool sys_var_set::update(THD *thd __attribute__((unused)),
867
bool sys_var_set::update(THD *thd __attribute__((__unused__)),
775
870
*value= var->save_result.ulong_value;
779
unsigned char *sys_var_set::value_ptr(THD *thd,
780
enum_var_type type __attribute__((unused)),
781
LEX_STRING *base __attribute__((unused)))
874
uchar *sys_var_set::value_ptr(THD *thd,
875
enum_var_type type __attribute__((__unused__)),
876
LEX_STRING *base __attribute__((__unused__)))
784
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
879
String tmp(buff, sizeof(buff), &my_charset_latin1);
786
881
ulong val= *value;
789
for (uint32_t i= 0; val; val>>= 1, i++)
884
for (uint i= 0; val; val>>= 1, i++)
799
894
if ((length= tmp.length()))
801
return (unsigned char*) thd->strmake(tmp.ptr(), length);
896
return (uchar*) thd->strmake(tmp.ptr(), length);
804
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((unused)),
805
enum_var_type type __attribute__((unused)))
899
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((__unused__)),
900
enum_var_type type __attribute__((__unused__)))
807
902
slave_exec_mode_options= 0;
808
903
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
833
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
928
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
930
compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT
931
> SLAVE_EXEC_MODE_LAST_BIT - 1);
835
932
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
836
933
bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
838
sql_print_error(_("Ambiguous slave modes combination."
839
" STRICT will be used"));
935
sql_print_error("Ambiguous slave modes combination."
936
" STRICT will be used");
840
937
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
842
939
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
881
978
void fix_binlog_format_after_update(THD *thd,
882
enum_var_type type __attribute__((unused)))
979
enum_var_type type __attribute__((__unused__)))
884
981
thd->reset_current_stmt_binlog_row_based();
888
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
889
enum_var_type type __attribute__((unused)))
985
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
986
enum_var_type type __attribute__((__unused__)))
891
988
mysql_bin_log.set_max_size(max_binlog_size);
989
#ifdef HAVE_REPLICATION
892
990
if (!max_relay_log_size)
893
991
active_mi->rli.relay_log.set_max_size(max_binlog_size);
897
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
898
enum_var_type type __attribute__((unused)))
996
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
997
enum_var_type type __attribute__((__unused__)))
999
#ifdef HAVE_REPLICATION
900
1000
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
901
1001
max_relay_log_size: max_binlog_size);
905
static void fix_max_connections(THD *thd __attribute__((unused)),
906
enum_var_type type __attribute__((unused)))
1006
static void fix_max_connections(THD *thd __attribute__((__unused__)),
1007
enum_var_type type __attribute__((__unused__)))
908
1009
resize_thr_alarm(max_connections + 10);
938
1039
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
939
const char *name, int64_t val)
1040
const char *name, longlong val)
946
ullstr((uint64_t) val, buf);
1047
ullstr((ulonglong) val, buf);
948
1049
llstr(val, buf);
950
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1051
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
951
1052
ER_TRUNCATED_WRONG_VALUE,
952
1053
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
957
static uint64_t fix_unsigned(THD *thd, uint64_t num,
1058
static ulonglong fix_unsigned(THD *thd, ulonglong num,
958
1059
const struct my_option *option_limits)
961
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
1061
my_bool fixed= false;
1062
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
963
throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
1064
throw_bounds_warning(thd, fixed, true, option_limits->name, (longlong) num);
967
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
1068
static bool get_unsigned(THD *thd __attribute__((__unused__)), set_var *var)
969
1070
if (var->value->unsigned_flag)
970
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
1071
var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
973
int64_t v= var->value->val_int();
974
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
1074
longlong v= var->value->val_int();
1075
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
1028
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
1129
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
1030
uint64_t tmp= var->save_result.uint64_t_value;
1131
ulonglong tmp= var->save_result.ulonglong_value;
1031
1132
pthread_mutex_lock(&LOCK_global_system_variables);
1032
1133
if (option_limits)
1033
*value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
1134
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
1035
*value= (uint64_t) tmp;
1136
*value= (ulonglong) tmp;
1036
1137
pthread_mutex_unlock(&LOCK_global_system_variables);
1041
void sys_var_uint64_t_ptr::set_default(THD *thd __attribute__((unused)),
1042
enum_var_type type __attribute__((unused)))
1142
void sys_var_ulonglong_ptr::set_default(THD *thd __attribute__((__unused__)),
1143
enum_var_type type __attribute__((__unused__)))
1045
1146
pthread_mutex_lock(&LOCK_global_system_variables);
1046
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
1147
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
1047
1148
option_limits, ¬_used);
1048
1149
pthread_mutex_unlock(&LOCK_global_system_variables);
1052
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
1153
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1054
*value= (bool) var->save_result.ulong_value;
1155
*value= (my_bool) var->save_result.ulong_value;
1059
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
1160
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1061
*value= (bool) option_limits->def_value;
1162
*value= (my_bool) option_limits->def_value;
1065
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
1166
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1067
1168
*value= (uint) var->save_result.ulong_value;
1072
unsigned char *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1073
enum_var_type type __attribute__((unused)),
1074
LEX_STRING *base __attribute__((unused)))
1173
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
1174
enum_var_type type __attribute__((__unused__)),
1175
LEX_STRING *base __attribute__((__unused__)))
1076
return (unsigned char*) enum_names->type_names[*value];
1177
return (uchar*) enum_names->type_names[*value];
1080
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1081
enum_var_type type __attribute__((unused)),
1082
LEX_STRING *base __attribute__((unused)))
1181
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
1182
enum_var_type type __attribute__((__unused__)),
1183
LEX_STRING *base __attribute__((__unused__)))
1084
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1185
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1087
1188
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1093
1194
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1095
uint64_t tmp= var->save_result.uint64_t_value;
1196
ulonglong tmp= var->save_result.ulonglong_value;
1097
1198
/* Don't use bigger value than given with --maximum-variable-name=.. */
1098
1199
if ((ulong) tmp > max_system_variables.*offset)
1100
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1201
throw_bounds_warning(thd, true, true, name, (longlong) tmp);
1101
1202
tmp= max_system_variables.*offset;
1138
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
LEX_STRING *base __attribute__((unused)))
1239
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1240
LEX_STRING *base __attribute__((__unused__)))
1141
1242
if (type == OPT_GLOBAL)
1142
return (unsigned char*) &(global_system_variables.*offset);
1143
return (unsigned char*) &(thd->variables.*offset);
1243
return (uchar*) &(global_system_variables.*offset);
1244
return (uchar*) &(thd->variables.*offset);
1147
1248
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1149
uint64_t tmp= var->save_result.uint64_t_value;
1250
ulonglong tmp= var->save_result.ulonglong_value;
1151
1252
/* Don't use bigger value than given with --maximum-variable-name=.. */
1152
1253
if ((ha_rows) tmp > max_system_variables.*offset)
1187
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1188
LEX_STRING *base __attribute__((unused)))
1288
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1289
LEX_STRING *base __attribute__((__unused__)))
1190
1291
if (type == OPT_GLOBAL)
1191
return (unsigned char*) &(global_system_variables.*offset);
1192
return (unsigned char*) &(thd->variables.*offset);
1292
return (uchar*) &(global_system_variables.*offset);
1293
return (uchar*) &(thd->variables.*offset);
1195
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1296
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1197
1298
return get_unsigned(thd, var);
1200
bool sys_var_thd_uint64_t::update(THD *thd, set_var *var)
1301
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
1202
uint64_t tmp= var->save_result.uint64_t_value;
1303
ulonglong tmp= var->save_result.ulonglong_value;
1204
1305
if (tmp > max_system_variables.*offset)
1205
1306
tmp= max_system_variables.*offset;
1211
1312
/* Lock is needed to make things safe on 32 bit systems */
1212
1313
pthread_mutex_lock(&LOCK_global_system_variables);
1213
global_system_variables.*offset= (uint64_t) tmp;
1314
global_system_variables.*offset= (ulonglong) tmp;
1214
1315
pthread_mutex_unlock(&LOCK_global_system_variables);
1217
thd->variables.*offset= (uint64_t) tmp;
1318
thd->variables.*offset= (ulonglong) tmp;
1222
void sys_var_thd_uint64_t::set_default(THD *thd, enum_var_type type)
1323
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
1224
1325
if (type == OPT_GLOBAL)
1227
1328
pthread_mutex_lock(&LOCK_global_system_variables);
1228
1329
global_system_variables.*offset=
1229
getopt_ull_limit_value((uint64_t) option_limits->def_value,
1330
getopt_ull_limit_value((ulonglong) option_limits->def_value,
1230
1331
option_limits, ¬_used);
1231
1332
pthread_mutex_unlock(&LOCK_global_system_variables);
1238
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1239
LEX_STRING *base __attribute__((unused)))
1339
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
1340
LEX_STRING *base __attribute__((__unused__)))
1241
1342
if (type == OPT_GLOBAL)
1242
return (unsigned char*) &(global_system_variables.*offset);
1243
return (unsigned char*) &(thd->variables.*offset);
1343
return (uchar*) &(global_system_variables.*offset);
1344
return (uchar*) &(thd->variables.*offset);
1247
1348
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1249
1350
if (var->type == OPT_GLOBAL)
1250
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1351
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1252
thd->variables.*offset= (bool) var->save_result.ulong_value;
1353
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1257
1358
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1259
1360
if (type == OPT_GLOBAL)
1260
global_system_variables.*offset= (bool) option_limits->def_value;
1361
global_system_variables.*offset= (my_bool) option_limits->def_value;
1262
1363
thd->variables.*offset= global_system_variables.*offset;
1266
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1267
LEX_STRING *base __attribute__((unused)))
1367
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1368
LEX_STRING *base __attribute__((__unused__)))
1269
1370
if (type == OPT_GLOBAL)
1270
return (unsigned char*) &(global_system_variables.*offset);
1271
return (unsigned char*) &(thd->variables.*offset);
1371
return (uchar*) &(global_system_variables.*offset);
1372
return (uchar*) &(thd->variables.*offset);
1275
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1376
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1276
1377
set_var *var, const TYPELIB *enum_names)
1278
1379
char buff[STRING_BUFFER_USUAL_SIZE];
1312
bool sys_var::check_set(THD *thd __attribute__((unused)),
1413
bool sys_var::check_set(THD *thd __attribute__((__unused__)),
1313
1414
set_var *var, TYPELIB *enum_names)
1316
1417
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1317
uint32_t error_len= 0;
1318
1419
String str(buff, sizeof(buff), system_charset_info), *res;
1320
1421
if (var->value->result_type() == STRING_RESULT)
1322
1423
if (!(res= var->value->val_str(&str)))
1324
my_stpcpy(buff, "NULL");
1425
strmov(buff, "NULL");
1412
1513
pthread_mutex_lock(&LOCK_global_system_variables);
1413
1514
value= *(ulong*) value_ptr(thd, var_type, base);
1414
1515
pthread_mutex_unlock(&LOCK_global_system_variables);
1415
return new Item_uint((uint64_t) value);
1516
return new Item_uint((ulonglong) value);
1417
1518
case SHOW_LONGLONG:
1420
1521
pthread_mutex_lock(&LOCK_global_system_variables);
1421
value= *(int64_t*) value_ptr(thd, var_type, base);
1522
value= *(longlong*) value_ptr(thd, var_type, base);
1422
1523
pthread_mutex_unlock(&LOCK_global_system_variables);
1423
1524
return new Item_int(value);
1437
1538
pthread_mutex_lock(&LOCK_global_system_variables);
1438
1539
value= *(ha_rows*) value_ptr(thd, var_type, base);
1439
1540
pthread_mutex_unlock(&LOCK_global_system_variables);
1440
return new Item_int((uint64_t) value);
1541
return new Item_int((ulonglong) value);
1442
1543
case SHOW_MY_BOOL:
1445
1546
pthread_mutex_lock(&LOCK_global_system_variables);
1446
value= *(bool*) value_ptr(thd, var_type, base);
1547
value= *(my_bool*) value_ptr(thd, var_type, base);
1447
1548
pthread_mutex_unlock(&LOCK_global_system_variables);
1448
1549
return new Item_int(value,1);
1511
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1512
LEX_STRING *base __attribute__((unused)))
1612
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1613
LEX_STRING *base __attribute__((__unused__)))
1514
1615
ulong tmp= ((type == OPT_GLOBAL) ?
1515
1616
global_system_variables.*offset :
1516
1617
thd->variables.*offset);
1517
return (unsigned char*) enum_names->type_names[tmp];
1618
return (uchar*) enum_names->type_names[tmp];
1520
1621
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1533
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1534
enum_var_type type __attribute__((unused)),
1535
LEX_STRING *base __attribute__((unused)))
1634
uchar *sys_var_thd_bit::value_ptr(THD *thd,
1635
enum_var_type type __attribute__((__unused__)),
1636
LEX_STRING *base __attribute__((__unused__)))
1538
1639
If reverse is 0 (default) return 1 if bit is set.
1539
1640
If reverse is 1, return 0 if bit is set
1541
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1642
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1542
1643
!reverse : reverse);
1543
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1644
return (uchar*) &thd->sys_var_tmp.my_bool_value;
1653
1754
const char *new_name;
1656
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1757
static my_old_conv old_conv[]=
1759
{ "cp1251_koi8" , "cp1251" },
1760
{ "cp1250_latin2" , "cp1250" },
1761
{ "kam_latin2" , "keybcs2" },
1762
{ "mac_latin2" , "MacRoman" },
1763
{ "macce_latin2" , "MacCE" },
1764
{ "pc2_latin2" , "pclatin2" },
1765
{ "vga_latin2" , "pclatin1" },
1766
{ "koi8_cp1251" , "koi8r" },
1767
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
1768
{ "koi8_ukr_win1251ukr" , "koi8u" },
1772
CHARSET_INFO *get_old_charset_by_name(const char *name)
1776
for (conv= old_conv; conv->old_name; conv++)
1778
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
1779
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
1785
bool sys_var_collation::check(THD *thd __attribute__((__unused__)),
1659
const CHARSET_INFO *tmp;
1661
1790
if (var->value->result_type() == STRING_RESULT)
1738
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1739
LEX_STRING *base __attribute__((unused)))
1868
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1869
LEX_STRING *base __attribute__((__unused__)))
1741
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1742
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1871
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
1872
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1827
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
LEX_STRING *base __attribute__((unused)))
1957
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1958
LEX_STRING *base __attribute__((__unused__)))
1830
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1960
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
1961
global_system_variables.*offset : thd->variables.*offset);
1832
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1962
return cs ? (uchar*) cs->name : (uchar*) "NULL";
1850
unsigned char *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1851
enum_var_type type __attribute__((unused)),
1852
LEX_STRING *base __attribute__((unused)))
1980
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((__unused__)),
1981
enum_var_type type __attribute__((__unused__)),
1982
LEX_STRING *base __attribute__((__unused__)))
1854
1984
KEY_CACHE *key_cache= get_key_cache(base);
1855
1985
if (!key_cache)
1856
1986
key_cache= &zero_key_cache;
1857
return (unsigned char*) key_cache + offset ;
1987
return (uchar*) key_cache + offset ;
1861
1991
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
1863
uint64_t tmp= var->save_result.uint64_t_value;
1993
ulonglong tmp= var->save_result.ulonglong_value;
1864
1994
LEX_STRING *base_name= &var->base;
1865
1995
KEY_CACHE *key_cache;
2003
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2133
bool sys_var_log_state::update(THD *thd, set_var *var)
2006
2136
pthread_mutex_lock(&LOCK_global_system_variables);
2007
2137
if (!var->save_result.ulong_value)
2139
logger.deactivate_log_handler(thd, log_type);
2143
res= logger.activate_log_handler(thd, log_type);
2011
2144
pthread_mutex_unlock(&LOCK_global_system_variables);
2015
void sys_var_log_state::set_default(THD *thd __attribute__((unused)),
2016
enum_var_type type __attribute__((unused)))
2021
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
2148
void sys_var_log_state::set_default(THD *thd,
2149
enum_var_type type __attribute__((__unused__)))
2151
pthread_mutex_lock(&LOCK_global_system_variables);
2152
logger.deactivate_log_handler(thd, log_type);
2153
pthread_mutex_unlock(&LOCK_global_system_variables);
2157
static int sys_check_log_path(THD *thd __attribute__((__unused__)),
2160
char path[FN_REFLEN], buff[FN_REFLEN];
2162
String str(buff, sizeof(buff), system_charset_info), *res;
2163
const char *log_file_str;
2166
if (!(res= var->value->val_str(&str)))
2169
log_file_str= res->c_ptr();
2170
bzero(&f_stat, sizeof(struct stat));
2172
path_length= unpack_filename(path, log_file_str);
2176
/* File name is empty. */
2181
if (!stat(path, &f_stat))
2184
A file system object exists. Check if argument is a file and we have
2188
if (!MY_S_ISREG(f_stat.st_mode) ||
2189
!(f_stat.st_mode & MY_S_IWRITE))
2195
/* Get dirname of the file path. */
2196
(void) dirname_part(path, log_file_str, &path_length);
2198
/* Dirname is empty if file path is relative. */
2203
Check if directory exists and we have permission to create file and
2206
if (my_access(path, (F_OK|W_OK)))
2212
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2213
res ? log_file_str : "NULL");
2218
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
2022
2219
sys_var_str *var_str,
2023
2220
set_var *var, const char *log_ext,
2024
bool log_state, uint32_t log_type)
2221
bool log_state, uint log_type)
2223
MYSQL_QUERY_LOG *file_log;
2026
2224
char buff[FN_REFLEN];
2027
2225
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2028
2226
bool result= 0;
2029
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2227
uint str_length= (var ? var->value->str_value.length() : 0);
2031
2229
switch (log_type) {
2230
case QUERY_LOG_SLOW:
2231
file_log= logger.get_slow_log_file_handler();
2233
case QUERY_LOG_GENERAL:
2234
file_log= logger.get_log_file_handler();
2033
2237
assert(0); // Impossible
2070
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
2282
static bool sys_update_general_log_path(THD *thd, set_var * var)
2284
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2285
var, ".log", opt_log, QUERY_LOG_GENERAL);
2289
static void sys_default_general_log_path(THD *thd,
2290
enum_var_type type __attribute__((__unused__)))
2292
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2293
0, ".log", opt_log, QUERY_LOG_GENERAL);
2297
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2299
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2300
var, "-slow.log", opt_slow_log,
2305
static void sys_default_slow_log_path(THD *thd,
2306
enum_var_type type __attribute__((__unused__)))
2308
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2309
0, "-slow.log", opt_slow_log,
2314
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
2073
2317
pthread_mutex_lock(&LOCK_global_system_variables);
2074
2318
logger.lock_exclusive();
2319
logger.init_slow_log(var->save_result.ulong_value);
2320
logger.init_general_log(var->save_result.ulong_value);
2075
2321
*value= var->save_result.ulong_value;
2076
2322
logger.unlock();
2077
2323
pthread_mutex_unlock(&LOCK_global_system_variables);
2082
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
2083
enum_var_type type __attribute__((unused)))
2328
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
2329
enum_var_type type __attribute__((__unused__)))
2085
2331
pthread_mutex_lock(&LOCK_global_system_variables);
2086
2332
logger.lock_exclusive();
2333
logger.init_slow_log(LOG_FILE);
2334
logger.init_general_log(LOG_FILE);
2087
2335
*value= LOG_FILE;
2088
2336
logger.unlock();
2089
2337
pthread_mutex_unlock(&LOCK_global_system_variables);
2093
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2094
enum_var_type type __attribute__((unused)),
2095
LEX_STRING *base __attribute__((unused)))
2341
uchar *sys_var_log_output::value_ptr(THD *thd,
2342
enum_var_type type __attribute__((__unused__)),
2343
LEX_STRING *base __attribute__((__unused__)))
2097
2345
char buff[256];
2098
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2346
String tmp(buff, sizeof(buff), &my_charset_latin1);
2100
2348
ulong val= *value;
2103
for (uint32_t i= 0; val; val>>= 1, i++)
2351
for (uint i= 0; val; val>>= 1, i++)
2147
2395
bool sys_var_timestamp::update(THD *thd, set_var *var)
2149
thd->set_time((time_t) var->save_result.uint64_t_value);
2397
thd->set_time((time_t) var->save_result.ulonglong_value);
2154
2402
void sys_var_timestamp::set_default(THD *thd,
2155
enum_var_type type __attribute__((unused)))
2403
enum_var_type type __attribute__((__unused__)))
2157
2405
thd->user_time=0;
2161
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2162
enum_var_type type __attribute__((unused)),
2163
LEX_STRING *base __attribute__((unused)))
2409
uchar *sys_var_timestamp::value_ptr(THD *thd,
2410
enum_var_type type __attribute__((__unused__)),
2411
LEX_STRING *base __attribute__((__unused__)))
2165
2413
thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
return (unsigned char*) &thd->sys_var_tmp.long_value;
2414
return (uchar*) &thd->sys_var_tmp.long_value;
2170
2418
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2172
2420
thd->first_successful_insert_id_in_prev_stmt=
2173
var->save_result.uint64_t_value;
2421
var->save_result.ulonglong_value;
2178
unsigned char *sys_var_last_insert_id::value_ptr(THD *thd,
2179
enum_var_type type __attribute__((unused)),
2180
LEX_STRING *base __attribute__((unused)))
2426
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
2427
enum_var_type type __attribute__((__unused__)),
2428
LEX_STRING *base __attribute__((__unused__)))
2183
2431
this tmp var makes it robust againt change of type of
2184
2432
read_first_successful_insert_id_in_prev_stmt().
2186
thd->sys_var_tmp.uint64_t_value=
2434
thd->sys_var_tmp.ulonglong_value=
2187
2435
thd->read_first_successful_insert_id_in_prev_stmt();
2188
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2436
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2192
2440
bool sys_var_insert_id::update(THD *thd, set_var *var)
2194
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2442
thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
2199
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2200
enum_var_type type __attribute__((unused)),
2201
LEX_STRING *base __attribute__((unused)))
2447
uchar *sys_var_insert_id::value_ptr(THD *thd,
2448
enum_var_type type __attribute__((__unused__)),
2449
LEX_STRING *base __attribute__((__unused__)))
2203
thd->sys_var_tmp.uint64_t_value=
2451
thd->sys_var_tmp.ulonglong_value=
2204
2452
thd->auto_inc_intervals_forced.minimum();
2205
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2453
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2209
2457
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2211
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2459
thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2215
2463
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2217
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2465
thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2252
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2253
LEX_STRING *base __attribute__((unused)))
2500
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2501
LEX_STRING *base __attribute__((__unused__)))
2256
2504
We can use ptr() instead of c_ptr() here because String contaning
2257
2505
time zone name is guaranteed to be zero ended.
2259
2507
if (type == OPT_GLOBAL)
2260
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
2508
return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2315
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
2563
bool sys_var_max_user_conn::update(THD *thd __attribute__((__unused__)),
2318
2566
assert(var->type == OPT_GLOBAL);
2319
2567
pthread_mutex_lock(&LOCK_global_system_variables);
2320
max_user_connections= (uint)var->save_result.uint64_t_value;
2568
max_user_connections= (uint)var->save_result.ulonglong_value;
2321
2569
pthread_mutex_unlock(&LOCK_global_system_variables);
2326
void sys_var_max_user_conn::set_default(THD *thd __attribute__((unused)),
2327
enum_var_type type __attribute__((unused)))
2574
void sys_var_max_user_conn::set_default(THD *thd __attribute__((__unused__)),
2575
enum_var_type type __attribute__((__unused__)))
2329
2577
assert(type == OPT_GLOBAL);
2330
2578
pthread_mutex_lock(&LOCK_global_system_variables);
2336
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2337
LEX_STRING *base __attribute__((unused)))
2584
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2585
LEX_STRING *base __attribute__((__unused__)))
2339
2587
if (type != OPT_GLOBAL &&
2340
2588
thd->user_connect && thd->user_connect->user_resources.user_conn)
2341
return (unsigned char*) &(thd->user_connect->user_resources.user_conn);
2342
return (unsigned char*) &(max_user_connections);
2589
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2590
return (uchar*) &(max_user_connections);
2346
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
2594
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((__unused__)),
2349
2597
MY_LOCALE *locale_match;
2394
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2642
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2395
2643
enum_var_type type,
2396
LEX_STRING *base __attribute__((unused)))
2644
LEX_STRING *base __attribute__((__unused__)))
2398
2646
return type == OPT_GLOBAL ?
2399
(unsigned char *) global_system_variables.lc_time_names->name :
2400
(unsigned char *) thd->variables.lc_time_names->name;
2647
(uchar *) global_system_variables.lc_time_names->name :
2648
(uchar *) thd->variables.lc_time_names->name;
2416
2664
The argument to long query time is in seconds in decimal
2417
which is converted to uint64_t integer holding microseconds for storage.
2665
which is converted to ulonglong integer holding microseconds for storage.
2418
2666
This is used for handling long_query_time
2421
2669
bool sys_var_microseconds::update(THD *thd, set_var *var)
2423
2671
double num= var->value->val_real();
2424
int64_t microseconds;
2672
longlong microseconds;
2425
2673
if (num > (double) option_limits->max_value)
2426
2674
num= (double) option_limits->max_value;
2427
2675
if (num < (double) option_limits->min_value)
2428
2676
num= (double) option_limits->min_value;
2429
microseconds= (int64_t) (num * 1000000.0 + 0.5);
2677
microseconds= (longlong) (num * 1000000.0 + 0.5);
2430
2678
if (var->type == OPT_GLOBAL)
2432
2680
pthread_mutex_lock(&LOCK_global_system_variables);
2456
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
LEX_STRING *base __attribute__((unused)))
2704
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2705
LEX_STRING *base __attribute__((__unused__)))
2459
2707
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
2708
global_system_variables.*offset :
2461
2709
thd->variables.*offset) / 1000000.0;
2462
return (unsigned char*) &thd->tmp_double_value;
2710
return (uchar*) &thd->tmp_double_value;
2512
static int check_log_update(THD *thd __attribute__((unused)),
2513
set_var *var __attribute__((unused)))
2519
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2760
static int check_log_update(THD *thd __attribute__((__unused__)),
2761
set_var *var __attribute__((__unused__)))
2766
static bool set_log_update(THD *thd __attribute__((__unused__)),
2767
set_var *var __attribute__((__unused__)))
2770
The update log is not supported anymore since 5.0.
2771
See sql/mysqld.cc/, comments in function init_server_components() for an
2772
explaination of the different warnings we send below
2775
if (opt_sql_bin_update)
2777
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2778
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2779
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2782
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2783
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2784
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2785
set_option_bit(thd, var);
2790
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2522
var->save_result.uint64_t_value= var->value->val_int();
2793
var->save_result.ulonglong_value= var->value->val_int();
2526
static unsigned char *get_warning_count(THD *thd)
2797
static uchar *get_warning_count(THD *thd)
2528
2799
thd->sys_var_tmp.long_value=
2529
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2530
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2531
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2532
return (unsigned char*) &thd->sys_var_tmp.long_value;
2800
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
2801
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
2802
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
2803
return (uchar*) &thd->sys_var_tmp.long_value;
2535
static unsigned char *get_error_count(THD *thd)
2806
static uchar *get_error_count(THD *thd)
2537
2808
thd->sys_var_tmp.long_value=
2538
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2539
return (unsigned char*) &thd->sys_var_tmp.long_value;
2809
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2810
return (uchar*) &thd->sys_var_tmp.long_value;
2604
2875
Return variable name and length for hashing of variables.
2607
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length,
2608
bool first __attribute__((unused)))
2878
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2879
my_bool first __attribute__((__unused__)))
2610
2881
*length= var->name_length;
2611
return (unsigned char*) var->name;
2882
return (uchar*) var->name;
3009
3288
!(engine_name.str= (char *)res->ptr()) ||
3010
3289
!(engine_name.length= res->length()) ||
3011
3290
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
3012
!(hton= plugin_data(var->save_result.plugin, handlerton *)))
3291
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
3292
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
3014
3294
value= res ? res->c_ptr() : "NULL";
3080
3360
sys_var_thd_optimizer_switch::
3081
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
3361
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
3083
3363
char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3364
String tmp(buff, sizeof(buff), &my_charset_latin1);
3088
for (uint32_t i= 0; val; val>>= 1, i++)
3368
for (uint i= 0; val; val>>= 1, i++)
3109
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3110
LEX_STRING *base __attribute__((unused)))
3389
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3390
LEX_STRING *base __attribute__((__unused__)))
3112
3392
LEX_STRING opts;
3113
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3393
ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3114
3394
thd->variables.*offset);
3115
3395
(void) symbolic_mode_representation(thd, val, &opts);
3116
return (unsigned char *) opts.str;
3396
return (uchar *) opts.str;
3164
3444
/* Key cache functions */
3166
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3446
static KEY_CACHE *create_key_cache(const char *name, uint length)
3168
3448
KEY_CACHE *key_cache;
3170
3450
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3171
3451
MYF(MY_ZEROFILL | MY_WME))))
3173
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
3453
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3175
free((char*) key_cache);
3455
my_free((char*) key_cache, MYF(0));