87
87
static void sys_default_init_connect(Session*, enum_var_type type);
88
88
static bool sys_update_init_slave(Session*, set_var*);
89
89
static void sys_default_init_slave(Session*, enum_var_type type);
90
static bool set_option_bit(Session *thd, set_var *var);
91
static bool set_option_autocommit(Session *thd, set_var *var);
92
static int check_log_update(Session *thd, set_var *var);
93
static int check_pseudo_thread_id(Session *thd, set_var *var);
94
static void fix_low_priority_updates(Session *thd, enum_var_type type);
95
static int check_tx_isolation(Session *thd, set_var *var);
96
static void fix_tx_isolation(Session *thd, enum_var_type type);
97
static int check_completion_type(Session *thd, set_var *var);
98
static void fix_completion_type(Session *thd, enum_var_type type);
99
static void fix_net_read_timeout(Session *thd, enum_var_type type);
100
static void fix_net_write_timeout(Session *thd, enum_var_type type);
101
static void fix_net_retry_count(Session *thd, enum_var_type type);
102
static void fix_max_join_size(Session *thd, enum_var_type type);
103
static void fix_myisam_max_sort_file_size(Session *thd, enum_var_type type);
104
static void fix_max_binlog_size(Session *thd, enum_var_type type);
105
static void fix_max_relay_log_size(Session *thd, enum_var_type type);
106
static void fix_max_connections(Session *thd, enum_var_type type);
107
static void fix_thd_mem_root(Session *thd, enum_var_type type);
108
static void fix_trans_mem_root(Session *thd, enum_var_type type);
109
static void fix_server_id(Session *thd, 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
110
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
111
static bool get_unsigned(Session *thd, set_var *var);
112
bool throw_bounds_warning(Session *thd, bool fixed, bool unsignd,
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(Session *thd);
116
static unsigned char *get_warning_count(Session *thd);
117
static unsigned char *get_tmpdir(Session *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
193
193
param_age_threshold));
194
194
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
195
195
&opt_local_infile);
196
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",
197
197
&SV::low_priority_updates,
198
198
fix_low_priority_updates);
199
199
#ifndef TO_BE_DELETED /* Alias for the low_priority_updates */
200
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",
201
201
&SV::low_priority_updates,
202
202
fix_low_priority_updates);
204
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",
205
205
&SV::max_allowed_packet);
206
206
static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
207
207
&max_binlog_cache_size);
213
213
fix_max_connections);
214
214
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors",
215
215
&max_connect_errors);
216
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",
217
217
&SV::max_error_count);
218
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",
219
219
&SV::max_heap_table_size);
220
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",
221
221
&SV::pseudo_thread_id,
222
222
check_pseudo_thread_id, 0,
223
223
sys_var::SESSION_VARIABLE_IN_BINLOG);
224
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",
225
225
&SV::max_join_size,
226
226
fix_max_join_size);
227
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",
228
228
&SV::max_seeks_for_key);
229
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",
230
230
&SV::max_length_for_sort_data);
231
231
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
232
232
&max_relay_log_size,
233
233
fix_max_relay_log_size);
234
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",
235
235
&SV::max_sort_length);
236
236
static sys_var_max_user_conn sys_max_user_connections(&vars, "max_user_connections");
237
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",
238
238
&SV::max_tmp_tables);
239
239
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
240
240
&max_write_lock_count);
241
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",
242
242
&SV::min_examined_row_limit);
243
static sys_var_thd_uint64_t sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
244
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
245
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);
247
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",
248
248
&SV::myisam_stats_method,
249
249
&myisam_stats_method_typelib,
251
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",
252
252
&SV::net_buffer_length);
253
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",
254
254
&SV::net_read_timeout,
255
255
0, fix_net_read_timeout);
256
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",
257
257
&SV::net_write_timeout,
258
258
0, fix_net_write_timeout);
259
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",
260
260
&SV::net_retry_count,
261
261
0, fix_net_retry_count);
262
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);
263
263
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
264
264
&global_system_variables.old_mode);
265
265
/* these two cannot be static */
266
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",
267
267
&SV::old_alter_table);
268
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",
269
269
&SV::optimizer_prune_level);
270
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",
271
271
&SV::optimizer_search_depth);
273
273
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
276
276
optimizer_use_mrr_names, NULL
279
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",
280
280
&SV::optimizer_use_mrr,
281
281
&optimizer_use_mrr_typelib,
284
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",
285
285
&SV::preload_buff_size);
286
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",
287
287
&SV::read_buff_size);
288
288
static sys_var_opt_readonly sys_readonly(&vars, "read_only", &opt_readonly);
289
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",
290
290
&SV::read_rnd_buff_size);
291
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",
292
292
&SV::div_precincrement);
294
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",
295
295
&SV::range_alloc_block_size);
296
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",
297
297
&SV::query_alloc_block_size,
298
0, fix_thd_mem_root);
299
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",
300
300
&SV::query_prealloc_size,
301
0, fix_thd_mem_root);
301
0, fix_session_mem_root);
302
302
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
303
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",
304
304
&SV::trans_alloc_block_size,
305
305
0, fix_trans_mem_root);
306
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",
307
307
&SV::trans_prealloc_size,
308
308
0, fix_trans_mem_root);
362
362
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
364
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",
365
365
&SV::net_wait_timeout);
367
367
/* Condition pushdown to storage engine */
368
static sys_var_thd_bool
368
static sys_var_session_bool
369
369
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
370
370
&SV::engine_condition_pushdown);
372
372
/* Time/date/datetime formats */
374
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",
375
375
&SV::time_format,
376
376
DRIZZLE_TIMESTAMP_TIME);
377
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",
378
378
&SV::date_format,
379
379
DRIZZLE_TIMESTAMP_DATE);
380
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",
381
381
&SV::datetime_format,
382
382
DRIZZLE_TIMESTAMP_DATETIME);
384
384
/* Variables that are bits in Session */
386
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
386
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
387
387
set_option_autocommit,
388
388
OPTION_NOT_AUTOCOMMIT,
390
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,
392
392
OPTION_BIG_SELECTS);
393
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",
394
394
check_log_update,
397
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,
399
399
OPTION_WARNINGS);
400
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,
402
402
OPTION_SQL_NOTES);
403
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,
405
405
OPTION_SAFE_UPDATES);
406
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,
408
408
OPTION_BUFFER_RESULT);
409
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,
411
411
OPTION_QUOTE_SHOW_CREATE);
412
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,
414
414
OPTION_NO_FOREIGN_KEY_CHECKS,
415
415
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
416
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,
418
418
OPTION_RELAXED_UNIQUE_CHECKS,
420
420
sys_var::SESSION_VARIABLE_IN_BINLOG);
421
421
/* Local state variables */
423
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",
424
424
&SV::select_limit);
425
425
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
426
426
sys_var::SESSION_VARIABLE_IN_BINLOG);
585
static bool sys_update_init_connect(Session *thd __attribute__((unused)), set_var *var)
585
static bool sys_update_init_connect(Session *session __attribute__((unused)), set_var *var)
587
587
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
591
static void sys_default_init_connect(Session* thd __attribute__((unused)),
591
static void sys_default_init_connect(Session* session __attribute__((unused)),
592
592
enum_var_type type __attribute__((unused)))
594
594
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
598
static bool sys_update_init_slave(Session *thd __attribute__((unused)),
598
static bool sys_update_init_slave(Session *session __attribute__((unused)),
601
601
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
605
static void sys_default_init_slave(Session* thd __attribute__((unused)),
605
static void sys_default_init_slave(Session* session __attribute__((unused)),
606
606
enum_var_type type __attribute__((unused)))
608
608
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
696
696
If we are changing the thread variable, we have to copy it to NET too
699
static void fix_net_read_timeout(Session *thd, enum_var_type type)
701
if (type != OPT_GLOBAL)
702
my_net_set_read_timeout(&thd->net, thd->variables.net_read_timeout);
706
static void fix_net_write_timeout(Session *thd, enum_var_type type)
708
if (type != OPT_GLOBAL)
709
my_net_set_write_timeout(&thd->net, thd->variables.net_write_timeout);
712
static void fix_net_retry_count(Session *thd, enum_var_type type)
714
if (type != OPT_GLOBAL)
715
thd->net.retry_count=thd->variables.net_retry_count;
719
extern void fix_delay_key_write(Session *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)),
720
720
enum_var_type type __attribute__((unused)))
722
722
switch ((enum_delay_key_write) delay_key_write_options) {
763
763
if ((length= tmp.length()))
765
return (unsigned char*) thd->strmake(tmp.ptr(), length);
765
return (unsigned char*) session->strmake(tmp.ptr(), length);
768
void sys_var_set_slave_mode::set_default(Session *thd __attribute__((unused)),
768
void sys_var_set_slave_mode::set_default(Session *session __attribute__((unused)),
769
769
enum_var_type type __attribute__((unused)))
771
771
slave_exec_mode_options= 0;
772
772
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
775
bool sys_var_set_slave_mode::check(Session *thd, set_var *var)
775
bool sys_var_set_slave_mode::check(Session *session, set_var *var)
777
bool rc= sys_var_set::check(thd, var);
777
bool rc= sys_var_set::check(session, var);
779
779
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 &&
780
780
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
862
static void fix_max_connections(Session *thd __attribute__((unused)),
862
static void fix_max_connections(Session *session __attribute__((unused)),
863
863
enum_var_type type __attribute__((unused)))
865
865
resize_thr_alarm(max_connections + 10);
869
static void fix_thd_mem_root(Session *thd, enum_var_type type)
871
if (type != OPT_GLOBAL)
872
reset_root_defaults(thd->mem_root,
873
thd->variables.query_alloc_block_size,
874
thd->variables.query_prealloc_size);
878
static void fix_trans_mem_root(Session *thd, enum_var_type type)
880
if (type != OPT_GLOBAL)
881
reset_root_defaults(&thd->transaction.mem_root,
882
thd->variables.trans_alloc_block_size,
883
thd->variables.trans_prealloc_size);
887
static void fix_server_id(Session *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)),
888
888
enum_var_type type __attribute__((unused)))
890
890
server_id_supplied = 1;
891
thd->server_id= server_id;
891
session->server_id= server_id;
895
bool throw_bounds_warning(Session *thd, bool fixed, bool unsignd,
895
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
896
896
const char *name, int64_t val)
907
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
907
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
908
908
ER_TRUNCATED_WRONG_VALUE,
909
909
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
914
static uint64_t fix_unsigned(Session *thd, uint64_t num,
914
static uint64_t fix_unsigned(Session *session, uint64_t num,
915
915
const struct my_option *option_limits)
917
917
bool fixed= false;
918
918
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
920
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);
924
static bool get_unsigned(Session *thd __attribute__((unused)), set_var *var)
924
static bool get_unsigned(Session *session __attribute__((unused)), set_var *var)
926
926
if (var->value->unsigned_flag)
927
927
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
945
bool sys_var_long_ptr_global::check(Session *thd, set_var *var)
945
bool sys_var_long_ptr_global::check(Session *session, set_var *var)
947
return get_unsigned(thd, var);
947
return get_unsigned(session, var);
950
bool sys_var_long_ptr_global::update(Session *thd, set_var *var)
950
bool sys_var_long_ptr_global::update(Session *session, set_var *var)
952
952
uint64_t tmp= var->save_result.uint64_t_value;
953
953
pthread_mutex_lock(guard);
954
954
if (option_limits)
955
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
955
*value= (ulong) fix_unsigned(session, tmp, option_limits);
958
958
if (tmp > UINT32_MAX)
961
throw_bounds_warning(thd, true, true, name,
961
throw_bounds_warning(session, true, true, name,
962
962
(int64_t) var->save_result.uint64_t_value);
964
964
*value= (ulong) tmp;
1034
unsigned char *sys_var_enum_const::value_ptr(Session *thd __attribute__((unused)),
1034
unsigned char *sys_var_enum_const::value_ptr(Session *session __attribute__((unused)),
1035
1035
enum_var_type type __attribute__((unused)),
1036
1036
LEX_STRING *base __attribute__((unused)))
1038
1038
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1041
bool sys_var_thd_ulong::check(Session *thd, set_var *var)
1041
bool sys_var_session_ulong::check(Session *session, set_var *var)
1043
return (get_unsigned(thd, var) ||
1044
(check_func && (*check_func)(thd, var)));
1043
return (get_unsigned(session, var) ||
1044
(check_func && (*check_func)(session, var)));
1047
bool sys_var_thd_ulong::update(Session *thd, set_var *var)
1047
bool sys_var_session_ulong::update(Session *session, set_var *var)
1049
1049
uint64_t tmp= var->save_result.uint64_t_value;
1051
1051
/* Don't use bigger value than given with --maximum-variable-name=.. */
1052
1052
if ((ulong) tmp > max_system_variables.*offset)
1054
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
1054
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1055
1055
tmp= max_system_variables.*offset;
1058
1058
if (option_limits)
1059
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1059
tmp= (ulong) fix_unsigned(session, tmp, option_limits);
1060
1060
else if (tmp > UINT32_MAX)
1062
1062
tmp= UINT32_MAX;
1063
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);
1066
1066
if (var->type == OPT_GLOBAL)
1067
1067
global_system_variables.*offset= (ulong) tmp;
1069
thd->variables.*offset= (ulong) tmp;
1069
session->variables.*offset= (ulong) tmp;
1075
void sys_var_thd_ulong::set_default(Session *thd, enum_var_type type)
1075
void sys_var_session_ulong::set_default(Session *session, enum_var_type type)
1077
1077
if (type == OPT_GLOBAL)
1132
1132
pthread_mutex_unlock(&LOCK_global_system_variables);
1135
thd->variables.*offset= global_system_variables.*offset;
1135
session->variables.*offset= global_system_variables.*offset;
1139
unsigned char *sys_var_thd_ha_rows::value_ptr(Session *thd, enum_var_type type,
1139
unsigned char *sys_var_session_ha_rows::value_ptr(Session *session, enum_var_type type,
1140
1140
LEX_STRING *base __attribute__((unused)))
1142
1142
if (type == OPT_GLOBAL)
1143
1143
return (unsigned char*) &(global_system_variables.*offset);
1144
return (unsigned char*) &(thd->variables.*offset);
1144
return (unsigned char*) &(session->variables.*offset);
1147
bool sys_var_thd_uint64_t::check(Session *thd, set_var *var)
1147
bool sys_var_session_uint64_t::check(Session *session, set_var *var)
1149
return get_unsigned(thd, var);
1149
return get_unsigned(session, var);
1152
bool sys_var_thd_uint64_t::update(Session *thd, set_var *var)
1152
bool sys_var_session_uint64_t::update(Session *session, set_var *var)
1154
1154
uint64_t tmp= var->save_result.uint64_t_value;
1183
1183
pthread_mutex_unlock(&LOCK_global_system_variables);
1186
thd->variables.*offset= global_system_variables.*offset;
1186
session->variables.*offset= global_system_variables.*offset;
1190
unsigned char *sys_var_thd_uint64_t::value_ptr(Session *thd, enum_var_type type,
1190
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session, enum_var_type type,
1191
1191
LEX_STRING *base __attribute__((unused)))
1193
1193
if (type == OPT_GLOBAL)
1194
1194
return (unsigned char*) &(global_system_variables.*offset);
1195
return (unsigned char*) &(thd->variables.*offset);
1195
return (unsigned char*) &(session->variables.*offset);
1199
bool sys_var_thd_bool::update(Session *thd, set_var *var)
1199
bool sys_var_session_bool::update(Session *session, set_var *var)
1201
1201
if (var->type == OPT_GLOBAL)
1202
1202
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1204
thd->variables.*offset= (bool) var->save_result.ulong_value;
1204
session->variables.*offset= (bool) var->save_result.ulong_value;
1209
void sys_var_thd_bool::set_default(Session *thd, enum_var_type type)
1209
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
1211
1211
if (type == OPT_GLOBAL)
1212
1212
global_system_variables.*offset= (bool) option_limits->def_value;
1214
thd->variables.*offset= global_system_variables.*offset;
1214
session->variables.*offset= global_system_variables.*offset;
1218
unsigned char *sys_var_thd_bool::value_ptr(Session *thd, enum_var_type type,
1218
unsigned char *sys_var_session_bool::value_ptr(Session *session, enum_var_type type,
1219
1219
LEX_STRING *base __attribute__((unused)))
1221
1221
if (type == OPT_GLOBAL)
1222
1222
return (unsigned char*) &(global_system_variables.*offset);
1223
return (unsigned char*) &(thd->variables.*offset);
1223
return (unsigned char*) &(session->variables.*offset);
1227
bool sys_var::check_enum(Session *thd __attribute__((unused)),
1227
bool sys_var::check_enum(Session *session __attribute__((unused)),
1228
1228
set_var *var, const TYPELIB *enum_names)
1230
1230
char buff[STRING_BUFFER_USUAL_SIZE];
1444
bool sys_var_thd_enum::update(Session *thd, set_var *var)
1444
bool sys_var_session_enum::update(Session *session, set_var *var)
1446
1446
if (var->type == OPT_GLOBAL)
1447
1447
global_system_variables.*offset= var->save_result.ulong_value;
1449
thd->variables.*offset= var->save_result.ulong_value;
1449
session->variables.*offset= var->save_result.ulong_value;
1454
void sys_var_thd_enum::set_default(Session *thd, enum_var_type type)
1454
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1456
1456
if (type == OPT_GLOBAL)
1457
1457
global_system_variables.*offset= (ulong) option_limits->def_value;
1459
thd->variables.*offset= global_system_variables.*offset;
1459
session->variables.*offset= global_system_variables.*offset;
1463
unsigned char *sys_var_thd_enum::value_ptr(Session *thd, enum_var_type type,
1463
unsigned char *sys_var_session_enum::value_ptr(Session *session, enum_var_type type,
1464
1464
LEX_STRING *base __attribute__((unused)))
1466
1466
ulong tmp= ((type == OPT_GLOBAL) ?
1467
1467
global_system_variables.*offset :
1468
thd->variables.*offset);
1468
session->variables.*offset);
1469
1469
return (unsigned char*) enum_names->type_names[tmp];
1472
bool sys_var_thd_bit::check(Session *thd, set_var *var)
1472
bool sys_var_session_bit::check(Session *session, set_var *var)
1474
return (check_enum(thd, var, &bool_typelib) ||
1475
(check_func && (*check_func)(thd, var)));
1474
return (check_enum(session, var, &bool_typelib) ||
1475
(check_func && (*check_func)(session, var)));
1478
bool sys_var_thd_bit::update(Session *thd, set_var *var)
1478
bool sys_var_session_bit::update(Session *session, set_var *var)
1480
int res= (*update_func)(thd, var);
1480
int res= (*update_func)(session, var);
1485
unsigned char *sys_var_thd_bit::value_ptr(Session *thd,
1485
unsigned char *sys_var_session_bit::value_ptr(Session *session,
1486
1486
enum_var_type type __attribute__((unused)),
1487
1487
LEX_STRING *base __attribute__((unused)))
1682
bool sys_var_character_set::update(Session *thd, set_var *var)
1682
bool sys_var_character_set::update(Session *session, set_var *var)
1684
ci_ptr(thd,var->type)[0]= var->save_result.charset;
1685
thd->update_charset();
1684
ci_ptr(session,var->type)[0]= var->save_result.charset;
1685
session->update_charset();
1690
unsigned char *sys_var_character_set::value_ptr(Session *thd, enum_var_type type,
1690
unsigned char *sys_var_character_set::value_ptr(Session *session, enum_var_type type,
1691
1691
LEX_STRING *base __attribute__((unused)))
1693
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1693
const CHARSET_INFO * const cs= ci_ptr(session,type)[0];
1694
1694
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1698
bool sys_var_collation_sv::update(Session *thd, set_var *var)
1698
bool sys_var_collation_sv::update(Session *session, set_var *var)
1700
1700
if (var->type == OPT_GLOBAL)
1701
1701
global_system_variables.*offset= var->save_result.charset;
1704
thd->variables.*offset= var->save_result.charset;
1705
thd->update_charset();
1704
session->variables.*offset= var->save_result.charset;
1705
session->update_charset();
1711
void sys_var_collation_sv::set_default(Session *thd, enum_var_type type)
1711
void sys_var_collation_sv::set_default(Session *session, enum_var_type type)
1713
1713
if (type == OPT_GLOBAL)
1714
1714
global_system_variables.*offset= *global_default;
1717
thd->variables.*offset= global_system_variables.*offset;
1718
thd->update_charset();
1717
session->variables.*offset= global_system_variables.*offset;
1718
session->update_charset();
1723
unsigned char *sys_var_collation_sv::value_ptr(Session *thd, enum_var_type type,
1723
unsigned char *sys_var_collation_sv::value_ptr(Session *session, enum_var_type type,
1724
1724
LEX_STRING *base __attribute__((unused)))
1726
1726
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1727
global_system_variables.*offset : thd->variables.*offset);
1727
global_system_variables.*offset : session->variables.*offset);
1728
1728
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
2031
int set_var_collation_client::update(Session *thd)
2031
int set_var_collation_client::update(Session *session)
2033
thd->variables.character_set_client= character_set_client;
2034
thd->variables.character_set_results= character_set_results;
2035
thd->variables.collation_connection= collation_connection;
2036
thd->update_charset();
2037
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);
2041
2041
/****************************************************************************/
2043
bool sys_var_timestamp::update(Session *thd, set_var *var)
2043
bool sys_var_timestamp::update(Session *session, set_var *var)
2045
thd->set_time((time_t) var->save_result.uint64_t_value);
2045
session->set_time((time_t) var->save_result.uint64_t_value);
2050
void sys_var_timestamp::set_default(Session *thd,
2050
void sys_var_timestamp::set_default(Session *session,
2051
2051
enum_var_type type __attribute__((unused)))
2053
session->user_time=0;
2057
unsigned char *sys_var_timestamp::value_ptr(Session *thd,
2057
unsigned char *sys_var_timestamp::value_ptr(Session *session,
2058
2058
enum_var_type type __attribute__((unused)),
2059
2059
LEX_STRING *base __attribute__((unused)))
2061
thd->sys_var_tmp.long_value= (long) thd->start_time;
2062
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;
2066
bool sys_var_last_insert_id::update(Session *thd, set_var *var)
2066
bool sys_var_last_insert_id::update(Session *session, set_var *var)
2068
thd->first_successful_insert_id_in_prev_stmt=
2068
session->first_successful_insert_id_in_prev_stmt=
2069
2069
var->save_result.uint64_t_value;
2074
unsigned char *sys_var_last_insert_id::value_ptr(Session *thd,
2074
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
2075
2075
enum_var_type type __attribute__((unused)),
2076
2076
LEX_STRING *base __attribute__((unused)))
2079
2079
this tmp var makes it robust againt change of type of
2080
2080
read_first_successful_insert_id_in_prev_stmt().
2082
thd->sys_var_tmp.uint64_t_value=
2083
thd->read_first_successful_insert_id_in_prev_stmt();
2084
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;
2088
bool sys_var_insert_id::update(Session *thd, set_var *var)
2088
bool sys_var_insert_id::update(Session *session, set_var *var)
2090
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);
2095
unsigned char *sys_var_insert_id::value_ptr(Session *thd,
2095
unsigned char *sys_var_insert_id::value_ptr(Session *session,
2096
2096
enum_var_type type __attribute__((unused)),
2097
2097
LEX_STRING *base __attribute__((unused)))
2099
thd->sys_var_tmp.uint64_t_value=
2100
thd->auto_inc_intervals_forced.minimum();
2101
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2105
bool sys_var_rand_seed1::update(Session *thd, set_var *var)
2107
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2111
bool sys_var_rand_seed2::update(Session *thd, set_var *var)
2113
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2118
bool sys_var_thd_time_zone::check(Session *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)
2120
2120
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2121
2121
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2122
2122
String *res= var->value->val_str(&str);
2124
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2124
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2126
2126
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
2280
bool sys_var_thd_lc_time_names::update(Session *thd, set_var *var)
2280
bool sys_var_session_lc_time_names::update(Session *session, set_var *var)
2282
2282
if (var->type == OPT_GLOBAL)
2283
2283
global_system_variables.lc_time_names= var->save_result.locale_value;
2285
thd->variables.lc_time_names= var->save_result.locale_value;
2285
session->variables.lc_time_names= var->save_result.locale_value;
2290
unsigned char *sys_var_thd_lc_time_names::value_ptr(Session *thd,
2290
unsigned char *sys_var_session_lc_time_names::value_ptr(Session *session,
2291
2291
enum_var_type type,
2292
2292
LEX_STRING *base __attribute__((unused)))
2294
2294
return type == OPT_GLOBAL ?
2295
2295
(unsigned char *) global_system_variables.lc_time_names->name :
2296
(unsigned char *) thd->variables.lc_time_names->name;
2296
(unsigned char *) session->variables.lc_time_names->name;
2300
void sys_var_thd_lc_time_names::set_default(Session *thd, enum_var_type type)
2300
void sys_var_session_lc_time_names::set_default(Session *session, enum_var_type type)
2302
2302
if (type == OPT_GLOBAL)
2303
2303
global_system_variables.lc_time_names= my_default_lc_time_names;
2305
thd->variables.lc_time_names= global_system_variables.lc_time_names;
2305
session->variables.lc_time_names= global_system_variables.lc_time_names;
2345
2345
pthread_mutex_unlock(&LOCK_global_system_variables);
2348
thd->variables.*offset= microseconds;
2348
session->variables.*offset= microseconds;
2352
unsigned char *sys_var_microseconds::value_ptr(Session *thd, enum_var_type type,
2352
unsigned char *sys_var_microseconds::value_ptr(Session *session, enum_var_type type,
2353
2353
LEX_STRING *base __attribute__((unused)))
2355
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2355
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2356
2356
global_system_variables.*offset :
2357
thd->variables.*offset) / 1000000.0;
2358
return (unsigned char*) &thd->tmp_double_value;
2357
session->variables.*offset) / 1000000.0;
2358
return (unsigned char*) &session->tmp_double_value;
2363
Functions to update thd->options bits
2363
Functions to update session->options bits
2366
static bool set_option_bit(Session *thd, set_var *var)
2366
static bool set_option_bit(Session *session, set_var *var)
2368
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);
2369
2369
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
2370
thd->options&= ~sys_var->bit_flag;
2370
session->options&= ~sys_var->bit_flag;
2372
thd->options|= sys_var->bit_flag;
2372
session->options|= sys_var->bit_flag;
2377
static bool set_option_autocommit(Session *thd, set_var *var)
2377
static bool set_option_autocommit(Session *session, set_var *var)
2379
2379
/* The test is negative as the flag we use is NOT autocommit */
2381
uint64_t org_options= thd->options;
2381
uint64_t org_options= session->options;
2383
2383
if (var->save_result.ulong_value != 0)
2384
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
2384
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2386
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
2386
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2388
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
2388
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2390
2390
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2392
2392
/* We changed to auto_commit mode */
2393
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2394
thd->transaction.all.modified_non_trans_table= false;
2395
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))
2401
thd->transaction.all.modified_non_trans_table= false;
2402
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2401
session->transaction.all.modified_non_trans_table= false;
2402
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2408
static int check_log_update(Session *thd __attribute__((unused)),
2408
static int check_log_update(Session *session __attribute__((unused)),
2409
2409
set_var *var __attribute__((unused)))
2415
static int check_pseudo_thread_id(Session *thd __attribute__((unused)),
2415
static int check_pseudo_thread_id(Session *session __attribute__((unused)),
2418
2418
var->save_result.uint64_t_value= var->value->val_int();
2422
static unsigned char *get_warning_count(Session *thd)
2422
static unsigned char *get_warning_count(Session *session)
2424
thd->sys_var_tmp.long_value=
2425
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2426
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2427
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2428
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;
2431
static unsigned char *get_error_count(Session *thd)
2431
static unsigned char *get_error_count(Session *session)
2433
thd->sys_var_tmp.long_value=
2434
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2435
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;
2923
unsigned char *sys_var_thd_storage_engine::value_ptr(Session *thd, enum_var_type type,
2923
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session, enum_var_type type,
2924
2924
LEX_STRING *base __attribute__((unused)))
2926
2926
unsigned char* result;
2927
2927
handlerton *hton;
2928
2928
LEX_STRING *engine_name;
2929
plugin_ref plugin= thd->variables.*offset;
2929
plugin_ref plugin= session->variables.*offset;
2930
2930
if (type == OPT_GLOBAL)
2931
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
2931
plugin= my_plugin_lock(session, &(global_system_variables.*offset));
2932
2932
hton= plugin_data(plugin, handlerton*);
2933
2933
engine_name= &hton2plugin[hton->slot]->name;
2934
result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
2934
result= (unsigned char *) session->strmake(engine_name->str, engine_name->length);
2935
2935
if (type == OPT_GLOBAL)
2936
plugin_unlock(thd, plugin);
2936
plugin_unlock(session, plugin);
2941
void sys_var_thd_storage_engine::set_default(Session *thd, enum_var_type type)
2941
void sys_var_session_storage_engine::set_default(Session *session, enum_var_type type)
2943
2943
plugin_ref old_value, new_value, *value;
2944
2944
if (type == OPT_GLOBAL)