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>
57
#include <my_getopt.h>
58
#include <thr_alarm.h>
53
59
#include <storage/myisam/myisam.h>
54
#include <drizzled/drizzled_error_messages.h>
55
#include <libdrizzle/gettext.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
284
&max_write_lock_count);
241
285
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
242
286
&SV::min_examined_row_limit);
287
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
288
&myisam_data_pointer_size);
243
289
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
290
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
291
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
270
316
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
271
317
&SV::optimizer_search_depth);
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
319
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
274
320
TYPELIB optimizer_use_mrr_typelib= {
275
321
array_elements(optimizer_use_mrr_names) - 1, "",
276
322
optimizer_use_mrr_names, NULL
290
336
&SV::read_rnd_buff_size);
291
337
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
292
338
&SV::div_precincrement);
339
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
294
342
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
295
343
&SV::range_alloc_block_size);
307
355
&SV::trans_prealloc_size,
308
356
0, fix_trans_mem_root);
358
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
310
359
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
311
360
&opt_secure_file_priv);
312
361
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
313
362
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
314
363
&opt_slave_compressed_protocol);
364
#ifdef HAVE_REPLICATION
315
365
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
316
366
&slave_allow_batching);
317
367
static sys_var_set_slave_mode slave_exec_mode(&vars,
332
383
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
333
384
&SV::optimizer_switch);
385
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
386
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
387
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
388
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
389
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
335
391
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
336
392
&SV::table_plugin);
393
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
337
394
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
338
395
system_time_zone);
339
396
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
356
413
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
357
414
static sys_var_const_str sys_version(&vars, "version", server_version);
358
415
static sys_var_const_str sys_version_comment(&vars, "version_comment",
359
DRIZZLE_COMPILATION_COMMENT);
416
MYSQL_COMPILATION_COMMENT);
360
417
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
362
419
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
374
431
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
375
432
&SV::time_format,
376
DRIZZLE_TIMESTAMP_TIME);
433
MYSQL_TIMESTAMP_TIME);
377
434
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
378
435
&SV::date_format,
379
DRIZZLE_TIMESTAMP_DATE);
436
MYSQL_TIMESTAMP_DATE);
380
437
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
381
438
&SV::datetime_format,
382
DRIZZLE_TIMESTAMP_DATETIME);
439
MYSQL_TIMESTAMP_DATETIME);
384
441
/* Variables that are bits in THD */
398
455
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
400
457
OPTION_BIG_SELECTS);
458
static sys_var_thd_bit sys_log_off(&vars, "sql_log_off",
462
static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
401
466
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
402
467
check_log_update,
408
473
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
410
475
OPTION_SQL_NOTES);
476
static sys_var_thd_bit sys_auto_is_null(&vars, "sql_auto_is_null", 0,
478
OPTION_AUTO_IS_NULL, 0,
479
sys_var::SESSION_VARIABLE_IN_BINLOG);
411
480
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
413
482
OPTION_SAFE_UPDATES);
495
564
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
496
565
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)
567
static uchar *slave_get_report_port(THD *thd)
500
569
thd->sys_var_tmp.long_value= report_port;
501
return (unsigned char*) &thd->sys_var_tmp.long_value;
570
return (uchar*) &thd->sys_var_tmp.long_value;
504
573
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
508
577
/* Read only variables */
510
579
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
580
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
511
581
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
582
/* Global read-only variable describing server license */
583
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
584
/* Global variables which enable|disable logging */
585
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
587
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
588
static sys_var_log_state sys_var_log(&vars, "log", &opt_log, QUERY_LOG_GENERAL);
589
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
591
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
592
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
593
&opt_slow_log, QUERY_LOG_SLOW);
594
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
595
sys_update_general_log_path,
596
sys_default_general_log_path,
598
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
599
sys_update_slow_log_path,
600
sys_default_slow_log_path,
602
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
603
&log_output_typelib, 0);
513
607
Additional variables (not derived from sys_var class, not accessible as
514
608
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
519
613
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
520
614
static SHOW_VAR fixed_vars[]= {
521
615
{"back_log", (char*) &back_log, SHOW_LONG},
616
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
522
617
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
523
618
{"language", language, SHOW_CHAR},
524
619
#ifdef HAVE_MLOCKALL
527
622
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
528
623
{"log_error", (char*) log_error_file, SHOW_CHAR},
624
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
625
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
529
626
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
530
627
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
531
628
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
532
629
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
533
630
{"port", (char*) &mysqld_port, SHOW_INT},
534
631
{"protocol_version", (char*) &protocol_version, SHOW_INT},
632
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
633
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
535
634
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
722
822
if (type != OPT_GLOBAL)
723
823
thd->net.retry_count=thd->variables.net_retry_count;
825
#else /* HAVE_REPLICATION */
826
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
827
enum_var_type type __attribute__((unused)))
829
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
830
enum_var_type type __attribute__((unused)))
832
static void fix_net_retry_count(THD *thd __attribute__((unused)),
833
enum_var_type type __attribute__((unused)))
835
#endif /* HAVE_REPLICATION */
727
838
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
751
unsigned char *sys_var_set::value_ptr(THD *thd,
862
uchar *sys_var_set::value_ptr(THD *thd,
752
863
enum_var_type type __attribute__((unused)),
753
864
LEX_STRING *base __attribute__((unused)))
756
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
867
String tmp(buff, sizeof(buff), &my_charset_latin1);
758
869
ulong val= *value;
761
for (uint32_t i= 0; val; val>>= 1, i++)
872
for (uint i= 0; val; val>>= 1, i++)
807
918
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
808
919
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"));
921
sql_print_error("Ambiguous slave modes combination."
922
" STRICT will be used");
812
923
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
814
925
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
1034
unsigned char *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1159
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1035
1160
enum_var_type type __attribute__((unused)),
1036
1161
LEX_STRING *base __attribute__((unused)))
1038
return (unsigned char*) enum_names->type_names[*value];
1163
return (uchar*) enum_names->type_names[*value];
1042
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1167
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1043
1168
enum_var_type type __attribute__((unused)),
1044
1169
LEX_STRING *base __attribute__((unused)))
1046
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1171
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1049
1174
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1066
1191
if (option_limits)
1067
1192
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1068
else if (tmp > UINT32_MAX)
1193
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1194
else if (tmp > ULONG_MAX)
1071
1197
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1074
1201
if (var->type == OPT_GLOBAL)
1075
1202
global_system_variables.*offset= (ulong) tmp;
1098
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1225
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1099
1226
LEX_STRING *base __attribute__((unused)))
1101
1228
if (type == OPT_GLOBAL)
1102
return (unsigned char*) &(global_system_variables.*offset);
1103
return (unsigned char*) &(thd->variables.*offset);
1229
return (uchar*) &(global_system_variables.*offset);
1230
return (uchar*) &(thd->variables.*offset);
1147
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1274
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1148
1275
LEX_STRING *base __attribute__((unused)))
1150
1277
if (type == OPT_GLOBAL)
1151
return (unsigned char*) &(global_system_variables.*offset);
1152
return (unsigned char*) &(thd->variables.*offset);
1278
return (uchar*) &(global_system_variables.*offset);
1279
return (uchar*) &(thd->variables.*offset);
1155
1282
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,
1325
uchar *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1199
1326
LEX_STRING *base __attribute__((unused)))
1201
1328
if (type == OPT_GLOBAL)
1202
return (unsigned char*) &(global_system_variables.*offset);
1203
return (unsigned char*) &(thd->variables.*offset);
1329
return (uchar*) &(global_system_variables.*offset);
1330
return (uchar*) &(thd->variables.*offset);
1226
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1353
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1227
1354
LEX_STRING *base __attribute__((unused)))
1229
1356
if (type == OPT_GLOBAL)
1230
return (unsigned char*) &(global_system_variables.*offset);
1231
return (unsigned char*) &(thd->variables.*offset);
1357
return (uchar*) &(global_system_variables.*offset);
1358
return (uchar*) &(thd->variables.*offset);
1471
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1598
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1472
1599
LEX_STRING *base __attribute__((unused)))
1474
1601
ulong tmp= ((type == OPT_GLOBAL) ?
1475
1602
global_system_variables.*offset :
1476
1603
thd->variables.*offset);
1477
return (unsigned char*) enum_names->type_names[tmp];
1604
return (uchar*) enum_names->type_names[tmp];
1480
1607
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1613
1740
const char *new_name;
1743
static my_old_conv old_conv[]=
1745
{ "cp1251_koi8" , "cp1251" },
1746
{ "cp1250_latin2" , "cp1250" },
1747
{ "kam_latin2" , "keybcs2" },
1748
{ "mac_latin2" , "MacRoman" },
1749
{ "macce_latin2" , "MacCE" },
1750
{ "pc2_latin2" , "pclatin2" },
1751
{ "vga_latin2" , "pclatin1" },
1752
{ "koi8_cp1251" , "koi8r" },
1753
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
1754
{ "koi8_ukr_win1251ukr" , "koi8u" },
1758
CHARSET_INFO *get_old_charset_by_name(const char *name)
1762
for (conv= old_conv; conv->old_name; conv++)
1764
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
1765
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
1616
1771
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1619
const CHARSET_INFO *tmp;
1621
1776
if (var->value->result_type() == STRING_RESULT)
1698
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1854
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1699
1855
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;
1857
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
1858
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1862
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1864
if (type == OPT_GLOBAL)
1865
global_system_variables.*offset= *global_default;
1868
thd->variables.*offset= global_system_variables.*offset;
1869
thd->update_charset();
1872
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1874
if (type == OPT_GLOBAL)
1875
return &(global_system_variables.*offset);
1877
return &(thd->variables.*offset);
1881
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1883
if (sys_var_character_set_sv::check(thd, var))
1885
/* Currently, UCS-2 cannot be used as a client character set */
1886
if (var->save_result.charset->mbminlen > 1)
1888
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1889
var->save_result.charset->csname);
1896
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1899
if (type == OPT_GLOBAL)
1900
return &global_system_variables.collation_database;
1902
return &thd->variables.collation_database;
1906
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1908
if (type == OPT_GLOBAL)
1909
global_system_variables.collation_database= default_charset_info;
1912
thd->variables.collation_database= thd->db_charset;
1913
thd->update_charset();
1731
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1943
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1732
1944
LEX_STRING *base __attribute__((unused)))
1734
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1946
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1735
1947
global_system_variables.*offset : thd->variables.*offset);
1736
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1948
return cs ? (uchar*) cs->name : (uchar*) "NULL";
1754
unsigned char *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1966
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1755
1967
enum_var_type type __attribute__((unused)),
1756
1968
LEX_STRING *base __attribute__((unused)))
1758
1970
KEY_CACHE *key_cache= get_key_cache(base);
1759
1971
if (!key_cache)
1760
1972
key_cache= &zero_key_cache;
1761
return (unsigned char*) key_cache + offset ;
1973
return (uchar*) key_cache + offset ;
1801
2013
if (key_cache == dflt_key_cache)
1803
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2015
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1804
2016
ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
1805
2017
ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
1806
2018
goto end; // Ignore default key cache
1907
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2119
bool sys_var_log_state::update(THD *thd, set_var *var)
1910
2122
pthread_mutex_lock(&LOCK_global_system_variables);
1911
2123
if (!var->save_result.ulong_value)
2125
logger.deactivate_log_handler(thd, log_type);
2129
res= logger.activate_log_handler(thd, log_type);
1915
2130
pthread_mutex_unlock(&LOCK_global_system_variables);
1919
void sys_var_log_state::set_default(THD *thd __attribute__((unused)),
2134
void sys_var_log_state::set_default(THD *thd,
1920
2135
enum_var_type type __attribute__((unused)))
2137
pthread_mutex_lock(&LOCK_global_system_variables);
2138
logger.deactivate_log_handler(thd, log_type);
2139
pthread_mutex_unlock(&LOCK_global_system_variables);
2143
static int sys_check_log_path(THD *thd __attribute__((unused)),
2146
char path[FN_REFLEN], buff[FN_REFLEN];
2148
String str(buff, sizeof(buff), system_charset_info), *res;
2149
const char *log_file_str;
2152
if (!(res= var->value->val_str(&str)))
2155
log_file_str= res->c_ptr();
2156
bzero(&f_stat, sizeof(struct stat));
2158
path_length= unpack_filename(path, log_file_str);
2162
/* File name is empty. */
2167
if (!stat(path, &f_stat))
2170
A file system object exists. Check if argument is a file and we have
2174
if (!MY_S_ISREG(f_stat.st_mode) ||
2175
!(f_stat.st_mode & MY_S_IWRITE))
2181
/* Get dirname of the file path. */
2182
(void) dirname_part(path, log_file_str, &path_length);
2184
/* Dirname is empty if file path is relative. */
2189
Check if directory exists and we have permission to create file and
2192
if (my_access(path, (F_OK|W_OK)))
2198
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2199
res ? log_file_str : "NULL");
1925
2204
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
1926
2205
sys_var_str *var_str,
1927
2206
set_var *var, const char *log_ext,
1928
bool log_state, uint32_t log_type)
2207
bool log_state, uint log_type)
2209
MYSQL_QUERY_LOG *file_log;
1930
2210
char buff[FN_REFLEN];
1931
2211
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
1932
2212
bool result= 0;
1933
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2213
uint str_length= (var ? var->value->str_value.length() : 0);
1935
2215
switch (log_type) {
2216
case QUERY_LOG_SLOW:
2217
file_log= logger.get_slow_log_file_handler();
2219
case QUERY_LOG_GENERAL:
2220
file_log= logger.get_log_file_handler();
1937
2223
assert(0); // Impossible
1951
2237
pthread_mutex_lock(&LOCK_global_system_variables);
1952
2238
logger.lock_exclusive();
2240
if (file_log && log_state)
1954
2242
old_value= var_str->value;
1955
2243
var_str->value= res;
1956
2244
var_str->value_length= str_length;
2245
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
2246
if (file_log && log_state)
1960
2248
switch (log_type) {
2249
case QUERY_LOG_SLOW:
2250
file_log->open_slow_log(sys_var_slow_log_path.value);
2252
case QUERY_LOG_GENERAL:
2253
file_log->open_query_log(sys_var_general_log_path.value);
2268
static bool sys_update_general_log_path(THD *thd, set_var * var)
2270
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2271
var, ".log", opt_log, QUERY_LOG_GENERAL);
2275
static void sys_default_general_log_path(THD *thd,
2276
enum_var_type type __attribute__((unused)))
2278
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2279
0, ".log", opt_log, QUERY_LOG_GENERAL);
2283
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2285
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2286
var, "-slow.log", opt_slow_log,
2291
static void sys_default_slow_log_path(THD *thd,
2292
enum_var_type type __attribute__((unused)))
2294
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2295
0, "-slow.log", opt_slow_log,
1974
2300
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
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);
1989
2317
pthread_mutex_lock(&LOCK_global_system_variables);
1990
2318
logger.lock_exclusive();
2319
logger.init_slow_log(LOG_FILE);
2320
logger.init_general_log(LOG_FILE);
1991
2321
*value= LOG_FILE;
1992
2322
logger.unlock();
1993
2323
pthread_mutex_unlock(&LOCK_global_system_variables);
1997
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2327
uchar *sys_var_log_output::value_ptr(THD *thd,
1998
2328
enum_var_type type __attribute__((unused)),
1999
2329
LEX_STRING *base __attribute__((unused)))
2001
2331
char buff[256];
2002
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2332
String tmp(buff, sizeof(buff), &my_charset_latin1);
2004
2334
ulong val= *value;
2007
for (uint32_t i= 0; val; val>>= 1, i++)
2337
for (uint i= 0; val; val>>= 1, i++)
2065
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2395
uchar *sys_var_timestamp::value_ptr(THD *thd,
2066
2396
enum_var_type type __attribute__((unused)),
2067
2397
LEX_STRING *base __attribute__((unused)))
2069
2399
thd->sys_var_tmp.long_value= (long) thd->start_time;
2070
return (unsigned char*) &thd->sys_var_tmp.long_value;
2400
return (uchar*) &thd->sys_var_tmp.long_value;
2103
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2433
uchar *sys_var_insert_id::value_ptr(THD *thd,
2104
2434
enum_var_type type __attribute__((unused)),
2105
2435
LEX_STRING *base __attribute__((unused)))
2107
2437
thd->sys_var_tmp.uint64_t_value=
2108
2438
thd->auto_inc_intervals_forced.minimum();
2109
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2439
return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2126
2456
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2128
2458
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2129
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2459
String str(buff, sizeof(buff), &my_charset_latin1);
2130
2460
String *res= var->value->val_str(&str);
2132
2462
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2240
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2570
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2241
2571
LEX_STRING *base __attribute__((unused)))
2243
2573
if (type != OPT_GLOBAL &&
2244
2574
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);
2575
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2576
return (uchar*) &(max_user_connections);
2265
2595
else // STRING_RESULT
2268
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
2598
String str(buff, sizeof(buff), &my_charset_latin1), *res;
2269
2599
if (!(res=var->value->val_str(&str)))
2271
2601
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
2298
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2628
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2299
2629
enum_var_type type,
2300
2630
LEX_STRING *base __attribute__((unused)))
2302
2632
return type == OPT_GLOBAL ?
2303
(unsigned char *) global_system_variables.lc_time_names->name :
2304
(unsigned char *) thd->variables.lc_time_names->name;
2633
(uchar *) global_system_variables.lc_time_names->name :
2634
(uchar *) thd->variables.lc_time_names->name;
2360
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2690
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2361
2691
LEX_STRING *base __attribute__((unused)))
2363
2693
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2364
2694
global_system_variables.*offset :
2365
2695
thd->variables.*offset) / 1000000.0;
2366
return (unsigned char*) &thd->tmp_double_value;
2696
return (uchar*) &thd->tmp_double_value;
2752
static bool set_log_update(THD *thd __attribute__((unused)),
2753
set_var *var __attribute__((unused)))
2756
The update log is not supported anymore since 5.0.
2757
See sql/mysqld.cc/, comments in function init_server_components() for an
2758
explaination of the different warnings we send below
2761
if (opt_sql_bin_update)
2763
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2764
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2765
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2768
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2769
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2770
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2771
set_option_bit(thd, var);
2423
2776
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2430
static unsigned char *get_warning_count(THD *thd)
2783
static uchar *get_warning_count(THD *thd)
2432
2785
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;
2786
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
2787
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
2788
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
2789
return (uchar*) &thd->sys_var_tmp.long_value;
2439
static unsigned char *get_error_count(THD *thd)
2792
static uchar *get_error_count(THD *thd)
2441
2794
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;
2795
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2796
return (uchar*) &thd->sys_var_tmp.long_value;
2459
2812
ptr pointer to NUL-terminated string
2461
static unsigned char *get_tmpdir(THD *thd __attribute__((unused)))
2814
static uchar *get_tmpdir(THD *thd __attribute__((unused)))
2463
2816
if (opt_mysql_tmpdir)
2464
return (unsigned char *)opt_mysql_tmpdir;
2465
return (unsigned char*)mysql_tmpdir;
2817
return (uchar *)opt_mysql_tmpdir;
2818
return (uchar*)mysql_tmpdir;
2468
2821
/****************************************************************************
2508
2861
Return variable name and length for hashing of variables.
2511
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length,
2864
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2512
2865
bool first __attribute__((unused)))
2514
2867
*length= var->name_length;
2515
return (unsigned char*) var->name;
2868
return (uchar*) var->name;
2913
3266
!(engine_name.str= (char *)res->ptr()) ||
2914
3267
!(engine_name.length= res->length()) ||
2915
3268
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
2916
!(hton= plugin_data(var->save_result.plugin, handlerton *)))
3269
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
3270
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
2918
3272
value= res ? res->c_ptr() : "NULL";
2939
3293
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
2940
3294
hton= plugin_data(plugin, handlerton*);
2941
3295
engine_name= &hton2plugin[hton->slot]->name;
2942
result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
3296
result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
2943
3297
if (type == OPT_GLOBAL)
2944
3298
plugin_unlock(thd, plugin);
2985
3339
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
2987
3341
char buff[STRING_BUFFER_USUAL_SIZE*8];
2988
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3342
String tmp(buff, sizeof(buff), &my_charset_latin1);
2992
for (uint32_t i= 0; val; val>>= 1, i++)
3346
for (uint i= 0; val; val>>= 1, i++)
3013
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3367
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3014
3368
LEX_STRING *base __attribute__((unused)))
3016
3370
LEX_STRING opts;
3017
3371
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3018
3372
thd->variables.*offset);
3019
3373
(void) symbolic_mode_representation(thd, val, &opts);
3020
return (unsigned char *) opts.str;
3374
return (uchar *) opts.str;
3068
3422
/* Key cache functions */
3070
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3424
static KEY_CACHE *create_key_cache(const char *name, uint length)
3072
3426
KEY_CACHE *key_cache;
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));