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
144
157
&SV::binlog_format);
145
158
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
146
159
&SV::bulk_insert_buff_size);
160
static sys_var_character_set_sv
161
sys_character_set_server(&vars, "character_set_server",
162
&SV::collation_server, &default_charset_info, 0,
163
sys_var::SESSION_VARIABLE_IN_BINLOG);
164
sys_var_const_str sys_charset_system(&vars, "character_set_system",
165
(char *)my_charset_utf8_general_ci.name);
166
static sys_var_character_set_database
167
sys_character_set_database(&vars, "character_set_database",
168
sys_var::SESSION_VARIABLE_IN_BINLOG);
169
static sys_var_character_set_client
170
sys_character_set_client(&vars, "character_set_client",
171
&SV::character_set_client,
172
&default_charset_info,
173
sys_var::SESSION_VARIABLE_IN_BINLOG);
174
static sys_var_character_set_sv
175
sys_character_set_connection(&vars, "character_set_connection",
176
&SV::collation_connection,
177
&default_charset_info, 0,
178
sys_var::SESSION_VARIABLE_IN_BINLOG);
179
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
180
&SV::character_set_results,
181
&default_charset_info, true);
182
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
183
&SV::character_set_filesystem,
184
&character_set_filesystem);
147
185
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
148
186
&SV::completion_type,
149
187
check_completion_type,
160
198
sys_collation_server(&vars, "collation_server", &SV::collation_server,
161
199
&default_charset_info,
162
200
sys_var::SESSION_VARIABLE_IN_BINLOG);
201
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
202
&myisam_concurrent_insert);
163
203
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
164
204
&connect_timeout);
165
205
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
207
static sys_var_thd_dbug sys_dbug(&vars, "debug");
166
209
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
167
210
&delay_key_write_options,
168
211
&delay_key_write_typelib,
171
214
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
172
215
&expire_logs_days);
173
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);
174
218
sys_var_str sys_init_connect(&vars, "init_connect", 0,
175
219
sys_update_init_connect,
176
220
sys_default_init_connect,0);
193
237
param_age_threshold));
194
238
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
195
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);
196
246
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
197
247
&SV::low_priority_updates,
198
248
fix_low_priority_updates);
215
265
&max_connect_errors);
216
266
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
217
267
&SV::max_error_count);
218
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",
219
269
&SV::max_heap_table_size);
220
270
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
221
271
&SV::pseudo_thread_id,
240
295
&max_write_lock_count);
241
296
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
242
297
&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);
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);
244
301
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
302
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
265
322
/* these two cannot be static */
266
323
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
267
324
&SV::old_alter_table);
325
sys_var_thd_bool sys_old_passwords(&vars, "old_passwords", &SV::old_passwords);
268
326
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
269
327
&SV::optimizer_prune_level);
270
328
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
271
329
&SV::optimizer_search_depth);
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
331
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
274
332
TYPELIB optimizer_use_mrr_typelib= {
275
333
array_elements(optimizer_use_mrr_names) - 1, "",
276
334
optimizer_use_mrr_names, NULL
307
367
&SV::trans_prealloc_size,
308
368
0, fix_trans_mem_root);
370
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
310
371
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
311
372
&opt_secure_file_priv);
312
373
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
313
374
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
314
375
&opt_slave_compressed_protocol);
376
#ifdef HAVE_REPLICATION
315
377
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
316
378
&slave_allow_batching);
317
379
static sys_var_set_slave_mode slave_exec_mode(&vars,
332
395
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
333
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);
335
403
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
336
404
&SV::table_plugin);
405
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
337
406
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
338
407
system_time_zone);
339
408
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
351
420
&tx_isolation_typelib,
352
421
fix_tx_isolation,
353
422
check_tx_isolation);
354
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",
355
424
&SV::tmp_table_size);
356
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",
357
427
static sys_var_const_str sys_version(&vars, "version", server_version);
358
428
static sys_var_const_str sys_version_comment(&vars, "version_comment",
359
DRIZZLE_COMPILATION_COMMENT);
429
MYSQL_COMPILATION_COMMENT);
360
430
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
362
432
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
374
444
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
375
445
&SV::time_format,
376
DRIZZLE_TIMESTAMP_TIME);
446
MYSQL_TIMESTAMP_TIME);
377
447
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
378
448
&SV::date_format,
379
DRIZZLE_TIMESTAMP_DATE);
449
MYSQL_TIMESTAMP_DATE);
380
450
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
381
451
&SV::datetime_format,
382
DRIZZLE_TIMESTAMP_DATETIME);
452
MYSQL_TIMESTAMP_DATETIME);
384
454
/* Variables that are bits in THD */
495
577
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
496
578
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)
580
static uchar *slave_get_report_port(THD *thd)
500
582
thd->sys_var_tmp.long_value= report_port;
501
return (unsigned char*) &thd->sys_var_tmp.long_value;
583
return (uchar*) &thd->sys_var_tmp.long_value;
504
586
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
508
590
/* Read only variables */
510
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);
511
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);
513
624
Additional variables (not derived from sys_var class, not accessible as
514
625
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
519
630
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
520
631
static SHOW_VAR fixed_vars[]= {
521
632
{"back_log", (char*) &back_log, SHOW_LONG},
633
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
522
634
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
523
635
{"language", language, SHOW_CHAR},
524
636
#ifdef HAVE_MLOCKALL
527
639
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
528
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},
529
643
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
530
644
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
531
645
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
532
646
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
533
647
{"port", (char*) &mysqld_port, SHOW_INT},
534
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},
535
652
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
539
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
656
bool sys_var::check(THD *thd, set_var *var)
541
var->save_result.uint64_t_value= var->value->val_int();
658
var->save_result.ulonglong_value= var->value->val_int();
585
702
var_str->value= res;
586
703
var_str->value_length= new_length;
587
704
rw_unlock(var_mutex);
705
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
593
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)
595
712
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)))
716
static void sys_default_init_connect(THD* thd, enum_var_type type)
602
718
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
606
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
722
static bool sys_update_init_slave(THD *thd, set_var *var)
609
724
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)))
728
static void sys_default_init_slave(THD* thd, enum_var_type type)
616
730
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
722
835
if (type != OPT_GLOBAL)
723
836
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)))
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)
730
853
switch ((enum_delay_key_write) delay_key_write_options) {
731
854
case DELAY_KEY_WRITE_NONE:
744
bool sys_var_set::update(THD *thd __attribute__((unused)),
867
bool sys_var_set::update(THD *thd, set_var *var)
747
869
*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)))
873
uchar *sys_var_set::value_ptr(THD *thd, enum_var_type type,
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, enum_var_type type)
779
899
slave_exec_mode_options= 0;
780
900
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
805
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);
807
930
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
808
931
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"));
933
sql_print_error("Ambiguous slave modes combination."
934
" STRICT will be used");
812
935
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
814
937
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
838
961
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
965
if in a stored function/trigger, it's too late to change mode
967
if (thd->in_sub_stmt)
969
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
842
972
return sys_var_thd_enum::is_readonly();
846
void fix_binlog_format_after_update(THD *thd,
847
enum_var_type type __attribute__((unused)))
976
void fix_binlog_format_after_update(THD *thd, enum_var_type type)
849
978
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)))
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));
856
987
mysql_bin_log.set_max_size(max_binlog_size);
988
#ifdef HAVE_REPLICATION
857
989
if (!max_relay_log_size)
858
990
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)))
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
865
1001
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
866
1002
max_relay_log_size: max_binlog_size);
870
static void fix_max_connections(THD *thd __attribute__((unused)),
871
enum_var_type type __attribute__((unused)))
1007
static void fix_max_connections(THD *thd, enum_var_type type)
873
1009
resize_thr_alarm(max_connections + 10);
903
1038
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
904
const char *name, int64_t val)
1039
const char *name, longlong val)
911
ullstr((uint64_t) val, buf);
1046
ullstr((ulonglong) val, buf);
913
1048
llstr(val, buf);
915
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1050
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
916
1051
ER_TRUNCATED_WRONG_VALUE,
917
1052
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
922
static uint64_t fix_unsigned(THD *thd, uint64_t num,
1057
static ulonglong fix_unsigned(THD *thd, ulonglong num,
923
1058
const struct my_option *option_limits)
926
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);
928
throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
1063
throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
932
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
1067
static bool get_unsigned(THD *thd, set_var *var)
934
1069
if (var->value->unsigned_flag)
935
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
1070
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);
1073
longlong v= var->value->val_int();
1074
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
958
1093
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
960
uint64_t tmp= var->save_result.uint64_t_value;
1095
ulonglong tmp= var->save_result.ulonglong_value;
961
1096
pthread_mutex_lock(guard);
962
1097
if (option_limits)
963
1098
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
966
if (tmp > UINT32_MAX)
1101
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1102
/* Avoid overflows on 32 bit systems */
1103
if (tmp > ULONG_MAX)
969
throw_bounds_warning(thd, true, true, name,
970
(int64_t) var->save_result.uint64_t_value);
1106
throw_bounds_warning(thd, TRUE, TRUE, name,
1107
(longlong) var->save_result.ulonglong_value);
972
1110
*value= (ulong) tmp;
990
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
1128
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
992
uint64_t tmp= var->save_result.uint64_t_value;
1130
ulonglong tmp= var->save_result.ulonglong_value;
993
1131
pthread_mutex_lock(&LOCK_global_system_variables);
994
1132
if (option_limits)
995
*value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
1133
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
997
*value= (uint64_t) tmp;
1135
*value= (ulonglong) tmp;
998
1136
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)))
1141
void sys_var_ulonglong_ptr::set_default(THD *thd, enum_var_type type)
1007
1144
pthread_mutex_lock(&LOCK_global_system_variables);
1008
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
1145
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
1009
1146
option_limits, ¬_used);
1010
1147
pthread_mutex_unlock(&LOCK_global_system_variables);
1014
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)
1016
*value= (bool) var->save_result.ulong_value;
1153
*value= (my_bool) var->save_result.ulong_value;
1021
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)
1023
*value= (bool) option_limits->def_value;
1160
*value= (my_bool) option_limits->def_value;
1027
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
1164
bool sys_var_enum::update(THD *thd, set_var *var)
1029
1166
*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)))
1171
uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
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, enum_var_type type,
1046
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1180
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1049
1183
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1055
1189
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1057
uint64_t tmp= var->save_result.uint64_t_value;
1191
ulonglong tmp= var->save_result.ulonglong_value;
1059
1193
/* Don't use bigger value than given with --maximum-variable-name=.. */
1060
1194
if ((ulong) tmp > max_system_variables.*offset)
1062
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1196
throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
1063
1197
tmp= max_system_variables.*offset;
1066
1200
if (option_limits)
1067
1201
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1068
else if (tmp > UINT32_MAX)
1202
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1203
else if (tmp > ULONG_MAX)
1071
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);
1074
1210
if (var->type == OPT_GLOBAL)
1075
global_system_variables.*offset= (ulong) tmp;
1077
thd->variables.*offset= (ulong) tmp;
1083
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
1085
if (type == OPT_GLOBAL)
1088
/* We will not come here if option_limits is not set */
1089
global_system_variables.*offset=
1090
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1091
option_limits, ¬_used);
1094
thd->variables.*offset= global_system_variables.*offset;
1098
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1099
LEX_STRING *base __attribute__((unused)))
1101
if (type == OPT_GLOBAL)
1102
return (unsigned char*) &(global_system_variables.*offset);
1103
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);
1107
1243
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1109
uint64_t tmp= var->save_result.uint64_t_value;
1245
ulonglong tmp= var->save_result.ulonglong_value;
1111
1247
/* Don't use bigger value than given with --maximum-variable-name=.. */
1112
1248
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)))
1283
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1150
1286
if (type == OPT_GLOBAL)
1151
return (unsigned char*) &(global_system_variables.*offset);
1152
return (unsigned char*) &(thd->variables.*offset);
1287
return (uchar*) &(global_system_variables.*offset);
1288
return (uchar*) &(thd->variables.*offset);
1155
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1291
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1157
1293
return get_unsigned(thd, var);
1160
bool sys_var_thd_uint64_t::update(THD *thd, set_var *var)
1296
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
1162
uint64_t tmp= var->save_result.uint64_t_value;
1298
ulonglong tmp= var->save_result.ulonglong_value;
1164
1300
if (tmp > max_system_variables.*offset)
1165
1301
tmp= max_system_variables.*offset;
1171
1307
/* Lock is needed to make things safe on 32 bit systems */
1172
1308
pthread_mutex_lock(&LOCK_global_system_variables);
1173
global_system_variables.*offset= (uint64_t) tmp;
1309
global_system_variables.*offset= (ulonglong) tmp;
1174
1310
pthread_mutex_unlock(&LOCK_global_system_variables);
1177
thd->variables.*offset= (uint64_t) tmp;
1313
thd->variables.*offset= (ulonglong) tmp;
1182
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)
1184
1320
if (type == OPT_GLOBAL)
1187
1323
pthread_mutex_lock(&LOCK_global_system_variables);
1188
1324
global_system_variables.*offset=
1189
getopt_ull_limit_value((uint64_t) option_limits->def_value,
1325
getopt_ull_limit_value((ulonglong) option_limits->def_value,
1190
1326
option_limits, ¬_used);
1191
1327
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)))
1334
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
1201
1337
if (type == OPT_GLOBAL)
1202
return (unsigned char*) &(global_system_variables.*offset);
1203
return (unsigned char*) &(thd->variables.*offset);
1338
return (uchar*) &(global_system_variables.*offset);
1339
return (uchar*) &(thd->variables.*offset);
1207
1343
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1209
1345
if (var->type == OPT_GLOBAL)
1210
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1346
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1212
thd->variables.*offset= (bool) var->save_result.ulong_value;
1348
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1217
1353
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1219
1355
if (type == OPT_GLOBAL)
1220
global_system_variables.*offset= (bool) option_limits->def_value;
1356
global_system_variables.*offset= (my_bool) option_limits->def_value;
1222
1358
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)))
1362
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1229
1365
if (type == OPT_GLOBAL)
1230
return (unsigned char*) &(global_system_variables.*offset);
1231
return (unsigned char*) &(thd->variables.*offset);
1366
return (uchar*) &(global_system_variables.*offset);
1367
return (uchar*) &(thd->variables.*offset);
1235
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1236
set_var *var, const TYPELIB *enum_names)
1371
bool sys_var::check_enum(THD *thd, set_var *var, const TYPELIB *enum_names)
1238
1373
char buff[STRING_BUFFER_USUAL_SIZE];
1239
1374
const char *value;
1272
bool sys_var::check_set(THD *thd __attribute__((unused)),
1273
set_var *var, TYPELIB *enum_names)
1407
bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
1276
1410
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1277
uint32_t error_len= 0;
1278
1412
String str(buff, sizeof(buff), system_charset_info), *res;
1280
1414
if (var->value->result_type() == STRING_RESULT)
1282
1416
if (!(res= var->value->val_str(&str)))
1284
my_stpcpy(buff, "NULL");
1418
strmov(buff, "NULL");
1372
1506
pthread_mutex_lock(&LOCK_global_system_variables);
1373
1507
value= *(ulong*) value_ptr(thd, var_type, base);
1374
1508
pthread_mutex_unlock(&LOCK_global_system_variables);
1375
return new Item_uint((uint64_t) value);
1509
return new Item_uint((ulonglong) value);
1377
1511
case SHOW_LONGLONG:
1380
1514
pthread_mutex_lock(&LOCK_global_system_variables);
1381
value= *(int64_t*) value_ptr(thd, var_type, base);
1515
value= *(longlong*) value_ptr(thd, var_type, base);
1382
1516
pthread_mutex_unlock(&LOCK_global_system_variables);
1383
1517
return new Item_int(value);
1397
1531
pthread_mutex_lock(&LOCK_global_system_variables);
1398
1532
value= *(ha_rows*) value_ptr(thd, var_type, base);
1399
1533
pthread_mutex_unlock(&LOCK_global_system_variables);
1400
return new Item_int((uint64_t) value);
1534
return new Item_int((ulonglong) value);
1402
1536
case SHOW_MY_BOOL:
1405
1539
pthread_mutex_lock(&LOCK_global_system_variables);
1406
value= *(bool*) value_ptr(thd, var_type, base);
1540
value= *(my_bool*) value_ptr(thd, var_type, base);
1407
1541
pthread_mutex_unlock(&LOCK_global_system_variables);
1408
1542
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)))
1605
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1474
1608
ulong tmp= ((type == OPT_GLOBAL) ?
1475
1609
global_system_variables.*offset :
1476
1610
thd->variables.*offset);
1477
return (unsigned char*) enum_names->type_names[tmp];
1611
return (uchar*) enum_names->type_names[tmp];
1480
1614
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)))
1627
uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
1498
1631
If reverse is 0 (default) return 1 if bit is set.
1499
1632
If reverse is 1, return 0 if bit is set
1501
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1634
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1502
1635
!reverse : reverse);
1503
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1636
return (uchar*) &thd->sys_var_tmp.my_bool_value;
1613
1749
const char *new_name;
1616
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1619
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)
1621
1784
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;
1861
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1864
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
1865
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1869
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1871
if (type == OPT_GLOBAL)
1872
global_system_variables.*offset= *global_default;
1875
thd->variables.*offset= global_system_variables.*offset;
1876
thd->update_charset();
1879
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1881
if (type == OPT_GLOBAL)
1882
return &(global_system_variables.*offset);
1884
return &(thd->variables.*offset);
1888
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1890
if (sys_var_character_set_sv::check(thd, var))
1892
/* Currently, UCS-2 cannot be used as a client character set */
1893
if (var->save_result.charset->mbminlen > 1)
1895
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1896
var->save_result.charset->csname);
1903
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1906
if (type == OPT_GLOBAL)
1907
return &global_system_variables.collation_database;
1909
return &thd->variables.collation_database;
1913
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1915
if (type == OPT_GLOBAL)
1916
global_system_variables.collation_database= default_charset_info;
1919
thd->variables.collation_database= thd->db_charset;
1920
thd->update_charset();
1731
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1732
LEX_STRING *base __attribute__((unused)))
1950
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1734
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1953
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1735
1954
global_system_variables.*offset : thd->variables.*offset);
1736
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1955
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)))
1973
uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
1758
1976
KEY_CACHE *key_cache= get_key_cache(base);
1759
1977
if (!key_cache)
1760
1978
key_cache= &zero_key_cache;
1761
return (unsigned char*) key_cache + offset ;
1979
return (uchar*) key_cache + offset ;
1765
1983
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
1767
uint64_t tmp= var->save_result.uint64_t_value;
1985
ulonglong tmp= var->save_result.ulonglong_value;
1768
1986
LEX_STRING *base_name= &var->base;
1769
1987
KEY_CACHE *key_cache;
1907
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)
1910
2128
pthread_mutex_lock(&LOCK_global_system_variables);
1911
2129
if (!var->save_result.ulong_value)
2131
logger.deactivate_log_handler(thd, log_type);
2135
res= logger.activate_log_handler(thd, log_type);
1915
2136
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)),
1926
sys_var_str *var_str,
1927
set_var *var, const char *log_ext,
1928
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;
1930
2213
char buff[FN_REFLEN];
1931
2214
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
1932
2215
bool result= 0;
1933
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2216
uint str_length= (var ? var->value->str_value.length() : 0);
1935
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();
1937
2226
assert(0); // Impossible
1974
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)
1977
2303
pthread_mutex_lock(&LOCK_global_system_variables);
1978
2304
logger.lock_exclusive();
2305
logger.init_slow_log(var->save_result.ulong_value);
2306
logger.init_general_log(var->save_result.ulong_value);
1979
2307
*value= var->save_result.ulong_value;
1980
2308
logger.unlock();
1981
2309
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)))
2314
void sys_var_log_output::set_default(THD *thd, enum_var_type type)
1989
2316
pthread_mutex_lock(&LOCK_global_system_variables);
1990
2317
logger.lock_exclusive();
2318
logger.init_slow_log(LOG_FILE);
2319
logger.init_general_log(LOG_FILE);
1991
2320
*value= LOG_FILE;
1992
2321
logger.unlock();
1993
2322
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)))
2326
uchar *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
2001
2329
char buff[256];
2002
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2330
String tmp(buff, sizeof(buff), &my_charset_latin1);
2004
2332
ulong val= *value;
2007
for (uint32_t i= 0; val; val>>= 1, i++)
2335
for (uint i= 0; val; val>>= 1, i++)
2051
2379
bool sys_var_timestamp::update(THD *thd, set_var *var)
2053
thd->set_time((time_t) var->save_result.uint64_t_value);
2381
thd->set_time((time_t) var->save_result.ulonglong_value);
2058
void sys_var_timestamp::set_default(THD *thd,
2059
enum_var_type type __attribute__((unused)))
2386
void sys_var_timestamp::set_default(THD *thd, enum_var_type type)
2061
2388
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)))
2392
uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
2069
2395
thd->sys_var_tmp.long_value= (long) thd->start_time;
2070
return (unsigned char*) &thd->sys_var_tmp.long_value;
2396
return (uchar*) &thd->sys_var_tmp.long_value;
2074
2400
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2076
thd->first_successful_insert_id_in_prev_stmt=
2077
var->save_result.uint64_t_value;
2402
thd->first_successful_insert_id_in_prev_stmt=
2403
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)))
2408
uchar *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
2087
this tmp var makes it robust againt change of type of
2412
this tmp var makes it robust againt change of type of
2088
2413
read_first_successful_insert_id_in_prev_stmt().
2090
thd->sys_var_tmp.uint64_t_value=
2415
thd->sys_var_tmp.ulonglong_value=
2091
2416
thd->read_first_successful_insert_id_in_prev_stmt();
2092
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2417
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2096
2421
bool sys_var_insert_id::update(THD *thd, set_var *var)
2098
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2423
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)))
2428
uchar *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
2107
thd->sys_var_tmp.uint64_t_value=
2431
thd->sys_var_tmp.ulonglong_value=
2108
2432
thd->auto_inc_intervals_forced.minimum();
2109
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2433
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2113
2437
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2115
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2439
thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2119
2443
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2121
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2445
thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2126
2450
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2128
2452
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2129
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2453
String str(buff, sizeof(buff), &my_charset_latin1);
2130
2454
String *res= var->value->val_str(&str);
2132
2456
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2156
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2157
LEX_STRING *base __attribute__((unused)))
2480
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2160
2484
We can use ptr() instead of c_ptr() here because String contaning
2161
2485
time zone name is guaranteed to be zero ended.
2163
2487
if (type == OPT_GLOBAL)
2164
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
2488
return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2212
2536
May be we should have a separate error message for this?
2214
2538
my_error(ER_GLOBAL_VARIABLE, MYF(0), name);
2219
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
2543
bool sys_var_max_user_conn::update(THD *thd, set_var *var)
2222
assert(var->type == OPT_GLOBAL);
2545
DBUG_ASSERT(var->type == OPT_GLOBAL);
2223
2546
pthread_mutex_lock(&LOCK_global_system_variables);
2224
max_user_connections= (uint)var->save_result.uint64_t_value;
2547
max_user_connections= (uint)var->save_result.ulonglong_value;
2225
2548
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)))
2553
void sys_var_max_user_conn::set_default(THD *thd, enum_var_type type)
2233
assert(type == OPT_GLOBAL);
2555
DBUG_ASSERT(type == OPT_GLOBAL);
2234
2556
pthread_mutex_lock(&LOCK_global_system_variables);
2235
2557
max_user_connections= (ulong) option_limits->def_value;
2236
2558
pthread_mutex_unlock(&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)))
2562
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2243
2565
if (type != OPT_GLOBAL &&
2244
2566
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);
2567
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2568
return (uchar*) &(max_user_connections);
2250
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)
2253
2574
MY_LOCALE *locale_match;
2298
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2300
LEX_STRING *base __attribute__((unused)))
2619
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
2302
2622
return type == OPT_GLOBAL ?
2303
(unsigned char *) global_system_variables.lc_time_names->name :
2304
(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;
2320
2640
The argument to long query time is in seconds in decimal
2321
which is converted to uint64_t integer holding microseconds for storage.
2641
which is converted to ulonglong integer holding microseconds for storage.
2322
2642
This is used for handling long_query_time
2325
2645
bool sys_var_microseconds::update(THD *thd, set_var *var)
2327
2647
double num= var->value->val_real();
2328
int64_t microseconds;
2648
longlong microseconds;
2329
2649
if (num > (double) option_limits->max_value)
2330
2650
num= (double) option_limits->max_value;
2331
2651
if (num < (double) option_limits->min_value)
2332
2652
num= (double) option_limits->min_value;
2333
microseconds= (int64_t) (num * 1000000.0 + 0.5);
2653
microseconds= (longlong) (num * 1000000.0 + 0.5);
2334
2654
if (var->type == OPT_GLOBAL)
2336
2656
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)))
2680
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2363
2683
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2364
2684
global_system_variables.*offset :
2365
2685
thd->variables.*offset) / 1000000.0;
2366
return (unsigned char*) &thd->tmp_double_value;
2686
return (uchar*) &thd->tmp_double_value;
2398
2718
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2400
2720
/* We changed to auto_commit mode */
2401
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2402
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;
2403
2723
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2404
2724
if (ha_commit(thd))
2409
thd->transaction.all.modified_non_trans_table= false;
2729
thd->transaction.all.modified_non_trans_table= FALSE;
2410
2730
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
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)),
2426
var->save_result.uint64_t_value= var->value->val_int();
2430
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)
2432
2772
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;
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;
2439
static unsigned char *get_error_count(THD *thd)
2779
static uchar *get_error_count(THD *thd)
2441
2781
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;
2782
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2783
return (uchar*) &thd->sys_var_tmp.long_value;
2508
2848
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)))
2851
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2514
2854
*length= var->name_length;
2515
return (unsigned char*) var->name;
2855
return (uchar*) var->name;
2913
3263
!(engine_name.str= (char *)res->ptr()) ||
2914
3264
!(engine_name.length= res->length()) ||
2915
3265
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
2916
!(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)
2918
3269
value= res ? res->c_ptr() : "NULL";
2984
3335
sys_var_thd_optimizer_switch::
2985
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
3336
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
2987
3338
char buff[STRING_BUFFER_USUAL_SIZE*8];
2988
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3339
String tmp(buff, sizeof(buff), &my_charset_latin1);
2992
for (uint32_t i= 0; val; val>>= 1, i++)
3343
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)))
3364
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3016
3367
LEX_STRING opts;
3017
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3368
ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3018
3369
thd->variables.*offset);
3019
3370
(void) symbolic_mode_representation(thd, val, &opts);
3020
return (unsigned char *) opts.str;
3371
return (uchar *) opts.str;
3055
3406
void delete_elements(I_List<NAMED_LIST> *list,
3056
void (*free_element)(const char *name, unsigned char*))
3407
void (*free_element)(const char *name, uchar*))
3058
3409
NAMED_LIST *element;
3410
DBUG_ENTER("delete_elements");
3059
3411
while ((element= list->get()))
3061
3413
(*free_element)(element->name, element->data);
3062
3414
delete element;
3068
3420
/* Key cache functions */
3070
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3422
static KEY_CACHE *create_key_cache(const char *name, uint length)
3072
3424
KEY_CACHE *key_cache;
3425
DBUG_ENTER("create_key_cache");
3426
DBUG_PRINT("enter",("name: %.*s", length, name));
3074
3428
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3075
3429
MYF(MY_ZEROFILL | MY_WME))))
3077
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
3431
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3079
free((char*) key_cache);
3433
my_free((char*) key_cache, MYF(0));
3179
3534
can cause to wait on a read lock, it's required for the client application
3180
3535
to unlock everything, and acceptable for the server to wait on all locks.
3182
if ((result= close_cached_tables(thd, NULL, false, true, true)) == true)
3537
if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE)) == true)
3183
3538
goto end_with_read_lock;
3185
3540
if ((result= make_global_read_lock_block_commit(thd)) == true)
3191
3546
end_with_read_lock:
3192
3547
/* Release the lock */
3193
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);
3197
3581
/****************************************************************************