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
144
155
&SV::binlog_format);
145
156
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
146
157
&SV::bulk_insert_buff_size);
158
static sys_var_character_set_sv
159
sys_character_set_server(&vars, "character_set_server",
160
&SV::collation_server, &default_charset_info, 0,
161
sys_var::SESSION_VARIABLE_IN_BINLOG);
162
sys_var_const_str sys_charset_system(&vars, "character_set_system",
163
(char *)my_charset_utf8_general_ci.name);
164
static sys_var_character_set_database
165
sys_character_set_database(&vars, "character_set_database",
166
sys_var::SESSION_VARIABLE_IN_BINLOG);
167
static sys_var_character_set_client
168
sys_character_set_client(&vars, "character_set_client",
169
&SV::character_set_client,
170
&default_charset_info,
171
sys_var::SESSION_VARIABLE_IN_BINLOG);
172
static sys_var_character_set_sv
173
sys_character_set_connection(&vars, "character_set_connection",
174
&SV::collation_connection,
175
&default_charset_info, 0,
176
sys_var::SESSION_VARIABLE_IN_BINLOG);
177
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
178
&SV::character_set_results,
179
&default_charset_info, true);
180
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
181
&SV::character_set_filesystem,
182
&character_set_filesystem);
147
183
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
148
184
&SV::completion_type,
149
185
check_completion_type,
160
196
sys_collation_server(&vars, "collation_server", &SV::collation_server,
161
197
&default_charset_info,
162
198
sys_var::SESSION_VARIABLE_IN_BINLOG);
199
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
200
&myisam_concurrent_insert);
163
201
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
164
202
&connect_timeout);
165
203
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
171
209
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
172
210
&expire_logs_days);
173
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);
174
213
sys_var_str sys_init_connect(&vars, "init_connect", 0,
175
214
sys_update_init_connect,
176
215
sys_default_init_connect,0);
193
232
param_age_threshold));
194
233
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
195
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);
196
241
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
197
242
&SV::low_priority_updates,
198
243
fix_low_priority_updates);
240
290
&max_write_lock_count);
241
291
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
242
292
&SV::min_examined_row_limit);
243
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);
244
296
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
297
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
270
322
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
271
323
&SV::optimizer_search_depth);
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
325
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
274
326
TYPELIB optimizer_use_mrr_typelib= {
275
327
array_elements(optimizer_use_mrr_names) - 1, "",
276
328
optimizer_use_mrr_names, NULL
307
361
&SV::trans_prealloc_size,
308
362
0, fix_trans_mem_root);
364
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
310
365
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
311
366
&opt_secure_file_priv);
312
367
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
313
368
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
314
369
&opt_slave_compressed_protocol);
370
#ifdef HAVE_REPLICATION
315
371
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
316
372
&slave_allow_batching);
317
373
static sys_var_set_slave_mode slave_exec_mode(&vars,
332
389
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
333
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);
335
397
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
336
398
&SV::table_plugin);
399
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
337
400
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
338
401
system_time_zone);
339
402
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
351
414
&tx_isolation_typelib,
352
415
fix_tx_isolation,
353
416
check_tx_isolation);
354
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",
355
418
&SV::tmp_table_size);
356
419
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
357
420
static sys_var_const_str sys_version(&vars, "version", server_version);
358
421
static sys_var_const_str sys_version_comment(&vars, "version_comment",
359
DRIZZLE_COMPILATION_COMMENT);
422
MYSQL_COMPILATION_COMMENT);
360
423
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
362
425
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
495
570
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
496
571
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
498
static unsigned char *slave_get_report_port(THD *thd)
573
static uchar *slave_get_report_port(THD *thd)
500
575
thd->sys_var_tmp.long_value= report_port;
501
return (unsigned char*) &thd->sys_var_tmp.long_value;
576
return (uchar*) &thd->sys_var_tmp.long_value;
504
579
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
508
583
/* Read only variables */
510
585
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
586
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
587
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
588
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
589
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
511
590
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
591
/* Global read-only variable describing server license */
592
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
593
/* Global variables which enable|disable logging */
594
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
596
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
597
static sys_var_log_state sys_var_log(&vars, "log", &opt_log, QUERY_LOG_GENERAL);
598
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
600
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
601
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
602
&opt_slow_log, QUERY_LOG_SLOW);
603
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
604
sys_update_general_log_path,
605
sys_default_general_log_path,
607
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
608
sys_update_slow_log_path,
609
sys_default_slow_log_path,
611
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
612
&log_output_typelib, 0);
513
616
Additional variables (not derived from sys_var class, not accessible as
514
617
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
519
622
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
520
623
static SHOW_VAR fixed_vars[]= {
521
624
{"back_log", (char*) &back_log, SHOW_LONG},
625
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
522
626
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
523
627
{"language", language, SHOW_CHAR},
524
628
#ifdef HAVE_MLOCKALL
527
631
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
528
632
{"log_error", (char*) log_error_file, SHOW_CHAR},
633
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
634
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
529
635
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
530
636
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
531
637
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
532
638
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
533
639
{"port", (char*) &mysqld_port, SHOW_INT},
534
640
{"protocol_version", (char*) &protocol_version, SHOW_INT},
641
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
642
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
643
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
535
644
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
539
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
648
bool sys_var::check(THD *thd __attribute__((__unused__)), set_var *var)
541
var->save_result.uint64_t_value= var->value->val_int();
650
var->save_result.ulonglong_value= var->value->val_int();
585
694
var_str->value= res;
586
695
var_str->value_length= new_length;
587
696
rw_unlock(var_mutex);
697
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
593
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
702
static bool sys_update_init_connect(THD *thd __attribute__((__unused__)), set_var *var)
595
704
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
599
static void sys_default_init_connect(THD* thd __attribute__((unused)),
600
enum_var_type type __attribute__((unused)))
708
static void sys_default_init_connect(THD* thd __attribute__((__unused__)),
709
enum_var_type type __attribute__((__unused__)))
602
711
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
606
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
715
static bool sys_update_init_slave(THD *thd __attribute__((__unused__)),
609
718
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
613
static void sys_default_init_slave(THD* thd __attribute__((unused)),
614
enum_var_type type __attribute__((unused)))
722
static void sys_default_init_slave(THD* thd __attribute__((__unused__)),
723
enum_var_type type __attribute__((__unused__)))
616
725
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
722
832
if (type != OPT_GLOBAL)
723
833
thd->net.retry_count=thd->variables.net_retry_count;
727
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
728
enum_var_type type __attribute__((unused)))
835
#else /* HAVE_REPLICATION */
836
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
837
enum_var_type type __attribute__((unused)))
839
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
840
enum_var_type type __attribute__((unused)))
842
static void fix_net_retry_count(THD *thd __attribute__((unused)),
843
enum_var_type type __attribute__((unused)))
845
#endif /* HAVE_REPLICATION */
848
extern void fix_delay_key_write(THD *thd __attribute__((__unused__)),
849
enum_var_type type __attribute__((__unused__)))
730
851
switch ((enum_delay_key_write) delay_key_write_options) {
731
852
case DELAY_KEY_WRITE_NONE:
744
bool sys_var_set::update(THD *thd __attribute__((unused)),
865
bool sys_var_set::update(THD *thd __attribute__((__unused__)),
747
868
*value= var->save_result.ulong_value;
751
unsigned char *sys_var_set::value_ptr(THD *thd,
752
enum_var_type type __attribute__((unused)),
753
LEX_STRING *base __attribute__((unused)))
872
uchar *sys_var_set::value_ptr(THD *thd,
873
enum_var_type type __attribute__((__unused__)),
874
LEX_STRING *base __attribute__((__unused__)))
756
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
877
String tmp(buff, sizeof(buff), &my_charset_latin1);
758
879
ulong val= *value;
761
for (uint32_t i= 0; val; val>>= 1, i++)
882
for (uint i= 0; val; val>>= 1, i++)
771
892
if ((length= tmp.length()))
773
return (unsigned char*) thd->strmake(tmp.ptr(), length);
894
return (uchar*) thd->strmake(tmp.ptr(), length);
776
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((unused)),
777
enum_var_type type __attribute__((unused)))
897
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((__unused__)),
898
enum_var_type type __attribute__((__unused__)))
779
900
slave_exec_mode_options= 0;
780
901
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
805
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
926
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
807
928
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
808
929
bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
810
sql_print_error(_("Ambiguous slave modes combination."
811
" STRICT will be used"));
931
sql_print_error("Ambiguous slave modes combination."
932
" STRICT will be used");
812
933
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
814
935
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
838
959
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
963
if in a stored function/trigger, it's too late to change mode
965
if (thd->in_sub_stmt)
967
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
842
970
return sys_var_thd_enum::is_readonly();
846
974
void fix_binlog_format_after_update(THD *thd,
847
enum_var_type type __attribute__((unused)))
975
enum_var_type type __attribute__((__unused__)))
849
977
thd->reset_current_stmt_binlog_row_based();
853
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
854
enum_var_type type __attribute__((unused)))
981
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
982
enum_var_type type __attribute__((__unused__)))
856
984
mysql_bin_log.set_max_size(max_binlog_size);
985
#ifdef HAVE_REPLICATION
857
986
if (!max_relay_log_size)
858
987
active_mi->rli.relay_log.set_max_size(max_binlog_size);
862
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
863
enum_var_type type __attribute__((unused)))
992
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
993
enum_var_type type __attribute__((__unused__)))
995
#ifdef HAVE_REPLICATION
865
996
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
866
997
max_relay_log_size: max_binlog_size);
870
static void fix_max_connections(THD *thd __attribute__((unused)),
871
enum_var_type type __attribute__((unused)))
1002
static void fix_max_connections(THD *thd __attribute__((__unused__)),
1003
enum_var_type type __attribute__((__unused__)))
873
1005
resize_thr_alarm(max_connections + 10);
903
1035
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
904
const char *name, int64_t val)
1036
const char *name, longlong val)
911
ullstr((uint64_t) val, buf);
1043
ullstr((ulonglong) val, buf);
913
1045
llstr(val, buf);
915
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1047
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
916
1048
ER_TRUNCATED_WRONG_VALUE,
917
1049
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
922
static uint64_t fix_unsigned(THD *thd, uint64_t num,
1054
static ulonglong fix_unsigned(THD *thd, ulonglong num,
923
1055
const struct my_option *option_limits)
925
1057
bool fixed= false;
926
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
1058
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
928
throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
1060
throw_bounds_warning(thd, fixed, true, option_limits->name, (longlong) num);
932
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
1064
static bool get_unsigned(THD *thd __attribute__((__unused__)), set_var *var)
934
1066
if (var->value->unsigned_flag)
935
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
1067
var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
938
int64_t v= var->value->val_int();
939
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
1070
longlong v= var->value->val_int();
1071
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
958
1090
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
960
uint64_t tmp= var->save_result.uint64_t_value;
1092
ulonglong tmp= var->save_result.ulonglong_value;
961
1093
pthread_mutex_lock(guard);
962
1094
if (option_limits)
963
1095
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
966
if (tmp > UINT32_MAX)
1098
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1099
/* Avoid overflows on 32 bit systems */
1100
if (tmp > ULONG_MAX)
969
1103
throw_bounds_warning(thd, true, true, name,
970
(int64_t) var->save_result.uint64_t_value);
1104
(longlong) var->save_result.ulonglong_value);
972
1107
*value= (ulong) tmp;
990
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
1125
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
992
uint64_t tmp= var->save_result.uint64_t_value;
1127
ulonglong tmp= var->save_result.ulonglong_value;
993
1128
pthread_mutex_lock(&LOCK_global_system_variables);
994
1129
if (option_limits)
995
*value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
1130
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
997
*value= (uint64_t) tmp;
1132
*value= (ulonglong) tmp;
998
1133
pthread_mutex_unlock(&LOCK_global_system_variables);
1003
void sys_var_uint64_t_ptr::set_default(THD *thd __attribute__((unused)),
1004
enum_var_type type __attribute__((unused)))
1138
void sys_var_ulonglong_ptr::set_default(THD *thd __attribute__((__unused__)),
1139
enum_var_type type __attribute__((__unused__)))
1007
1142
pthread_mutex_lock(&LOCK_global_system_variables);
1008
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
1143
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
1009
1144
option_limits, ¬_used);
1010
1145
pthread_mutex_unlock(&LOCK_global_system_variables);
1014
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
1149
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1016
1151
*value= (bool) var->save_result.ulong_value;
1021
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
1156
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1023
1158
*value= (bool) option_limits->def_value;
1027
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
1162
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1029
1164
*value= (uint) var->save_result.ulong_value;
1034
unsigned char *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1035
enum_var_type type __attribute__((unused)),
1036
LEX_STRING *base __attribute__((unused)))
1169
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
1170
enum_var_type type __attribute__((__unused__)),
1171
LEX_STRING *base __attribute__((__unused__)))
1038
return (unsigned char*) enum_names->type_names[*value];
1173
return (uchar*) enum_names->type_names[*value];
1042
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1043
enum_var_type type __attribute__((unused)),
1044
LEX_STRING *base __attribute__((unused)))
1177
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
1178
enum_var_type type __attribute__((__unused__)),
1179
LEX_STRING *base __attribute__((__unused__)))
1046
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1181
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1049
1184
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1055
1190
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1057
uint64_t tmp= var->save_result.uint64_t_value;
1192
ulonglong tmp= var->save_result.ulonglong_value;
1059
1194
/* Don't use bigger value than given with --maximum-variable-name=.. */
1060
1195
if ((ulong) tmp > max_system_variables.*offset)
1062
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1197
throw_bounds_warning(thd, true, true, name, (longlong) tmp);
1063
1198
tmp= max_system_variables.*offset;
1066
1201
if (option_limits)
1067
1202
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1068
else if (tmp > UINT32_MAX)
1203
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1204
else if (tmp > ULONG_MAX)
1071
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1207
throw_bounds_warning(thd, true, true, name, (longlong) var->save_result.ulonglong_value);
1074
1211
if (var->type == OPT_GLOBAL)
1075
1212
global_system_variables.*offset= (ulong) tmp;
1098
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1099
LEX_STRING *base __attribute__((unused)))
1235
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1236
LEX_STRING *base __attribute__((__unused__)))
1101
1238
if (type == OPT_GLOBAL)
1102
return (unsigned char*) &(global_system_variables.*offset);
1103
return (unsigned char*) &(thd->variables.*offset);
1239
return (uchar*) &(global_system_variables.*offset);
1240
return (uchar*) &(thd->variables.*offset);
1107
1244
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1109
uint64_t tmp= var->save_result.uint64_t_value;
1246
ulonglong tmp= var->save_result.ulonglong_value;
1111
1248
/* Don't use bigger value than given with --maximum-variable-name=.. */
1112
1249
if ((ha_rows) tmp > max_system_variables.*offset)
1147
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1148
LEX_STRING *base __attribute__((unused)))
1284
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1285
LEX_STRING *base __attribute__((__unused__)))
1150
1287
if (type == OPT_GLOBAL)
1151
return (unsigned char*) &(global_system_variables.*offset);
1152
return (unsigned char*) &(thd->variables.*offset);
1288
return (uchar*) &(global_system_variables.*offset);
1289
return (uchar*) &(thd->variables.*offset);
1155
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1292
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1157
1294
return get_unsigned(thd, var);
1160
bool sys_var_thd_uint64_t::update(THD *thd, set_var *var)
1297
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
1162
uint64_t tmp= var->save_result.uint64_t_value;
1299
ulonglong tmp= var->save_result.ulonglong_value;
1164
1301
if (tmp > max_system_variables.*offset)
1165
1302
tmp= max_system_variables.*offset;
1171
1308
/* Lock is needed to make things safe on 32 bit systems */
1172
1309
pthread_mutex_lock(&LOCK_global_system_variables);
1173
global_system_variables.*offset= (uint64_t) tmp;
1310
global_system_variables.*offset= (ulonglong) tmp;
1174
1311
pthread_mutex_unlock(&LOCK_global_system_variables);
1177
thd->variables.*offset= (uint64_t) tmp;
1314
thd->variables.*offset= (ulonglong) tmp;
1182
void sys_var_thd_uint64_t::set_default(THD *thd, enum_var_type type)
1319
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
1184
1321
if (type == OPT_GLOBAL)
1187
1324
pthread_mutex_lock(&LOCK_global_system_variables);
1188
1325
global_system_variables.*offset=
1189
getopt_ull_limit_value((uint64_t) option_limits->def_value,
1326
getopt_ull_limit_value((ulonglong) option_limits->def_value,
1190
1327
option_limits, ¬_used);
1191
1328
pthread_mutex_unlock(&LOCK_global_system_variables);
1198
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1199
LEX_STRING *base __attribute__((unused)))
1335
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
1336
LEX_STRING *base __attribute__((__unused__)))
1201
1338
if (type == OPT_GLOBAL)
1202
return (unsigned char*) &(global_system_variables.*offset);
1203
return (unsigned char*) &(thd->variables.*offset);
1339
return (uchar*) &(global_system_variables.*offset);
1340
return (uchar*) &(thd->variables.*offset);
1207
1344
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1209
1346
if (var->type == OPT_GLOBAL)
1210
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1347
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1212
thd->variables.*offset= (bool) var->save_result.ulong_value;
1349
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1217
1354
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1219
1356
if (type == OPT_GLOBAL)
1220
global_system_variables.*offset= (bool) option_limits->def_value;
1357
global_system_variables.*offset= (my_bool) option_limits->def_value;
1222
1359
thd->variables.*offset= global_system_variables.*offset;
1226
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1227
LEX_STRING *base __attribute__((unused)))
1363
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1364
LEX_STRING *base __attribute__((__unused__)))
1229
1366
if (type == OPT_GLOBAL)
1230
return (unsigned char*) &(global_system_variables.*offset);
1231
return (unsigned char*) &(thd->variables.*offset);
1367
return (uchar*) &(global_system_variables.*offset);
1368
return (uchar*) &(thd->variables.*offset);
1235
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1372
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1236
1373
set_var *var, const TYPELIB *enum_names)
1238
1375
char buff[STRING_BUFFER_USUAL_SIZE];
1272
bool sys_var::check_set(THD *thd __attribute__((unused)),
1409
bool sys_var::check_set(THD *thd __attribute__((__unused__)),
1273
1410
set_var *var, TYPELIB *enum_names)
1276
1413
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1277
uint32_t error_len= 0;
1278
1415
String str(buff, sizeof(buff), system_charset_info), *res;
1280
1417
if (var->value->result_type() == STRING_RESULT)
1282
1419
if (!(res= var->value->val_str(&str)))
1284
my_stpcpy(buff, "NULL");
1421
strmov(buff, "NULL");
1372
1509
pthread_mutex_lock(&LOCK_global_system_variables);
1373
1510
value= *(ulong*) value_ptr(thd, var_type, base);
1374
1511
pthread_mutex_unlock(&LOCK_global_system_variables);
1375
return new Item_uint((uint64_t) value);
1512
return new Item_uint((ulonglong) value);
1377
1514
case SHOW_LONGLONG:
1380
1517
pthread_mutex_lock(&LOCK_global_system_variables);
1381
value= *(int64_t*) value_ptr(thd, var_type, base);
1518
value= *(longlong*) value_ptr(thd, var_type, base);
1382
1519
pthread_mutex_unlock(&LOCK_global_system_variables);
1383
1520
return new Item_int(value);
1397
1534
pthread_mutex_lock(&LOCK_global_system_variables);
1398
1535
value= *(ha_rows*) value_ptr(thd, var_type, base);
1399
1536
pthread_mutex_unlock(&LOCK_global_system_variables);
1400
return new Item_int((uint64_t) value);
1537
return new Item_int((ulonglong) value);
1402
1539
case SHOW_MY_BOOL:
1405
1542
pthread_mutex_lock(&LOCK_global_system_variables);
1406
value= *(bool*) value_ptr(thd, var_type, base);
1543
value= *(my_bool*) value_ptr(thd, var_type, base);
1407
1544
pthread_mutex_unlock(&LOCK_global_system_variables);
1408
1545
return new Item_int(value,1);
1471
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1472
LEX_STRING *base __attribute__((unused)))
1608
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1609
LEX_STRING *base __attribute__((__unused__)))
1474
1611
ulong tmp= ((type == OPT_GLOBAL) ?
1475
1612
global_system_variables.*offset :
1476
1613
thd->variables.*offset);
1477
return (unsigned char*) enum_names->type_names[tmp];
1614
return (uchar*) enum_names->type_names[tmp];
1480
1617
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1493
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1494
enum_var_type type __attribute__((unused)),
1495
LEX_STRING *base __attribute__((unused)))
1630
uchar *sys_var_thd_bit::value_ptr(THD *thd,
1631
enum_var_type type __attribute__((__unused__)),
1632
LEX_STRING *base __attribute__((__unused__)))
1498
1635
If reverse is 0 (default) return 1 if bit is set.
1499
1636
If reverse is 1, return 0 if bit is set
1501
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1638
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1502
1639
!reverse : reverse);
1503
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1640
return (uchar*) &thd->sys_var_tmp.my_bool_value;
1613
1750
const char *new_name;
1616
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1753
static my_old_conv old_conv[]=
1755
{ "cp1251_koi8" , "cp1251" },
1756
{ "cp1250_latin2" , "cp1250" },
1757
{ "kam_latin2" , "keybcs2" },
1758
{ "mac_latin2" , "MacRoman" },
1759
{ "macce_latin2" , "MacCE" },
1760
{ "pc2_latin2" , "pclatin2" },
1761
{ "vga_latin2" , "pclatin1" },
1762
{ "koi8_cp1251" , "koi8r" },
1763
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
1764
{ "koi8_ukr_win1251ukr" , "koi8u" },
1768
CHARSET_INFO *get_old_charset_by_name(const char *name)
1772
for (conv= old_conv; conv->old_name; conv++)
1774
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
1775
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
1781
bool sys_var_collation::check(THD *thd __attribute__((__unused__)),
1619
const CHARSET_INFO *tmp;
1621
1786
if (var->value->result_type() == STRING_RESULT)
1698
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1699
LEX_STRING *base __attribute__((unused)))
1701
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1702
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1864
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1865
LEX_STRING *base __attribute__((__unused__)))
1867
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
1868
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1872
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1874
if (type == OPT_GLOBAL)
1875
global_system_variables.*offset= *global_default;
1878
thd->variables.*offset= global_system_variables.*offset;
1879
thd->update_charset();
1882
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1884
if (type == OPT_GLOBAL)
1885
return &(global_system_variables.*offset);
1887
return &(thd->variables.*offset);
1891
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1893
if (sys_var_character_set_sv::check(thd, var))
1895
/* Currently, UCS-2 cannot be used as a client character set */
1896
if (var->save_result.charset->mbminlen > 1)
1898
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1899
var->save_result.charset->csname);
1906
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1909
if (type == OPT_GLOBAL)
1910
return &global_system_variables.collation_database;
1912
return &thd->variables.collation_database;
1916
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1918
if (type == OPT_GLOBAL)
1919
global_system_variables.collation_database= default_charset_info;
1922
thd->variables.collation_database= thd->db_charset;
1923
thd->update_charset();
1731
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1732
LEX_STRING *base __attribute__((unused)))
1953
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1954
LEX_STRING *base __attribute__((__unused__)))
1734
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1956
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1735
1957
global_system_variables.*offset : thd->variables.*offset);
1736
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1958
return cs ? (uchar*) cs->name : (uchar*) "NULL";
1754
unsigned char *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1755
enum_var_type type __attribute__((unused)),
1756
LEX_STRING *base __attribute__((unused)))
1976
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((__unused__)),
1977
enum_var_type type __attribute__((__unused__)),
1978
LEX_STRING *base __attribute__((__unused__)))
1758
1980
KEY_CACHE *key_cache= get_key_cache(base);
1759
1981
if (!key_cache)
1760
1982
key_cache= &zero_key_cache;
1761
return (unsigned char*) key_cache + offset ;
1983
return (uchar*) key_cache + offset ;
1765
1987
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
1767
uint64_t tmp= var->save_result.uint64_t_value;
1989
ulonglong tmp= var->save_result.ulonglong_value;
1768
1990
LEX_STRING *base_name= &var->base;
1769
1991
KEY_CACHE *key_cache;
1907
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2129
bool sys_var_log_state::update(THD *thd, set_var *var)
1910
2132
pthread_mutex_lock(&LOCK_global_system_variables);
1911
2133
if (!var->save_result.ulong_value)
2135
logger.deactivate_log_handler(thd, log_type);
2139
res= logger.activate_log_handler(thd, log_type);
1915
2140
pthread_mutex_unlock(&LOCK_global_system_variables);
1919
void sys_var_log_state::set_default(THD *thd __attribute__((unused)),
1920
enum_var_type type __attribute__((unused)))
1925
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
2144
void sys_var_log_state::set_default(THD *thd,
2145
enum_var_type type __attribute__((__unused__)))
2147
pthread_mutex_lock(&LOCK_global_system_variables);
2148
logger.deactivate_log_handler(thd, log_type);
2149
pthread_mutex_unlock(&LOCK_global_system_variables);
2153
static int sys_check_log_path(THD *thd __attribute__((__unused__)),
2156
char path[FN_REFLEN], buff[FN_REFLEN];
2158
String str(buff, sizeof(buff), system_charset_info), *res;
2159
const char *log_file_str;
2162
if (!(res= var->value->val_str(&str)))
2165
log_file_str= res->c_ptr();
2166
bzero(&f_stat, sizeof(struct stat));
2168
path_length= unpack_filename(path, log_file_str);
2172
/* File name is empty. */
2177
if (!stat(path, &f_stat))
2180
A file system object exists. Check if argument is a file and we have
2184
if (!MY_S_ISREG(f_stat.st_mode) ||
2185
!(f_stat.st_mode & MY_S_IWRITE))
2191
/* Get dirname of the file path. */
2192
(void) dirname_part(path, log_file_str, &path_length);
2194
/* Dirname is empty if file path is relative. */
2199
Check if directory exists and we have permission to create file and
2202
if (my_access(path, (F_OK|W_OK)))
2208
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2209
res ? log_file_str : "NULL");
2214
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
1926
2215
sys_var_str *var_str,
1927
2216
set_var *var, const char *log_ext,
1928
bool log_state, uint32_t log_type)
2217
bool log_state, uint log_type)
2219
MYSQL_QUERY_LOG *file_log;
1930
2220
char buff[FN_REFLEN];
1931
2221
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
1932
2222
bool result= 0;
1933
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2223
uint str_length= (var ? var->value->str_value.length() : 0);
1935
2225
switch (log_type) {
2226
case QUERY_LOG_SLOW:
2227
file_log= logger.get_slow_log_file_handler();
2229
case QUERY_LOG_GENERAL:
2230
file_log= logger.get_log_file_handler();
1937
2233
assert(0); // Impossible
1974
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
2278
static bool sys_update_general_log_path(THD *thd, set_var * var)
2280
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2281
var, ".log", opt_log, QUERY_LOG_GENERAL);
2285
static void sys_default_general_log_path(THD *thd,
2286
enum_var_type type __attribute__((__unused__)))
2288
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2289
0, ".log", opt_log, QUERY_LOG_GENERAL);
2293
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2295
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2296
var, "-slow.log", opt_slow_log,
2301
static void sys_default_slow_log_path(THD *thd,
2302
enum_var_type type __attribute__((__unused__)))
2304
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2305
0, "-slow.log", opt_slow_log,
2310
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
1977
2313
pthread_mutex_lock(&LOCK_global_system_variables);
1978
2314
logger.lock_exclusive();
2315
logger.init_slow_log(var->save_result.ulong_value);
2316
logger.init_general_log(var->save_result.ulong_value);
1979
2317
*value= var->save_result.ulong_value;
1980
2318
logger.unlock();
1981
2319
pthread_mutex_unlock(&LOCK_global_system_variables);
1986
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
1987
enum_var_type type __attribute__((unused)))
2324
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
2325
enum_var_type type __attribute__((__unused__)))
1989
2327
pthread_mutex_lock(&LOCK_global_system_variables);
1990
2328
logger.lock_exclusive();
2329
logger.init_slow_log(LOG_FILE);
2330
logger.init_general_log(LOG_FILE);
1991
2331
*value= LOG_FILE;
1992
2332
logger.unlock();
1993
2333
pthread_mutex_unlock(&LOCK_global_system_variables);
1997
unsigned char *sys_var_log_output::value_ptr(THD *thd,
1998
enum_var_type type __attribute__((unused)),
1999
LEX_STRING *base __attribute__((unused)))
2337
uchar *sys_var_log_output::value_ptr(THD *thd,
2338
enum_var_type type __attribute__((__unused__)),
2339
LEX_STRING *base __attribute__((__unused__)))
2001
2341
char buff[256];
2002
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2342
String tmp(buff, sizeof(buff), &my_charset_latin1);
2004
2344
ulong val= *value;
2007
for (uint32_t i= 0; val; val>>= 1, i++)
2347
for (uint i= 0; val; val>>= 1, i++)
2051
2391
bool sys_var_timestamp::update(THD *thd, set_var *var)
2053
thd->set_time((time_t) var->save_result.uint64_t_value);
2393
thd->set_time((time_t) var->save_result.ulonglong_value);
2058
2398
void sys_var_timestamp::set_default(THD *thd,
2059
enum_var_type type __attribute__((unused)))
2399
enum_var_type type __attribute__((__unused__)))
2061
2401
thd->user_time=0;
2065
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2066
enum_var_type type __attribute__((unused)),
2067
LEX_STRING *base __attribute__((unused)))
2405
uchar *sys_var_timestamp::value_ptr(THD *thd,
2406
enum_var_type type __attribute__((__unused__)),
2407
LEX_STRING *base __attribute__((__unused__)))
2069
2409
thd->sys_var_tmp.long_value= (long) thd->start_time;
2070
return (unsigned char*) &thd->sys_var_tmp.long_value;
2410
return (uchar*) &thd->sys_var_tmp.long_value;
2074
2414
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2076
2416
thd->first_successful_insert_id_in_prev_stmt=
2077
var->save_result.uint64_t_value;
2417
var->save_result.ulonglong_value;
2082
unsigned char *sys_var_last_insert_id::value_ptr(THD *thd,
2083
enum_var_type type __attribute__((unused)),
2084
LEX_STRING *base __attribute__((unused)))
2422
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
2423
enum_var_type type __attribute__((__unused__)),
2424
LEX_STRING *base __attribute__((__unused__)))
2087
2427
this tmp var makes it robust againt change of type of
2088
2428
read_first_successful_insert_id_in_prev_stmt().
2090
thd->sys_var_tmp.uint64_t_value=
2430
thd->sys_var_tmp.ulonglong_value=
2091
2431
thd->read_first_successful_insert_id_in_prev_stmt();
2092
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2432
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2096
2436
bool sys_var_insert_id::update(THD *thd, set_var *var)
2098
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2438
thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
2103
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2104
enum_var_type type __attribute__((unused)),
2105
LEX_STRING *base __attribute__((unused)))
2443
uchar *sys_var_insert_id::value_ptr(THD *thd,
2444
enum_var_type type __attribute__((__unused__)),
2445
LEX_STRING *base __attribute__((__unused__)))
2107
thd->sys_var_tmp.uint64_t_value=
2447
thd->sys_var_tmp.ulonglong_value=
2108
2448
thd->auto_inc_intervals_forced.minimum();
2109
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2449
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2113
2453
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2115
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2455
thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2119
2459
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2121
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2461
thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2156
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2157
LEX_STRING *base __attribute__((unused)))
2496
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2497
LEX_STRING *base __attribute__((__unused__)))
2160
2500
We can use ptr() instead of c_ptr() here because String contaning
2161
2501
time zone name is guaranteed to be zero ended.
2163
2503
if (type == OPT_GLOBAL)
2164
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
2504
return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2219
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
2559
bool sys_var_max_user_conn::update(THD *thd __attribute__((__unused__)),
2222
2562
assert(var->type == OPT_GLOBAL);
2223
2563
pthread_mutex_lock(&LOCK_global_system_variables);
2224
max_user_connections= (uint)var->save_result.uint64_t_value;
2564
max_user_connections= (uint)var->save_result.ulonglong_value;
2225
2565
pthread_mutex_unlock(&LOCK_global_system_variables);
2230
void sys_var_max_user_conn::set_default(THD *thd __attribute__((unused)),
2231
enum_var_type type __attribute__((unused)))
2570
void sys_var_max_user_conn::set_default(THD *thd __attribute__((__unused__)),
2571
enum_var_type type __attribute__((__unused__)))
2233
2573
assert(type == OPT_GLOBAL);
2234
2574
pthread_mutex_lock(&LOCK_global_system_variables);
2240
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2241
LEX_STRING *base __attribute__((unused)))
2580
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2581
LEX_STRING *base __attribute__((__unused__)))
2243
2583
if (type != OPT_GLOBAL &&
2244
2584
thd->user_connect && thd->user_connect->user_resources.user_conn)
2245
return (unsigned char*) &(thd->user_connect->user_resources.user_conn);
2246
return (unsigned char*) &(max_user_connections);
2585
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2586
return (uchar*) &(max_user_connections);
2250
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
2590
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((__unused__)),
2253
2593
MY_LOCALE *locale_match;
2298
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2638
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2299
2639
enum_var_type type,
2300
LEX_STRING *base __attribute__((unused)))
2640
LEX_STRING *base __attribute__((__unused__)))
2302
2642
return type == OPT_GLOBAL ?
2303
(unsigned char *) global_system_variables.lc_time_names->name :
2304
(unsigned char *) thd->variables.lc_time_names->name;
2643
(uchar *) global_system_variables.lc_time_names->name :
2644
(uchar *) thd->variables.lc_time_names->name;
2320
2660
The argument to long query time is in seconds in decimal
2321
which is converted to uint64_t integer holding microseconds for storage.
2661
which is converted to ulonglong integer holding microseconds for storage.
2322
2662
This is used for handling long_query_time
2325
2665
bool sys_var_microseconds::update(THD *thd, set_var *var)
2327
2667
double num= var->value->val_real();
2328
int64_t microseconds;
2668
longlong microseconds;
2329
2669
if (num > (double) option_limits->max_value)
2330
2670
num= (double) option_limits->max_value;
2331
2671
if (num < (double) option_limits->min_value)
2332
2672
num= (double) option_limits->min_value;
2333
microseconds= (int64_t) (num * 1000000.0 + 0.5);
2673
microseconds= (longlong) (num * 1000000.0 + 0.5);
2334
2674
if (var->type == OPT_GLOBAL)
2336
2676
pthread_mutex_lock(&LOCK_global_system_variables);
2360
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2361
LEX_STRING *base __attribute__((unused)))
2700
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2701
LEX_STRING *base __attribute__((__unused__)))
2363
2703
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2364
2704
global_system_variables.*offset :
2365
2705
thd->variables.*offset) / 1000000.0;
2366
return (unsigned char*) &thd->tmp_double_value;
2706
return (uchar*) &thd->tmp_double_value;
2416
static int check_log_update(THD *thd __attribute__((unused)),
2417
set_var *var __attribute__((unused)))
2423
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2756
static int check_log_update(THD *thd __attribute__((__unused__)),
2757
set_var *var __attribute__((__unused__)))
2762
static bool set_log_update(THD *thd __attribute__((__unused__)),
2763
set_var *var __attribute__((__unused__)))
2766
The update log is not supported anymore since 5.0.
2767
See sql/mysqld.cc/, comments in function init_server_components() for an
2768
explaination of the different warnings we send below
2771
if (opt_sql_bin_update)
2773
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2774
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2775
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2778
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2779
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2780
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2781
set_option_bit(thd, var);
2786
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2426
var->save_result.uint64_t_value= var->value->val_int();
2789
var->save_result.ulonglong_value= var->value->val_int();
2430
static unsigned char *get_warning_count(THD *thd)
2793
static uchar *get_warning_count(THD *thd)
2432
2795
thd->sys_var_tmp.long_value=
2433
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2434
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2435
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2436
return (unsigned char*) &thd->sys_var_tmp.long_value;
2796
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
2797
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
2798
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
2799
return (uchar*) &thd->sys_var_tmp.long_value;
2439
static unsigned char *get_error_count(THD *thd)
2802
static uchar *get_error_count(THD *thd)
2441
2804
thd->sys_var_tmp.long_value=
2442
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2443
return (unsigned char*) &thd->sys_var_tmp.long_value;
2805
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2806
return (uchar*) &thd->sys_var_tmp.long_value;
2508
2871
Return variable name and length for hashing of variables.
2511
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length,
2512
bool first __attribute__((unused)))
2874
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2875
my_bool first __attribute__((__unused__)))
2514
2877
*length= var->name_length;
2515
return (unsigned char*) var->name;
2878
return (uchar*) var->name;
2913
3284
!(engine_name.str= (char *)res->ptr()) ||
2914
3285
!(engine_name.length= res->length()) ||
2915
3286
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
2916
!(hton= plugin_data(var->save_result.plugin, handlerton *)))
3287
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
3288
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
2918
3290
value= res ? res->c_ptr() : "NULL";
2984
3356
sys_var_thd_optimizer_switch::
2985
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
3357
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
2987
3359
char buff[STRING_BUFFER_USUAL_SIZE*8];
2988
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3360
String tmp(buff, sizeof(buff), &my_charset_latin1);
2992
for (uint32_t i= 0; val; val>>= 1, i++)
3364
for (uint i= 0; val; val>>= 1, i++)
3013
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3014
LEX_STRING *base __attribute__((unused)))
3385
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3386
LEX_STRING *base __attribute__((__unused__)))
3016
3388
LEX_STRING opts;
3017
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3389
ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3018
3390
thd->variables.*offset);
3019
3391
(void) symbolic_mode_representation(thd, val, &opts);
3020
return (unsigned char *) opts.str;
3392
return (uchar *) opts.str;
3068
3440
/* Key cache functions */
3070
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3442
static KEY_CACHE *create_key_cache(const char *name, uint length)
3072
3444
KEY_CACHE *key_cache;
3074
3446
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3075
3447
MYF(MY_ZEROFILL | MY_WME))))
3077
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
3449
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3079
free((char*) key_cache);
3451
my_free((char*) key_cache, MYF(0));