83
91
slave_exec_mode_names, (unsigned int *) slave_exec_mode_names_len
86
static bool sys_update_init_connect(THD*, set_var*);
87
static void sys_default_init_connect(THD*, enum_var_type type);
88
static bool sys_update_init_slave(THD*, set_var*);
89
static void sys_default_init_slave(THD*, enum_var_type type);
90
static bool set_option_bit(THD *thd, set_var *var);
91
static bool set_option_autocommit(THD *thd, set_var *var);
92
static int check_log_update(THD *thd, set_var *var);
93
static bool set_log_update(THD *thd, set_var *var);
94
static int check_pseudo_thread_id(THD *thd, set_var *var);
95
static void fix_low_priority_updates(THD *thd, enum_var_type type);
96
static int check_tx_isolation(THD *thd, set_var *var);
97
static void fix_tx_isolation(THD *thd, enum_var_type type);
98
static int check_completion_type(THD *thd, set_var *var);
99
static void fix_completion_type(THD *thd, enum_var_type type);
100
static void fix_net_read_timeout(THD *thd, enum_var_type type);
101
static void fix_net_write_timeout(THD *thd, enum_var_type type);
102
static void fix_net_retry_count(THD *thd, enum_var_type type);
103
static void fix_max_join_size(THD *thd, enum_var_type type);
104
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
105
static void fix_max_binlog_size(THD *thd, enum_var_type type);
106
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
107
static void fix_max_connections(THD *thd, enum_var_type type);
108
static void fix_thd_mem_root(THD *thd, enum_var_type type);
109
static void fix_trans_mem_root(THD *thd, enum_var_type type);
110
static void fix_server_id(THD *thd, enum_var_type type);
111
static uint64_t fix_unsigned(THD *, uint64_t, const struct my_option *);
112
static bool get_unsigned(THD *thd, set_var *var);
113
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
94
static bool sys_update_init_connect(Session*, set_var*);
95
static void sys_default_init_connect(Session*, enum_var_type type);
96
static bool sys_update_init_slave(Session*, set_var*);
97
static void sys_default_init_slave(Session*, enum_var_type type);
98
static bool set_option_bit(Session *session, set_var *var);
99
static bool set_option_autocommit(Session *session, set_var *var);
100
static int check_log_update(Session *session, set_var *var);
101
static int check_pseudo_thread_id(Session *session, set_var *var);
102
static void fix_low_priority_updates(Session *session, enum_var_type type);
103
static int check_tx_isolation(Session *session, set_var *var);
104
static void fix_tx_isolation(Session *session, enum_var_type type);
105
static int check_completion_type(Session *session, set_var *var);
106
static void fix_completion_type(Session *session, enum_var_type type);
107
static void fix_net_read_timeout(Session *session, enum_var_type type);
108
static void fix_net_write_timeout(Session *session, enum_var_type type);
109
static void fix_net_retry_count(Session *session, enum_var_type type);
110
static void fix_max_join_size(Session *session, enum_var_type type);
111
static void fix_myisam_max_sort_file_size(Session *session, enum_var_type type);
112
static void fix_max_binlog_size(Session *session, enum_var_type type);
113
static void fix_max_relay_log_size(Session *session, enum_var_type type);
114
static void fix_max_connections(Session *session, enum_var_type type);
115
static void fix_session_mem_root(Session *session, enum_var_type type);
116
static void fix_trans_mem_root(Session *session, enum_var_type type);
117
static void fix_server_id(Session *session, enum_var_type type);
118
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
119
static bool get_unsigned(Session *session, set_var *var);
120
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
114
121
const char *name, int64_t val);
115
static KEY_CACHE *create_key_cache(const char *name, uint length);
116
static uchar *get_error_count(THD *thd);
117
static uchar *get_warning_count(THD *thd);
118
static uchar *get_tmpdir(THD *thd);
119
static int sys_check_log_path(THD *thd, set_var *var);
120
static bool sys_update_general_log_path(THD *thd, set_var * var);
121
static void sys_default_general_log_path(THD *thd, enum_var_type type);
122
static bool sys_update_slow_log_path(THD *thd, set_var * var);
123
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
122
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
123
static unsigned char *get_error_count(Session *session);
124
static unsigned char *get_warning_count(Session *session);
125
static unsigned char *get_tmpdir(Session *session);
126
128
Variable definition list
146
148
static sys_var_const_str sys_basedir(&vars, "basedir", mysql_home);
147
149
static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size",
148
150
&binlog_cache_size);
149
static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format",
151
static sys_var_session_binlog_format sys_binlog_format(&vars, "binlog_format",
150
152
&SV::binlog_format);
151
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
153
static sys_var_session_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
152
154
&SV::bulk_insert_buff_size);
153
static sys_var_character_set_sv
154
sys_character_set_server(&vars, "character_set_server",
155
&SV::collation_server, &default_charset_info, 0,
156
sys_var::SESSION_VARIABLE_IN_BINLOG);
157
sys_var_const_str sys_charset_system(&vars, "character_set_system",
158
(char *)my_charset_utf8_general_ci.name);
159
static sys_var_character_set_database
160
sys_character_set_database(&vars, "character_set_database",
161
sys_var::SESSION_VARIABLE_IN_BINLOG);
162
static sys_var_character_set_client
163
sys_character_set_client(&vars, "character_set_client",
164
&SV::character_set_client,
165
&default_charset_info,
166
sys_var::SESSION_VARIABLE_IN_BINLOG);
167
static sys_var_character_set_sv
168
sys_character_set_connection(&vars, "character_set_connection",
169
&SV::collation_connection,
170
&default_charset_info, 0,
171
sys_var::SESSION_VARIABLE_IN_BINLOG);
172
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
173
&SV::character_set_results,
174
&default_charset_info, true);
175
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
176
&SV::character_set_filesystem,
177
&character_set_filesystem);
178
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
155
static sys_var_session_ulong sys_completion_type(&vars, "completion_type",
179
156
&SV::completion_type,
180
157
check_completion_type,
181
158
fix_completion_type);
250
221
fix_max_connections);
251
222
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors",
252
223
&max_connect_errors);
253
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
224
static sys_var_session_ulong sys_max_error_count(&vars, "max_error_count",
254
225
&SV::max_error_count);
255
static sys_var_thd_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
226
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
256
227
&SV::max_heap_table_size);
257
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
228
static sys_var_session_uint64_t sys_pseudo_thread_id(&vars, "pseudo_thread_id",
258
229
&SV::pseudo_thread_id,
259
check_pseudo_thread_id, 0,
230
0, check_pseudo_thread_id,
260
231
sys_var::SESSION_VARIABLE_IN_BINLOG);
261
static sys_var_thd_ha_rows sys_max_join_size(&vars, "max_join_size",
232
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size",
262
233
&SV::max_join_size,
263
234
fix_max_join_size);
264
static sys_var_thd_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
235
static sys_var_session_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
265
236
&SV::max_seeks_for_key);
266
static sys_var_thd_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
237
static sys_var_session_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
267
238
&SV::max_length_for_sort_data);
268
239
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
269
240
&max_relay_log_size,
270
241
fix_max_relay_log_size);
271
static sys_var_thd_ulong sys_max_sort_length(&vars, "max_sort_length",
242
static sys_var_session_ulong sys_max_sort_length(&vars, "max_sort_length",
272
243
&SV::max_sort_length);
273
244
static sys_var_max_user_conn sys_max_user_connections(&vars, "max_user_connections");
274
static sys_var_thd_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
245
static sys_var_session_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
275
246
&SV::max_tmp_tables);
276
247
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
277
248
&max_write_lock_count);
278
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
249
static sys_var_session_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
279
250
&SV::min_examined_row_limit);
280
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);
281
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
282
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
251
static sys_var_session_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);
252
static sys_var_session_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
253
static sys_var_session_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
284
static sys_var_thd_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
255
static sys_var_session_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
285
256
&SV::myisam_stats_method,
286
257
&myisam_stats_method_typelib,
288
static sys_var_thd_ulong sys_net_buffer_length(&vars, "net_buffer_length",
259
static sys_var_session_ulong sys_net_buffer_length(&vars, "net_buffer_length",
289
260
&SV::net_buffer_length);
290
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
261
static sys_var_session_ulong sys_net_read_timeout(&vars, "net_read_timeout",
291
262
&SV::net_read_timeout,
292
263
0, fix_net_read_timeout);
293
static sys_var_thd_ulong sys_net_write_timeout(&vars, "net_write_timeout",
264
static sys_var_session_ulong sys_net_write_timeout(&vars, "net_write_timeout",
294
265
&SV::net_write_timeout,
295
266
0, fix_net_write_timeout);
296
static sys_var_thd_ulong sys_net_retry_count(&vars, "net_retry_count",
267
static sys_var_session_ulong sys_net_retry_count(&vars, "net_retry_count",
297
268
&SV::net_retry_count,
298
269
0, fix_net_retry_count);
299
static sys_var_thd_bool sys_new_mode(&vars, "new", &SV::new_mode);
270
static sys_var_session_bool sys_new_mode(&vars, "new", &SV::new_mode);
300
271
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
301
272
&global_system_variables.old_mode);
302
273
/* these two cannot be static */
303
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
274
sys_var_session_bool sys_old_alter_table(&vars, "old_alter_table",
304
275
&SV::old_alter_table);
305
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
276
static sys_var_session_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
306
277
&SV::optimizer_prune_level);
307
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
278
static sys_var_session_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
308
279
&SV::optimizer_search_depth);
310
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
281
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
311
282
TYPELIB optimizer_use_mrr_typelib= {
312
283
array_elements(optimizer_use_mrr_names) - 1, "",
313
284
optimizer_use_mrr_names, NULL
316
static sys_var_thd_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
287
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
317
288
&SV::optimizer_use_mrr,
318
289
&optimizer_use_mrr_typelib,
321
static sys_var_thd_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
292
static sys_var_session_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
322
293
&SV::preload_buff_size);
323
static sys_var_thd_ulong sys_read_buff_size(&vars, "read_buffer_size",
294
static sys_var_session_ulong sys_read_buff_size(&vars, "read_buffer_size",
324
295
&SV::read_buff_size);
325
296
static sys_var_opt_readonly sys_readonly(&vars, "read_only", &opt_readonly);
326
static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
297
static sys_var_session_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
327
298
&SV::read_rnd_buff_size);
328
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
299
static sys_var_session_ulong sys_div_precincrement(&vars, "div_precision_increment",
329
300
&SV::div_precincrement);
330
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
333
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
302
static sys_var_session_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
334
303
&SV::range_alloc_block_size);
335
static sys_var_thd_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
304
static sys_var_session_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
336
305
&SV::query_alloc_block_size,
337
0, fix_thd_mem_root);
338
static sys_var_thd_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
306
0, fix_session_mem_root);
307
static sys_var_session_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
339
308
&SV::query_prealloc_size,
340
0, fix_thd_mem_root);
309
0, fix_session_mem_root);
341
310
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
342
static sys_var_thd_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
311
static sys_var_session_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
343
312
&SV::trans_alloc_block_size,
344
313
0, fix_trans_mem_root);
345
static sys_var_thd_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
314
static sys_var_session_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
346
315
&SV::trans_prealloc_size,
347
316
0, fix_trans_mem_root);
349
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
350
318
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
351
319
&opt_secure_file_priv);
352
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
320
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id,
353
323
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
354
324
&opt_slave_compressed_protocol);
355
#ifdef HAVE_REPLICATION
356
325
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
357
326
&slave_allow_batching);
358
327
static sys_var_set_slave_mode slave_exec_mode(&vars,
388
356
&thread_cache_size);
389
357
sys_var_long_ptr sys_thread_pool_size(&vars, "thread_pool_size",
390
358
&thread_pool_size);
391
static sys_var_thd_enum sys_tx_isolation(&vars, "tx_isolation",
359
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation",
392
360
&SV::tx_isolation,
393
361
&tx_isolation_typelib,
394
362
fix_tx_isolation,
395
363
check_tx_isolation);
396
static sys_var_thd_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
364
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
397
365
&SV::tmp_table_size);
398
366
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
399
367
static sys_var_const_str sys_version(&vars, "version", server_version);
400
368
static sys_var_const_str sys_version_comment(&vars, "version_comment",
401
DRIZZLE_COMPILATION_COMMENT);
369
COMPILATION_COMMENT);
402
370
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
404
372
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
406
static sys_var_thd_ulong sys_net_wait_timeout(&vars, "wait_timeout",
374
static sys_var_session_ulong sys_net_wait_timeout(&vars, "wait_timeout",
407
375
&SV::net_wait_timeout);
409
377
/* Condition pushdown to storage engine */
410
static sys_var_thd_bool
378
static sys_var_session_bool
411
379
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
412
380
&SV::engine_condition_pushdown);
414
382
/* Time/date/datetime formats */
416
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
384
static sys_var_session_date_time_format sys_time_format(&vars, "time_format",
417
385
&SV::time_format,
418
386
DRIZZLE_TIMESTAMP_TIME);
419
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
387
static sys_var_session_date_time_format sys_date_format(&vars, "date_format",
420
388
&SV::date_format,
421
389
DRIZZLE_TIMESTAMP_DATE);
422
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
390
static sys_var_session_date_time_format sys_datetime_format(&vars, "datetime_format",
423
391
&SV::datetime_format,
424
392
DRIZZLE_TIMESTAMP_DATETIME);
426
/* Variables that are bits in THD */
394
/* Variables that are bits in Session */
428
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
396
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
429
397
set_option_autocommit,
430
398
OPTION_NOT_AUTOCOMMIT,
432
static sys_var_thd_bit sys_big_tables(&vars, "big_tables", 0,
435
#ifndef TO_BE_DELETED /* Alias for big_tables */
436
static sys_var_thd_bit sys_sql_big_tables(&vars, "sql_big_tables", 0,
440
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
400
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0,
442
402
OPTION_BIG_SELECTS);
443
static sys_var_thd_bit sys_log_off(&vars, "sql_log_off",
447
static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
451
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
403
static sys_var_session_bit sys_log_binlog(&vars, "sql_log_bin",
452
404
check_log_update,
455
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
407
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0,
457
409
OPTION_WARNINGS);
458
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
410
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0,
460
412
OPTION_SQL_NOTES);
461
static sys_var_thd_bit sys_auto_is_null(&vars, "sql_auto_is_null", 0,
463
OPTION_AUTO_IS_NULL, 0,
464
sys_var::SESSION_VARIABLE_IN_BINLOG);
465
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
413
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
467
415
OPTION_SAFE_UPDATES);
468
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
416
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
470
418
OPTION_BUFFER_RESULT);
471
static sys_var_thd_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
419
static sys_var_session_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
473
421
OPTION_QUOTE_SHOW_CREATE);
474
static sys_var_thd_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
422
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
476
424
OPTION_NO_FOREIGN_KEY_CHECKS,
477
425
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
478
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
426
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0,
480
428
OPTION_RELAXED_UNIQUE_CHECKS,
482
430
sys_var::SESSION_VARIABLE_IN_BINLOG);
483
431
/* Local state variables */
485
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
433
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit",
486
434
&SV::select_limit);
487
435
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
488
436
sys_var::SESSION_VARIABLE_IN_BINLOG);
533
481
static sys_var_rand_seed2 sys_rand_seed2(&vars, "rand_seed2",
534
482
sys_var::SESSION_VARIABLE_IN_BINLOG);
536
static sys_var_thd_ulong sys_default_week_format(&vars, "default_week_format",
484
static sys_var_session_ulong sys_default_week_format(&vars, "default_week_format",
537
485
&SV::default_week_format);
539
sys_var_thd_ulong sys_group_concat_max_len(&vars, "group_concat_max_len",
487
sys_var_session_ulong sys_group_concat_max_len(&vars, "group_concat_max_len",
540
488
&SV::group_concat_max_len);
542
sys_var_thd_time_zone sys_time_zone(&vars, "time_zone",
490
sys_var_session_time_zone sys_time_zone(&vars, "time_zone",
543
491
sys_var::SESSION_VARIABLE_IN_BINLOG);
545
493
/* Global read-only variable containing hostname */
546
494
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
548
496
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
549
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
550
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
552
static uchar *slave_get_report_port(THD *thd)
554
thd->sys_var_tmp.long_value= report_port;
555
return (uchar*) &thd->sys_var_tmp.long_value;
558
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
560
sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
498
sys_var_session_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
561
499
&SV::keep_files_on_create);
562
500
/* Read only variables */
564
502
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
565
503
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
566
/* Global variables which enable|disable logging */
567
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
569
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
570
static sys_var_log_state sys_var_log(&vars, "log", &opt_log, QUERY_LOG_GENERAL);
571
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
573
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
574
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
575
&opt_slow_log, QUERY_LOG_SLOW);
576
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
577
sys_update_general_log_path,
578
sys_default_general_log_path,
580
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
581
sys_update_slow_log_path,
582
sys_default_slow_log_path,
584
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
585
&log_output_typelib, 0);
589
505
Additional variables (not derived from sys_var class, not accessible as
590
506
@@varname in SELECT or SET). Sorted in alphabetical order to facilitate
920
815
If we don't have row-based replication compiled in, the variable
921
816
is always read-only.
923
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) &&
924
thd->temporary_tables)
818
if ((session->variables.binlog_format == BINLOG_FORMAT_ROW) &&
819
session->temporary_tables)
926
821
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
930
if in a stored function/trigger, it's too late to change mode
932
if (thd->in_sub_stmt)
934
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
937
return sys_var_thd_enum::is_readonly();
825
return sys_var_session_enum::is_readonly();
941
void fix_binlog_format_after_update(THD *thd,
942
enum_var_type type __attribute__((unused)))
829
void fix_binlog_format_after_update(Session *session, enum_var_type)
944
thd->reset_current_stmt_binlog_row_based();
831
session->reset_current_stmt_binlog_row_based();
948
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
949
enum_var_type type __attribute__((unused)))
835
static void fix_max_binlog_size(Session *, enum_var_type)
951
837
mysql_bin_log.set_max_size(max_binlog_size);
952
#ifdef HAVE_REPLICATION
953
838
if (!max_relay_log_size)
954
839
active_mi->rli.relay_log.set_max_size(max_binlog_size);
959
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
960
enum_var_type type __attribute__((unused)))
843
static void fix_max_relay_log_size(Session *, enum_var_type)
962
#ifdef HAVE_REPLICATION
963
845
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
964
846
max_relay_log_size: max_binlog_size);
969
static void fix_max_connections(THD *thd __attribute__((unused)),
970
enum_var_type type __attribute__((unused)))
850
static void fix_max_connections(Session *, enum_var_type)
972
852
resize_thr_alarm(max_connections + 10);
976
static void fix_thd_mem_root(THD *thd, enum_var_type type)
978
if (type != OPT_GLOBAL)
979
reset_root_defaults(thd->mem_root,
980
thd->variables.query_alloc_block_size,
981
thd->variables.query_prealloc_size);
985
static void fix_trans_mem_root(THD *thd, enum_var_type type)
987
if (type != OPT_GLOBAL)
988
reset_root_defaults(&thd->transaction.mem_root,
989
thd->variables.trans_alloc_block_size,
990
thd->variables.trans_prealloc_size);
994
static void fix_server_id(THD *thd __attribute__((unused)),
995
enum_var_type type __attribute__((unused)))
856
static void fix_session_mem_root(Session *session, enum_var_type type)
858
if (type != OPT_GLOBAL)
859
reset_root_defaults(session->mem_root,
860
session->variables.query_alloc_block_size,
861
session->variables.query_prealloc_size);
865
static void fix_trans_mem_root(Session *session, enum_var_type type)
867
if (type != OPT_GLOBAL)
868
reset_root_defaults(&session->transaction.mem_root,
869
session->variables.trans_alloc_block_size,
870
session->variables.trans_prealloc_size);
874
static void fix_server_id(Session *session, enum_var_type)
997
876
server_id_supplied = 1;
998
thd->server_id= server_id;
877
session->server_id= server_id;
1002
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
881
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
1003
882
const char *name, int64_t val)
1116
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
1013
bool sys_var_bool_ptr::update(Session *, set_var *var)
1118
*value= (bool) var->save_result.ulong_value;
1015
*value= (bool) var->save_result.uint32_t_value;
1123
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
1020
void sys_var_bool_ptr::set_default(Session *, enum_var_type)
1125
1022
*value= (bool) option_limits->def_value;
1129
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
1026
bool sys_var_enum::update(Session *, set_var *var)
1131
*value= (uint) var->save_result.ulong_value;
1028
*value= (uint) var->save_result.uint32_t_value;
1136
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1137
enum_var_type type __attribute__((unused)),
1138
LEX_STRING *base __attribute__((unused)))
1140
return (uchar*) enum_names->type_names[*value];
1144
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1145
enum_var_type type __attribute__((unused)),
1146
LEX_STRING *base __attribute__((unused)))
1148
return (uchar*) enum_names->type_names[global_system_variables.*offset];
1151
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1153
return (get_unsigned(thd, var) ||
1154
(check_func && (*check_func)(thd, var)));
1157
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1033
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, LEX_STRING *)
1035
return (unsigned char*) enum_names->type_names[*value];
1039
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type,
1042
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1045
bool sys_var_session_ulong::check(Session *session, set_var *var)
1047
return (get_unsigned(session, var) ||
1048
(check_func && (*check_func)(session, var)));
1051
bool sys_var_session_ulong::update(Session *session, set_var *var)
1159
1053
uint64_t tmp= var->save_result.uint64_t_value;
1161
1055
/* Don't use bigger value than given with --maximum-variable-name=.. */
1162
1056
if ((ulong) tmp > max_system_variables.*offset)
1164
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1058
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1165
1059
tmp= max_system_variables.*offset;
1168
1062
if (option_limits)
1169
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1170
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1171
else if (tmp > ULONG_MAX)
1063
tmp= (ulong) fix_unsigned(session, tmp, option_limits);
1064
else if (tmp > UINT32_MAX)
1174
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1067
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value);
1178
1070
if (var->type == OPT_GLOBAL)
1179
1071
global_system_variables.*offset= (ulong) tmp;
1181
thd->variables.*offset= (ulong) tmp;
1073
session->variables.*offset= (ulong) tmp;
1187
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
1079
void sys_var_session_ulong::set_default(Session *session, enum_var_type type)
1189
1081
if (type == OPT_GLOBAL)
1295
1190
pthread_mutex_unlock(&LOCK_global_system_variables);
1298
thd->variables.*offset= global_system_variables.*offset;
1193
session->variables.*offset= global_system_variables.*offset;
1302
uchar *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1303
LEX_STRING *base __attribute__((unused)))
1197
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session,
1305
1201
if (type == OPT_GLOBAL)
1306
return (uchar*) &(global_system_variables.*offset);
1307
return (uchar*) &(thd->variables.*offset);
1202
return (unsigned char*) &(global_system_variables.*offset);
1203
return (unsigned char*) &(session->variables.*offset);
1311
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1207
bool sys_var_session_bool::update(Session *session, set_var *var)
1313
1209
if (var->type == OPT_GLOBAL)
1314
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1210
global_system_variables.*offset= (bool) var->save_result.uint32_t_value;
1316
thd->variables.*offset= (bool) var->save_result.ulong_value;
1212
session->variables.*offset= (bool) var->save_result.uint32_t_value;
1321
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1217
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
1323
1219
if (type == OPT_GLOBAL)
1324
1220
global_system_variables.*offset= (bool) option_limits->def_value;
1326
thd->variables.*offset= global_system_variables.*offset;
1222
session->variables.*offset= global_system_variables.*offset;
1330
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1331
LEX_STRING *base __attribute__((unused)))
1226
unsigned char *sys_var_session_bool::value_ptr(Session *session,
1333
1230
if (type == OPT_GLOBAL)
1334
return (uchar*) &(global_system_variables.*offset);
1335
return (uchar*) &(thd->variables.*offset);
1231
return (unsigned char*) &(global_system_variables.*offset);
1232
return (unsigned char*) &(session->variables.*offset);
1339
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1236
bool sys_var::check_enum(Session *,
1340
1237
set_var *var, const TYPELIB *enum_names)
1342
1239
char buff[STRING_BUFFER_USUAL_SIZE];
1556
bool sys_var_thd_enum::update(THD *thd, set_var *var)
1449
bool sys_var_session_enum::update(Session *session, set_var *var)
1558
1451
if (var->type == OPT_GLOBAL)
1559
global_system_variables.*offset= var->save_result.ulong_value;
1452
global_system_variables.*offset= var->save_result.uint32_t_value;
1561
thd->variables.*offset= var->save_result.ulong_value;
1454
session->variables.*offset= var->save_result.uint32_t_value;
1566
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
1459
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1568
1461
if (type == OPT_GLOBAL)
1569
1462
global_system_variables.*offset= (ulong) option_limits->def_value;
1571
thd->variables.*offset= global_system_variables.*offset;
1464
session->variables.*offset= global_system_variables.*offset;
1575
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1576
LEX_STRING *base __attribute__((unused)))
1468
unsigned char *sys_var_session_enum::value_ptr(Session *session,
1578
1472
ulong tmp= ((type == OPT_GLOBAL) ?
1579
1473
global_system_variables.*offset :
1580
thd->variables.*offset);
1581
return (uchar*) enum_names->type_names[tmp];
1584
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1586
return (check_enum(thd, var, &bool_typelib) ||
1587
(check_func && (*check_func)(thd, var)));
1590
bool sys_var_thd_bit::update(THD *thd, set_var *var)
1592
int res= (*update_func)(thd, var);
1474
session->variables.*offset);
1475
return (unsigned char*) enum_names->type_names[tmp];
1478
bool sys_var_session_bit::check(Session *session, set_var *var)
1480
return (check_enum(session, var, &bool_typelib) ||
1481
(check_func && (*check_func)(session, var)));
1484
bool sys_var_session_bit::update(Session *session, set_var *var)
1486
int res= (*update_func)(session, var);
1597
uchar *sys_var_thd_bit::value_ptr(THD *thd,
1598
enum_var_type type __attribute__((unused)),
1599
LEX_STRING *base __attribute__((unused)))
1491
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type,
1602
1495
If reverse is 0 (default) return 1 if bit is set.
1603
1496
If reverse is 1, return 0 if bit is set
1605
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1498
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ?
1606
1499
!reverse : reverse);
1607
return (uchar*) &thd->sys_var_tmp.bool_value;
1500
return (unsigned char*) &session->sys_var_tmp.bool_value;
1611
1504
/** Update a date_time format variable based on given value. */
1613
void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
1506
void sys_var_session_date_time_format::update2(Session *session, enum_var_type type,
1614
1507
DATE_TIME_FORMAT *new_value)
1616
1509
DATE_TIME_FORMAT *old;
1794
bool sys_var_character_set::update(THD *thd, set_var *var)
1796
ci_ptr(thd,var->type)[0]= var->save_result.charset;
1797
thd->update_charset();
1802
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1803
LEX_STRING *base __attribute__((unused)))
1805
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1806
return cs ? (uchar*) cs->csname : (uchar*) NULL;
1810
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1812
if (type == OPT_GLOBAL)
1813
global_system_variables.*offset= *global_default;
1816
thd->variables.*offset= global_system_variables.*offset;
1817
thd->update_charset();
1820
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1822
if (type == OPT_GLOBAL)
1823
return &(global_system_variables.*offset);
1825
return &(thd->variables.*offset);
1829
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1831
if (sys_var_character_set_sv::check(thd, var))
1833
/* Currently, UCS-2 cannot be used as a client character set */
1834
if (var->save_result.charset->mbminlen > 1)
1836
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1837
var->save_result.charset->csname);
1844
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1847
if (type == OPT_GLOBAL)
1848
return &global_system_variables.collation_database;
1850
return &thd->variables.collation_database;
1854
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1856
if (type == OPT_GLOBAL)
1857
global_system_variables.collation_database= default_charset_info;
1860
thd->variables.collation_database= thd->db_charset;
1861
thd->update_charset();
1866
bool sys_var_collation_sv::update(THD *thd, set_var *var)
1686
bool sys_var_character_set::update(Session *session, set_var *var)
1688
ci_ptr(session,var->type)[0]= var->save_result.charset;
1689
session->update_charset();
1694
unsigned char *sys_var_character_set::value_ptr(Session *session,
1698
const CHARSET_INFO * const cs= ci_ptr(session,type)[0];
1699
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1703
bool sys_var_collation_sv::update(Session *session, set_var *var)
1868
1705
if (var->type == OPT_GLOBAL)
1869
1706
global_system_variables.*offset= var->save_result.charset;
1872
thd->variables.*offset= var->save_result.charset;
1873
thd->update_charset();
1709
session->variables.*offset= var->save_result.charset;
1710
session->update_charset();
1879
void sys_var_collation_sv::set_default(THD *thd, enum_var_type type)
1716
void sys_var_collation_sv::set_default(Session *session, enum_var_type type)
1881
1718
if (type == OPT_GLOBAL)
1882
1719
global_system_variables.*offset= *global_default;
1885
thd->variables.*offset= global_system_variables.*offset;
1886
thd->update_charset();
1722
session->variables.*offset= global_system_variables.*offset;
1723
session->update_charset();
1891
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1892
LEX_STRING *base __attribute__((unused)))
1728
unsigned char *sys_var_collation_sv::value_ptr(Session *session,
1894
1732
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1895
global_system_variables.*offset : thd->variables.*offset);
1896
return cs ? (uchar*) cs->name : (uchar*) "NULL";
1733
global_system_variables.*offset :
1734
session->variables.*offset);
1735
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
2067
bool sys_var_log_state::update(THD *thd, set_var *var)
1905
bool sys_var_log_state::update(Session *, set_var *var)
2070
1908
pthread_mutex_lock(&LOCK_global_system_variables);
2071
if (!var->save_result.ulong_value)
2073
logger.deactivate_log_handler(thd, log_type);
1909
if (!var->save_result.uint32_t_value)
2077
res= logger.activate_log_handler(thd, log_type);
2078
1913
pthread_mutex_unlock(&LOCK_global_system_variables);
2082
void sys_var_log_state::set_default(THD *thd,
2083
enum_var_type type __attribute__((unused)))
2085
pthread_mutex_lock(&LOCK_global_system_variables);
2086
logger.deactivate_log_handler(thd, log_type);
2087
pthread_mutex_unlock(&LOCK_global_system_variables);
2091
static int sys_check_log_path(THD *thd __attribute__((unused)),
2094
char path[FN_REFLEN], buff[FN_REFLEN];
2096
String str(buff, sizeof(buff), system_charset_info), *res;
2097
const char *log_file_str;
2100
if (!(res= var->value->val_str(&str)))
2103
log_file_str= res->c_ptr();
2104
memset(&f_stat, 0, sizeof(struct stat));
2106
path_length= unpack_filename(path, log_file_str);
2110
/* File name is empty. */
2115
if (!stat(path, &f_stat))
2118
A file system object exists. Check if argument is a file and we have
2122
if (!S_ISREG(f_stat.st_mode) ||
2123
!(f_stat.st_mode & S_IWRITE))
2129
/* Get dirname of the file path. */
2130
(void) dirname_part(path, log_file_str, &path_length);
2132
/* Dirname is empty if file path is relative. */
2137
Check if directory exists and we have permission to create file and
2140
if (my_access(path, (F_OK|W_OK)))
2146
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
2147
res ? log_file_str : "NULL");
2152
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
2153
sys_var_str *var_str,
1917
void sys_var_log_state::set_default(Session *, enum_var_type)
1922
bool update_sys_var_str_path(Session *, sys_var_str *var_str,
2154
1923
set_var *var, const char *log_ext,
2155
bool log_state, uint log_type)
1924
bool log_state, uint32_t log_type)
2157
DRIZZLE_QUERY_LOG *file_log;
2158
1926
char buff[FN_REFLEN];
2159
1927
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2160
1928
bool result= 0;
2161
uint str_length= (var ? var->value->str_value.length() : 0);
1929
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2163
1931
switch (log_type) {
2164
case QUERY_LOG_SLOW:
2165
file_log= logger.get_slow_log_file_handler();
2167
case QUERY_LOG_GENERAL:
2168
file_log= logger.get_log_file_handler();
2171
1933
assert(0); // Impossible
2216
static bool sys_update_general_log_path(THD *thd, set_var * var)
2218
return update_sys_var_str_path(thd, &sys_var_general_log_path,
2219
var, ".log", opt_log, QUERY_LOG_GENERAL);
2223
static void sys_default_general_log_path(THD *thd,
2224
enum_var_type type __attribute__((unused)))
2226
(void) update_sys_var_str_path(thd, &sys_var_general_log_path,
2227
0, ".log", opt_log, QUERY_LOG_GENERAL);
2231
static bool sys_update_slow_log_path(THD *thd, set_var * var)
2233
return update_sys_var_str_path(thd, &sys_var_slow_log_path,
2234
var, "-slow.log", opt_slow_log,
2239
static void sys_default_slow_log_path(THD *thd,
2240
enum_var_type type __attribute__((unused)))
2242
(void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
2243
0, "-slow.log", opt_slow_log,
2248
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
1970
bool sys_var_log_output::update(Session *, set_var *var)
2251
1972
pthread_mutex_lock(&LOCK_global_system_variables);
2252
1973
logger.lock_exclusive();
2253
logger.init_slow_log(var->save_result.ulong_value);
2254
logger.init_general_log(var->save_result.ulong_value);
2255
*value= var->save_result.ulong_value;
1974
*value= var->save_result.uint32_t_value;
2256
1975
logger.unlock();
2257
1976
pthread_mutex_unlock(&LOCK_global_system_variables);
2262
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
2263
enum_var_type type __attribute__((unused)))
1981
void sys_var_log_output::set_default(Session *, enum_var_type)
2265
1983
pthread_mutex_lock(&LOCK_global_system_variables);
2266
1984
logger.lock_exclusive();
2267
logger.init_slow_log(LOG_FILE);
2268
logger.init_general_log(LOG_FILE);
2269
1985
*value= LOG_FILE;
2270
1986
logger.unlock();
2271
1987
pthread_mutex_unlock(&LOCK_global_system_variables);
2275
uchar *sys_var_log_output::value_ptr(THD *thd,
2276
enum_var_type type __attribute__((unused)),
2277
LEX_STRING *base __attribute__((unused)))
1991
unsigned char *sys_var_log_output::value_ptr(Session *session,
1992
enum_var_type, LEX_STRING *)
2279
1994
char buff[256];
2280
1995
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2317
int set_var_collation_client::update(THD *thd)
2032
int set_var_collation_client::update(Session *session)
2319
thd->variables.character_set_client= character_set_client;
2320
thd->variables.character_set_results= character_set_results;
2321
thd->variables.collation_connection= collation_connection;
2322
thd->update_charset();
2323
thd->protocol_text.init(thd);
2034
session->variables.character_set_client= character_set_client;
2035
session->variables.character_set_results= character_set_results;
2036
session->variables.collation_connection= collation_connection;
2037
session->update_charset();
2038
session->protocol_text.init(session);
2327
2042
/****************************************************************************/
2329
bool sys_var_timestamp::update(THD *thd, set_var *var)
2044
bool sys_var_timestamp::update(Session *session, set_var *var)
2331
thd->set_time((time_t) var->save_result.uint64_t_value);
2046
session->set_time((time_t) var->save_result.uint64_t_value);
2336
void sys_var_timestamp::set_default(THD *thd,
2337
enum_var_type type __attribute__((unused)))
2343
uchar *sys_var_timestamp::value_ptr(THD *thd,
2344
enum_var_type type __attribute__((unused)),
2345
LEX_STRING *base __attribute__((unused)))
2347
thd->sys_var_tmp.long_value= (long) thd->start_time;
2348
return (uchar*) &thd->sys_var_tmp.long_value;
2352
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2354
thd->first_successful_insert_id_in_prev_stmt=
2051
void sys_var_timestamp::set_default(Session *session, enum_var_type)
2053
session->user_time=0;
2057
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type,
2060
session->sys_var_tmp.long_value= (long) session->start_time;
2061
return (unsigned char*) &session->sys_var_tmp.long_value;
2065
bool sys_var_last_insert_id::update(Session *session, set_var *var)
2067
session->first_successful_insert_id_in_prev_stmt=
2355
2068
var->save_result.uint64_t_value;
2360
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
2361
enum_var_type type __attribute__((unused)),
2362
LEX_STRING *base __attribute__((unused)))
2073
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
2365
2078
this tmp var makes it robust againt change of type of
2366
2079
read_first_successful_insert_id_in_prev_stmt().
2368
thd->sys_var_tmp.uint64_t_value=
2369
thd->read_first_successful_insert_id_in_prev_stmt();
2370
return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2374
bool sys_var_insert_id::update(THD *thd, set_var *var)
2376
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2381
uchar *sys_var_insert_id::value_ptr(THD *thd,
2382
enum_var_type type __attribute__((unused)),
2383
LEX_STRING *base __attribute__((unused)))
2385
thd->sys_var_tmp.uint64_t_value=
2386
thd->auto_inc_intervals_forced.minimum();
2387
return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2391
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2393
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2397
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2399
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2404
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2081
session->sys_var_tmp.uint64_t_value=
2082
session->read_first_successful_insert_id_in_prev_stmt();
2083
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
2087
bool sys_var_insert_id::update(Session *session, set_var *var)
2089
session->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2094
unsigned char *sys_var_insert_id::value_ptr(Session *session, enum_var_type,
2097
session->sys_var_tmp.uint64_t_value=
2098
session->auto_inc_intervals_forced.minimum();
2099
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
2103
bool sys_var_rand_seed1::update(Session *session, set_var *var)
2105
session->rand.seed1= (ulong) var->save_result.uint64_t_value;
2109
bool sys_var_rand_seed2::update(Session *session, set_var *var)
2111
session->rand.seed2= (ulong) var->save_result.uint64_t_value;
2116
bool sys_var_session_time_zone::check(Session *session, set_var *var)
2406
2118
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2407
2119
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2408
2120
String *res= var->value->val_str(&str);
2410
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2122
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2412
2124
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
2631
2342
pthread_mutex_unlock(&LOCK_global_system_variables);
2634
thd->variables.*offset= microseconds;
2345
session->variables.*offset= microseconds;
2638
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2639
LEX_STRING *base __attribute__((unused)))
2349
unsigned char *sys_var_microseconds::value_ptr(Session *session,
2641
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2353
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2642
2354
global_system_variables.*offset :
2643
thd->variables.*offset) / 1000000.0;
2644
return (uchar*) &thd->tmp_double_value;
2355
session->variables.*offset) / 1000000.0;
2356
return (unsigned char*) &session->tmp_double_value;
2649
Functions to update thd->options bits
2361
Functions to update session->options bits
2652
static bool set_option_bit(THD *thd, set_var *var)
2364
static bool set_option_bit(Session *session, set_var *var)
2654
sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
2655
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
2656
thd->options&= ~sys_var->bit_flag;
2366
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var);
2367
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse)
2368
session->options&= ~sys_var->bit_flag;
2658
thd->options|= sys_var->bit_flag;
2370
session->options|= sys_var->bit_flag;
2663
static bool set_option_autocommit(THD *thd, set_var *var)
2375
static bool set_option_autocommit(Session *session, set_var *var)
2665
2377
/* The test is negative as the flag we use is NOT autocommit */
2667
uint64_t org_options= thd->options;
2379
uint64_t org_options= session->options;
2669
if (var->save_result.ulong_value != 0)
2670
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
2381
if (var->save_result.uint32_t_value != 0)
2382
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2672
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
2384
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2674
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
2386
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2676
2388
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2678
2390
/* We changed to auto_commit mode */
2679
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2680
thd->transaction.all.modified_non_trans_table= false;
2681
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2391
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2392
session->transaction.all.modified_non_trans_table= false;
2393
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
2394
if (ha_commit(session))
2687
thd->transaction.all.modified_non_trans_table= false;
2688
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2399
session->transaction.all.modified_non_trans_table= false;
2400
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2694
static int check_log_update(THD *thd __attribute__((unused)),
2695
set_var *var __attribute__((unused)))
2700
static bool set_log_update(THD *thd __attribute__((unused)),
2701
set_var *var __attribute__((unused)))
2704
The update log is not supported anymore since 5.0.
2705
See sql/mysqld.cc/, comments in function init_server_components() for an
2706
explaination of the different warnings we send below
2709
if (opt_sql_bin_update)
2711
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
2712
ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
2713
ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
2716
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
2717
ER_UPDATE_LOG_DEPRECATED_IGNORED,
2718
ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
2719
set_option_bit(thd, var);
2724
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2406
static int check_log_update(Session *, set_var *)
2412
static int check_pseudo_thread_id(Session *, set_var *var)
2727
2414
var->save_result.uint64_t_value= var->value->val_int();
2731
static uchar *get_warning_count(THD *thd)
2418
static unsigned char *get_warning_count(Session *session)
2733
thd->sys_var_tmp.long_value=
2734
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2735
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2736
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2737
return (uchar*) &thd->sys_var_tmp.long_value;
2420
session->sys_var_tmp.long_value=
2421
(session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2422
session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2423
session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2424
return (unsigned char*) &session->sys_var_tmp.long_value;
2740
static uchar *get_error_count(THD *thd)
2427
static unsigned char *get_error_count(Session *session)
2742
thd->sys_var_tmp.long_value=
2743
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2744
return (uchar*) &thd->sys_var_tmp.long_value;
2429
session->sys_var_tmp.long_value=
2430
session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2431
return (unsigned char*) &session->sys_var_tmp.long_value;