48
44
Be careful with var->save_result: sys_var::check() only updates
49
uint64_t_value; so other members of the union are garbage then; to use
45
ulonglong_value; so other members of the union are garbage then; to use
50
46
them you must first assign a value to them (in specific ::check() for
54
#include <drizzled/server_includes.h>
55
#include <mysys/my_getopt.h>
56
#include <storage/myisam/myisam.h>
57
#include <drizzled/error.h>
58
#include <drizzled/gettext.h>
59
#include <drizzled/tztime.h>
60
#include <drizzled/data_home.h>
61
#include <drizzled/set_var.h>
62
#include <drizzled/session.h>
63
#include <drizzled/sql_base.h>
64
#include <drizzled/lock.h>
65
#include <drizzled/item/uint.h>
66
#include <drizzled/item/null.h>
67
#include <drizzled/item/float.h>
74
extern const CHARSET_INFO *character_set_filesystem;
75
extern I_List<NAMED_LIST> key_caches;
76
extern size_t my_thread_stack_size;
50
#ifdef USE_PRAGMA_IMPLEMENTATION
51
#pragma implementation // gcc: Class implementation
54
#include "mysql_priv.h"
57
#include <my_getopt.h>
58
#include <thr_alarm.h>
62
extern CHARSET_INFO *character_set_filesystem;
78
65
static DYNAMIC_ARRAY fixed_show_vars;
79
static map<const string, sys_var *> system_variable_hash;
80
extern char *opt_drizzle_tmpdir;
66
static HASH system_variable_hash;
82
const char *bool_type_names[]= { "OFF", "ON", NULL };
68
const char *bool_type_names[]= { "OFF", "ON", NullS };
83
69
TYPELIB bool_typelib=
85
71
array_elements(bool_type_names)-1, "", bool_type_names, NULL
88
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL };
74
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
89
75
TYPELIB delay_key_write_typelib=
91
77
array_elements(delay_key_write_type_names)-1, "",
92
78
delay_key_write_type_names, NULL
95
static bool set_option_bit(Session *session, set_var *var);
96
static bool set_option_autocommit(Session *session, set_var *var);
97
static int check_pseudo_thread_id(Session *session, set_var *var);
98
static int check_tx_isolation(Session *session, set_var *var);
99
static void fix_tx_isolation(Session *session, enum_var_type type);
100
static int check_completion_type(Session *session, set_var *var);
101
static void fix_completion_type(Session *session, enum_var_type type);
102
static void fix_net_read_timeout(Session *session, enum_var_type type);
103
static void fix_net_write_timeout(Session *session, enum_var_type type);
104
static void fix_net_retry_count(Session *session, enum_var_type type);
105
static void fix_max_join_size(Session *session, enum_var_type type);
106
static void fix_session_mem_root(Session *session, enum_var_type type);
107
static void fix_trans_mem_root(Session *session, enum_var_type type);
108
static void fix_server_id(Session *session, enum_var_type type);
109
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
110
static bool get_unsigned32(Session *session, set_var *var);
111
static bool get_unsigned64(Session *session, set_var *var);
112
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
113
const char *name, int64_t val);
114
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
115
static unsigned char *get_error_count(Session *session);
116
static unsigned char *get_warning_count(Session *session);
117
static unsigned char *get_tmpdir(Session *session);
81
const char *slave_exec_mode_names[]=
82
{ "STRICT", "IDEMPOTENT", NullS };
83
static const unsigned int slave_exec_mode_names_len[]=
84
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
85
TYPELIB slave_exec_mode_typelib=
87
array_elements(slave_exec_mode_names)-1, "",
88
slave_exec_mode_names, (unsigned int *) slave_exec_mode_names_len
91
static bool sys_update_init_connect(THD*, set_var*);
92
static void sys_default_init_connect(THD*, enum_var_type type);
93
static bool sys_update_init_slave(THD*, set_var*);
94
static void sys_default_init_slave(THD*, enum_var_type type);
95
static bool set_option_bit(THD *thd, set_var *var);
96
static bool set_option_autocommit(THD *thd, set_var *var);
97
static int check_log_update(THD *thd, set_var *var);
98
static bool set_log_update(THD *thd, set_var *var);
99
static int check_pseudo_thread_id(THD *thd, set_var *var);
100
static void fix_low_priority_updates(THD *thd, enum_var_type type);
101
static int check_tx_isolation(THD *thd, set_var *var);
102
static void fix_tx_isolation(THD *thd, enum_var_type type);
103
static int check_completion_type(THD *thd, set_var *var);
104
static void fix_completion_type(THD *thd, enum_var_type type);
105
static void fix_net_read_timeout(THD *thd, enum_var_type type);
106
static void fix_net_write_timeout(THD *thd, enum_var_type type);
107
static void fix_net_retry_count(THD *thd, enum_var_type type);
108
static void fix_max_join_size(THD *thd, enum_var_type type);
109
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
110
static void fix_max_binlog_size(THD *thd, enum_var_type type);
111
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
112
static void fix_max_connections(THD *thd, enum_var_type type);
113
static void fix_thd_mem_root(THD *thd, enum_var_type type);
114
static void fix_trans_mem_root(THD *thd, enum_var_type type);
115
static void fix_server_id(THD *thd, enum_var_type type);
116
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
117
static bool get_unsigned(THD *thd, set_var *var);
118
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
119
const char *name, longlong val);
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
152
196
sys_collation_server(&vars, "collation_server", &SV::collation_server,
153
197
&default_charset_info,
154
198
sys_var::SESSION_VARIABLE_IN_BINLOG);
155
static sys_var_uint32_t_ptr sys_connect_timeout(&vars, "connect_timeout",
157
static sys_var_const_str sys_datadir(&vars, "datadir", drizzle_real_data_home);
199
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
200
&myisam_concurrent_insert);
201
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
203
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
158
204
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
159
205
&delay_key_write_options,
160
206
&delay_key_write_typelib,
161
207
fix_delay_key_write);
209
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
163
211
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
164
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
165
&SV::join_buff_size);
212
static sys_var_long_ptr sys_flush_time(&vars, "flush_time", &flush_time);
213
sys_var_str sys_init_connect(&vars, "init_connect", 0,
214
sys_update_init_connect,
215
sys_default_init_connect,0);
216
sys_var_str sys_init_slave(&vars, "init_slave", 0,
217
sys_update_init_slave,
218
sys_default_init_slave,0);
219
static sys_var_thd_ulong sys_interactive_timeout(&vars, "interactive_timeout",
220
&SV::net_interactive_timeout);
221
static sys_var_thd_ulong sys_join_buffer_size(&vars, "join_buffer_size",
222
&SV::join_buff_size);
166
223
static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size");
167
static sys_var_key_cache_uint32_t sys_key_cache_block_size(&vars, "key_cache_block_size",
170
static sys_var_key_cache_uint32_t sys_key_cache_division_limit(&vars, "key_cache_division_limit",
172
param_division_limit));
173
static sys_var_key_cache_uint32_t sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
175
param_age_threshold));
176
static sys_var_session_uint32_t sys_max_allowed_packet(&vars, "max_allowed_packet",
177
&SV::max_allowed_packet);
178
static sys_var_uint64_t_ptr sys_max_connect_errors(&vars, "max_connect_errors",
179
&max_connect_errors);
180
static sys_var_session_uint64_t sys_max_error_count(&vars, "max_error_count",
181
&SV::max_error_count);
182
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
183
&SV::max_heap_table_size);
184
static sys_var_session_uint64_t sys_pseudo_thread_id(&vars, "pseudo_thread_id",
224
static sys_var_key_cache_long sys_key_cache_block_size(&vars, "key_cache_block_size",
227
static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_division_limit",
229
param_division_limit));
230
static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
232
param_age_threshold));
233
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
235
static sys_var_bool_ptr
236
sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
237
&opt_log_queries_not_using_indexes);
238
static sys_var_thd_ulong sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
239
static sys_var_microseconds sys_var_long_query_time(&vars, "long_query_time",
240
&SV::long_query_time);
241
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
242
&SV::low_priority_updates,
243
fix_low_priority_updates);
244
#ifndef TO_BE_DELETED /* Alias for the low_priority_updates */
245
static sys_var_thd_bool sys_sql_low_priority_updates(&vars, "sql_low_priority_updates",
246
&SV::low_priority_updates,
247
fix_low_priority_updates);
249
static sys_var_thd_ulong sys_max_allowed_packet(&vars, "max_allowed_packet",
250
&SV::max_allowed_packet);
251
static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
252
&max_binlog_cache_size);
253
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size",
255
fix_max_binlog_size);
256
static sys_var_long_ptr sys_max_connections(&vars, "max_connections",
258
fix_max_connections);
259
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors",
260
&max_connect_errors);
261
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
262
&SV::max_error_count);
263
static sys_var_thd_ulonglong sys_max_heap_table_size(&vars, "max_heap_table_size",
264
&SV::max_heap_table_size);
265
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
185
266
&SV::pseudo_thread_id,
186
0, check_pseudo_thread_id,
267
check_pseudo_thread_id, 0,
187
268
sys_var::SESSION_VARIABLE_IN_BINLOG);
188
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size",
191
static sys_var_session_uint64_t sys_max_seeks_for_key(&vars, "max_seeks_for_key",
192
&SV::max_seeks_for_key);
193
static sys_var_session_uint64_t sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
194
&SV::max_length_for_sort_data);
195
static sys_var_session_size_t sys_max_sort_length(&vars, "max_sort_length",
196
&SV::max_sort_length);
197
static sys_var_session_uint64_t sys_max_tmp_tables(&vars, "max_tmp_tables",
198
&SV::max_tmp_tables);
199
static sys_var_uint64_t_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
200
&max_write_lock_count);
201
static sys_var_session_uint64_t sys_min_examined_row_limit(&vars, "min_examined_row_limit",
202
&SV::min_examined_row_limit);
269
static sys_var_thd_ha_rows sys_max_join_size(&vars, "max_join_size",
272
static sys_var_thd_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
273
&SV::max_seeks_for_key);
274
static sys_var_thd_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
275
&SV::max_length_for_sort_data);
276
#ifndef TO_BE_DELETED /* Alias for max_join_size */
277
static sys_var_thd_ha_rows sys_sql_max_join_size(&vars, "sql_max_join_size",
281
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
283
fix_max_relay_log_size);
284
static sys_var_thd_ulong sys_max_sort_length(&vars, "max_sort_length",
285
&SV::max_sort_length);
286
static sys_var_max_user_conn sys_max_user_connections(&vars, "max_user_connections");
287
static sys_var_thd_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
288
&SV::max_tmp_tables);
289
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
290
&max_write_lock_count);
291
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
292
&SV::min_examined_row_limit);
293
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
294
&myisam_data_pointer_size);
295
static sys_var_thd_ulonglong sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
296
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
297
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
204
static sys_var_session_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
205
&SV::myisam_stats_method,
206
&myisam_stats_method_typelib,
208
static sys_var_session_uint32_t sys_net_buffer_length(&vars, "net_buffer_length",
209
&SV::net_buffer_length);
210
static sys_var_session_uint32_t sys_net_read_timeout(&vars, "net_read_timeout",
211
&SV::net_read_timeout,
212
0, fix_net_read_timeout);
213
static sys_var_session_uint32_t sys_net_write_timeout(&vars, "net_write_timeout",
214
&SV::net_write_timeout,
215
0, fix_net_write_timeout);
216
static sys_var_session_uint32_t sys_net_retry_count(&vars, "net_retry_count",
217
&SV::net_retry_count,
218
0, fix_net_retry_count);
299
static sys_var_thd_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
300
&SV::myisam_stats_method,
301
&myisam_stats_method_typelib,
303
static sys_var_thd_ulong sys_net_buffer_length(&vars, "net_buffer_length",
304
&SV::net_buffer_length);
305
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
306
&SV::net_read_timeout,
307
0, fix_net_read_timeout);
308
static sys_var_thd_ulong sys_net_write_timeout(&vars, "net_write_timeout",
309
&SV::net_write_timeout,
310
0, fix_net_write_timeout);
311
static sys_var_thd_ulong sys_net_retry_count(&vars, "net_retry_count",
312
&SV::net_retry_count,
313
0, fix_net_retry_count);
314
static sys_var_thd_bool sys_new_mode(&vars, "new", &SV::new_mode);
315
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
316
&global_system_variables.old_mode);
219
317
/* these two cannot be static */
220
sys_var_session_bool sys_old_alter_table(&vars, "old_alter_table",
221
&SV::old_alter_table);
222
static sys_var_session_bool sys_optimizer_prune_level(&vars, "optimizer_prune_level",
223
&SV::optimizer_prune_level);
224
static sys_var_session_uint32_t sys_optimizer_search_depth(&vars, "optimizer_search_depth",
225
&SV::optimizer_search_depth);
318
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
319
&SV::old_alter_table);
320
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
321
&SV::optimizer_prune_level);
322
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
323
&SV::optimizer_search_depth);
227
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
325
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
228
326
TYPELIB optimizer_use_mrr_typelib= {
229
327
array_elements(optimizer_use_mrr_names) - 1, "",
230
328
optimizer_use_mrr_names, NULL
233
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
234
&SV::optimizer_use_mrr,
235
&optimizer_use_mrr_typelib,
238
static sys_var_session_uint64_t sys_preload_buff_size(&vars, "preload_buffer_size",
239
&SV::preload_buff_size);
240
static sys_var_session_uint32_t sys_read_buff_size(&vars, "read_buffer_size",
241
&SV::read_buff_size);
242
static sys_var_session_uint32_t sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
243
&SV::read_rnd_buff_size);
244
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment",
245
&SV::div_precincrement);
247
static sys_var_session_size_t sys_range_alloc_block_size(&vars, "range_alloc_block_size",
248
&SV::range_alloc_block_size);
249
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size",
250
&SV::query_alloc_block_size,
251
false, fix_session_mem_root);
252
static sys_var_session_uint32_t sys_query_prealloc_size(&vars, "query_prealloc_size",
253
&SV::query_prealloc_size,
254
false, fix_session_mem_root);
255
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
256
static sys_var_session_uint32_t sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
257
&SV::trans_alloc_block_size,
258
false, fix_trans_mem_root);
259
static sys_var_session_uint32_t sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
260
&SV::trans_prealloc_size,
261
false, fix_trans_mem_root);
331
static sys_var_thd_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
332
&SV::optimizer_use_mrr,
333
&optimizer_use_mrr_typelib,
336
static sys_var_thd_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
337
&SV::preload_buff_size);
338
static sys_var_thd_ulong sys_read_buff_size(&vars, "read_buffer_size",
339
&SV::read_buff_size);
340
static sys_var_opt_readonly sys_readonly(&vars, "read_only", &opt_readonly);
341
static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
342
&SV::read_rnd_buff_size);
343
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
344
&SV::div_precincrement);
345
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
348
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
349
&SV::range_alloc_block_size);
350
static sys_var_thd_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
351
&SV::query_alloc_block_size,
352
0, fix_thd_mem_root);
353
static sys_var_thd_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
354
&SV::query_prealloc_size,
355
0, fix_thd_mem_root);
356
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
357
static sys_var_thd_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
358
&SV::trans_alloc_block_size,
359
0, fix_trans_mem_root);
360
static sys_var_thd_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
361
&SV::trans_prealloc_size,
362
0, fix_trans_mem_root);
364
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
263
365
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
264
366
&opt_secure_file_priv);
265
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id,
268
static sys_var_session_size_t sys_sort_buffer(&vars, "sort_buffer_size",
367
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
368
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
369
&opt_slave_compressed_protocol);
370
#ifdef HAVE_REPLICATION
371
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
372
&slave_allow_batching);
373
static sys_var_set_slave_mode slave_exec_mode(&vars,
375
&slave_exec_mode_options,
376
&slave_exec_mode_typelib,
379
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time",
381
static sys_var_thd_ulong sys_sort_buffer(&vars, "sort_buffer_size",
271
384
sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
272
385
even though it is written to the binlog, the slave ignores the
273
386
MODE_NO_DIR_IN_CREATE variable, so slave's value differs from
274
387
master's (see log_event.cc: Query_log_event::do_apply_event()).
276
static sys_var_session_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
277
&SV::optimizer_switch);
389
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
390
&SV::optimizer_switch);
391
static sys_var_const_str sys_ssl_ca(&vars, "ssl_ca", NULL);
392
static sys_var_const_str sys_ssl_capath(&vars, "ssl_capath", NULL);
393
static sys_var_const_str sys_ssl_cert(&vars, "ssl_cert", NULL);
394
static sys_var_const_str sys_ssl_cipher(&vars, "ssl_cipher", NULL);
395
static sys_var_const_str sys_ssl_key(&vars, "ssl_key", NULL);
279
static sys_var_session_storage_engine sys_storage_engine(&vars, "storage_engine",
280
&SV::storage_engine);
397
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
399
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
281
400
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
282
401
system_time_zone);
283
static sys_var_uint64_t_ptr sys_table_def_size(&vars, "table_definition_cache",
402
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
284
403
&table_def_size);
285
static sys_var_uint64_t_ptr sys_table_cache_size(&vars, "table_open_cache",
404
static sys_var_long_ptr sys_table_cache_size(&vars, "table_open_cache",
286
405
&table_cache_size);
287
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
406
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
288
407
&table_lock_wait_timeout);
289
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation",
291
&tx_isolation_typelib,
294
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
408
static sys_var_long_ptr sys_thread_cache_size(&vars, "thread_cache_size",
410
sys_var_long_ptr sys_thread_pool_size(&vars, "thread_pool_size",
412
static sys_var_thd_enum sys_tx_isolation(&vars, "tx_isolation",
414
&tx_isolation_typelib,
417
static sys_var_thd_ulonglong sys_tmp_table_size(&vars, "tmp_table_size",
295
418
&SV::tmp_table_size);
296
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
419
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes",
297
421
static sys_var_const_str sys_version(&vars, "version", server_version);
298
422
static sys_var_const_str sys_version_comment(&vars, "version_comment",
299
COMPILATION_COMMENT);
423
MYSQL_COMPILATION_COMMENT);
300
424
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
302
426
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
304
static sys_var_session_uint32_t sys_net_wait_timeout(&vars, "wait_timeout",
305
&SV::net_wait_timeout);
428
static sys_var_thd_ulong sys_net_wait_timeout(&vars, "wait_timeout",
429
&SV::net_wait_timeout);
307
431
/* Condition pushdown to storage engine */
308
static sys_var_session_bool
432
static sys_var_thd_bool
309
433
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
310
434
&SV::engine_condition_pushdown);
312
/* Variables that are bits in Session */
314
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
436
/* Time/date/datetime formats */
438
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
440
MYSQL_TIMESTAMP_TIME);
441
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
443
MYSQL_TIMESTAMP_DATE);
444
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
445
&SV::datetime_format,
446
MYSQL_TIMESTAMP_DATETIME);
448
/* Variables that are bits in THD */
450
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
315
451
set_option_autocommit,
316
452
OPTION_NOT_AUTOCOMMIT,
318
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0,
454
static sys_var_thd_bit sys_big_tables(&vars, "big_tables", 0,
457
#ifndef TO_BE_DELETED /* Alias for big_tables */
458
static sys_var_thd_bit sys_sql_big_tables(&vars, "sql_big_tables", 0,
462
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
320
464
OPTION_BIG_SELECTS);
321
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0,
465
static sys_var_thd_bit sys_log_off(&vars, "sql_log_off",
469
static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
473
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
477
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
323
479
OPTION_WARNINGS);
324
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0,
480
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
326
482
OPTION_SQL_NOTES);
327
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
483
static sys_var_thd_bit sys_auto_is_null(&vars, "sql_auto_is_null", 0,
485
OPTION_AUTO_IS_NULL, 0,
486
sys_var::SESSION_VARIABLE_IN_BINLOG);
487
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
329
489
OPTION_SAFE_UPDATES);
330
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
490
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
332
492
OPTION_BUFFER_RESULT);
333
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
493
static sys_var_thd_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
495
OPTION_QUOTE_SHOW_CREATE);
496
static sys_var_thd_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
335
498
OPTION_NO_FOREIGN_KEY_CHECKS,
336
499
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
337
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0,
500
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
339
502
OPTION_RELAXED_UNIQUE_CHECKS,
341
504
sys_var::SESSION_VARIABLE_IN_BINLOG);
342
505
/* Local state variables */
344
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit",
507
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
345
508
&SV::select_limit);
346
509
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
347
510
sys_var::SESSION_VARIABLE_IN_BINLOG);
377
540
statement-based logging mode: t will be different on master and
380
static sys_var_readonly sys_error_count(&vars, "error_count",
384
static sys_var_readonly sys_warning_count(&vars, "warning_count",
389
sys_var_session_uint64_t sys_group_concat_max_len(&vars, "group_concat_max_len",
390
&SV::group_concat_max_len);
392
sys_var_session_time_zone sys_time_zone(&vars, "time_zone",
543
static sys_var_insert_id sys_insert_id(&vars, "insert_id");
544
static sys_var_readonly sys_error_count(&vars, "error_count",
548
static sys_var_readonly sys_warning_count(&vars, "warning_count",
553
static sys_var_rand_seed1 sys_rand_seed1(&vars, "rand_seed1",
554
sys_var::SESSION_VARIABLE_IN_BINLOG);
555
static sys_var_rand_seed2 sys_rand_seed2(&vars, "rand_seed2",
556
sys_var::SESSION_VARIABLE_IN_BINLOG);
558
static sys_var_thd_ulong sys_default_week_format(&vars, "default_week_format",
559
&SV::default_week_format);
561
sys_var_thd_ulong sys_group_concat_max_len(&vars, "group_concat_max_len",
562
&SV::group_concat_max_len);
564
sys_var_thd_time_zone sys_time_zone(&vars, "time_zone",
393
565
sys_var::SESSION_VARIABLE_IN_BINLOG);
395
567
/* Global read-only variable containing hostname */
396
568
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
398
sys_var_session_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
570
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
571
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
572
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
574
static uchar *slave_get_report_port(THD *thd)
576
thd->sys_var_tmp.long_value= report_port;
577
return (uchar*) &thd->sys_var_tmp.long_value;
580
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
582
sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
399
583
&SV::keep_files_on_create);
400
584
/* Read only variables */
586
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
587
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
588
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
589
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
590
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
402
591
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
592
/* Global read-only variable describing server license */
593
static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
594
/* Global variables which enable|disable logging */
595
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
597
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
598
static sys_var_log_state sys_var_log(&vars, "log", &opt_log,
600
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
602
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
603
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
604
&opt_slow_log, QUERY_LOG_SLOW);
605
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
606
sys_update_general_log_path,
607
sys_default_general_log_path,
609
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
610
sys_update_slow_log_path,
611
sys_default_slow_log_path,
613
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
614
&log_output_typelib, 0);
404
618
Additional variables (not derived from sys_var class, not accessible as
405
619
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
545
static void fix_session_mem_root(Session *session, enum_var_type type)
547
if (type != OPT_GLOBAL)
548
reset_root_defaults(session->mem_root,
549
session->variables.query_alloc_block_size,
550
session->variables.query_prealloc_size);
554
static void fix_trans_mem_root(Session *session, enum_var_type type)
556
if (type != OPT_GLOBAL)
557
reset_root_defaults(&session->transaction.mem_root,
558
session->variables.trans_alloc_block_size,
559
session->variables.trans_prealloc_size);
563
static void fix_server_id(Session *, enum_var_type)
568
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
569
const char *name, int64_t val)
867
bool sys_var_set::update(THD *thd __attribute__((__unused__)),
870
*value= var->save_result.ulong_value;
874
uchar *sys_var_set::value_ptr(THD *thd,
875
enum_var_type type __attribute__((__unused__)),
876
LEX_STRING *base __attribute__((__unused__)))
879
String tmp(buff, sizeof(buff), &my_charset_latin1);
884
for (uint i= 0; val; val>>= 1, i++)
888
tmp.append(enum_names->type_names[i],
889
enum_names->type_lengths[i]);
894
if ((length= tmp.length()))
896
return (uchar*) thd->strmake(tmp.ptr(), length);
899
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((__unused__)),
900
enum_var_type type __attribute__((__unused__)))
902
slave_exec_mode_options= 0;
903
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
906
bool sys_var_set_slave_mode::check(THD *thd, set_var *var)
908
bool rc= sys_var_set::check(thd, var);
910
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 &&
911
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
914
my_error(ER_SLAVE_AMBIGOUS_EXEC_MODE, MYF(0), "");
919
bool sys_var_set_slave_mode::update(THD *thd, set_var *var)
922
pthread_mutex_lock(&LOCK_global_system_variables);
923
rc= sys_var_set::update(thd, var);
924
pthread_mutex_unlock(&LOCK_global_system_variables);
928
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
930
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
931
bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
933
sql_print_error("Ambiguous slave modes combination."
934
" STRICT will be used");
935
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
937
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
938
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
941
bool sys_var_thd_binlog_format::is_readonly() const
944
Under certain circumstances, the variable is read-only (unchangeable):
946
THD *thd= current_thd;
948
If RBR and open temporary tables, their CREATE TABLE may not be in the
949
binlog, so we can't toggle to SBR in this connection.
950
The test below will also prevent SET GLOBAL, well it was not easy to test
951
if global or not here.
952
And this test will also prevent switching from RBR to RBR (a no-op which
953
should not happen too often).
955
If we don't have row-based replication compiled in, the variable
958
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) &&
959
thd->temporary_tables)
961
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
965
if in a stored function/trigger, it's too late to change mode
967
if (thd->in_sub_stmt)
969
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
972
return sys_var_thd_enum::is_readonly();
976
void fix_binlog_format_after_update(THD *thd,
977
enum_var_type type __attribute__((__unused__)))
979
thd->reset_current_stmt_binlog_row_based();
983
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
984
enum_var_type type __attribute__((__unused__)))
986
mysql_bin_log.set_max_size(max_binlog_size);
987
#ifdef HAVE_REPLICATION
988
if (!max_relay_log_size)
989
active_mi->rli.relay_log.set_max_size(max_binlog_size);
994
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
995
enum_var_type type __attribute__((__unused__)))
997
#ifdef HAVE_REPLICATION
998
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
999
max_relay_log_size: max_binlog_size);
1004
static void fix_max_connections(THD *thd __attribute__((__unused__)),
1005
enum_var_type type __attribute__((__unused__)))
1007
resize_thr_alarm(max_connections + 10);
1011
static void fix_thd_mem_root(THD *thd, enum_var_type type)
1013
if (type != OPT_GLOBAL)
1014
reset_root_defaults(thd->mem_root,
1015
thd->variables.query_alloc_block_size,
1016
thd->variables.query_prealloc_size);
1020
static void fix_trans_mem_root(THD *thd, enum_var_type type)
1022
if (type != OPT_GLOBAL)
1023
reset_root_defaults(&thd->transaction.mem_root,
1024
thd->variables.trans_alloc_block_size,
1025
thd->variables.trans_prealloc_size);
1029
static void fix_server_id(THD *thd __attribute__((__unused__)),
1030
enum_var_type type __attribute__((__unused__)))
1032
server_id_supplied = 1;
1033
thd->server_id= server_id;
1037
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
1038
const char *name, longlong val)
576
ullstr((uint64_t) val, buf);
1045
ullstr((ulonglong) val, buf);
578
1047
llstr(val, buf);
580
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1049
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
581
1050
ER_TRUNCATED_WRONG_VALUE,
582
1051
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
587
static uint64_t fix_unsigned(Session *session, uint64_t num,
1056
static ulonglong fix_unsigned(THD *thd, ulonglong num,
588
1057
const struct my_option *option_limits)
591
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
593
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
598
static size_t fix_size_t(Session *session, size_t num,
599
const struct my_option *option_limits)
602
size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed);
604
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
608
static bool get_unsigned32(Session *, set_var *var)
610
if (var->value->unsigned_flag)
611
var->save_result.uint32_t_value= (uint32_t) var->value->val_int();
614
int64_t v= var->value->val_int();
615
var->save_result.uint32_t_value= (uint32_t) ((v < 0) ? 0 : v);
620
static bool get_unsigned64(Session *, set_var *var)
622
if (var->value->unsigned_flag)
623
var->save_result.uint64_t_value=(uint64_t) var->value->val_int();
626
int64_t v= var->value->val_int();
627
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
632
static bool get_size_t(Session *, set_var *var)
634
if (var->value->unsigned_flag)
635
var->save_result.size_t_value= (size_t) var->value->val_int();
638
ssize_t v= (ssize_t)var->value->val_int();
639
var->save_result.size_t_value= (size_t) ((v < 0) ? 0 : v);
644
bool sys_var_uint32_t_ptr::check(Session *, set_var *var)
646
var->save_result.uint32_t_value= (uint32_t)var->value->val_int();
650
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
652
uint32_t tmp= var->save_result.uint32_t_value;
653
pthread_mutex_lock(&LOCK_global_system_variables);
656
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
661
*value= (uint32_t) tmp;
662
pthread_mutex_unlock(&LOCK_global_system_variables);
667
void sys_var_uint32_t_ptr::set_default(Session *, enum_var_type)
670
pthread_mutex_lock(&LOCK_global_system_variables);
671
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
672
option_limits, ¬_used);
673
pthread_mutex_unlock(&LOCK_global_system_variables);
677
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
679
uint64_t tmp= var->save_result.uint64_t_value;
680
pthread_mutex_lock(&LOCK_global_system_variables);
683
uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits);
688
*value= (uint64_t) tmp;
689
pthread_mutex_unlock(&LOCK_global_system_variables);
694
void sys_var_uint64_t_ptr::set_default(Session *, enum_var_type)
697
pthread_mutex_lock(&LOCK_global_system_variables);
698
*value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
1059
my_bool fixed= false;
1060
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
1062
throw_bounds_warning(thd, fixed, true, option_limits->name, (longlong) num);
1066
static bool get_unsigned(THD *thd __attribute__((__unused__)), set_var *var)
1068
if (var->value->unsigned_flag)
1069
var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
1072
longlong v= var->value->val_int();
1073
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
1080
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_arg,
1081
sys_after_update_func after_update_arg)
1082
:sys_var_long_ptr_global(chain, name_arg, value_ptr_arg,
1083
&LOCK_global_system_variables, after_update_arg)
1087
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
1089
return get_unsigned(thd, var);
1092
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
1094
ulonglong tmp= var->save_result.ulonglong_value;
1095
pthread_mutex_lock(guard);
1097
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
1100
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1101
/* Avoid overflows on 32 bit systems */
1102
if (tmp > ULONG_MAX)
1105
throw_bounds_warning(thd, true, true, name,
1106
(longlong) var->save_result.ulonglong_value);
1109
*value= (ulong) tmp;
1112
pthread_mutex_unlock(guard);
1117
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1120
pthread_mutex_lock(guard);
1121
*value= (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1122
option_limits, ¬_used);
1123
pthread_mutex_unlock(guard);
1127
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
1129
ulonglong tmp= var->save_result.ulonglong_value;
1130
pthread_mutex_lock(&LOCK_global_system_variables);
1132
*value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
1134
*value= (ulonglong) tmp;
1135
pthread_mutex_unlock(&LOCK_global_system_variables);
1140
void sys_var_ulonglong_ptr::set_default(THD *thd __attribute__((__unused__)),
1141
enum_var_type type __attribute__((__unused__)))
1144
pthread_mutex_lock(&LOCK_global_system_variables);
1145
*value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
699
1146
option_limits, ¬_used);
700
1147
pthread_mutex_unlock(&LOCK_global_system_variables);
704
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
706
size_t tmp= var->save_result.size_t_value;
707
pthread_mutex_lock(&LOCK_global_system_variables);
709
*value= fix_size_t(session, tmp, option_limits);
712
pthread_mutex_unlock(&LOCK_global_system_variables);
717
void sys_var_size_t_ptr::set_default(Session *, enum_var_type)
720
pthread_mutex_lock(&LOCK_global_system_variables);
721
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
722
option_limits, ¬_used);
723
pthread_mutex_unlock(&LOCK_global_system_variables);
726
bool sys_var_bool_ptr::update(Session *, set_var *var)
728
*value= (bool) var->save_result.uint32_t_value;
733
void sys_var_bool_ptr::set_default(Session *, enum_var_type)
735
*value= (bool) option_limits->def_value;
739
bool sys_var_enum::update(Session *, set_var *var)
741
*value= (uint32_t) var->save_result.uint32_t_value;
746
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, const LEX_STRING *)
748
return (unsigned char*) enum_names->type_names[*value];
752
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type,
755
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
759
32 bit types for session variables
761
bool sys_var_session_uint32_t::check(Session *session, set_var *var)
763
return (get_unsigned32(session, var) ||
764
(check_func && (*check_func)(session, var)));
767
bool sys_var_session_uint32_t::update(Session *session, set_var *var)
769
uint64_t tmp= (uint64_t) var->save_result.uint32_t_value;
1151
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1153
*value= (my_bool) var->save_result.ulong_value;
1158
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1160
*value= (my_bool) option_limits->def_value;
1164
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1166
*value= (uint) var->save_result.ulong_value;
1171
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
1172
enum_var_type type __attribute__((__unused__)),
1173
LEX_STRING *base __attribute__((__unused__)))
1175
return (uchar*) enum_names->type_names[*value];
1179
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
1180
enum_var_type type __attribute__((__unused__)),
1181
LEX_STRING *base __attribute__((__unused__)))
1183
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1186
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1188
return (get_unsigned(thd, var) ||
1189
(check_func && (*check_func)(thd, var)));
1192
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1194
ulonglong tmp= var->save_result.ulonglong_value;
771
1196
/* Don't use bigger value than given with --maximum-variable-name=.. */
772
if ((uint32_t) tmp > max_system_variables.*offset)
1197
if ((ulong) tmp > max_system_variables.*offset)
774
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1199
throw_bounds_warning(thd, true, true, name, (longlong) tmp);
775
1200
tmp= max_system_variables.*offset;
778
1203
if (option_limits)
779
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits);
780
else if (tmp > UINT32_MAX)
1204
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1205
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1206
else if (tmp > ULONG_MAX)
783
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value);
1209
throw_bounds_warning(thd, true, true, name, (longlong) var->save_result.ulonglong_value);
786
1213
if (var->type == OPT_GLOBAL)
787
global_system_variables.*offset= (uint32_t) tmp;
1214
global_system_variables.*offset= (ulong) tmp;
789
session->variables.*offset= (uint32_t) tmp;
1216
thd->variables.*offset= (ulong) tmp;
795
void sys_var_session_uint32_t::set_default(Session *session, enum_var_type type)
1222
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
797
1224
if (type == OPT_GLOBAL)
800
1227
/* We will not come here if option_limits is not set */
801
1228
global_system_variables.*offset=
802
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value,
1229
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
803
1230
option_limits, ¬_used);
806
session->variables.*offset= global_system_variables.*offset;
1233
thd->variables.*offset= global_system_variables.*offset;
810
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session,
1237
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1238
LEX_STRING *base __attribute__((__unused__)))
814
1240
if (type == OPT_GLOBAL)
815
return (unsigned char*) &(global_system_variables.*offset);
816
return (unsigned char*) &(session->variables.*offset);
1241
return (uchar*) &(global_system_variables.*offset);
1242
return (uchar*) &(thd->variables.*offset);
820
bool sys_var_session_ha_rows::update(Session *session, set_var *var)
1246
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
822
uint64_t tmp= var->save_result.uint64_t_value;
1248
ulonglong tmp= var->save_result.ulonglong_value;
824
1250
/* Don't use bigger value than given with --maximum-variable-name=.. */
825
1251
if ((ha_rows) tmp > max_system_variables.*offset)
826
1252
tmp= max_system_variables.*offset;
828
1254
if (option_limits)
829
tmp= (ha_rows) fix_unsigned(session, tmp, option_limits);
1255
tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
830
1256
if (var->type == OPT_GLOBAL)
832
1258
/* Lock is needed to make things safe on 32 bit systems */
833
pthread_mutex_lock(&LOCK_global_system_variables);
1259
pthread_mutex_lock(&LOCK_global_system_variables);
834
1260
global_system_variables.*offset= (ha_rows) tmp;
835
1261
pthread_mutex_unlock(&LOCK_global_system_variables);
838
session->variables.*offset= (ha_rows) tmp;
1264
thd->variables.*offset= (ha_rows) tmp;
843
void sys_var_session_ha_rows::set_default(Session *session, enum_var_type type)
1269
void sys_var_thd_ha_rows::set_default(THD *thd, enum_var_type type)
845
1271
if (type == OPT_GLOBAL)
848
1274
/* We will not come here if option_limits is not set */
849
1275
pthread_mutex_lock(&LOCK_global_system_variables);
850
1276
global_system_variables.*offset=
853
1279
pthread_mutex_unlock(&LOCK_global_system_variables);
856
session->variables.*offset= global_system_variables.*offset;
1282
thd->variables.*offset= global_system_variables.*offset;
860
unsigned char *sys_var_session_ha_rows::value_ptr(Session *session,
1286
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1287
LEX_STRING *base __attribute__((__unused__)))
864
1289
if (type == OPT_GLOBAL)
865
return (unsigned char*) &(global_system_variables.*offset);
866
return (unsigned char*) &(session->variables.*offset);
869
bool sys_var_session_uint64_t::check(Session *session, set_var *var)
871
return (get_unsigned64(session, var) ||
872
(check_func && (*check_func)(session, var)));
875
bool sys_var_session_uint64_t::update(Session *session, set_var *var)
877
uint64_t tmp= var->save_result.uint64_t_value;
1290
return (uchar*) &(global_system_variables.*offset);
1291
return (uchar*) &(thd->variables.*offset);
1294
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1296
return get_unsigned(thd, var);
1299
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
1301
ulonglong tmp= var->save_result.ulonglong_value;
879
1303
if (tmp > max_system_variables.*offset)
880
1304
tmp= max_system_variables.*offset;
882
1306
if (option_limits)
883
tmp= fix_unsigned(session, tmp, option_limits);
1307
tmp= fix_unsigned(thd, tmp, option_limits);
884
1308
if (var->type == OPT_GLOBAL)
886
1310
/* Lock is needed to make things safe on 32 bit systems */
887
1311
pthread_mutex_lock(&LOCK_global_system_variables);
888
global_system_variables.*offset= (uint64_t) tmp;
1312
global_system_variables.*offset= (ulonglong) tmp;
889
1313
pthread_mutex_unlock(&LOCK_global_system_variables);
892
session->variables.*offset= (uint64_t) tmp;
1316
thd->variables.*offset= (ulonglong) tmp;
897
void sys_var_session_uint64_t::set_default(Session *session, enum_var_type type)
1321
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
899
1323
if (type == OPT_GLOBAL)
902
1326
pthread_mutex_lock(&LOCK_global_system_variables);
903
1327
global_system_variables.*offset=
904
getopt_ull_limit_value((uint64_t) option_limits->def_value,
1328
getopt_ull_limit_value((ulonglong) option_limits->def_value,
905
1329
option_limits, ¬_used);
906
1330
pthread_mutex_unlock(&LOCK_global_system_variables);
909
session->variables.*offset= global_system_variables.*offset;
913
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session,
917
if (type == OPT_GLOBAL)
918
return (unsigned char*) &(global_system_variables.*offset);
919
return (unsigned char*) &(session->variables.*offset);
922
bool sys_var_session_size_t::check(Session *session, set_var *var)
924
return (get_size_t(session, var) ||
925
(check_func && (*check_func)(session, var)));
928
bool sys_var_session_size_t::update(Session *session, set_var *var)
930
size_t tmp= var->save_result.size_t_value;
932
if (tmp > max_system_variables.*offset)
933
tmp= max_system_variables.*offset;
936
tmp= fix_size_t(session, tmp, option_limits);
937
if (var->type == OPT_GLOBAL)
939
/* Lock is needed to make things safe on 32 bit systems */
940
pthread_mutex_lock(&LOCK_global_system_variables);
941
global_system_variables.*offset= tmp;
942
pthread_mutex_unlock(&LOCK_global_system_variables);
945
session->variables.*offset= tmp;
950
void sys_var_session_size_t::set_default(Session *session, enum_var_type type)
952
if (type == OPT_GLOBAL)
955
pthread_mutex_lock(&LOCK_global_system_variables);
956
global_system_variables.*offset=
957
(size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
958
option_limits, ¬_used);
959
pthread_mutex_unlock(&LOCK_global_system_variables);
962
session->variables.*offset= global_system_variables.*offset;
966
unsigned char *sys_var_session_size_t::value_ptr(Session *session,
970
if (type == OPT_GLOBAL)
971
return (unsigned char*) &(global_system_variables.*offset);
972
return (unsigned char*) &(session->variables.*offset);
976
bool sys_var_session_bool::update(Session *session, set_var *var)
978
if (var->type == OPT_GLOBAL)
979
global_system_variables.*offset= (bool) var->save_result.uint32_t_value;
981
session->variables.*offset= (bool) var->save_result.uint32_t_value;
986
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
988
if (type == OPT_GLOBAL)
989
global_system_variables.*offset= (bool) option_limits->def_value;
991
session->variables.*offset= global_system_variables.*offset;
995
unsigned char *sys_var_session_bool::value_ptr(Session *session,
999
if (type == OPT_GLOBAL)
1000
return (unsigned char*) &(global_system_variables.*offset);
1001
return (unsigned char*) &(session->variables.*offset);
1005
bool sys_var::check_enum(Session *,
1333
thd->variables.*offset= global_system_variables.*offset;
1337
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
1338
LEX_STRING *base __attribute__((__unused__)))
1340
if (type == OPT_GLOBAL)
1341
return (uchar*) &(global_system_variables.*offset);
1342
return (uchar*) &(thd->variables.*offset);
1346
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1348
if (var->type == OPT_GLOBAL)
1349
global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1351
thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1356
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1358
if (type == OPT_GLOBAL)
1359
global_system_variables.*offset= (my_bool) option_limits->def_value;
1361
thd->variables.*offset= global_system_variables.*offset;
1365
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1366
LEX_STRING *base __attribute__((__unused__)))
1368
if (type == OPT_GLOBAL)
1369
return (uchar*) &(global_system_variables.*offset);
1370
return (uchar*) &(thd->variables.*offset);
1374
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1006
1375
set_var *var, const TYPELIB *enum_names)
1008
1377
char buff[STRING_BUFFER_USUAL_SIZE];
1225
bool sys_var_session_enum::update(Session *session, set_var *var)
1591
bool sys_var_thd_enum::update(THD *thd, set_var *var)
1227
1593
if (var->type == OPT_GLOBAL)
1228
global_system_variables.*offset= var->save_result.uint32_t_value;
1594
global_system_variables.*offset= var->save_result.ulong_value;
1230
session->variables.*offset= var->save_result.uint32_t_value;
1596
thd->variables.*offset= var->save_result.ulong_value;
1235
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1601
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
1237
1603
if (type == OPT_GLOBAL)
1238
global_system_variables.*offset= (uint32_t) option_limits->def_value;
1604
global_system_variables.*offset= (ulong) option_limits->def_value;
1240
session->variables.*offset= global_system_variables.*offset;
1606
thd->variables.*offset= global_system_variables.*offset;
1244
unsigned char *sys_var_session_enum::value_ptr(Session *session,
1610
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1611
LEX_STRING *base __attribute__((__unused__)))
1248
uint32_t tmp= ((type == OPT_GLOBAL) ?
1613
ulong tmp= ((type == OPT_GLOBAL) ?
1249
1614
global_system_variables.*offset :
1250
session->variables.*offset);
1251
return (unsigned char*) enum_names->type_names[tmp];
1254
bool sys_var_session_bit::check(Session *session, set_var *var)
1256
return (check_enum(session, var, &bool_typelib) ||
1257
(check_func && (*check_func)(session, var)));
1260
bool sys_var_session_bit::update(Session *session, set_var *var)
1262
int res= (*update_func)(session, var);
1615
thd->variables.*offset);
1616
return (uchar*) enum_names->type_names[tmp];
1619
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1621
return (check_enum(thd, var, &bool_typelib) ||
1622
(check_func && (*check_func)(thd, var)));
1625
bool sys_var_thd_bit::update(THD *thd, set_var *var)
1627
int res= (*update_func)(thd, var);
1267
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type,
1632
uchar *sys_var_thd_bit::value_ptr(THD *thd,
1633
enum_var_type type __attribute__((__unused__)),
1634
LEX_STRING *base __attribute__((__unused__)))
1271
1637
If reverse is 0 (default) return 1 if bit is set.
1272
1638
If reverse is 1, return 0 if bit is set
1274
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ?
1640
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1275
1641
!reverse : reverse);
1276
return (unsigned char*) &session->sys_var_tmp.bool_value;
1642
return (uchar*) &thd->sys_var_tmp.my_bool_value;
1646
/** Update a date_time format variable based on given value. */
1648
void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
1649
DATE_TIME_FORMAT *new_value)
1651
DATE_TIME_FORMAT *old;
1653
if (type == OPT_GLOBAL)
1655
pthread_mutex_lock(&LOCK_global_system_variables);
1656
old= (global_system_variables.*offset);
1657
(global_system_variables.*offset)= new_value;
1658
pthread_mutex_unlock(&LOCK_global_system_variables);
1662
old= (thd->variables.*offset);
1663
(thd->variables.*offset)= new_value;
1665
my_free((char*) old, MYF(MY_ALLOW_ZERO_PTR));
1670
bool sys_var_thd_date_time_format::update(THD *thd, set_var *var)
1672
DATE_TIME_FORMAT *new_value;
1673
/* We must make a copy of the last value to get it into normal memory */
1674
new_value= date_time_format_copy((THD*) 0,
1675
var->save_result.date_time_format);
1677
return 1; // Out of memory
1678
update2(thd, var->type, new_value); // Can't fail
1683
bool sys_var_thd_date_time_format::check(THD *thd, set_var *var)
1685
char buff[STRING_BUFFER_USUAL_SIZE];
1686
String str(buff,sizeof(buff), system_charset_info), *res;
1687
DATE_TIME_FORMAT *format;
1689
if (!(res=var->value->val_str(&str)))
1690
res= &my_empty_string;
1692
if (!(format= date_time_format_make(date_time_type,
1693
res->ptr(), res->length())))
1695
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr());
1700
We must copy result to thread space to not get a memory leak if
1703
var->save_result.date_time_format= date_time_format_copy(thd, format);
1704
my_free((char*) format, MYF(0));
1705
return var->save_result.date_time_format == 0;
1709
void sys_var_thd_date_time_format::set_default(THD *thd, enum_var_type type)
1711
DATE_TIME_FORMAT *res= 0;
1713
if (type == OPT_GLOBAL)
1716
if ((format= opt_date_time_formats[date_time_type]))
1717
res= date_time_format_make(date_time_type, format, strlen(format));
1721
/* Make copy with malloc */
1722
res= date_time_format_copy((THD *) 0, global_system_variables.*offset);
1725
if (res) // Should always be true
1726
update2(thd, type, res);
1730
uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
1731
LEX_STRING *base __attribute__((__unused__)))
1733
if (type == OPT_GLOBAL)
1737
We do a copy here just to be sure things will work even if someone
1738
is modifying the original string while the copy is accessed
1739
(Can't happen now in SQL SHOW, but this is a good safety for the future)
1741
res= thd->strmake((global_system_variables.*offset)->format.str,
1742
(global_system_variables.*offset)->format.length);
1743
return (uchar*) res;
1745
return (uchar*) (thd->variables.*offset)->format.str;
2131
bool sys_var_log_state::update(THD *thd, set_var *var)
2134
pthread_mutex_lock(&LOCK_global_system_variables);
2135
if (!var->save_result.ulong_value)
2137
logger.deactivate_log_handler(thd, log_type);
2141
res= logger.activate_log_handler(thd, log_type);
2142
pthread_mutex_unlock(&LOCK_global_system_variables);
2146
void sys_var_log_state::set_default(THD *thd,
2147
enum_var_type type __attribute__((__unused__)))
2149
pthread_mutex_lock(&LOCK_global_system_variables);
2150
logger.deactivate_log_handler(thd, log_type);
2151
pthread_mutex_unlock(&LOCK_global_system_variables);
2155
static int sys_check_log_path(THD *thd __attribute__((__unused__)),
2158
char path[FN_REFLEN], buff[FN_REFLEN];
2160
String str(buff, sizeof(buff), system_charset_info), *res;
2161
const char *log_file_str;
2164
if (!(res= var->value->val_str(&str)))
2167
log_file_str= res->c_ptr();
2168
bzero(&f_stat, sizeof(struct stat));
2170
path_length= unpack_filename(path, log_file_str);
2174
/* File name is empty. */
2179
if (!stat(path, &f_stat))
2182
A file system object exists. Check if argument is a file and we have
2186
if (!MY_S_ISREG(f_stat.st_mode) ||
2187
!(f_stat.st_mode & MY_S_IWRITE))
2193
/* Get dirname of the file path. */
2194
(void) dirname_part(path, log_file_str, &path_length);
2196
/* Dirname is empty if file path is relative. */
2201
Check if directory exists and we have permission to create file and
2204
if (my_access(path, (F_OK|W_OK)))
2210
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2211
res ? log_file_str : "NULL");
2216
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
2217
sys_var_str *var_str,
2218
set_var *var, const char *log_ext,
2219
bool log_state, uint log_type)
2221
MYSQL_QUERY_LOG *file_log;
2222
char buff[FN_REFLEN];
2223
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2225
uint str_length= (var ? var->value->str_value.length() : 0);
2228
case QUERY_LOG_SLOW:
2229
file_log= logger.get_slow_log_file_handler();
2231
case QUERY_LOG_GENERAL:
2232
file_log= logger.get_log_file_handler();
2235
assert(0); // Impossible
2240
old_value= make_default_log_name(buff, log_ext);
2241
str_length= strlen(old_value);
2243
if (!(res= my_strndup(old_value, str_length, MYF(MY_FAE+MY_WME))))
2249
pthread_mutex_lock(&LOCK_global_system_variables);
2250
logger.lock_exclusive();
2252
if (file_log && log_state)
2254
old_value= var_str->value;
2255
var_str->value= res;
2256
var_str->value_length= str_length;
2257
my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
2258
if (file_log && log_state)
2261
case QUERY_LOG_SLOW:
2262
file_log->open_slow_log(sys_var_slow_log_path.value);
2264
case QUERY_LOG_GENERAL:
2265
file_log->open_query_log(sys_var_general_log_path.value);
2273
pthread_mutex_unlock(&LOCK_global_system_variables);
2280
static bool sys_update_general_log_path(THD *thd, set_var * var)
2282
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2283
var, ".log", opt_log, QUERY_LOG_GENERAL);
2287
static void sys_default_general_log_path(THD *thd,
2288
enum_var_type type __attribute__((__unused__)))
2290
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2291
0, ".log", opt_log, QUERY_LOG_GENERAL);
2295
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2297
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2298
var, "-slow.log", opt_slow_log,
2303
static void sys_default_slow_log_path(THD *thd,
2304
enum_var_type type __attribute__((__unused__)))
2306
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2307
0, "-slow.log", opt_slow_log,
2312
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
2315
pthread_mutex_lock(&LOCK_global_system_variables);
2316
logger.lock_exclusive();
2317
logger.init_slow_log(var->save_result.ulong_value);
2318
logger.init_general_log(var->save_result.ulong_value);
2319
*value= var->save_result.ulong_value;
2321
pthread_mutex_unlock(&LOCK_global_system_variables);
2326
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
2327
enum_var_type type __attribute__((__unused__)))
2329
pthread_mutex_lock(&LOCK_global_system_variables);
2330
logger.lock_exclusive();
2331
logger.init_slow_log(LOG_FILE);
2332
logger.init_general_log(LOG_FILE);
2335
pthread_mutex_unlock(&LOCK_global_system_variables);
2339
uchar *sys_var_log_output::value_ptr(THD *thd,
2340
enum_var_type type __attribute__((__unused__)),
2341
LEX_STRING *base __attribute__((__unused__)))
2344
String tmp(buff, sizeof(buff), &my_charset_latin1);
2349
for (uint i= 0; val; val>>= 1, i++)
2353
tmp.append(log_output_typelib.type_names[i],
2354
log_output_typelib.type_lengths[i]);
2359
if ((length= tmp.length()))
2361
return (uchar*) thd->strmake(tmp.ptr(), length);
2365
/*****************************************************************************
2366
Functions to handle SET NAMES and SET CHARACTER SET
2367
*****************************************************************************/
2369
int set_var_collation_client::check(THD *thd __attribute__((__unused__)))
2371
/* Currently, UCS-2 cannot be used as a client character set */
2372
if (character_set_client->mbminlen > 1)
2374
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
2375
character_set_client->csname);
2381
int set_var_collation_client::update(THD *thd)
2383
thd->variables.character_set_client= character_set_client;
2384
thd->variables.character_set_results= character_set_results;
2385
thd->variables.collation_connection= collation_connection;
2386
thd->update_charset();
2387
thd->protocol_text.init(thd);
1522
2391
/****************************************************************************/
1524
bool sys_var_timestamp::update(Session *session, set_var *var)
1526
session->set_time((time_t) var->save_result.uint64_t_value);
1531
void sys_var_timestamp::set_default(Session *session, enum_var_type)
1533
session->user_time=0;
1537
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type,
1540
session->sys_var_tmp.long_value= (long) session->start_time;
1541
return (unsigned char*) &session->sys_var_tmp.long_value;
1545
bool sys_var_last_insert_id::update(Session *session, set_var *var)
1547
session->first_successful_insert_id_in_prev_stmt=
1548
var->save_result.uint64_t_value;
1553
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
2393
bool sys_var_timestamp::update(THD *thd, set_var *var)
2395
thd->set_time((time_t) var->save_result.ulonglong_value);
2400
void sys_var_timestamp::set_default(THD *thd,
2401
enum_var_type type __attribute__((__unused__)))
2407
uchar *sys_var_timestamp::value_ptr(THD *thd,
2408
enum_var_type type __attribute__((__unused__)),
2409
LEX_STRING *base __attribute__((__unused__)))
2411
thd->sys_var_tmp.long_value= (long) thd->start_time;
2412
return (uchar*) &thd->sys_var_tmp.long_value;
2416
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2418
thd->first_successful_insert_id_in_prev_stmt=
2419
var->save_result.ulonglong_value;
2424
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
2425
enum_var_type type __attribute__((__unused__)),
2426
LEX_STRING *base __attribute__((__unused__)))
1558
2429
this tmp var makes it robust againt change of type of
1559
2430
read_first_successful_insert_id_in_prev_stmt().
1561
session->sys_var_tmp.uint64_t_value=
1562
session->read_first_successful_insert_id_in_prev_stmt();
1563
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1567
bool sys_var_session_time_zone::check(Session *session, set_var *var)
2432
thd->sys_var_tmp.ulonglong_value=
2433
thd->read_first_successful_insert_id_in_prev_stmt();
2434
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2438
bool sys_var_insert_id::update(THD *thd, set_var *var)
2440
thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
2445
uchar *sys_var_insert_id::value_ptr(THD *thd,
2446
enum_var_type type __attribute__((__unused__)),
2447
LEX_STRING *base __attribute__((__unused__)))
2449
thd->sys_var_tmp.ulonglong_value=
2450
thd->auto_inc_intervals_forced.minimum();
2451
return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2455
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2457
thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2461
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2463
thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2468
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
1569
2470
char buff[MAX_TIME_ZONE_NAME_LENGTH];
1570
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2471
String str(buff, sizeof(buff), &my_charset_latin1);
1571
2472
String *res= var->value->val_str(&str);
1573
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2474
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
1575
2476
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
1747
2695
pthread_mutex_unlock(&LOCK_global_system_variables);
1750
session->variables.*offset= microseconds;
2698
thd->variables.*offset= microseconds;
1754
unsigned char *sys_var_microseconds::value_ptr(Session *session,
2702
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2703
LEX_STRING *base __attribute__((__unused__)))
1758
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2705
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
1759
2706
global_system_variables.*offset :
1760
session->variables.*offset) / 1000000.0;
1761
return (unsigned char*) &session->tmp_double_value;
2707
thd->variables.*offset) / 1000000.0;
2708
return (uchar*) &thd->tmp_double_value;
1766
Functions to update session->options bits
2713
Functions to update thd->options bits
1769
static bool set_option_bit(Session *session, set_var *var)
2716
static bool set_option_bit(THD *thd, set_var *var)
1771
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var);
1772
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse)
1773
session->options&= ~sys_var->bit_flag;
2718
sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
2719
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
2720
thd->options&= ~sys_var->bit_flag;
1775
session->options|= sys_var->bit_flag;
2722
thd->options|= sys_var->bit_flag;
1780
static bool set_option_autocommit(Session *session, set_var *var)
2727
static bool set_option_autocommit(THD *thd, set_var *var)
1782
2729
/* The test is negative as the flag we use is NOT autocommit */
1784
uint64_t org_options= session->options;
2731
ulonglong org_options= thd->options;
1786
if (var->save_result.uint32_t_value != 0)
1787
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2733
if (var->save_result.ulong_value != 0)
2734
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
1789
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2736
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
1791
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2738
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
1793
2740
if ((org_options & OPTION_NOT_AUTOCOMMIT))
1795
2742
/* We changed to auto_commit mode */
1796
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
1797
session->transaction.all.modified_non_trans_table= false;
1798
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1799
if (ha_commit(session))
2743
thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
2744
thd->transaction.all.modified_non_trans_table= false;
2745
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
1804
session->transaction.all.modified_non_trans_table= false;
1805
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2751
thd->transaction.all.modified_non_trans_table= false;
2752
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1811
static int check_pseudo_thread_id(Session *, set_var *var)
1813
var->save_result.uint64_t_value= var->value->val_int();
1817
static unsigned char *get_warning_count(Session *session)
1819
session->sys_var_tmp.uint32_t_value=
1820
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
1821
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
1822
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
1823
return (unsigned char*) &session->sys_var_tmp.uint32_t_value;
1826
static unsigned char *get_error_count(Session *session)
1828
session->sys_var_tmp.uint32_t_value=
1829
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
1830
return (unsigned char*) &session->sys_var_tmp.uint32_t_value;
2758
static int check_log_update(THD *thd __attribute__((__unused__)),
2759
set_var *var __attribute__((__unused__)))
2764
static bool set_log_update(THD *thd __attribute__((__unused__)),
2765
set_var *var __attribute__((__unused__)))
2768
The update log is not supported anymore since 5.0.
2769
See sql/mysqld.cc/, comments in function init_server_components() for an
2770
explaination of the different warnings we send below
2773
if (opt_sql_bin_update)
2775
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2776
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2777
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2780
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2781
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2782
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2783
set_option_bit(thd, var);
2788
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2791
var->save_result.ulonglong_value= var->value->val_int();
2795
static uchar *get_warning_count(THD *thd)
2797
thd->sys_var_tmp.long_value=
2798
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
2799
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
2800
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
2801
return (uchar*) &thd->sys_var_tmp.long_value;
2804
static uchar *get_error_count(THD *thd)
2806
thd->sys_var_tmp.long_value=
2807
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
2808
return (uchar*) &thd->sys_var_tmp.long_value;