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