60
59
static DYNAMIC_ARRAY fixed_show_vars;
61
60
static HASH system_variable_hash;
63
const char *bool_type_names[]= { "OFF", "ON", NULL };
62
const char *bool_type_names[]= { "OFF", "ON", NullS };
64
63
TYPELIB bool_typelib=
66
65
array_elements(bool_type_names)-1, "", bool_type_names, NULL
69
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL };
68
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
70
69
TYPELIB delay_key_write_typelib=
72
71
array_elements(delay_key_write_type_names)-1, "",
76
75
const char *slave_exec_mode_names[]=
77
{ "STRICT", "IDEMPOTENT", NULL };
76
{ "STRICT", "IDEMPOTENT", NullS };
78
77
static const unsigned int slave_exec_mode_names_len[]=
79
78
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
80
79
TYPELIB slave_exec_mode_typelib=
90
89
static bool set_option_bit(THD *thd, set_var *var);
91
90
static bool set_option_autocommit(THD *thd, set_var *var);
92
91
static int check_log_update(THD *thd, set_var *var);
92
static bool set_log_update(THD *thd, set_var *var);
93
93
static int check_pseudo_thread_id(THD *thd, set_var *var);
94
94
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
95
static int check_tx_isolation(THD *thd, set_var *var);
111
111
static bool get_unsigned(THD *thd, set_var *var);
112
112
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
113
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);
114
static KEY_CACHE *create_key_cache(const char *name, uint length);
115
static uchar *get_error_count(THD *thd);
116
static uchar *get_warning_count(THD *thd);
117
static uchar *get_tmpdir(THD *thd);
118
static int sys_check_log_path(THD *thd, set_var *var);
119
static bool sys_update_general_log_path(THD *thd, set_var * var);
120
static void sys_default_general_log_path(THD *thd, enum_var_type type);
121
static bool sys_update_slow_log_path(THD *thd, set_var * var);
122
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
120
125
Variable definition list
144
149
&SV::binlog_format);
145
150
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
146
151
&SV::bulk_insert_buff_size);
152
static sys_var_character_set_sv
153
sys_character_set_server(&vars, "character_set_server",
154
&SV::collation_server, &default_charset_info, 0,
155
sys_var::SESSION_VARIABLE_IN_BINLOG);
156
sys_var_const_str sys_charset_system(&vars, "character_set_system",
157
(char *)my_charset_utf8_general_ci.name);
158
static sys_var_character_set_database
159
sys_character_set_database(&vars, "character_set_database",
160
sys_var::SESSION_VARIABLE_IN_BINLOG);
161
static sys_var_character_set_client
162
sys_character_set_client(&vars, "character_set_client",
163
&SV::character_set_client,
164
&default_charset_info,
165
sys_var::SESSION_VARIABLE_IN_BINLOG);
166
static sys_var_character_set_sv
167
sys_character_set_connection(&vars, "character_set_connection",
168
&SV::collation_connection,
169
&default_charset_info, 0,
170
sys_var::SESSION_VARIABLE_IN_BINLOG);
171
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
172
&SV::character_set_results,
173
&default_charset_info, true);
174
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
175
&SV::character_set_filesystem,
176
&character_set_filesystem);
147
177
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
148
178
&SV::completion_type,
149
179
check_completion_type,
160
190
sys_collation_server(&vars, "collation_server", &SV::collation_server,
161
191
&default_charset_info,
162
192
sys_var::SESSION_VARIABLE_IN_BINLOG);
193
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
194
&myisam_concurrent_insert);
163
195
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
164
196
&connect_timeout);
165
197
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
193
225
param_age_threshold));
194
226
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
195
227
&opt_local_infile);
228
static sys_var_bool_ptr
229
sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
230
&opt_log_queries_not_using_indexes);
231
static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
232
static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time",
233
&SV::long_query_time);
196
234
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
197
235
&SV::low_priority_updates,
198
236
fix_low_priority_updates);
240
278
&max_write_lock_count);
241
279
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
242
280
&SV::min_examined_row_limit);
281
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
282
&myisam_data_pointer_size);
243
283
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
284
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
285
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
270
310
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
271
311
&SV::optimizer_search_depth);
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
313
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
274
314
TYPELIB optimizer_use_mrr_typelib= {
275
315
array_elements(optimizer_use_mrr_names) - 1, "",
276
316
optimizer_use_mrr_names, NULL
290
330
&SV::read_rnd_buff_size);
291
331
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
292
332
&SV::div_precincrement);
333
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
294
336
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
295
337
&SV::range_alloc_block_size);
307
349
&SV::trans_prealloc_size,
308
350
0, fix_trans_mem_root);
352
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
310
353
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
311
354
&opt_secure_file_priv);
312
355
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
313
356
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
314
357
&opt_slave_compressed_protocol);
358
#ifdef HAVE_REPLICATION
315
359
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
316
360
&slave_allow_batching);
317
361
static sys_var_set_slave_mode slave_exec_mode(&vars,
332
377
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
333
378
&SV::optimizer_switch);
379
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
380
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
381
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
382
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
383
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
335
385
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
336
386
&SV::table_plugin);
387
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
337
388
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
338
389
system_time_zone);
339
390
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
356
407
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
357
408
static sys_var_const_str sys_version(&vars, "version", server_version);
358
409
static sys_var_const_str sys_version_comment(&vars, "version_comment",
359
DRIZZLE_COMPILATION_COMMENT);
410
MYSQL_COMPILATION_COMMENT);
360
411
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
362
413
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
398
449
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
400
451
OPTION_BIG_SELECTS);
452
static sys_var_thd_bit sys_log_off(&vars, "sql_log_off",
456
static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
401
460
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
402
461
check_log_update,
408
467
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
410
469
OPTION_SQL_NOTES);
470
static sys_var_thd_bit sys_auto_is_null(&vars, "sql_auto_is_null", 0,
472
OPTION_AUTO_IS_NULL, 0,
473
sys_var::SESSION_VARIABLE_IN_BINLOG);
411
474
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
413
476
OPTION_SAFE_UPDATES);
495
558
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
496
559
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)
561
static uchar *slave_get_report_port(THD *thd)
500
563
thd->sys_var_tmp.long_value= report_port;
501
return (unsigned char*) &thd->sys_var_tmp.long_value;
564
return (uchar*) &thd->sys_var_tmp.long_value;
504
567
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
510
573
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
511
574
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
575
/* Global variables which enable|disable logging */
576
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
578
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
579
static sys_var_log_state sys_var_log(&vars, "log", &opt_log, QUERY_LOG_GENERAL);
580
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
582
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
583
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
584
&opt_slow_log, QUERY_LOG_SLOW);
585
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
586
sys_update_general_log_path,
587
sys_default_general_log_path,
589
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
590
sys_update_slow_log_path,
591
sys_default_slow_log_path,
593
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
594
&log_output_typelib, 0);
513
598
Additional variables (not derived from sys_var class, not accessible as
514
599
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
519
604
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
520
605
static SHOW_VAR fixed_vars[]= {
521
606
{"back_log", (char*) &back_log, SHOW_LONG},
607
{"character_sets_dir", mysql_charsets_dir, SHOW_CHAR},
522
608
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
523
609
{"language", language, SHOW_CHAR},
524
610
#ifdef HAVE_MLOCKALL
722
809
if (type != OPT_GLOBAL)
723
810
thd->net.retry_count=thd->variables.net_retry_count;
812
#else /* HAVE_REPLICATION */
813
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
814
enum_var_type type __attribute__((unused)))
816
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
817
enum_var_type type __attribute__((unused)))
819
static void fix_net_retry_count(THD *thd __attribute__((unused)),
820
enum_var_type type __attribute__((unused)))
822
#endif /* HAVE_REPLICATION */
727
825
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
751
unsigned char *sys_var_set::value_ptr(THD *thd,
849
uchar *sys_var_set::value_ptr(THD *thd,
752
850
enum_var_type type __attribute__((unused)),
753
851
LEX_STRING *base __attribute__((unused)))
756
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
854
String tmp(buff, sizeof(buff), &my_charset_latin1);
758
856
ulong val= *value;
761
for (uint32_t i= 0; val; val>>= 1, i++)
859
for (uint i= 0; val; val>>= 1, i++)
807
905
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
808
906
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"));
908
sql_print_error("Ambiguous slave modes combination."
909
" STRICT will be used");
812
910
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
814
912
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)),
1146
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1035
1147
enum_var_type type __attribute__((unused)),
1036
1148
LEX_STRING *base __attribute__((unused)))
1038
return (unsigned char*) enum_names->type_names[*value];
1150
return (uchar*) enum_names->type_names[*value];
1042
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1154
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1043
1155
enum_var_type type __attribute__((unused)),
1044
1156
LEX_STRING *base __attribute__((unused)))
1046
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1158
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1049
1161
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1066
1178
if (option_limits)
1067
1179
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1068
else if (tmp > UINT32_MAX)
1180
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1181
else if (tmp > ULONG_MAX)
1071
1184
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1074
1188
if (var->type == OPT_GLOBAL)
1075
1189
global_system_variables.*offset= (ulong) tmp;
1098
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1212
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1099
1213
LEX_STRING *base __attribute__((unused)))
1101
1215
if (type == OPT_GLOBAL)
1102
return (unsigned char*) &(global_system_variables.*offset);
1103
return (unsigned char*) &(thd->variables.*offset);
1216
return (uchar*) &(global_system_variables.*offset);
1217
return (uchar*) &(thd->variables.*offset);
1147
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1261
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1148
1262
LEX_STRING *base __attribute__((unused)))
1150
1264
if (type == OPT_GLOBAL)
1151
return (unsigned char*) &(global_system_variables.*offset);
1152
return (unsigned char*) &(thd->variables.*offset);
1265
return (uchar*) &(global_system_variables.*offset);
1266
return (uchar*) &(thd->variables.*offset);
1155
1269
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,
1312
uchar *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1199
1313
LEX_STRING *base __attribute__((unused)))
1201
1315
if (type == OPT_GLOBAL)
1202
return (unsigned char*) &(global_system_variables.*offset);
1203
return (unsigned char*) &(thd->variables.*offset);
1316
return (uchar*) &(global_system_variables.*offset);
1317
return (uchar*) &(thd->variables.*offset);
1226
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1340
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1227
1341
LEX_STRING *base __attribute__((unused)))
1229
1343
if (type == OPT_GLOBAL)
1230
return (unsigned char*) &(global_system_variables.*offset);
1231
return (unsigned char*) &(thd->variables.*offset);
1344
return (uchar*) &(global_system_variables.*offset);
1345
return (uchar*) &(thd->variables.*offset);
1471
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1585
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1472
1586
LEX_STRING *base __attribute__((unused)))
1474
1588
ulong tmp= ((type == OPT_GLOBAL) ?
1475
1589
global_system_variables.*offset :
1476
1590
thd->variables.*offset);
1477
return (unsigned char*) enum_names->type_names[tmp];
1591
return (uchar*) enum_names->type_names[tmp];
1480
1594
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1613
1727
const char *new_name;
1730
static my_old_conv old_conv[]=
1732
{ "cp1251_koi8" , "cp1251" },
1733
{ "cp1250_latin2" , "cp1250" },
1734
{ "kam_latin2" , "keybcs2" },
1735
{ "mac_latin2" , "MacRoman" },
1736
{ "macce_latin2" , "MacCE" },
1737
{ "pc2_latin2" , "pclatin2" },
1738
{ "vga_latin2" , "pclatin1" },
1739
{ "koi8_cp1251" , "koi8r" },
1740
{ "win1251ukr_koi8_ukr" , "win1251ukr" },
1741
{ "koi8_ukr_win1251ukr" , "koi8u" },
1745
const CHARSET_INFO *get_old_charset_by_name(const char *name)
1749
for (conv= old_conv; conv->old_name; conv++)
1751
if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
1752
return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
1616
1758
bool sys_var_collation::check(THD *thd __attribute__((unused)),
1698
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1841
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1699
1842
LEX_STRING *base __attribute__((unused)))
1701
1844
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1702
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1845
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1849
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1851
if (type == OPT_GLOBAL)
1852
global_system_variables.*offset= *global_default;
1855
thd->variables.*offset= global_system_variables.*offset;
1856
thd->update_charset();
1859
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1861
if (type == OPT_GLOBAL)
1862
return &(global_system_variables.*offset);
1864
return &(thd->variables.*offset);
1868
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1870
if (sys_var_character_set_sv::check(thd, var))
1872
/* Currently, UCS-2 cannot be used as a client character set */
1873
if (var->save_result.charset->mbminlen > 1)
1875
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1876
var->save_result.charset->csname);
1883
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1886
if (type == OPT_GLOBAL)
1887
return &global_system_variables.collation_database;
1889
return &thd->variables.collation_database;
1893
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1895
if (type == OPT_GLOBAL)
1896
global_system_variables.collation_database= default_charset_info;
1899
thd->variables.collation_database= thd->db_charset;
1900
thd->update_charset();
1731
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1930
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1732
1931
LEX_STRING *base __attribute__((unused)))
1734
1933
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1735
1934
global_system_variables.*offset : thd->variables.*offset);
1736
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
1935
return cs ? (uchar*) cs->name : (uchar*) "NULL";
1754
unsigned char *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1953
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1755
1954
enum_var_type type __attribute__((unused)),
1756
1955
LEX_STRING *base __attribute__((unused)))
1758
1957
KEY_CACHE *key_cache= get_key_cache(base);
1759
1958
if (!key_cache)
1760
1959
key_cache= &zero_key_cache;
1761
return (unsigned char*) key_cache + offset ;
1960
return (uchar*) key_cache + offset ;
1907
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2106
bool sys_var_log_state::update(THD *thd, set_var *var)
1910
2109
pthread_mutex_lock(&LOCK_global_system_variables);
1911
2110
if (!var->save_result.ulong_value)
2112
logger.deactivate_log_handler(thd, log_type);
2116
res= logger.activate_log_handler(thd, log_type);
1915
2117
pthread_mutex_unlock(&LOCK_global_system_variables);
1919
void sys_var_log_state::set_default(THD *thd __attribute__((unused)),
2121
void sys_var_log_state::set_default(THD *thd,
1920
2122
enum_var_type type __attribute__((unused)))
2124
pthread_mutex_lock(&LOCK_global_system_variables);
2125
logger.deactivate_log_handler(thd, log_type);
2126
pthread_mutex_unlock(&LOCK_global_system_variables);
2130
static int sys_check_log_path(THD *thd __attribute__((unused)),
2133
char path[FN_REFLEN], buff[FN_REFLEN];
2135
String str(buff, sizeof(buff), system_charset_info), *res;
2136
const char *log_file_str;
2139
if (!(res= var->value->val_str(&str)))
2142
log_file_str= res->c_ptr();
2143
memset(&f_stat, 0, sizeof(struct stat));
2145
path_length= unpack_filename(path, log_file_str);
2149
/* File name is empty. */
2154
if (!stat(path, &f_stat))
2157
A file system object exists. Check if argument is a file and we have
2161
if (!S_ISREG(f_stat.st_mode) ||
2162
!(f_stat.st_mode & S_IWRITE))
2168
/* Get dirname of the file path. */
2169
(void) dirname_part(path, log_file_str, &path_length);
2171
/* Dirname is empty if file path is relative. */
2176
Check if directory exists and we have permission to create file and
2179
if (my_access(path, (F_OK|W_OK)))
2185
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2186
res ? log_file_str : "NULL");
1925
2191
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
1926
2192
sys_var_str *var_str,
1927
2193
set_var *var, const char *log_ext,
1928
bool log_state, uint32_t log_type)
2194
bool log_state, uint log_type)
2196
MYSQL_QUERY_LOG *file_log;
1930
2197
char buff[FN_REFLEN];
1931
2198
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
1932
2199
bool result= 0;
1933
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2200
uint str_length= (var ? var->value->str_value.length() : 0);
1935
2202
switch (log_type) {
2203
case QUERY_LOG_SLOW:
2204
file_log= logger.get_slow_log_file_handler();
2206
case QUERY_LOG_GENERAL:
2207
file_log= logger.get_log_file_handler();
1937
2210
assert(0); // Impossible
1951
2224
pthread_mutex_lock(&LOCK_global_system_variables);
1952
2225
logger.lock_exclusive();
2227
if (file_log && log_state)
1954
2229
old_value= var_str->value;
1955
2230
var_str->value= res;
1956
2231
var_str->value_length= str_length;
2232
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
2233
if (file_log && log_state)
1960
2235
switch (log_type) {
2236
case QUERY_LOG_SLOW:
2237
file_log->open_slow_log(sys_var_slow_log_path.value);
2239
case QUERY_LOG_GENERAL:
2240
file_log->open_query_log(sys_var_general_log_path.value);
2255
static bool sys_update_general_log_path(THD *thd, set_var * var)
2257
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2258
var, ".log", opt_log, QUERY_LOG_GENERAL);
2262
static void sys_default_general_log_path(THD *thd,
2263
enum_var_type type __attribute__((unused)))
2265
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2266
0, ".log", opt_log, QUERY_LOG_GENERAL);
2270
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2272
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2273
var, "-slow.log", opt_slow_log,
2278
static void sys_default_slow_log_path(THD *thd,
2279
enum_var_type type __attribute__((unused)))
2281
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2282
0, "-slow.log", opt_slow_log,
1974
2287
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
1977
2290
pthread_mutex_lock(&LOCK_global_system_variables);
1978
2291
logger.lock_exclusive();
2292
logger.init_slow_log(var->save_result.ulong_value);
2293
logger.init_general_log(var->save_result.ulong_value);
1979
2294
*value= var->save_result.ulong_value;
1980
2295
logger.unlock();
1981
2296
pthread_mutex_unlock(&LOCK_global_system_variables);
1989
2304
pthread_mutex_lock(&LOCK_global_system_variables);
1990
2305
logger.lock_exclusive();
2306
logger.init_slow_log(LOG_FILE);
2307
logger.init_general_log(LOG_FILE);
1991
2308
*value= LOG_FILE;
1992
2309
logger.unlock();
1993
2310
pthread_mutex_unlock(&LOCK_global_system_variables);
1997
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2314
uchar *sys_var_log_output::value_ptr(THD *thd,
1998
2315
enum_var_type type __attribute__((unused)),
1999
2316
LEX_STRING *base __attribute__((unused)))
2001
2318
char buff[256];
2002
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2319
String tmp(buff, sizeof(buff), &my_charset_latin1);
2004
2321
ulong val= *value;
2007
for (uint32_t i= 0; val; val>>= 1, i++)
2324
for (uint i= 0; val; val>>= 1, i++)
2065
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2382
uchar *sys_var_timestamp::value_ptr(THD *thd,
2066
2383
enum_var_type type __attribute__((unused)),
2067
2384
LEX_STRING *base __attribute__((unused)))
2069
2386
thd->sys_var_tmp.long_value= (long) thd->start_time;
2070
return (unsigned char*) &thd->sys_var_tmp.long_value;
2387
return (uchar*) &thd->sys_var_tmp.long_value;
2103
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2420
uchar *sys_var_insert_id::value_ptr(THD *thd,
2104
2421
enum_var_type type __attribute__((unused)),
2105
2422
LEX_STRING *base __attribute__((unused)))
2107
2424
thd->sys_var_tmp.uint64_t_value=
2108
2425
thd->auto_inc_intervals_forced.minimum();
2109
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2426
return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2126
2443
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2128
2445
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2129
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2446
String str(buff, sizeof(buff), &my_charset_latin1);
2130
2447
String *res= var->value->val_str(&str);
2132
2449
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,
2557
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2241
2558
LEX_STRING *base __attribute__((unused)))
2243
2560
if (type != OPT_GLOBAL &&
2244
2561
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);
2562
return (uchar*) &(thd->user_connect->user_resources.user_conn);
2563
return (uchar*) &(max_user_connections);
2265
2582
else // STRING_RESULT
2268
String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
2585
String str(buff, sizeof(buff), &my_charset_latin1), *res;
2269
2586
if (!(res=var->value->val_str(&str)))
2271
2588
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
2298
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2615
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2299
2616
enum_var_type type,
2300
2617
LEX_STRING *base __attribute__((unused)))
2302
2619
return type == OPT_GLOBAL ?
2303
(unsigned char *) global_system_variables.lc_time_names->name :
2304
(unsigned char *) thd->variables.lc_time_names->name;
2620
(uchar *) global_system_variables.lc_time_names->name :
2621
(uchar *) thd->variables.lc_time_names->name;
2360
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2677
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2361
2678
LEX_STRING *base __attribute__((unused)))
2363
2680
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2364
2681
global_system_variables.*offset :
2365
2682
thd->variables.*offset) / 1000000.0;
2366
return (unsigned char*) &thd->tmp_double_value;
2683
return (uchar*) &thd->tmp_double_value;
2739
static bool set_log_update(THD *thd __attribute__((unused)),
2740
set_var *var __attribute__((unused)))
2743
The update log is not supported anymore since 5.0.
2744
See sql/mysqld.cc/, comments in function init_server_components() for an
2745
explaination of the different warnings we send below
2748
if (opt_sql_bin_update)
2750
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
2751
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2752
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2755
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
2756
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2757
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2758
set_option_bit(thd, var);
2423
2763
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2430
static unsigned char *get_warning_count(THD *thd)
2770
static uchar *get_warning_count(THD *thd)
2432
2772
thd->sys_var_tmp.long_value=
2433
2773
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2434
2774
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2435
2775
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2436
return (unsigned char*) &thd->sys_var_tmp.long_value;
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
2782
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2443
return (unsigned char*) &thd->sys_var_tmp.long_value;
2783
return (uchar*) &thd->sys_var_tmp.long_value;
2459
2799
ptr pointer to NUL-terminated string
2461
static unsigned char *get_tmpdir(THD *thd __attribute__((unused)))
2801
static uchar *get_tmpdir(THD *thd __attribute__((unused)))
2463
2803
if (opt_mysql_tmpdir)
2464
return (unsigned char *)opt_mysql_tmpdir;
2465
return (unsigned char*)mysql_tmpdir;
2804
return (uchar *)opt_mysql_tmpdir;
2805
return (uchar*)mysql_tmpdir;
2468
2808
/****************************************************************************
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,
2851
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
2512
2852
bool first __attribute__((unused)))
2514
2854
*length= var->name_length;
2515
return (unsigned char*) var->name;
2855
return (uchar*) var->name;
2913
3253
!(engine_name.str= (char *)res->ptr()) ||
2914
3254
!(engine_name.length= res->length()) ||
2915
3255
!(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
2916
!(hton= plugin_data(var->save_result.plugin, handlerton *)))
3256
!(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
3257
ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
2918
3259
value= res ? res->c_ptr() : "NULL";
2939
3280
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
2940
3281
hton= plugin_data(plugin, handlerton*);
2941
3282
engine_name= &hton2plugin[hton->slot]->name;
2942
result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
3283
result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
2943
3284
if (type == OPT_GLOBAL)
2944
3285
plugin_unlock(thd, plugin);
2985
3326
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
2987
3328
char buff[STRING_BUFFER_USUAL_SIZE*8];
2988
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3329
String tmp(buff, sizeof(buff), &my_charset_latin1);
2992
for (uint32_t i= 0; val; val>>= 1, i++)
3333
for (uint i= 0; val; val>>= 1, i++)
3013
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3354
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3014
3355
LEX_STRING *base __attribute__((unused)))
3016
3357
LEX_STRING opts;
3017
3358
uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3018
3359
thd->variables.*offset);
3019
3360
(void) symbolic_mode_representation(thd, val, &opts);
3020
return (unsigned char *) opts.str;
3361
return (uchar *) opts.str;
3068
3409
/* Key cache functions */
3070
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
3411
static KEY_CACHE *create_key_cache(const char *name, uint length)
3072
3413
KEY_CACHE *key_cache;
3074
3415
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3075
3416
MYF(MY_ZEROFILL | MY_WME))))
3077
if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
3418
if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3079
free((char*) key_cache);
3420
my_free((char*) key_cache, MYF(0));