83
83
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 int check_pseudo_thread_id(THD *thd, set_var *var);
94
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
static int check_tx_isolation(THD *thd, set_var *var);
96
static void fix_tx_isolation(THD *thd, enum_var_type type);
97
static int check_completion_type(THD *thd, set_var *var);
98
static void fix_completion_type(THD *thd, enum_var_type type);
99
static void fix_net_read_timeout(THD *thd, enum_var_type type);
100
static void fix_net_write_timeout(THD *thd, enum_var_type type);
101
static void fix_net_retry_count(THD *thd, enum_var_type type);
102
static void fix_max_join_size(THD *thd, enum_var_type type);
103
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
104
static void fix_max_binlog_size(THD *thd, enum_var_type type);
105
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
106
static void fix_max_connections(THD *thd, enum_var_type type);
107
static void fix_thd_mem_root(THD *thd, enum_var_type type);
108
static void fix_trans_mem_root(THD *thd, enum_var_type type);
109
static void fix_server_id(THD *thd, enum_var_type type);
110
static uint64_t fix_unsigned(THD *, uint64_t, const struct my_option *);
111
static bool get_unsigned(THD *thd, set_var *var);
112
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
86
static bool sys_update_init_connect(Session*, set_var*);
87
static void sys_default_init_connect(Session*, enum_var_type type);
88
static bool sys_update_init_slave(Session*, set_var*);
89
static void sys_default_init_slave(Session*, enum_var_type type);
90
static bool set_option_bit(Session *session, set_var *var);
91
static bool set_option_autocommit(Session *session, set_var *var);
92
static int check_log_update(Session *session, set_var *var);
93
static int check_pseudo_thread_id(Session *session, set_var *var);
94
static void fix_low_priority_updates(Session *session, enum_var_type type);
95
static int check_tx_isolation(Session *session, set_var *var);
96
static void fix_tx_isolation(Session *session, enum_var_type type);
97
static int check_completion_type(Session *session, set_var *var);
98
static void fix_completion_type(Session *session, enum_var_type type);
99
static void fix_net_read_timeout(Session *session, enum_var_type type);
100
static void fix_net_write_timeout(Session *session, enum_var_type type);
101
static void fix_net_retry_count(Session *session, enum_var_type type);
102
static void fix_max_join_size(Session *session, enum_var_type type);
103
static void fix_myisam_max_sort_file_size(Session *session, enum_var_type type);
104
static void fix_max_binlog_size(Session *session, enum_var_type type);
105
static void fix_max_relay_log_size(Session *session, enum_var_type type);
106
static void fix_max_connections(Session *session, enum_var_type type);
107
static void fix_session_mem_root(Session *session, enum_var_type type);
108
static void fix_trans_mem_root(Session *session, enum_var_type type);
109
static void fix_server_id(Session *session, enum_var_type type);
110
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
111
static bool get_unsigned(Session *session, set_var *var);
112
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
113
113
const char *name, int64_t val);
114
114
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
115
static unsigned char *get_error_count(THD *thd);
116
static unsigned char *get_warning_count(THD *thd);
117
static unsigned char *get_tmpdir(THD *thd);
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);
120
120
Variable definition list
140
140
static sys_var_const_str sys_basedir(&vars, "basedir", mysql_home);
141
141
static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size",
142
142
&binlog_cache_size);
143
static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format",
143
static sys_var_session_binlog_format sys_binlog_format(&vars, "binlog_format",
144
144
&SV::binlog_format);
145
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
145
static sys_var_session_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
146
146
&SV::bulk_insert_buff_size);
147
static sys_var_character_set_sv
148
sys_character_set_server(&vars, "character_set_server",
149
&SV::collation_server, &default_charset_info, 0,
150
sys_var::SESSION_VARIABLE_IN_BINLOG);
151
sys_var_const_str sys_charset_system(&vars, "character_set_system",
152
(char *)my_charset_utf8_general_ci.name);
153
static sys_var_character_set_database
154
sys_character_set_database(&vars, "character_set_database",
155
sys_var::SESSION_VARIABLE_IN_BINLOG);
156
static sys_var_character_set_client
157
sys_character_set_client(&vars, "character_set_client",
158
&SV::character_set_client,
159
&default_charset_info,
160
sys_var::SESSION_VARIABLE_IN_BINLOG);
161
static sys_var_character_set_sv
162
sys_character_set_connection(&vars, "character_set_connection",
163
&SV::collation_connection,
164
&default_charset_info, 0,
165
sys_var::SESSION_VARIABLE_IN_BINLOG);
166
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
167
&SV::character_set_results,
168
&default_charset_info, true);
169
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
170
&SV::character_set_filesystem,
171
&character_set_filesystem);
172
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
147
static sys_var_session_ulong sys_completion_type(&vars, "completion_type",
173
148
&SV::completion_type,
174
149
check_completion_type,
175
150
fix_completion_type);
218
193
param_age_threshold));
219
194
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
220
195
&opt_local_infile);
221
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
196
static sys_var_session_bool sys_low_priority_updates(&vars, "low_priority_updates",
222
197
&SV::low_priority_updates,
223
198
fix_low_priority_updates);
224
199
#ifndef TO_BE_DELETED /* Alias for the low_priority_updates */
225
static sys_var_thd_bool sys_sql_low_priority_updates(&vars, "sql_low_priority_updates",
200
static sys_var_session_bool sys_sql_low_priority_updates(&vars, "sql_low_priority_updates",
226
201
&SV::low_priority_updates,
227
202
fix_low_priority_updates);
229
static sys_var_thd_ulong sys_max_allowed_packet(&vars, "max_allowed_packet",
204
static sys_var_session_ulong sys_max_allowed_packet(&vars, "max_allowed_packet",
230
205
&SV::max_allowed_packet);
231
206
static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
232
207
&max_binlog_cache_size);
238
213
fix_max_connections);
239
214
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors",
240
215
&max_connect_errors);
241
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
216
static sys_var_session_ulong sys_max_error_count(&vars, "max_error_count",
242
217
&SV::max_error_count);
243
static sys_var_thd_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
218
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
244
219
&SV::max_heap_table_size);
245
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
220
static sys_var_session_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
246
221
&SV::pseudo_thread_id,
247
222
check_pseudo_thread_id, 0,
248
223
sys_var::SESSION_VARIABLE_IN_BINLOG);
249
static sys_var_thd_ha_rows sys_max_join_size(&vars, "max_join_size",
224
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size",
250
225
&SV::max_join_size,
251
226
fix_max_join_size);
252
static sys_var_thd_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
227
static sys_var_session_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
253
228
&SV::max_seeks_for_key);
254
static sys_var_thd_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
229
static sys_var_session_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
255
230
&SV::max_length_for_sort_data);
256
231
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
257
232
&max_relay_log_size,
258
233
fix_max_relay_log_size);
259
static sys_var_thd_ulong sys_max_sort_length(&vars, "max_sort_length",
234
static sys_var_session_ulong sys_max_sort_length(&vars, "max_sort_length",
260
235
&SV::max_sort_length);
261
236
static sys_var_max_user_conn sys_max_user_connections(&vars, "max_user_connections");
262
static sys_var_thd_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
237
static sys_var_session_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
263
238
&SV::max_tmp_tables);
264
239
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
265
240
&max_write_lock_count);
266
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
241
static sys_var_session_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
267
242
&SV::min_examined_row_limit);
268
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);
269
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
270
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
243
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);
244
static sys_var_session_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
static sys_var_session_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
272
static sys_var_thd_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
247
static sys_var_session_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
273
248
&SV::myisam_stats_method,
274
249
&myisam_stats_method_typelib,
276
static sys_var_thd_ulong sys_net_buffer_length(&vars, "net_buffer_length",
251
static sys_var_session_ulong sys_net_buffer_length(&vars, "net_buffer_length",
277
252
&SV::net_buffer_length);
278
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
253
static sys_var_session_ulong sys_net_read_timeout(&vars, "net_read_timeout",
279
254
&SV::net_read_timeout,
280
255
0, fix_net_read_timeout);
281
static sys_var_thd_ulong sys_net_write_timeout(&vars, "net_write_timeout",
256
static sys_var_session_ulong sys_net_write_timeout(&vars, "net_write_timeout",
282
257
&SV::net_write_timeout,
283
258
0, fix_net_write_timeout);
284
static sys_var_thd_ulong sys_net_retry_count(&vars, "net_retry_count",
259
static sys_var_session_ulong sys_net_retry_count(&vars, "net_retry_count",
285
260
&SV::net_retry_count,
286
261
0, fix_net_retry_count);
287
static sys_var_thd_bool sys_new_mode(&vars, "new", &SV::new_mode);
262
static sys_var_session_bool sys_new_mode(&vars, "new", &SV::new_mode);
288
263
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
289
264
&global_system_variables.old_mode);
290
265
/* these two cannot be static */
291
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
266
sys_var_session_bool sys_old_alter_table(&vars, "old_alter_table",
292
267
&SV::old_alter_table);
293
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
268
static sys_var_session_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
294
269
&SV::optimizer_prune_level);
295
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
270
static sys_var_session_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
296
271
&SV::optimizer_search_depth);
298
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
301
276
optimizer_use_mrr_names, NULL
304
static sys_var_thd_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
279
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
305
280
&SV::optimizer_use_mrr,
306
281
&optimizer_use_mrr_typelib,
309
static sys_var_thd_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
284
static sys_var_session_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
310
285
&SV::preload_buff_size);
311
static sys_var_thd_ulong sys_read_buff_size(&vars, "read_buffer_size",
286
static sys_var_session_ulong sys_read_buff_size(&vars, "read_buffer_size",
312
287
&SV::read_buff_size);
313
288
static sys_var_opt_readonly sys_readonly(&vars, "read_only", &opt_readonly);
314
static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
289
static sys_var_session_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
315
290
&SV::read_rnd_buff_size);
316
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
291
static sys_var_session_ulong sys_div_precincrement(&vars, "div_precision_increment",
317
292
&SV::div_precincrement);
318
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
321
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
294
static sys_var_session_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
322
295
&SV::range_alloc_block_size);
323
static sys_var_thd_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
296
static sys_var_session_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
324
297
&SV::query_alloc_block_size,
325
0, fix_thd_mem_root);
326
static sys_var_thd_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
298
0, fix_session_mem_root);
299
static sys_var_session_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
327
300
&SV::query_prealloc_size,
328
0, fix_thd_mem_root);
301
0, fix_session_mem_root);
329
302
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
330
static sys_var_thd_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
303
static sys_var_session_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
331
304
&SV::trans_alloc_block_size,
332
305
0, fix_trans_mem_root);
333
static sys_var_thd_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
306
static sys_var_session_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
334
307
&SV::trans_prealloc_size,
335
308
0, fix_trans_mem_root);
337
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
338
310
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
339
311
&opt_secure_file_priv);
340
312
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
390
362
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
392
static sys_var_thd_ulong sys_net_wait_timeout(&vars, "wait_timeout",
364
static sys_var_session_ulong sys_net_wait_timeout(&vars, "wait_timeout",
393
365
&SV::net_wait_timeout);
395
367
/* Condition pushdown to storage engine */
396
static sys_var_thd_bool
368
static sys_var_session_bool
397
369
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
398
370
&SV::engine_condition_pushdown);
400
372
/* Time/date/datetime formats */
402
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
374
static sys_var_session_date_time_format sys_time_format(&vars, "time_format",
403
375
&SV::time_format,
404
376
DRIZZLE_TIMESTAMP_TIME);
405
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
377
static sys_var_session_date_time_format sys_date_format(&vars, "date_format",
406
378
&SV::date_format,
407
379
DRIZZLE_TIMESTAMP_DATE);
408
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
380
static sys_var_session_date_time_format sys_datetime_format(&vars, "datetime_format",
409
381
&SV::datetime_format,
410
382
DRIZZLE_TIMESTAMP_DATETIME);
412
/* Variables that are bits in THD */
384
/* Variables that are bits in Session */
414
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
386
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
415
387
set_option_autocommit,
416
388
OPTION_NOT_AUTOCOMMIT,
418
static sys_var_thd_bit sys_big_tables(&vars, "big_tables", 0,
421
#ifndef TO_BE_DELETED /* Alias for big_tables */
422
static sys_var_thd_bit sys_sql_big_tables(&vars, "sql_big_tables", 0,
426
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
390
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0,
428
392
OPTION_BIG_SELECTS);
429
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
393
static sys_var_session_bit sys_log_binlog(&vars, "sql_log_bin",
430
394
check_log_update,
433
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
397
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0,
435
399
OPTION_WARNINGS);
436
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
400
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0,
438
402
OPTION_SQL_NOTES);
439
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
403
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
441
405
OPTION_SAFE_UPDATES);
442
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
406
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
444
408
OPTION_BUFFER_RESULT);
445
static sys_var_thd_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
409
static sys_var_session_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
447
411
OPTION_QUOTE_SHOW_CREATE);
448
static sys_var_thd_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
412
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
450
414
OPTION_NO_FOREIGN_KEY_CHECKS,
451
415
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
452
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
416
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0,
454
418
OPTION_RELAXED_UNIQUE_CHECKS,
456
420
sys_var::SESSION_VARIABLE_IN_BINLOG);
457
421
/* Local state variables */
459
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
423
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit",
460
424
&SV::select_limit);
461
425
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
462
426
sys_var::SESSION_VARIABLE_IN_BINLOG);
621
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
585
static bool sys_update_init_connect(Session *session __attribute__((unused)), set_var *var)
623
587
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
627
static void sys_default_init_connect(THD* thd __attribute__((unused)),
591
static void sys_default_init_connect(Session* session __attribute__((unused)),
628
592
enum_var_type type __attribute__((unused)))
630
594
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
634
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
598
static bool sys_update_init_slave(Session *session __attribute__((unused)),
637
601
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
641
static void sys_default_init_slave(THD* thd __attribute__((unused)),
605
static void sys_default_init_slave(Session* session __attribute__((unused)),
642
606
enum_var_type type __attribute__((unused)))
644
608
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
732
696
If we are changing the thread variable, we have to copy it to NET too
735
static void fix_net_read_timeout(THD *thd, enum_var_type type)
737
if (type != OPT_GLOBAL)
738
my_net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
742
static void fix_net_write_timeout(THD *thd, enum_var_type type)
744
if (type != OPT_GLOBAL)
745
my_net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
748
static void fix_net_retry_count(THD *thd, enum_var_type type)
750
if (type != OPT_GLOBAL)
751
thd->net.retry_count=thd->variables.net_retry_count;
755
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
699
static void fix_net_read_timeout(Session *session, enum_var_type type)
701
if (type != OPT_GLOBAL)
702
my_net_set_read_timeout(&session->net, session->variables.net_read_timeout);
706
static void fix_net_write_timeout(Session *session, enum_var_type type)
708
if (type != OPT_GLOBAL)
709
my_net_set_write_timeout(&session->net, session->variables.net_write_timeout);
712
static void fix_net_retry_count(Session *session, enum_var_type type)
714
if (type != OPT_GLOBAL)
715
session->net.retry_count=session->variables.net_retry_count;
719
extern void fix_delay_key_write(Session *session __attribute__((unused)),
756
720
enum_var_type type __attribute__((unused)))
758
722
switch ((enum_delay_key_write) delay_key_write_options) {
799
763
if ((length= tmp.length()))
801
return (unsigned char*) thd->strmake(tmp.ptr(), length);
765
return (unsigned char*) session->strmake(tmp.ptr(), length);
804
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((unused)),
768
void sys_var_set_slave_mode::set_default(Session *session __attribute__((unused)),
805
769
enum_var_type type __attribute__((unused)))
807
771
slave_exec_mode_options= 0;
808
772
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
811
bool sys_var_set_slave_mode::check(THD *thd, set_var *var)
775
bool sys_var_set_slave_mode::check(Session *session, set_var *var)
813
bool rc= sys_var_set::check(thd, var);
777
bool rc= sys_var_set::check(session, var);
815
779
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 &&
816
780
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
860
824
If we don't have row-based replication compiled in, the variable
861
825
is always read-only.
863
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) &&
864
thd->temporary_tables)
827
if ((session->variables.binlog_format == BINLOG_FORMAT_ROW) &&
828
session->temporary_tables)
866
830
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
870
if in a stored function/trigger, it's too late to change mode
872
if (thd->in_sub_stmt)
874
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
877
return sys_var_thd_enum::is_readonly();
834
return sys_var_session_enum::is_readonly();
881
void fix_binlog_format_after_update(THD *thd,
838
void fix_binlog_format_after_update(Session *session,
882
839
enum_var_type type __attribute__((unused)))
884
thd->reset_current_stmt_binlog_row_based();
841
session->reset_current_stmt_binlog_row_based();
888
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
845
static void fix_max_binlog_size(Session *session __attribute__((unused)),
889
846
enum_var_type type __attribute__((unused)))
891
848
mysql_bin_log.set_max_size(max_binlog_size);
905
static void fix_max_connections(THD *thd __attribute__((unused)),
862
static void fix_max_connections(Session *session __attribute__((unused)),
906
863
enum_var_type type __attribute__((unused)))
908
865
resize_thr_alarm(max_connections + 10);
912
static void fix_thd_mem_root(THD *thd, enum_var_type type)
914
if (type != OPT_GLOBAL)
915
reset_root_defaults(thd->mem_root,
916
thd->variables.query_alloc_block_size,
917
thd->variables.query_prealloc_size);
921
static void fix_trans_mem_root(THD *thd, enum_var_type type)
923
if (type != OPT_GLOBAL)
924
reset_root_defaults(&thd->transaction.mem_root,
925
thd->variables.trans_alloc_block_size,
926
thd->variables.trans_prealloc_size);
930
static void fix_server_id(THD *thd __attribute__((unused)),
869
static void fix_session_mem_root(Session *session, enum_var_type type)
871
if (type != OPT_GLOBAL)
872
reset_root_defaults(session->mem_root,
873
session->variables.query_alloc_block_size,
874
session->variables.query_prealloc_size);
878
static void fix_trans_mem_root(Session *session, enum_var_type type)
880
if (type != OPT_GLOBAL)
881
reset_root_defaults(&session->transaction.mem_root,
882
session->variables.trans_alloc_block_size,
883
session->variables.trans_prealloc_size);
887
static void fix_server_id(Session *session __attribute__((unused)),
931
888
enum_var_type type __attribute__((unused)))
933
890
server_id_supplied = 1;
934
thd->server_id= server_id;
891
session->server_id= server_id;
938
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
895
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
939
896
const char *name, int64_t val)
950
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
907
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
951
908
ER_TRUNCATED_WRONG_VALUE,
952
909
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
957
static uint64_t fix_unsigned(THD *thd, uint64_t num,
914
static uint64_t fix_unsigned(Session *session, uint64_t num,
958
915
const struct my_option *option_limits)
960
917
bool fixed= false;
961
918
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
963
throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
920
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
967
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
924
static bool get_unsigned(Session *session __attribute__((unused)), set_var *var)
969
926
if (var->value->unsigned_flag)
970
927
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
988
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
945
bool sys_var_long_ptr_global::check(Session *session, set_var *var)
990
return get_unsigned(thd, var);
947
return get_unsigned(session, var);
993
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
950
bool sys_var_long_ptr_global::update(Session *session, set_var *var)
995
952
uint64_t tmp= var->save_result.uint64_t_value;
996
953
pthread_mutex_lock(guard);
997
954
if (option_limits)
998
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
955
*value= (ulong) fix_unsigned(session, tmp, option_limits);
1001
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1002
/* Avoid overflows on 32 bit systems */
1003
if (tmp > ULONG_MAX)
958
if (tmp > UINT32_MAX)
1006
throw_bounds_warning(thd, true, true, name,
961
throw_bounds_warning(session, true, true, name,
1007
962
(int64_t) var->save_result.uint64_t_value);
1010
964
*value= (ulong) tmp;
1080
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1034
unsigned char *sys_var_enum_const::value_ptr(Session *session __attribute__((unused)),
1081
1035
enum_var_type type __attribute__((unused)),
1082
1036
LEX_STRING *base __attribute__((unused)))
1084
1038
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1087
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1041
bool sys_var_session_ulong::check(Session *session, set_var *var)
1089
return (get_unsigned(thd, var) ||
1090
(check_func && (*check_func)(thd, var)));
1043
return (get_unsigned(session, var) ||
1044
(check_func && (*check_func)(session, var)));
1093
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1047
bool sys_var_session_ulong::update(Session *session, set_var *var)
1095
1049
uint64_t tmp= var->save_result.uint64_t_value;
1097
1051
/* Don't use bigger value than given with --maximum-variable-name=.. */
1098
1052
if ((ulong) tmp > max_system_variables.*offset)
1100
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1054
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1101
1055
tmp= max_system_variables.*offset;
1104
1058
if (option_limits)
1105
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1106
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1107
else if (tmp > ULONG_MAX)
1059
tmp= (ulong) fix_unsigned(session, tmp, option_limits);
1060
else if (tmp > UINT32_MAX)
1110
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
1063
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value);
1114
1066
if (var->type == OPT_GLOBAL)
1115
1067
global_system_variables.*offset= (ulong) tmp;
1117
thd->variables.*offset= (ulong) tmp;
1069
session->variables.*offset= (ulong) tmp;
1123
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
1075
void sys_var_session_ulong::set_default(Session *session, enum_var_type type)
1125
1077
if (type == OPT_GLOBAL)
1180
1132
pthread_mutex_unlock(&LOCK_global_system_variables);
1183
thd->variables.*offset= global_system_variables.*offset;
1135
session->variables.*offset= global_system_variables.*offset;
1187
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1139
unsigned char *sys_var_session_ha_rows::value_ptr(Session *session, enum_var_type type,
1188
1140
LEX_STRING *base __attribute__((unused)))
1190
1142
if (type == OPT_GLOBAL)
1191
1143
return (unsigned char*) &(global_system_variables.*offset);
1192
return (unsigned char*) &(thd->variables.*offset);
1144
return (unsigned char*) &(session->variables.*offset);
1195
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1147
bool sys_var_session_uint64_t::check(Session *session, set_var *var)
1197
return get_unsigned(thd, var);
1149
return get_unsigned(session, var);
1200
bool sys_var_thd_uint64_t::update(THD *thd, set_var *var)
1152
bool sys_var_session_uint64_t::update(Session *session, set_var *var)
1202
1154
uint64_t tmp= var->save_result.uint64_t_value;
1231
1183
pthread_mutex_unlock(&LOCK_global_system_variables);
1234
thd->variables.*offset= global_system_variables.*offset;
1186
session->variables.*offset= global_system_variables.*offset;
1238
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1190
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session, enum_var_type type,
1239
1191
LEX_STRING *base __attribute__((unused)))
1241
1193
if (type == OPT_GLOBAL)
1242
1194
return (unsigned char*) &(global_system_variables.*offset);
1243
return (unsigned char*) &(thd->variables.*offset);
1195
return (unsigned char*) &(session->variables.*offset);
1247
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1199
bool sys_var_session_bool::update(Session *session, set_var *var)
1249
1201
if (var->type == OPT_GLOBAL)
1250
1202
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1252
thd->variables.*offset= (bool) var->save_result.ulong_value;
1204
session->variables.*offset= (bool) var->save_result.ulong_value;
1257
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
1209
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
1259
1211
if (type == OPT_GLOBAL)
1260
1212
global_system_variables.*offset= (bool) option_limits->def_value;
1262
thd->variables.*offset= global_system_variables.*offset;
1214
session->variables.*offset= global_system_variables.*offset;
1266
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1218
unsigned char *sys_var_session_bool::value_ptr(Session *session, enum_var_type type,
1267
1219
LEX_STRING *base __attribute__((unused)))
1269
1221
if (type == OPT_GLOBAL)
1270
1222
return (unsigned char*) &(global_system_variables.*offset);
1271
return (unsigned char*) &(thd->variables.*offset);
1223
return (unsigned char*) &(session->variables.*offset);
1275
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1227
bool sys_var::check_enum(Session *session __attribute__((unused)),
1276
1228
set_var *var, const TYPELIB *enum_names)
1278
1230
char buff[STRING_BUFFER_USUAL_SIZE];
1492
bool sys_var_thd_enum::update(THD *thd, set_var *var)
1444
bool sys_var_session_enum::update(Session *session, set_var *var)
1494
1446
if (var->type == OPT_GLOBAL)
1495
1447
global_system_variables.*offset= var->save_result.ulong_value;
1497
thd->variables.*offset= var->save_result.ulong_value;
1449
session->variables.*offset= var->save_result.ulong_value;
1502
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
1454
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1504
1456
if (type == OPT_GLOBAL)
1505
1457
global_system_variables.*offset= (ulong) option_limits->def_value;
1507
thd->variables.*offset= global_system_variables.*offset;
1459
session->variables.*offset= global_system_variables.*offset;
1511
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1463
unsigned char *sys_var_session_enum::value_ptr(Session *session, enum_var_type type,
1512
1464
LEX_STRING *base __attribute__((unused)))
1514
1466
ulong tmp= ((type == OPT_GLOBAL) ?
1515
1467
global_system_variables.*offset :
1516
thd->variables.*offset);
1468
session->variables.*offset);
1517
1469
return (unsigned char*) enum_names->type_names[tmp];
1520
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1472
bool sys_var_session_bit::check(Session *session, set_var *var)
1522
return (check_enum(thd, var, &bool_typelib) ||
1523
(check_func && (*check_func)(thd, var)));
1474
return (check_enum(session, var, &bool_typelib) ||
1475
(check_func && (*check_func)(session, var)));
1526
bool sys_var_thd_bit::update(THD *thd, set_var *var)
1478
bool sys_var_session_bit::update(Session *session, set_var *var)
1528
int res= (*update_func)(thd, var);
1480
int res= (*update_func)(session, var);
1533
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1485
unsigned char *sys_var_session_bit::value_ptr(Session *session,
1534
1486
enum_var_type type __attribute__((unused)),
1535
1487
LEX_STRING *base __attribute__((unused)))
1563
old= (thd->variables.*offset);
1564
(thd->variables.*offset)= new_value;
1515
old= (session->variables.*offset);
1516
(session->variables.*offset)= new_value;
1566
1518
free((char*) old);
1571
bool sys_var_thd_date_time_format::update(THD *thd, set_var *var)
1523
bool sys_var_session_date_time_format::update(Session *session, set_var *var)
1573
1525
DATE_TIME_FORMAT *new_value;
1574
1526
/* We must make a copy of the last value to get it into normal memory */
1575
new_value= date_time_format_copy((THD*) 0,
1527
new_value= date_time_format_copy((Session*) 0,
1576
1528
var->save_result.date_time_format);
1577
1529
if (!new_value)
1578
1530
return 1; // Out of memory
1579
update2(thd, var->type, new_value); // Can't fail
1531
update2(session, var->type, new_value); // Can't fail
1584
bool sys_var_thd_date_time_format::check(THD *thd, set_var *var)
1536
bool sys_var_session_date_time_format::check(Session *session, set_var *var)
1586
1538
char buff[STRING_BUFFER_USUAL_SIZE];
1587
1539
String str(buff,sizeof(buff), system_charset_info), *res;
1730
bool sys_var_character_set::update(THD *thd, set_var *var)
1682
bool sys_var_character_set::update(Session *session, set_var *var)
1732
ci_ptr(thd,var->type)[0]= var->save_result.charset;
1733
thd->update_charset();
1684
ci_ptr(session,var->type)[0]= var->save_result.charset;
1685
session->update_charset();
1738
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1690
unsigned char *sys_var_character_set::value_ptr(Session *session, enum_var_type type,
1739
1691
LEX_STRING *base __attribute__((unused)))
1741
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1693
const CHARSET_INFO * const cs= ci_ptr(session,type)[0];
1742
1694
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1746
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1748
if (type == OPT_GLOBAL)
1749
global_system_variables.*offset= *global_default;
1752
thd->variables.*offset= global_system_variables.*offset;
1753
thd->update_charset();
1756
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1758
if (type == OPT_GLOBAL)
1759
return &(global_system_variables.*offset);
1761
return &(thd->variables.*offset);
1765
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1767
if (sys_var_character_set_sv::check(thd, var))
1769
/* Currently, UCS-2 cannot be used as a client character set */
1770
if (var->save_result.charset->mbminlen > 1)
1772
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1773
var->save_result.charset->csname);
1780
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1783
if (type == OPT_GLOBAL)
1784
return &global_system_variables.collation_database;
1786
return &thd->variables.collation_database;
1790
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1792
if (type == OPT_GLOBAL)
1793
global_system_variables.collation_database= default_charset_info;
1796
thd->variables.collation_database= thd->db_charset;
1797
thd->update_charset();
1802
bool sys_var_collation_sv::update(THD *thd, set_var *var)
1698
bool sys_var_collation_sv::update(Session *session, set_var *var)
1804
1700
if (var->type == OPT_GLOBAL)
1805
1701
global_system_variables.*offset= var->save_result.charset;
1808
thd->variables.*offset= var->save_result.charset;
1809
thd->update_charset();
1704
session->variables.*offset= var->save_result.charset;
1705
session->update_charset();
1815
void sys_var_collation_sv::set_default(THD *thd, enum_var_type type)
1711
void sys_var_collation_sv::set_default(Session *session, enum_var_type type)
1817
1713
if (type == OPT_GLOBAL)
1818
1714
global_system_variables.*offset= *global_default;
1821
thd->variables.*offset= global_system_variables.*offset;
1822
thd->update_charset();
1717
session->variables.*offset= global_system_variables.*offset;
1718
session->update_charset();
1827
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1723
unsigned char *sys_var_collation_sv::value_ptr(Session *session, enum_var_type type,
1828
1724
LEX_STRING *base __attribute__((unused)))
1830
1726
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
global_system_variables.*offset : thd->variables.*offset);
1727
global_system_variables.*offset : session->variables.*offset);
1832
1728
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
2135
int set_var_collation_client::update(THD *thd)
2031
int set_var_collation_client::update(Session *session)
2137
thd->variables.character_set_client= character_set_client;
2138
thd->variables.character_set_results= character_set_results;
2139
thd->variables.collation_connection= collation_connection;
2140
thd->update_charset();
2141
thd->protocol_text.init(thd);
2033
session->variables.character_set_client= character_set_client;
2034
session->variables.character_set_results= character_set_results;
2035
session->variables.collation_connection= collation_connection;
2036
session->update_charset();
2037
session->protocol_text.init(session);
2145
2041
/****************************************************************************/
2147
bool sys_var_timestamp::update(THD *thd, set_var *var)
2043
bool sys_var_timestamp::update(Session *session, set_var *var)
2149
thd->set_time((time_t) var->save_result.uint64_t_value);
2045
session->set_time((time_t) var->save_result.uint64_t_value);
2154
void sys_var_timestamp::set_default(THD *thd,
2050
void sys_var_timestamp::set_default(Session *session,
2155
2051
enum_var_type type __attribute__((unused)))
2053
session->user_time=0;
2161
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2057
unsigned char *sys_var_timestamp::value_ptr(Session *session,
2162
2058
enum_var_type type __attribute__((unused)),
2163
2059
LEX_STRING *base __attribute__((unused)))
2165
thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
return (unsigned char*) &thd->sys_var_tmp.long_value;
2061
session->sys_var_tmp.long_value= (long) session->start_time;
2062
return (unsigned char*) &session->sys_var_tmp.long_value;
2170
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2066
bool sys_var_last_insert_id::update(Session *session, set_var *var)
2172
thd->first_successful_insert_id_in_prev_stmt=
2068
session->first_successful_insert_id_in_prev_stmt=
2173
2069
var->save_result.uint64_t_value;
2178
unsigned char *sys_var_last_insert_id::value_ptr(THD *thd,
2074
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
2179
2075
enum_var_type type __attribute__((unused)),
2180
2076
LEX_STRING *base __attribute__((unused)))
2183
2079
this tmp var makes it robust againt change of type of
2184
2080
read_first_successful_insert_id_in_prev_stmt().
2186
thd->sys_var_tmp.uint64_t_value=
2187
thd->read_first_successful_insert_id_in_prev_stmt();
2188
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2082
session->sys_var_tmp.uint64_t_value=
2083
session->read_first_successful_insert_id_in_prev_stmt();
2084
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
2192
bool sys_var_insert_id::update(THD *thd, set_var *var)
2088
bool sys_var_insert_id::update(Session *session, set_var *var)
2194
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2090
session->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2199
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2095
unsigned char *sys_var_insert_id::value_ptr(Session *session,
2200
2096
enum_var_type type __attribute__((unused)),
2201
2097
LEX_STRING *base __attribute__((unused)))
2203
thd->sys_var_tmp.uint64_t_value=
2204
thd->auto_inc_intervals_forced.minimum();
2205
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2209
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2211
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2215
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2217
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2222
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2099
session->sys_var_tmp.uint64_t_value=
2100
session->auto_inc_intervals_forced.minimum();
2101
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
2105
bool sys_var_rand_seed1::update(Session *session, set_var *var)
2107
session->rand.seed1= (ulong) var->save_result.uint64_t_value;
2111
bool sys_var_rand_seed2::update(Session *session, set_var *var)
2113
session->rand.seed2= (ulong) var->save_result.uint64_t_value;
2118
bool sys_var_session_time_zone::check(Session *session, set_var *var)
2224
2120
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
2121
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2226
2122
String *res= var->value->val_str(&str);
2228
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2124
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2230
2126
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
2384
bool sys_var_thd_lc_time_names::update(THD *thd, set_var *var)
2280
bool sys_var_session_lc_time_names::update(Session *session, set_var *var)
2386
2282
if (var->type == OPT_GLOBAL)
2387
2283
global_system_variables.lc_time_names= var->save_result.locale_value;
2389
thd->variables.lc_time_names= var->save_result.locale_value;
2285
session->variables.lc_time_names= var->save_result.locale_value;
2394
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2290
unsigned char *sys_var_session_lc_time_names::value_ptr(Session *session,
2395
2291
enum_var_type type,
2396
2292
LEX_STRING *base __attribute__((unused)))
2398
2294
return type == OPT_GLOBAL ?
2399
2295
(unsigned char *) global_system_variables.lc_time_names->name :
2400
(unsigned char *) thd->variables.lc_time_names->name;
2296
(unsigned char *) session->variables.lc_time_names->name;
2404
void sys_var_thd_lc_time_names::set_default(THD *thd, enum_var_type type)
2300
void sys_var_session_lc_time_names::set_default(Session *session, enum_var_type type)
2406
2302
if (type == OPT_GLOBAL)
2407
2303
global_system_variables.lc_time_names= my_default_lc_time_names;
2409
thd->variables.lc_time_names= global_system_variables.lc_time_names;
2305
session->variables.lc_time_names= global_system_variables.lc_time_names;
2449
2345
pthread_mutex_unlock(&LOCK_global_system_variables);
2452
thd->variables.*offset= microseconds;
2348
session->variables.*offset= microseconds;
2456
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2352
unsigned char *sys_var_microseconds::value_ptr(Session *session, enum_var_type type,
2457
2353
LEX_STRING *base __attribute__((unused)))
2459
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2355
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
2356
global_system_variables.*offset :
2461
thd->variables.*offset) / 1000000.0;
2462
return (unsigned char*) &thd->tmp_double_value;
2357
session->variables.*offset) / 1000000.0;
2358
return (unsigned char*) &session->tmp_double_value;
2467
Functions to update thd->options bits
2363
Functions to update session->options bits
2470
static bool set_option_bit(THD *thd, set_var *var)
2366
static bool set_option_bit(Session *session, set_var *var)
2472
sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
2368
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var);
2473
2369
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
2474
thd->options&= ~sys_var->bit_flag;
2370
session->options&= ~sys_var->bit_flag;
2476
thd->options|= sys_var->bit_flag;
2372
session->options|= sys_var->bit_flag;
2481
static bool set_option_autocommit(THD *thd, set_var *var)
2377
static bool set_option_autocommit(Session *session, set_var *var)
2483
2379
/* The test is negative as the flag we use is NOT autocommit */
2485
uint64_t org_options= thd->options;
2381
uint64_t org_options= session->options;
2487
2383
if (var->save_result.ulong_value != 0)
2488
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
2384
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2490
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
2386
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2492
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
2388
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2494
2390
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2496
2392
/* We changed to auto_commit mode */
2497
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2498
thd->transaction.all.modified_non_trans_table= false;
2499
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2393
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2394
session->transaction.all.modified_non_trans_table= false;
2395
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
2396
if (ha_commit(session))
2505
thd->transaction.all.modified_non_trans_table= false;
2506
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2401
session->transaction.all.modified_non_trans_table= false;
2402
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2512
static int check_log_update(THD *thd __attribute__((unused)),
2408
static int check_log_update(Session *session __attribute__((unused)),
2513
2409
set_var *var __attribute__((unused)))
2519
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
2415
static int check_pseudo_thread_id(Session *session __attribute__((unused)),
2522
2418
var->save_result.uint64_t_value= var->value->val_int();
2526
static unsigned char *get_warning_count(THD *thd)
2422
static unsigned char *get_warning_count(Session *session)
2528
thd->sys_var_tmp.long_value=
2529
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2530
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2531
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2532
return (unsigned char*) &thd->sys_var_tmp.long_value;
2424
session->sys_var_tmp.long_value=
2425
(session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2426
session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2427
session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2428
return (unsigned char*) &session->sys_var_tmp.long_value;
2535
static unsigned char *get_error_count(THD *thd)
2431
static unsigned char *get_error_count(Session *session)
2537
thd->sys_var_tmp.long_value=
2538
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2539
return (unsigned char*) &thd->sys_var_tmp.long_value;
2433
session->sys_var_tmp.long_value=
2434
session->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2435
return (unsigned char*) &session->sys_var_tmp.long_value;
3027
unsigned char *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
2923
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session, enum_var_type type,
3028
2924
LEX_STRING *base __attribute__((unused)))
3030
2926
unsigned char* result;
3031
2927
handlerton *hton;
3032
2928
LEX_STRING *engine_name;
3033
plugin_ref plugin= thd->variables.*offset;
2929
plugin_ref plugin= session->variables.*offset;
3034
2930
if (type == OPT_GLOBAL)
3035
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
2931
plugin= my_plugin_lock(session, &(global_system_variables.*offset));
3036
2932
hton= plugin_data(plugin, handlerton*);
3037
2933
engine_name= &hton2plugin[hton->slot]->name;
3038
result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
2934
result= (unsigned char *) session->strmake(engine_name->str, engine_name->length);
3039
2935
if (type == OPT_GLOBAL)
3040
plugin_unlock(thd, plugin);
2936
plugin_unlock(session, plugin);
3045
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
2941
void sys_var_session_storage_engine::set_default(Session *session, enum_var_type type)
3047
2943
plugin_ref old_value, new_value, *value;
3048
2944
if (type == OPT_GLOBAL)