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
57
#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>
58
#include <my_getopt.h>
59
#include <thr_alarm.h>
57
extern const CHARSET_INFO *character_set_filesystem;
63
extern CHARSET_INFO *character_set_filesystem;
60
66
static DYNAMIC_ARRAY fixed_show_vars;
61
67
static HASH system_variable_hash;
63
const char *bool_type_names[]= { "OFF", "ON", NULL };
69
const char *bool_type_names[]= { "OFF", "ON", NullS };
64
70
TYPELIB bool_typelib=
66
72
array_elements(bool_type_names)-1, "", bool_type_names, NULL
69
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL };
75
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
70
76
TYPELIB delay_key_write_typelib=
72
78
array_elements(delay_key_write_type_names)-1, "",
76
82
const char *slave_exec_mode_names[]=
77
{ "STRICT", "IDEMPOTENT", NULL };
83
{ "STRICT", "IDEMPOTENT", NullS };
78
84
static const unsigned int slave_exec_mode_names_len[]=
79
85
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
80
86
TYPELIB slave_exec_mode_typelib=
90
96
static bool set_option_bit(THD *thd, set_var *var);
91
97
static bool set_option_autocommit(THD *thd, set_var *var);
92
98
static int check_log_update(THD *thd, set_var *var);
99
static bool set_log_update(THD *thd, set_var *var);
93
100
static int check_pseudo_thread_id(THD *thd, set_var *var);
101
void fix_binlog_format_after_update(THD *thd, enum_var_type type);
94
102
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
103
static int check_tx_isolation(THD *thd, set_var *var);
96
104
static void fix_tx_isolation(THD *thd, enum_var_type type);
107
115
static void fix_thd_mem_root(THD *thd, enum_var_type type);
108
116
static void fix_trans_mem_root(THD *thd, enum_var_type type);
109
117
static void fix_server_id(THD *thd, enum_var_type type);
110
static uint64_t fix_unsigned(THD *, uint64_t, const struct my_option *);
118
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
111
119
static bool get_unsigned(THD *thd, set_var *var);
112
120
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);
121
const char *name, longlong val);
122
static KEY_CACHE *create_key_cache(const char *name, uint length);
123
static uchar *get_error_count(THD *thd);
124
static uchar *get_warning_count(THD *thd);
125
static uchar *get_tmpdir(THD *thd);
126
static int sys_check_log_path(THD *thd, set_var *var);
127
static bool sys_update_general_log_path(THD *thd, set_var * var);
128
static void sys_default_general_log_path(THD *thd, enum_var_type type);
129
static bool sys_update_slow_log_path(THD *thd, set_var * var);
130
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
120
133
Variable definition list
185
198
sys_collation_server(&vars, "collation_server", &SV::collation_server,
186
199
&default_charset_info,
187
200
sys_var::SESSION_VARIABLE_IN_BINLOG);
201
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
202
&myisam_concurrent_insert);
188
203
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
189
204
&connect_timeout);
190
205
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
207
static sys_var_thd_dbug sys_dbug(&vars, "debug");
191
209
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
192
210
&delay_key_write_options,
193
211
&delay_key_write_typelib,
196
214
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
197
215
&expire_logs_days);
198
216
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
217
static sys_var_long_ptr sys_flush_time(&vars, "flush_time", &flush_time);
199
218
sys_var_str sys_init_connect(&vars, "init_connect", 0,
200
219
sys_update_init_connect,
201
220
sys_default_init_connect,0);
218
237
param_age_threshold));
219
238
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
220
239
&opt_local_infile);
240
static sys_var_bool_ptr
241
sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
242
&opt_log_queries_not_using_indexes);
243
static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
244
static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time",
245
&SV::long_query_time);
221
246
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
222
247
&SV::low_priority_updates,
223
248
fix_low_priority_updates);
240
265
&max_connect_errors);
241
266
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
242
267
&SV::max_error_count);
243
static sys_var_thd_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
268
static sys_var_thd_ulonglong sys_max_heap_table_size(&vars, "max_heap_table_size",
244
269
&SV::max_heap_table_size);
245
270
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
246
271
&SV::pseudo_thread_id,
265
295
&max_write_lock_count);
266
296
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
267
297
&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);
298
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
299
&myisam_data_pointer_size);
300
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
301
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
270
302
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
290
322
/* these two cannot be static */
291
323
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
292
324
&SV::old_alter_table);
325
sys_var_thd_bool sys_old_passwords(&vars, "old_passwords", &SV::old_passwords);
293
326
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
294
327
&SV::optimizer_prune_level);
295
328
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
296
329
&SV::optimizer_search_depth);
298
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
331
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
299
332
TYPELIB optimizer_use_mrr_typelib= {
300
333
array_elements(optimizer_use_mrr_names) - 1, "",
301
334
optimizer_use_mrr_names, NULL
340
373
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
341
374
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
342
375
&opt_slave_compressed_protocol);
376
#ifdef HAVE_REPLICATION
343
377
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
344
378
&slave_allow_batching);
345
379
static sys_var_set_slave_mode slave_exec_mode(&vars,
360
395
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
361
396
&SV::optimizer_switch);
397
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
398
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
399
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
400
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
401
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
363
403
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
364
404
&SV::table_plugin);
405
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
365
406
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
366
407
system_time_zone);
367
408
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
379
420
&tx_isolation_typelib,
380
421
fix_tx_isolation,
381
422
check_tx_isolation);
382
static sys_var_thd_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
423
static sys_var_thd_ulonglong sys_tmp_table_size(&vars, "tmp_table_size",
383
424
&SV::tmp_table_size);
384
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
425
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes",
385
427
static sys_var_const_str sys_version(&vars, "version", server_version);
386
428
static sys_var_const_str sys_version_comment(&vars, "version_comment",
387
DRIZZLE_COMPILATION_COMMENT);
429
MYSQL_COMPILATION_COMMENT);
388
430
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
390
432
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
402
444
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
403
445
&SV::time_format,
404
DRIZZLE_TIMESTAMP_TIME);
446
MYSQL_TIMESTAMP_TIME);
405
447
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
406
448
&SV::date_format,
407
DRIZZLE_TIMESTAMP_DATE);
449
MYSQL_TIMESTAMP_DATE);
408
450
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
409
451
&SV::datetime_format,
410
DRIZZLE_TIMESTAMP_DATETIME);
452
MYSQL_TIMESTAMP_DATETIME);
412
454
/* Variables that are bits in THD */
523
577
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
524
578
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)
580
static uchar *slave_get_report_port(THD *thd)
528
582
thd->sys_var_tmp.long_value= report_port;
529
return (unsigned char*) &thd->sys_var_tmp.long_value;
583
return (uchar*) &thd->sys_var_tmp.long_value;
532
586
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
536
590
/* Read only variables */
538
592
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
593
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
594
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
595
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
596
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
539
597
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
598
/* Global read-only variable describing server license */
599
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
600
/* Global variables which enable|disable logging */
601
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
603
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
604
static sys_var_log_state sys_var_log(&vars, "log", &opt_log,
606
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
608
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
609
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
610
&opt_slow_log, QUERY_LOG_SLOW);
611
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
612
sys_update_general_log_path,
613
sys_default_general_log_path,
615
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
616
sys_update_slow_log_path,
617
sys_default_slow_log_path,
619
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
620
&log_output_typelib, 0);
541
624
Additional variables (not derived from sys_var class, not accessible as
542
625
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
547
630
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
548
631
static SHOW_VAR fixed_vars[]= {
549
632
{"back_log", (char*) &back_log, SHOW_LONG},
633
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
550
634
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
551
635
{"language", language, SHOW_CHAR},
552
636
#ifdef HAVE_MLOCKALL
555
639
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
556
640
{"log_error", (char*) log_error_file, SHOW_CHAR},
641
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
642
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
557
643
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
558
644
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
559
645
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
560
646
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
561
647
{"port", (char*) &mysqld_port, SHOW_INT},
562
648
{"protocol_version", (char*) &protocol_version, SHOW_INT},
649
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
650
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
651
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
563
652
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
567
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
656
bool sys_var::check(THD *thd, set_var *var)
569
var->save_result.uint64_t_value= var->value->val_int();
658
var->save_result.ulonglong_value= var->value->val_int();
613
702
var_str->value= res;
614
703
var_str->value_length= new_length;
615
704
rw_unlock(var_mutex);
705
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
621
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
710
static bool sys_update_init_connect(THD *thd, set_var *var)
623
712
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)))
716
static void sys_default_init_connect(THD* thd, enum_var_type type)
630
718
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
634
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
722
static bool sys_update_init_slave(THD *thd, set_var *var)
637
724
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)))
728
static void sys_default_init_slave(THD* thd, enum_var_type type)
644
730
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
750
835
if (type != OPT_GLOBAL)
751
836
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)))
838
#else /* HAVE_REPLICATION */
839
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
840
enum_var_type type __attribute__((unused)))
842
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
843
enum_var_type type __attribute__((unused)))
845
static void fix_net_retry_count(THD *thd __attribute__((unused)),
846
enum_var_type type __attribute__((unused)))
848
#endif /* HAVE_REPLICATION */
851
extern void fix_delay_key_write(THD *thd, enum_var_type type)
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, set_var *var)
775
869
*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)))
873
uchar *sys_var_set::value_ptr(THD *thd, enum_var_type type,
784
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
877
String tmp(buff, sizeof(buff), &my_charset_latin1);
786
879
ulong val= *value;
789
for (uint32_t i= 0; val; val>>= 1, i++)
882
for (uint i= 0; val; val>>= 1, i++)
799
892
if ((length= tmp.length()))
801
return (unsigned char*) thd->strmake(tmp.ptr(), length);
894
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)))
897
void sys_var_set_slave_mode::set_default(THD *thd, enum_var_type type)
807
899
slave_exec_mode_options= 0;
808
900
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
833
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
925
void fix_slave_exec_mode(enum_var_type type)
927
DBUG_ENTER("fix_slave_exec_mode");
928
compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT
929
> SLAVE_EXEC_MODE_LAST_BIT - 1);
835
930
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
836
931
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"));
933
sql_print_error("Ambiguous slave modes combination."
934
" STRICT will be used");
840
935
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
842
937
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
881
void fix_binlog_format_after_update(THD *thd,
882
enum_var_type type __attribute__((unused)))
976
void fix_binlog_format_after_update(THD *thd, enum_var_type type)
884
978
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)))
982
static void fix_max_binlog_size(THD *thd, enum_var_type type)
984
DBUG_ENTER("fix_max_binlog_size");
985
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
986
max_binlog_size, max_relay_log_size));
891
987
mysql_bin_log.set_max_size(max_binlog_size);
988
#ifdef HAVE_REPLICATION
892
989
if (!max_relay_log_size)
893
990
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)))
995
static void fix_max_relay_log_size(THD *thd, enum_var_type type)
997
DBUG_ENTER("fix_max_relay_log_size");
998
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
999
max_binlog_size, max_relay_log_size));
1000
#ifdef HAVE_REPLICATION
900
1001
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
901
1002
max_relay_log_size: max_binlog_size);
905
static void fix_max_connections(THD *thd __attribute__((unused)),
906
enum_var_type type __attribute__((unused)))
1007
static void fix_max_connections(THD *thd, enum_var_type type)
908
1009
resize_thr_alarm(max_connections + 10);
938
1038
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
939
const char *name, int64_t val)
1039
const char *name, longlong val)
946
ullstr((uint64_t) val, buf);
1046
ullstr((ulonglong) val, buf);
948
1048
llstr(val, buf);
950
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1050
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
951
1051
ER_TRUNCATED_WRONG_VALUE,
952
1052
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
957
static uint64_t fix_unsigned(THD *thd, uint64_t num,
1057
static ulonglong fix_unsigned(THD *thd, ulonglong num,
958
1058
const struct my_option *option_limits)
961
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
1060
my_bool fixed= FALSE;
1061
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
963
throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
1063
throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
967
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
1067
static bool get_unsigned(THD *thd, set_var *var)
969
1069
if (var->value->unsigned_flag)
970
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
1070
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);
1073
longlong v= var->value->val_int();
1074
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
1028
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
1128
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
1030
uint64_t tmp= var->save_result.uint64_t_value;
1130
ulonglong tmp= var->save_result.ulonglong_value;
1031
1131
pthread_mutex_lock(&LOCK_global_system_variables);
1032
1132
if (option_limits)
1033
*value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
1133
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
1035
*value= (uint64_t) tmp;
1135
*value= (ulonglong) tmp;
1036
1136
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)))
1141
void sys_var_ulonglong_ptr::set_default(THD *thd, enum_var_type type)
1045
1144
pthread_mutex_lock(&LOCK_global_system_variables);
1046
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
1145
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
1047
1146
option_limits, ¬_used);
1048
1147
pthread_mutex_unlock(&LOCK_global_system_variables);
1052
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
1151
bool sys_var_bool_ptr::update(THD *thd, set_var *var)
1054
*value= (bool) var->save_result.ulong_value;
1153
*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)))
1158
void sys_var_bool_ptr::set_default(THD *thd, enum_var_type type)
1061
*value= (bool) option_limits->def_value;
1160
*value= (my_bool) option_limits->def_value;
1065
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
1164
bool sys_var_enum::update(THD *thd, set_var *var)
1067
1166
*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)))
1171
uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
1076
return (unsigned char*) enum_names->type_names[*value];
1173
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)))
1177
uchar *sys_var_enum_const::value_ptr(THD *thd, enum_var_type type,
1084
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1180
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1087
1183
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1093
1189
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1095
uint64_t tmp= var->save_result.uint64_t_value;
1191
ulonglong tmp= var->save_result.ulonglong_value;
1097
1193
/* Don't use bigger value than given with --maximum-variable-name=.. */
1098
1194
if ((ulong) tmp > max_system_variables.*offset)
1100
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1196
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
1101
1197
tmp= max_system_variables.*offset;
1104
1200
if (option_limits)
1105
1201
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1106
1202
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1107
1203
else if (tmp > ULONG_MAX)
1109
1205
tmp= ULONG_MAX;
1110
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1206
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) var->save_result.ulonglong_value);
1114
1210
if (var->type == OPT_GLOBAL)
1115
global_system_variables.*offset= (ulong) tmp;
1117
thd->variables.*offset= (ulong) tmp;
1123
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
1125
if (type == OPT_GLOBAL)
1128
/* We will not come here if option_limits is not set */
1129
global_system_variables.*offset=
1130
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1131
option_limits, ¬_used);
1134
thd->variables.*offset= global_system_variables.*offset;
1138
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
LEX_STRING *base __attribute__((unused)))
1141
if (type == OPT_GLOBAL)
1142
return (unsigned char*) &(global_system_variables.*offset);
1143
return (unsigned char*) &(thd->variables.*offset);
1211
global_system_variables.*offset= (ulong) tmp;
1213
thd->variables.*offset= (ulong) tmp;
1219
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
1221
if (type == OPT_GLOBAL)
1224
/* We will not come here if option_limits is not set */
1225
global_system_variables.*offset=
1226
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1227
option_limits, ¬_used);
1230
thd->variables.*offset= global_system_variables.*offset;
1234
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1237
if (type == OPT_GLOBAL)
1238
return (uchar*) &(global_system_variables.*offset);
1239
return (uchar*) &(thd->variables.*offset);
1147
1243
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1149
uint64_t tmp= var->save_result.uint64_t_value;
1245
ulonglong tmp= var->save_result.ulonglong_value;
1151
1247
/* Don't use bigger value than given with --maximum-variable-name=.. */
1152
1248
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)))
1283
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1190
1286
if (type == OPT_GLOBAL)
1191
return (unsigned char*) &(global_system_variables.*offset);
1192
return (unsigned char*) &(thd->variables.*offset);
1287
return (uchar*) &(global_system_variables.*offset);
1288
return (uchar*) &(thd->variables.*offset);
1195
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1291
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1197
1293
return get_unsigned(thd, var);
1200
bool sys_var_thd_uint64_t::update(THD *thd, set_var *var)
1296
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
1202
uint64_t tmp= var->save_result.uint64_t_value;
1298
ulonglong tmp= var->save_result.ulonglong_value;
1204
1300
if (tmp > max_system_variables.*offset)
1205
1301
tmp= max_system_variables.*offset;
1211
1307
/* Lock is needed to make things safe on 32 bit systems */
1212
1308
pthread_mutex_lock(&LOCK_global_system_variables);
1213
global_system_variables.*offset= (uint64_t) tmp;
1309
global_system_variables.*offset= (ulonglong) tmp;
1214
1310
pthread_mutex_unlock(&LOCK_global_system_variables);
1217
thd->variables.*offset= (uint64_t) tmp;
1313
thd->variables.*offset= (ulonglong) tmp;
1222
void sys_var_thd_uint64_t::set_default(THD *thd, enum_var_type type)
1318
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
1224
1320
if (type == OPT_GLOBAL)
1227
1323
pthread_mutex_lock(&LOCK_global_system_variables);
1228
1324
global_system_variables.*offset=
1229
getopt_ull_limit_value((uint64_t) option_limits->def_value,
1325
getopt_ull_limit_value((ulonglong) option_limits->def_value,
1230
1326
option_limits, ¬_used);
1231
1327
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)))
1334
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
1241
1337
if (type == OPT_GLOBAL)
1242
return (unsigned char*) &(global_system_variables.*offset);
1243
return (unsigned char*) &(thd->variables.*offset);
1338
return (uchar*) &(global_system_variables.*offset);
1339
return (uchar*) &(thd->variables.*offset);
1247
1343
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1249
1345
if (var->type == OPT_GLOBAL)
1250
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1346
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1252
thd->variables.*offset= (bool) var->save_result.ulong_value;
1348
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1257
1353
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1259
1355
if (type == OPT_GLOBAL)
1260
global_system_variables.*offset= (bool) option_limits->def_value;
1356
global_system_variables.*offset= (my_bool) option_limits->def_value;
1262
1358
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)))
1362
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1269
1365
if (type == OPT_GLOBAL)
1270
return (unsigned char*) &(global_system_variables.*offset);
1271
return (unsigned char*) &(thd->variables.*offset);
1366
return (uchar*) &(global_system_variables.*offset);
1367
return (uchar*) &(thd->variables.*offset);
1275
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1276
set_var *var, const TYPELIB *enum_names)
1371
bool sys_var::check_enum(THD *thd, set_var *var, const TYPELIB *enum_names)
1278
1373
char buff[STRING_BUFFER_USUAL_SIZE];
1279
1374
const char *value;
1312
bool sys_var::check_set(THD *thd __attribute__((unused)),
1313
set_var *var, TYPELIB *enum_names)
1407
bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
1316
1410
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1317
uint32_t error_len= 0;
1318
1412
String str(buff, sizeof(buff), system_charset_info), *res;
1320
1414
if (var->value->result_type() == STRING_RESULT)
1322
1416
if (!(res= var->value->val_str(&str)))
1324
my_stpcpy(buff, "NULL");
1418
strmov(buff, "NULL");
1412
1506
pthread_mutex_lock(&LOCK_global_system_variables);
1413
1507
value= *(ulong*) value_ptr(thd, var_type, base);
1414
1508
pthread_mutex_unlock(&LOCK_global_system_variables);
1415
return new Item_uint((uint64_t) value);
1509
return new Item_uint((ulonglong) value);
1417
1511
case SHOW_LONGLONG:
1420
1514
pthread_mutex_lock(&LOCK_global_system_variables);
1421
value= *(int64_t*) value_ptr(thd, var_type, base);
1515
value= *(longlong*) value_ptr(thd, var_type, base);
1422
1516
pthread_mutex_unlock(&LOCK_global_system_variables);
1423
1517
return new Item_int(value);
1437
1531
pthread_mutex_lock(&LOCK_global_system_variables);
1438
1532
value= *(ha_rows*) value_ptr(thd, var_type, base);
1439
1533
pthread_mutex_unlock(&LOCK_global_system_variables);
1440
return new Item_int((uint64_t) value);
1534
return new Item_int((ulonglong) value);
1442
1536
case SHOW_MY_BOOL:
1445
1539
pthread_mutex_lock(&LOCK_global_system_variables);
1446
value= *(bool*) value_ptr(thd, var_type, base);
1540
value= *(my_bool*) value_ptr(thd, var_type, base);
1447
1541
pthread_mutex_unlock(&LOCK_global_system_variables);
1448
1542
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)))
1605
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1514
1608
ulong tmp= ((type == OPT_GLOBAL) ?
1515
1609
global_system_variables.*offset :
1516
1610
thd->variables.*offset);
1517
return (unsigned char*) enum_names->type_names[tmp];
1611
return (uchar*) enum_names->type_names[tmp];
1520
1614
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)))
1627
uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
1538
1631
If reverse is 0 (default) return 1 if bit is set.
1539
1632
If reverse is 1, return 0 if bit is set
1541
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1634
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1542
1635
!reverse : reverse);
1543
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1636
return (uchar*) &thd->sys_var_tmp.my_bool_value;
1653
1749
const char *new_name;
1656
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1659
const CHARSET_INFO *tmp;
1752
static my_old_conv old_conv[]=
1754
{ "cp1251_koi8" , "cp1251" },
1755
{ "cp1250_latin2" , "cp1250" },
1756
{ "kam_latin2" , "keybcs2" },
1757
{ "mac_latin2" , "MacRoman" },
1758
{ "macce_latin2" , "MacCE" },
1759
{ "pc2_latin2" , "pclatin2" },
1760
{ "vga_latin2" , "pclatin1" },
1761
{ "koi8_cp1251" , "koi8r" },
1762
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
1763
{ "koi8_ukr_win1251ukr" , "koi8u" },
1767
CHARSET_INFO *get_old_charset_by_name(const char *name)
1771
for (conv= old_conv; conv->old_name; conv++)
1773
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
1774
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
1780
bool sys_var_collation::check(THD *thd, set_var *var)
1661
1784
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)))
1861
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1741
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1742
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1864
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
1865
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)))
1950
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1830
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1953
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
1954
global_system_variables.*offset : thd->variables.*offset);
1832
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1955
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)))
1973
uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
1854
1976
KEY_CACHE *key_cache= get_key_cache(base);
1855
1977
if (!key_cache)
1856
1978
key_cache= &zero_key_cache;
1857
return (unsigned char*) key_cache + offset ;
1979
return (uchar*) key_cache + offset ;
1861
1983
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
1863
uint64_t tmp= var->save_result.uint64_t_value;
1985
ulonglong tmp= var->save_result.ulonglong_value;
1864
1986
LEX_STRING *base_name= &var->base;
1865
1987
KEY_CACHE *key_cache;
2003
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2125
bool sys_var_log_state::update(THD *thd, set_var *var)
2006
2128
pthread_mutex_lock(&LOCK_global_system_variables);
2007
2129
if (!var->save_result.ulong_value)
2131
logger.deactivate_log_handler(thd, log_type);
2135
res= logger.activate_log_handler(thd, log_type);
2011
2136
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)),
2022
sys_var_str *var_str,
2023
set_var *var, const char *log_ext,
2024
bool log_state, uint32_t log_type)
2140
void sys_var_log_state::set_default(THD *thd, enum_var_type type)
2142
pthread_mutex_lock(&LOCK_global_system_variables);
2143
logger.deactivate_log_handler(thd, log_type);
2144
pthread_mutex_unlock(&LOCK_global_system_variables);
2148
static int sys_check_log_path(THD *thd, set_var *var)
2150
char path[FN_REFLEN], buff[FN_REFLEN];
2152
String str(buff, sizeof(buff), system_charset_info), *res;
2153
const char *log_file_str;
2156
if (!(res= var->value->val_str(&str)))
2159
log_file_str= res->c_ptr();
2160
bzero(&f_stat, sizeof(struct stat));
2162
path_length= unpack_filename(path, log_file_str);
2166
/* File name is empty. */
2171
if (!stat(path, &f_stat))
2174
A file system object exists. Check if argument is a file and we have
2178
if (!MY_S_ISREG(f_stat.st_mode) ||
2179
!(f_stat.st_mode & MY_S_IWRITE))
2185
/* Get dirname of the file path. */
2186
(void) dirname_part(path, log_file_str, &path_length);
2188
/* Dirname is empty if file path is relative. */
2193
Check if directory exists and we have permission to create file and
2196
if (my_access(path, (F_OK|W_OK)))
2202
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2203
res ? log_file_str : "NULL");
2208
bool update_sys_var_str_path(THD *thd, sys_var_str *var_str,
2209
set_var *var, const char *log_ext,
2210
bool log_state, uint log_type)
2212
MYSQL_QUERY_LOG *file_log;
2026
2213
char buff[FN_REFLEN];
2027
2214
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2028
2215
bool result= 0;
2029
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2216
uint str_length= (var ? var->value->str_value.length() : 0);
2031
2218
switch (log_type) {
2219
case QUERY_LOG_SLOW:
2220
file_log= logger.get_slow_log_file_handler();
2222
case QUERY_LOG_GENERAL:
2223
file_log= logger.get_log_file_handler();
2033
2226
assert(0); // Impossible
2070
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
2271
static bool sys_update_general_log_path(THD *thd, set_var * var)
2273
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2274
var, ".log", opt_log, QUERY_LOG_GENERAL);
2278
static void sys_default_general_log_path(THD *thd, enum_var_type type)
2280
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2281
0, ".log", opt_log, QUERY_LOG_GENERAL);
2285
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2287
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2288
var, "-slow.log", opt_slow_log,
2293
static void sys_default_slow_log_path(THD *thd, enum_var_type type)
2295
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2296
0, "-slow.log", opt_slow_log,
2301
bool sys_var_log_output::update(THD *thd, set_var *var)
2073
2303
pthread_mutex_lock(&LOCK_global_system_variables);
2074
2304
logger.lock_exclusive();
2305
logger.init_slow_log(var->save_result.ulong_value);
2306
logger.init_general_log(var->save_result.ulong_value);
2075
2307
*value= var->save_result.ulong_value;
2076
2308
logger.unlock();
2077
2309
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)))
2314
void sys_var_log_output::set_default(THD *thd, enum_var_type type)
2085
2316
pthread_mutex_lock(&LOCK_global_system_variables);
2086
2317
logger.lock_exclusive();
2318
logger.init_slow_log(LOG_FILE);
2319
logger.init_general_log(LOG_FILE);
2087
2320
*value= LOG_FILE;
2088
2321
logger.unlock();
2089
2322
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)))
2326
uchar *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
2097
2329
char buff[256];
2098
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2330
String tmp(buff, sizeof(buff), &my_charset_latin1);
2100
2332
ulong val= *value;
2103
for (uint32_t i= 0; val; val>>= 1, i++)
2335
for (uint i= 0; val; val>>= 1, i++)
2147
2379
bool sys_var_timestamp::update(THD *thd, set_var *var)
2149
thd->set_time((time_t) var->save_result.uint64_t_value);
2381
thd->set_time((time_t) var->save_result.ulonglong_value);
2154
void sys_var_timestamp::set_default(THD *thd,
2155
enum_var_type type __attribute__((unused)))
2386
void sys_var_timestamp::set_default(THD *thd, enum_var_type type)
2157
2388
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)))
2392
uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
2165
2395
thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
return (unsigned char*) &thd->sys_var_tmp.long_value;
2396
return (uchar*) &thd->sys_var_tmp.long_value;
2170
2400
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2172
thd->first_successful_insert_id_in_prev_stmt=
2173
var->save_result.uint64_t_value;
2402
thd->first_successful_insert_id_in_prev_stmt=
2403
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)))
2408
uchar *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
2183
this tmp var makes it robust againt change of type of
2412
this tmp var makes it robust againt change of type of
2184
2413
read_first_successful_insert_id_in_prev_stmt().
2186
thd->sys_var_tmp.uint64_t_value=
2415
thd->sys_var_tmp.ulonglong_value=
2187
2416
thd->read_first_successful_insert_id_in_prev_stmt();
2188
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2417
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2192
2421
bool sys_var_insert_id::update(THD *thd, set_var *var)
2194
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2423
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)))
2428
uchar *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
2203
thd->sys_var_tmp.uint64_t_value=
2431
thd->sys_var_tmp.ulonglong_value=
2204
2432
thd->auto_inc_intervals_forced.minimum();
2205
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2433
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2209
2437
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2211
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2439
thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2215
2443
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2217
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2445
thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2222
2450
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2224
2452
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2453
String str(buff, sizeof(buff), &my_charset_latin1);
2226
2454
String *res= var->value->val_str(&str);
2228
2456
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2252
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2253
LEX_STRING *base __attribute__((unused)))
2480
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2256
2484
We can use ptr() instead of c_ptr() here because String contaning
2257
2485
time zone name is guaranteed to be zero ended.
2259
2487
if (type == OPT_GLOBAL)
2260
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
2488
return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2308
2536
May be we should have a separate error message for this?
2310
2538
my_error(ER_GLOBAL_VARIABLE, MYF(0), name);
2315
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
2543
bool sys_var_max_user_conn::update(THD *thd, set_var *var)
2318
assert(var->type == OPT_GLOBAL);
2545
DBUG_ASSERT(var->type == OPT_GLOBAL);
2319
2546
pthread_mutex_lock(&LOCK_global_system_variables);
2320
max_user_connections= (uint)var->save_result.uint64_t_value;
2547
max_user_connections= (uint)var->save_result.ulonglong_value;
2321
2548
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)))
2553
void sys_var_max_user_conn::set_default(THD *thd, enum_var_type type)
2329
assert(type == OPT_GLOBAL);
2555
DBUG_ASSERT(type == OPT_GLOBAL);
2330
2556
pthread_mutex_lock(&LOCK_global_system_variables);
2331
2557
max_user_connections= (ulong) option_limits->def_value;
2332
2558
pthread_mutex_unlock(&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)))
2562
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2339
2565
if (type != OPT_GLOBAL &&
2340
2566
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);
2567
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2568
return (uchar*) &(max_user_connections);
2346
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
2572
bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var)
2349
2574
MY_LOCALE *locale_match;
2394
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2396
LEX_STRING *base __attribute__((unused)))
2619
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
2398
2622
return type == OPT_GLOBAL ?
2399
(unsigned char *) global_system_variables.lc_time_names->name :
2400
(unsigned char *) thd->variables.lc_time_names->name;
2623
(uchar *) global_system_variables.lc_time_names->name :
2624
(uchar *) thd->variables.lc_time_names->name;
2416
2640
The argument to long query time is in seconds in decimal
2417
which is converted to uint64_t integer holding microseconds for storage.
2641
which is converted to ulonglong integer holding microseconds for storage.
2418
2642
This is used for handling long_query_time
2421
2645
bool sys_var_microseconds::update(THD *thd, set_var *var)
2423
2647
double num= var->value->val_real();
2424
int64_t microseconds;
2648
longlong microseconds;
2425
2649
if (num > (double) option_limits->max_value)
2426
2650
num= (double) option_limits->max_value;
2427
2651
if (num < (double) option_limits->min_value)
2428
2652
num= (double) option_limits->min_value;
2429
microseconds= (int64_t) (num * 1000000.0 + 0.5);
2653
microseconds= (longlong) (num * 1000000.0 + 0.5);
2430
2654
if (var->type == OPT_GLOBAL)
2432
2656
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)))
2680
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2459
2683
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
2684
global_system_variables.*offset :
2461
2685
thd->variables.*offset) / 1000000.0;
2462
return (unsigned char*) &thd->tmp_double_value;
2686
return (uchar*) &thd->tmp_double_value;
2494
2718
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2496
2720
/* We changed to auto_commit mode */
2497
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2498
thd->transaction.all.modified_non_trans_table= false;
2721
thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
2722
thd->transaction.all.modified_non_trans_table= FALSE;
2499
2723
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2500
2724
if (ha_commit(thd))
2505
thd->transaction.all.modified_non_trans_table= false;
2729
thd->transaction.all.modified_non_trans_table= FALSE;
2506
2730
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
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)),
2522
var->save_result.uint64_t_value= var->value->val_int();
2526
static unsigned char *get_warning_count(THD *thd)
2736
static int check_log_update(THD *thd, set_var *var)
2741
static bool set_log_update(THD *thd, set_var *var)
2744
The update log is not supported anymore since 5.0.
2745
See sql/mysqld.cc/, comments in function init_server_components() for an
2746
explaination of the different warnings we send below
2749
if (opt_sql_bin_update)
2751
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2752
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2753
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2756
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2757
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2758
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2759
set_option_bit(thd, var);
2764
static int check_pseudo_thread_id(THD *thd, set_var *var)
2766
var->save_result.ulonglong_value= var->value->val_int();
2770
static uchar *get_warning_count(THD *thd)
2528
2772
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;
2773
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
2774
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
2775
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
2776
return (uchar*) &thd->sys_var_tmp.long_value;
2535
static unsigned char *get_error_count(THD *thd)
2779
static uchar *get_error_count(THD *thd)
2537
2781
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;
2782
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2783
return (uchar*) &thd->sys_var_tmp.long_value;
2604
2848
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)))
2851
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2610
2854
*length= var->name_length;
2611
return (unsigned char*) var->name;
2855
return (uchar*) var->name;
3009
3263
!(engine_name.str= (char *)res->ptr()) ||
3010
3264
!(engine_name.length= res->length()) ||
3011
3265
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
3012
!(hton= plugin_data(var->save_result.plugin, handlerton *)))
3266
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
3267
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
3014
3269
value= res ? res->c_ptr() : "NULL";
3080
3335
sys_var_thd_optimizer_switch::
3081
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
3336
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
3083
3338
char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3339
String tmp(buff, sizeof(buff), &my_charset_latin1);
3088
for (uint32_t i= 0; val; val>>= 1, i++)
3343
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)))
3364
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3112
3367
LEX_STRING opts;
3113
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3368
ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3114
3369
thd->variables.*offset);
3115
3370
(void) symbolic_mode_representation(thd, val, &opts);
3116
return (unsigned char *) opts.str;
3371
return (uchar *) opts.str;
3151
3406
void delete_elements(I_List<NAMED_LIST> *list,
3152
void (*free_element)(const char *name, unsigned char*))
3407
void (*free_element)(const char *name, uchar*))
3154
3409
NAMED_LIST *element;
3410
DBUG_ENTER("delete_elements");
3155
3411
while ((element= list->get()))
3157
3413
(*free_element)(element->name, element->data);
3158
3414
delete element;
3164
3420
/* Key cache functions */
3166
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3422
static KEY_CACHE *create_key_cache(const char *name, uint length)
3168
3424
KEY_CACHE *key_cache;
3425
DBUG_ENTER("create_key_cache");
3426
DBUG_PRINT("enter",("name: %.*s", length, name));
3170
3428
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3171
3429
MYF(MY_ZEROFILL | MY_WME))))
3173
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
3431
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3175
free((char*) key_cache);
3433
my_free((char*) key_cache, MYF(0));
3275
3534
can cause to wait on a read lock, it's required for the client application
3276
3535
to unlock everything, and acceptable for the server to wait on all locks.
3278
if ((result= close_cached_tables(thd, NULL, false, true, true)) == true)
3537
if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE)) == true)
3279
3538
goto end_with_read_lock;
3281
3540
if ((result= make_global_read_lock_block_commit(thd)) == true)
3287
3546
end_with_read_lock:
3288
3547
/* Release the lock */
3289
3548
unlock_global_read_lock(thd);
3549
DBUG_RETURN(result);
3552
bool sys_var_thd_dbug::update(THD *thd, set_var *var)
3554
if (var->type == OPT_GLOBAL)
3556
DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : "");
3560
DBUG_SET(var ? var->value->str_value.c_ptr() : "");
3567
uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
3570
if (type == OPT_GLOBAL)
3572
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
3576
DBUG_EXPLAIN(buf, sizeof(buf));
3578
return (uchar*) thd->strdup(buf);
3293
3581
/****************************************************************************