46
46
them you must first assign a value to them (in specific ::check() for
49
#include <drizzled/server_includes.h>
50
#ifdef USE_PRAGMA_IMPLEMENTATION
51
#pragma implementation // gcc: Class implementation
54
#include "mysql_priv.h"
50
56
#include "rpl_mi.h"
51
#include <mysys/my_getopt.h>
52
#include <mysys/thr_alarm.h>
53
#include <storage/myisam/myisam.h>
54
#include <drizzled/drizzled_error_messages.h>
55
#include <libdrizzle/gettext.h>
57
#include <my_getopt.h>
58
#include <thr_alarm.h>
57
extern const CHARSET_INFO *character_set_filesystem;
62
extern CHARSET_INFO *character_set_filesystem;
60
65
static DYNAMIC_ARRAY fixed_show_vars;
61
66
static HASH system_variable_hash;
63
const char *bool_type_names[]= { "OFF", "ON", NULL };
68
const char *bool_type_names[]= { "OFF", "ON", NullS };
64
69
TYPELIB bool_typelib=
66
71
array_elements(bool_type_names)-1, "", bool_type_names, NULL
69
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL };
74
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
70
75
TYPELIB delay_key_write_typelib=
72
77
array_elements(delay_key_write_type_names)-1, "",
76
81
const char *slave_exec_mode_names[]=
77
{ "STRICT", "IDEMPOTENT", NULL };
82
{ "STRICT", "IDEMPOTENT", NullS };
78
83
static const unsigned int slave_exec_mode_names_len[]=
79
84
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
80
85
TYPELIB slave_exec_mode_typelib=
90
95
static bool set_option_bit(THD *thd, set_var *var);
91
96
static bool set_option_autocommit(THD *thd, set_var *var);
92
97
static int check_log_update(THD *thd, set_var *var);
98
static bool set_log_update(THD *thd, set_var *var);
93
99
static int check_pseudo_thread_id(THD *thd, set_var *var);
94
100
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
101
static int check_tx_isolation(THD *thd, set_var *var);
111
117
static bool get_unsigned(THD *thd, set_var *var);
112
118
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
113
119
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);
120
static KEY_CACHE *create_key_cache(const char *name, uint length);
121
static uchar *get_error_count(THD *thd);
122
static uchar *get_warning_count(THD *thd);
123
static uchar *get_tmpdir(THD *thd);
124
static int sys_check_log_path(THD *thd, set_var *var);
125
static bool sys_update_general_log_path(THD *thd, set_var * var);
126
static void sys_default_general_log_path(THD *thd, enum_var_type type);
127
static bool sys_update_slow_log_path(THD *thd, set_var * var);
128
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
120
131
Variable definition list
144
155
&SV::binlog_format);
145
156
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
146
157
&SV::bulk_insert_buff_size);
158
static sys_var_character_set_sv
159
sys_character_set_server(&vars, "character_set_server",
160
&SV::collation_server, &default_charset_info, 0,
161
sys_var::SESSION_VARIABLE_IN_BINLOG);
162
sys_var_const_str sys_charset_system(&vars, "character_set_system",
163
(char *)my_charset_utf8_general_ci.name);
164
static sys_var_character_set_database
165
sys_character_set_database(&vars, "character_set_database",
166
sys_var::SESSION_VARIABLE_IN_BINLOG);
167
static sys_var_character_set_client
168
sys_character_set_client(&vars, "character_set_client",
169
&SV::character_set_client,
170
&default_charset_info,
171
sys_var::SESSION_VARIABLE_IN_BINLOG);
172
static sys_var_character_set_sv
173
sys_character_set_connection(&vars, "character_set_connection",
174
&SV::collation_connection,
175
&default_charset_info, 0,
176
sys_var::SESSION_VARIABLE_IN_BINLOG);
177
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
178
&SV::character_set_results,
179
&default_charset_info, true);
180
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
181
&SV::character_set_filesystem,
182
&character_set_filesystem);
147
183
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
148
184
&SV::completion_type,
149
185
check_completion_type,
160
196
sys_collation_server(&vars, "collation_server", &SV::collation_server,
161
197
&default_charset_info,
162
198
sys_var::SESSION_VARIABLE_IN_BINLOG);
199
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
200
&myisam_concurrent_insert);
163
201
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
164
202
&connect_timeout);
165
203
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
193
231
param_age_threshold));
194
232
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
195
233
&opt_local_infile);
234
static sys_var_bool_ptr
235
sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
236
&opt_log_queries_not_using_indexes);
237
static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
238
static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time",
239
&SV::long_query_time);
196
240
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
197
241
&SV::low_priority_updates,
198
242
fix_low_priority_updates);
240
289
&max_write_lock_count);
241
290
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
242
291
&SV::min_examined_row_limit);
292
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
293
&myisam_data_pointer_size);
243
294
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);
244
295
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
296
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
270
321
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
271
322
&SV::optimizer_search_depth);
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
324
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
274
325
TYPELIB optimizer_use_mrr_typelib= {
275
326
array_elements(optimizer_use_mrr_names) - 1, "",
276
327
optimizer_use_mrr_names, NULL
307
360
&SV::trans_prealloc_size,
308
361
0, fix_trans_mem_root);
363
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
310
364
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
311
365
&opt_secure_file_priv);
312
366
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
313
367
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
314
368
&opt_slave_compressed_protocol);
369
#ifdef HAVE_REPLICATION
315
370
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
316
371
&slave_allow_batching);
317
372
static sys_var_set_slave_mode slave_exec_mode(&vars,
332
388
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
333
389
&SV::optimizer_switch);
390
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
391
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
392
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
393
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
394
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
335
396
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
336
397
&SV::table_plugin);
398
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
337
399
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
338
400
system_time_zone);
339
401
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
356
418
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
357
419
static sys_var_const_str sys_version(&vars, "version", server_version);
358
420
static sys_var_const_str sys_version_comment(&vars, "version_comment",
359
DRIZZLE_COMPILATION_COMMENT);
421
MYSQL_COMPILATION_COMMENT);
360
422
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
362
424
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
374
436
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
375
437
&SV::time_format,
376
DRIZZLE_TIMESTAMP_TIME);
438
MYSQL_TIMESTAMP_TIME);
377
439
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
378
440
&SV::date_format,
379
DRIZZLE_TIMESTAMP_DATE);
441
MYSQL_TIMESTAMP_DATE);
380
442
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
381
443
&SV::datetime_format,
382
DRIZZLE_TIMESTAMP_DATETIME);
444
MYSQL_TIMESTAMP_DATETIME);
384
446
/* Variables that are bits in THD */
495
569
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
496
570
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)
572
static uchar *slave_get_report_port(THD *thd)
500
574
thd->sys_var_tmp.long_value= report_port;
501
return (unsigned char*) &thd->sys_var_tmp.long_value;
575
return (uchar*) &thd->sys_var_tmp.long_value;
504
578
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
508
582
/* Read only variables */
510
584
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
585
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
586
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
587
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
588
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
511
589
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
590
/* Global read-only variable describing server license */
591
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
592
/* Global variables which enable|disable logging */
593
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
595
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
596
static sys_var_log_state sys_var_log(&vars, "log", &opt_log, QUERY_LOG_GENERAL);
597
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
599
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
600
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
601
&opt_slow_log, QUERY_LOG_SLOW);
602
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
603
sys_update_general_log_path,
604
sys_default_general_log_path,
606
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
607
sys_update_slow_log_path,
608
sys_default_slow_log_path,
610
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
611
&log_output_typelib, 0);
513
615
Additional variables (not derived from sys_var class, not accessible as
514
616
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
519
621
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
520
622
static SHOW_VAR fixed_vars[]= {
521
623
{"back_log", (char*) &back_log, SHOW_LONG},
624
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
522
625
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
523
626
{"language", language, SHOW_CHAR},
524
627
#ifdef HAVE_MLOCKALL
527
630
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
528
631
{"log_error", (char*) log_error_file, SHOW_CHAR},
632
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
633
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
529
634
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
530
635
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
531
636
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
532
637
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
533
638
{"port", (char*) &mysqld_port, SHOW_INT},
534
639
{"protocol_version", (char*) &protocol_version, SHOW_INT},
640
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
641
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
535
642
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
539
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
646
bool sys_var::check(THD *thd __attribute__((__unused__)), set_var *var)
541
648
var->save_result.uint64_t_value= var->value->val_int();
585
692
var_str->value= res;
586
693
var_str->value_length= new_length;
587
694
rw_unlock(var_mutex);
695
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
593
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
700
static bool sys_update_init_connect(THD *thd __attribute__((__unused__)), set_var *var)
595
702
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)))
706
static void sys_default_init_connect(THD* thd __attribute__((__unused__)),
707
enum_var_type type __attribute__((__unused__)))
602
709
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
606
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
713
static bool sys_update_init_slave(THD *thd __attribute__((__unused__)),
609
716
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)))
720
static void sys_default_init_slave(THD* thd __attribute__((__unused__)),
721
enum_var_type type __attribute__((__unused__)))
616
723
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
722
830
if (type != OPT_GLOBAL)
723
831
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)))
833
#else /* HAVE_REPLICATION */
834
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
835
enum_var_type type __attribute__((unused)))
837
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
838
enum_var_type type __attribute__((unused)))
840
static void fix_net_retry_count(THD *thd __attribute__((unused)),
841
enum_var_type type __attribute__((unused)))
843
#endif /* HAVE_REPLICATION */
846
extern void fix_delay_key_write(THD *thd __attribute__((__unused__)),
847
enum_var_type type __attribute__((__unused__)))
730
849
switch ((enum_delay_key_write) delay_key_write_options) {
731
850
case DELAY_KEY_WRITE_NONE:
744
bool sys_var_set::update(THD *thd __attribute__((unused)),
863
bool sys_var_set::update(THD *thd __attribute__((__unused__)),
747
866
*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)))
870
uchar *sys_var_set::value_ptr(THD *thd,
871
enum_var_type type __attribute__((__unused__)),
872
LEX_STRING *base __attribute__((__unused__)))
756
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
875
String tmp(buff, sizeof(buff), &my_charset_latin1);
758
877
ulong val= *value;
761
for (uint32_t i= 0; val; val>>= 1, i++)
880
for (uint i= 0; val; val>>= 1, i++)
771
890
if ((length= tmp.length()))
773
return (unsigned char*) thd->strmake(tmp.ptr(), length);
892
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)))
895
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((__unused__)),
896
enum_var_type type __attribute__((__unused__)))
779
898
slave_exec_mode_options= 0;
780
899
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
805
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
924
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
807
926
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
808
927
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"));
929
sql_print_error("Ambiguous slave modes combination."
930
" STRICT will be used");
812
931
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
814
933
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
838
957
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
961
if in a stored function/trigger, it's too late to change mode
963
if (thd->in_sub_stmt)
965
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
842
968
return sys_var_thd_enum::is_readonly();
846
972
void fix_binlog_format_after_update(THD *thd,
847
enum_var_type type __attribute__((unused)))
973
enum_var_type type __attribute__((__unused__)))
849
975
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)))
979
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
980
enum_var_type type __attribute__((__unused__)))
856
982
mysql_bin_log.set_max_size(max_binlog_size);
983
#ifdef HAVE_REPLICATION
857
984
if (!max_relay_log_size)
858
985
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)))
990
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
991
enum_var_type type __attribute__((__unused__)))
993
#ifdef HAVE_REPLICATION
865
994
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
866
995
max_relay_log_size: max_binlog_size);
870
static void fix_max_connections(THD *thd __attribute__((unused)),
871
enum_var_type type __attribute__((unused)))
1000
static void fix_max_connections(THD *thd __attribute__((__unused__)),
1001
enum_var_type type __attribute__((__unused__)))
873
1003
resize_thr_alarm(max_connections + 10);
1014
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
1147
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1016
1149
*value= (bool) var->save_result.ulong_value;
1021
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
1154
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1023
1156
*value= (bool) option_limits->def_value;
1027
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
1160
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1029
1162
*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)))
1167
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
1168
enum_var_type type __attribute__((__unused__)),
1169
LEX_STRING *base __attribute__((__unused__)))
1038
return (unsigned char*) enum_names->type_names[*value];
1171
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)))
1175
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
1176
enum_var_type type __attribute__((__unused__)),
1177
LEX_STRING *base __attribute__((__unused__)))
1046
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1179
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1049
1182
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1066
1199
if (option_limits)
1067
1200
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1068
else if (tmp > UINT32_MAX)
1201
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1202
else if (tmp > ULONG_MAX)
1071
1205
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1074
1209
if (var->type == OPT_GLOBAL)
1075
1210
global_system_variables.*offset= (ulong) tmp;
1098
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1099
LEX_STRING *base __attribute__((unused)))
1233
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1234
LEX_STRING *base __attribute__((__unused__)))
1101
1236
if (type == OPT_GLOBAL)
1102
return (unsigned char*) &(global_system_variables.*offset);
1103
return (unsigned char*) &(thd->variables.*offset);
1237
return (uchar*) &(global_system_variables.*offset);
1238
return (uchar*) &(thd->variables.*offset);
1147
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1148
LEX_STRING *base __attribute__((unused)))
1282
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1283
LEX_STRING *base __attribute__((__unused__)))
1150
1285
if (type == OPT_GLOBAL)
1151
return (unsigned char*) &(global_system_variables.*offset);
1152
return (unsigned char*) &(thd->variables.*offset);
1286
return (uchar*) &(global_system_variables.*offset);
1287
return (uchar*) &(thd->variables.*offset);
1155
1290
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1198
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1199
LEX_STRING *base __attribute__((unused)))
1333
uchar *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1334
LEX_STRING *base __attribute__((__unused__)))
1201
1336
if (type == OPT_GLOBAL)
1202
return (unsigned char*) &(global_system_variables.*offset);
1203
return (unsigned char*) &(thd->variables.*offset);
1337
return (uchar*) &(global_system_variables.*offset);
1338
return (uchar*) &(thd->variables.*offset);
1207
1342
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1209
1344
if (var->type == OPT_GLOBAL)
1210
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1345
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1212
thd->variables.*offset= (bool) var->save_result.ulong_value;
1347
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1217
1352
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1219
1354
if (type == OPT_GLOBAL)
1220
global_system_variables.*offset= (bool) option_limits->def_value;
1355
global_system_variables.*offset= (my_bool) option_limits->def_value;
1222
1357
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)))
1361
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1362
LEX_STRING *base __attribute__((__unused__)))
1229
1364
if (type == OPT_GLOBAL)
1230
return (unsigned char*) &(global_system_variables.*offset);
1231
return (unsigned char*) &(thd->variables.*offset);
1365
return (uchar*) &(global_system_variables.*offset);
1366
return (uchar*) &(thd->variables.*offset);
1235
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1370
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1236
1371
set_var *var, const TYPELIB *enum_names)
1238
1373
char buff[STRING_BUFFER_USUAL_SIZE];
1272
bool sys_var::check_set(THD *thd __attribute__((unused)),
1407
bool sys_var::check_set(THD *thd __attribute__((__unused__)),
1273
1408
set_var *var, TYPELIB *enum_names)
1276
1411
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1277
uint32_t error_len= 0;
1278
1413
String str(buff, sizeof(buff), system_charset_info), *res;
1280
1415
if (var->value->result_type() == STRING_RESULT)
1282
1417
if (!(res= var->value->val_str(&str)))
1284
my_stpcpy(buff, "NULL");
1419
strmov(buff, "NULL");
1471
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1472
LEX_STRING *base __attribute__((unused)))
1606
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1607
LEX_STRING *base __attribute__((__unused__)))
1474
1609
ulong tmp= ((type == OPT_GLOBAL) ?
1475
1610
global_system_variables.*offset :
1476
1611
thd->variables.*offset);
1477
return (unsigned char*) enum_names->type_names[tmp];
1612
return (uchar*) enum_names->type_names[tmp];
1480
1615
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)))
1628
uchar *sys_var_thd_bit::value_ptr(THD *thd,
1629
enum_var_type type __attribute__((__unused__)),
1630
LEX_STRING *base __attribute__((__unused__)))
1498
1633
If reverse is 0 (default) return 1 if bit is set.
1499
1634
If reverse is 1, return 0 if bit is set
1501
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1636
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1502
1637
!reverse : reverse);
1503
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1638
return (uchar*) &thd->sys_var_tmp.my_bool_value;
1613
1748
const char *new_name;
1616
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1751
static my_old_conv old_conv[]=
1753
{ "cp1251_koi8" , "cp1251" },
1754
{ "cp1250_latin2" , "cp1250" },
1755
{ "kam_latin2" , "keybcs2" },
1756
{ "mac_latin2" , "MacRoman" },
1757
{ "macce_latin2" , "MacCE" },
1758
{ "pc2_latin2" , "pclatin2" },
1759
{ "vga_latin2" , "pclatin1" },
1760
{ "koi8_cp1251" , "koi8r" },
1761
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
1762
{ "koi8_ukr_win1251ukr" , "koi8u" },
1766
CHARSET_INFO *get_old_charset_by_name(const char *name)
1770
for (conv= old_conv; conv->old_name; conv++)
1772
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
1773
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
1779
bool sys_var_collation::check(THD *thd __attribute__((__unused__)),
1619
const CHARSET_INFO *tmp;
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;
1862
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1863
LEX_STRING *base __attribute__((__unused__)))
1865
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
1866
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1870
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1872
if (type == OPT_GLOBAL)
1873
global_system_variables.*offset= *global_default;
1876
thd->variables.*offset= global_system_variables.*offset;
1877
thd->update_charset();
1880
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1882
if (type == OPT_GLOBAL)
1883
return &(global_system_variables.*offset);
1885
return &(thd->variables.*offset);
1889
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1891
if (sys_var_character_set_sv::check(thd, var))
1893
/* Currently, UCS-2 cannot be used as a client character set */
1894
if (var->save_result.charset->mbminlen > 1)
1896
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1897
var->save_result.charset->csname);
1904
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1907
if (type == OPT_GLOBAL)
1908
return &global_system_variables.collation_database;
1910
return &thd->variables.collation_database;
1914
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1916
if (type == OPT_GLOBAL)
1917
global_system_variables.collation_database= default_charset_info;
1920
thd->variables.collation_database= thd->db_charset;
1921
thd->update_charset();
1731
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1732
LEX_STRING *base __attribute__((unused)))
1951
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1952
LEX_STRING *base __attribute__((__unused__)))
1734
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1954
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1735
1955
global_system_variables.*offset : thd->variables.*offset);
1736
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1956
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)))
1974
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((__unused__)),
1975
enum_var_type type __attribute__((__unused__)),
1976
LEX_STRING *base __attribute__((__unused__)))
1758
1978
KEY_CACHE *key_cache= get_key_cache(base);
1759
1979
if (!key_cache)
1760
1980
key_cache= &zero_key_cache;
1761
return (unsigned char*) key_cache + offset ;
1981
return (uchar*) key_cache + offset ;
1907
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2127
bool sys_var_log_state::update(THD *thd, set_var *var)
1910
2130
pthread_mutex_lock(&LOCK_global_system_variables);
1911
2131
if (!var->save_result.ulong_value)
2133
logger.deactivate_log_handler(thd, log_type);
2137
res= logger.activate_log_handler(thd, log_type);
1915
2138
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)),
2142
void sys_var_log_state::set_default(THD *thd,
2143
enum_var_type type __attribute__((__unused__)))
2145
pthread_mutex_lock(&LOCK_global_system_variables);
2146
logger.deactivate_log_handler(thd, log_type);
2147
pthread_mutex_unlock(&LOCK_global_system_variables);
2151
static int sys_check_log_path(THD *thd __attribute__((__unused__)),
2154
char path[FN_REFLEN], buff[FN_REFLEN];
2156
String str(buff, sizeof(buff), system_charset_info), *res;
2157
const char *log_file_str;
2160
if (!(res= var->value->val_str(&str)))
2163
log_file_str= res->c_ptr();
2164
bzero(&f_stat, sizeof(struct stat));
2166
path_length= unpack_filename(path, log_file_str);
2170
/* File name is empty. */
2175
if (!stat(path, &f_stat))
2178
A file system object exists. Check if argument is a file and we have
2182
if (!MY_S_ISREG(f_stat.st_mode) ||
2183
!(f_stat.st_mode & MY_S_IWRITE))
2189
/* Get dirname of the file path. */
2190
(void) dirname_part(path, log_file_str, &path_length);
2192
/* Dirname is empty if file path is relative. */
2197
Check if directory exists and we have permission to create file and
2200
if (my_access(path, (F_OK|W_OK)))
2206
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2207
res ? log_file_str : "NULL");
2212
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
1926
2213
sys_var_str *var_str,
1927
2214
set_var *var, const char *log_ext,
1928
bool log_state, uint32_t log_type)
2215
bool log_state, uint log_type)
2217
MYSQL_QUERY_LOG *file_log;
1930
2218
char buff[FN_REFLEN];
1931
2219
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
1932
2220
bool result= 0;
1933
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2221
uint str_length= (var ? var->value->str_value.length() : 0);
1935
2223
switch (log_type) {
2224
case QUERY_LOG_SLOW:
2225
file_log= logger.get_slow_log_file_handler();
2227
case QUERY_LOG_GENERAL:
2228
file_log= logger.get_log_file_handler();
1937
2231
assert(0); // Impossible
1951
2245
pthread_mutex_lock(&LOCK_global_system_variables);
1952
2246
logger.lock_exclusive();
2248
if (file_log && log_state)
1954
2250
old_value= var_str->value;
1955
2251
var_str->value= res;
1956
2252
var_str->value_length= str_length;
2253
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
2254
if (file_log && log_state)
1960
2256
switch (log_type) {
2257
case QUERY_LOG_SLOW:
2258
file_log->open_slow_log(sys_var_slow_log_path.value);
2260
case QUERY_LOG_GENERAL:
2261
file_log->open_query_log(sys_var_general_log_path.value);
1974
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
2276
static bool sys_update_general_log_path(THD *thd, set_var * var)
2278
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2279
var, ".log", opt_log, QUERY_LOG_GENERAL);
2283
static void sys_default_general_log_path(THD *thd,
2284
enum_var_type type __attribute__((__unused__)))
2286
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2287
0, ".log", opt_log, QUERY_LOG_GENERAL);
2291
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2293
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2294
var, "-slow.log", opt_slow_log,
2299
static void sys_default_slow_log_path(THD *thd,
2300
enum_var_type type __attribute__((__unused__)))
2302
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2303
0, "-slow.log", opt_slow_log,
2308
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
1977
2311
pthread_mutex_lock(&LOCK_global_system_variables);
1978
2312
logger.lock_exclusive();
2313
logger.init_slow_log(var->save_result.ulong_value);
2314
logger.init_general_log(var->save_result.ulong_value);
1979
2315
*value= var->save_result.ulong_value;
1980
2316
logger.unlock();
1981
2317
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)))
2322
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
2323
enum_var_type type __attribute__((__unused__)))
1989
2325
pthread_mutex_lock(&LOCK_global_system_variables);
1990
2326
logger.lock_exclusive();
2327
logger.init_slow_log(LOG_FILE);
2328
logger.init_general_log(LOG_FILE);
1991
2329
*value= LOG_FILE;
1992
2330
logger.unlock();
1993
2331
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)))
2335
uchar *sys_var_log_output::value_ptr(THD *thd,
2336
enum_var_type type __attribute__((__unused__)),
2337
LEX_STRING *base __attribute__((__unused__)))
2001
2339
char buff[256];
2002
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2340
String tmp(buff, sizeof(buff), &my_charset_latin1);
2004
2342
ulong val= *value;
2007
for (uint32_t i= 0; val; val>>= 1, i++)
2345
for (uint i= 0; val; val>>= 1, i++)
2058
2396
void sys_var_timestamp::set_default(THD *thd,
2059
enum_var_type type __attribute__((unused)))
2397
enum_var_type type __attribute__((__unused__)))
2061
2399
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)))
2403
uchar *sys_var_timestamp::value_ptr(THD *thd,
2404
enum_var_type type __attribute__((__unused__)),
2405
LEX_STRING *base __attribute__((__unused__)))
2069
2407
thd->sys_var_tmp.long_value= (long) thd->start_time;
2070
return (unsigned char*) &thd->sys_var_tmp.long_value;
2408
return (uchar*) &thd->sys_var_tmp.long_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)))
2420
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
2421
enum_var_type type __attribute__((__unused__)),
2422
LEX_STRING *base __attribute__((__unused__)))
2087
2425
this tmp var makes it robust againt change of type of
2103
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2104
enum_var_type type __attribute__((unused)),
2105
LEX_STRING *base __attribute__((unused)))
2441
uchar *sys_var_insert_id::value_ptr(THD *thd,
2442
enum_var_type type __attribute__((__unused__)),
2443
LEX_STRING *base __attribute__((__unused__)))
2107
2445
thd->sys_var_tmp.uint64_t_value=
2108
2446
thd->auto_inc_intervals_forced.minimum();
2109
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2447
return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2126
2464
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2128
2466
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2129
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2467
String str(buff, sizeof(buff), &my_charset_latin1);
2130
2468
String *res= var->value->val_str(&str);
2132
2470
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)))
2494
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2495
LEX_STRING *base __attribute__((__unused__)))
2160
2498
We can use ptr() instead of c_ptr() here because String contaning
2161
2499
time zone name is guaranteed to be zero ended.
2163
2501
if (type == OPT_GLOBAL)
2164
return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
2502
return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2240
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2241
LEX_STRING *base __attribute__((unused)))
2578
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2579
LEX_STRING *base __attribute__((__unused__)))
2243
2581
if (type != OPT_GLOBAL &&
2244
2582
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);
2583
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2584
return (uchar*) &(max_user_connections);
2250
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
2588
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((__unused__)),
2253
2591
MY_LOCALE *locale_match;
2298
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2636
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2299
2637
enum_var_type type,
2300
LEX_STRING *base __attribute__((unused)))
2638
LEX_STRING *base __attribute__((__unused__)))
2302
2640
return type == OPT_GLOBAL ?
2303
(unsigned char *) global_system_variables.lc_time_names->name :
2304
(unsigned char *) thd->variables.lc_time_names->name;
2641
(uchar *) global_system_variables.lc_time_names->name :
2642
(uchar *) thd->variables.lc_time_names->name;
2360
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2361
LEX_STRING *base __attribute__((unused)))
2698
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2699
LEX_STRING *base __attribute__((__unused__)))
2363
2701
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2364
2702
global_system_variables.*offset :
2365
2703
thd->variables.*offset) / 1000000.0;
2366
return (unsigned char*) &thd->tmp_double_value;
2704
return (uchar*) &thd->tmp_double_value;
2416
static int check_log_update(THD *thd __attribute__((unused)),
2417
set_var *var __attribute__((unused)))
2423
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2754
static int check_log_update(THD *thd __attribute__((__unused__)),
2755
set_var *var __attribute__((__unused__)))
2760
static bool set_log_update(THD *thd __attribute__((__unused__)),
2761
set_var *var __attribute__((__unused__)))
2764
The update log is not supported anymore since 5.0.
2765
See sql/mysqld.cc/, comments in function init_server_components() for an
2766
explaination of the different warnings we send below
2769
if (opt_sql_bin_update)
2771
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2772
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2773
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2776
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2777
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2778
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2779
set_option_bit(thd, var);
2784
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2426
2787
var->save_result.uint64_t_value= var->value->val_int();
2430
static unsigned char *get_warning_count(THD *thd)
2791
static uchar *get_warning_count(THD *thd)
2432
2793
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;
2794
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
2795
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
2796
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
2797
return (uchar*) &thd->sys_var_tmp.long_value;
2439
static unsigned char *get_error_count(THD *thd)
2800
static uchar *get_error_count(THD *thd)
2441
2802
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;
2803
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2804
return (uchar*) &thd->sys_var_tmp.long_value;
2459
2820
ptr pointer to NUL-terminated string
2461
static unsigned char *get_tmpdir(THD *thd __attribute__((unused)))
2822
static uchar *get_tmpdir(THD *thd __attribute__((__unused__)))
2463
2824
if (opt_mysql_tmpdir)
2464
return (unsigned char *)opt_mysql_tmpdir;
2465
return (unsigned char*)mysql_tmpdir;
2825
return (uchar *)opt_mysql_tmpdir;
2826
return (uchar*)mysql_tmpdir;
2468
2829
/****************************************************************************
2508
2869
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)))
2872
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2873
my_bool first __attribute__((__unused__)))
2514
2875
*length= var->name_length;
2515
return (unsigned char*) var->name;
2876
return (uchar*) var->name;
2913
3282
!(engine_name.str= (char *)res->ptr()) ||
2914
3283
!(engine_name.length= res->length()) ||
2915
3284
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
2916
!(hton= plugin_data(var->save_result.plugin, handlerton *)))
3285
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
3286
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
2918
3288
value= res ? res->c_ptr() : "NULL";
2939
3309
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
2940
3310
hton= plugin_data(plugin, handlerton*);
2941
3311
engine_name= &hton2plugin[hton->slot]->name;
2942
result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
3312
result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
2943
3313
if (type == OPT_GLOBAL)
2944
3314
plugin_unlock(thd, plugin);
2985
3355
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
2987
3357
char buff[STRING_BUFFER_USUAL_SIZE*8];
2988
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3358
String tmp(buff, sizeof(buff), &my_charset_latin1);
2992
for (uint32_t i= 0; val; val>>= 1, i++)
3362
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)))
3383
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3384
LEX_STRING *base __attribute__((__unused__)))
3016
3386
LEX_STRING opts;
3017
3387
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3018
3388
thd->variables.*offset);
3019
3389
(void) symbolic_mode_representation(thd, val, &opts);
3020
return (unsigned char *) opts.str;
3390
return (uchar *) opts.str;
3068
3438
/* Key cache functions */
3070
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3440
static KEY_CACHE *create_key_cache(const char *name, uint length)
3072
3442
KEY_CACHE *key_cache;
3074
3444
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3075
3445
MYF(MY_ZEROFILL | MY_WME))))
3077
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
3447
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3079
free((char*) key_cache);
3449
my_free((char*) key_cache, MYF(0));