73
92
delay_key_write_type_names, NULL
76
const char *slave_exec_mode_names[]=
77
{ "STRICT", "IDEMPOTENT", NULL };
78
static const unsigned int slave_exec_mode_names_len[]=
79
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
80
TYPELIB slave_exec_mode_typelib=
82
array_elements(slave_exec_mode_names)-1, "",
83
slave_exec_mode_names, (unsigned int *) slave_exec_mode_names_len
86
static bool sys_update_init_connect(THD*, set_var*);
87
static void sys_default_init_connect(THD*, enum_var_type type);
88
static bool sys_update_init_slave(THD*, set_var*);
89
static void sys_default_init_slave(THD*, enum_var_type type);
90
static bool set_option_bit(THD *thd, set_var *var);
91
static bool set_option_autocommit(THD *thd, set_var *var);
92
static int check_log_update(THD *thd, set_var *var);
93
static int check_pseudo_thread_id(THD *thd, set_var *var);
94
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
static int check_tx_isolation(THD *thd, set_var *var);
96
static void fix_tx_isolation(THD *thd, enum_var_type type);
97
static int check_completion_type(THD *thd, set_var *var);
98
static void fix_completion_type(THD *thd, enum_var_type type);
99
static void fix_net_read_timeout(THD *thd, enum_var_type type);
100
static void fix_net_write_timeout(THD *thd, enum_var_type type);
101
static void fix_net_retry_count(THD *thd, enum_var_type type);
102
static void fix_max_join_size(THD *thd, enum_var_type type);
103
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
104
static void fix_max_binlog_size(THD *thd, enum_var_type type);
105
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
106
static void fix_max_connections(THD *thd, enum_var_type type);
107
static void fix_thd_mem_root(THD *thd, enum_var_type type);
108
static void fix_trans_mem_root(THD *thd, enum_var_type type);
109
static void fix_server_id(THD *thd, enum_var_type type);
110
static uint64_t fix_unsigned(THD *, uint64_t, const struct my_option *);
111
static bool get_unsigned(THD *thd, set_var *var);
112
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
95
static bool sys_update_init_connect(Session*, set_var*);
96
static void sys_default_init_connect(Session*, enum_var_type type);
97
static bool set_option_bit(Session *session, set_var *var);
98
static bool set_option_autocommit(Session *session, set_var *var);
99
static int check_pseudo_thread_id(Session *session, set_var *var);
100
static int check_tx_isolation(Session *session, set_var *var);
101
static void fix_tx_isolation(Session *session, enum_var_type type);
102
static int check_completion_type(Session *session, set_var *var);
103
static void fix_completion_type(Session *session, enum_var_type type);
104
static void fix_net_read_timeout(Session *session, enum_var_type type);
105
static void fix_net_write_timeout(Session *session, enum_var_type type);
106
static void fix_net_retry_count(Session *session, enum_var_type type);
107
static void fix_max_join_size(Session *session, enum_var_type type);
108
static void fix_session_mem_root(Session *session, enum_var_type type);
109
static void fix_trans_mem_root(Session *session, enum_var_type type);
110
static void fix_server_id(Session *session, enum_var_type type);
111
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
112
static bool get_unsigned32(Session *session, set_var *var);
113
static bool get_unsigned64(Session *session, set_var *var);
114
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
113
115
const char *name, int64_t val);
114
116
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
115
static unsigned char *get_error_count(THD *thd);
116
static unsigned char *get_warning_count(THD *thd);
117
static unsigned char *get_tmpdir(THD *thd);
117
static unsigned char *get_error_count(Session *session);
118
static unsigned char *get_warning_count(Session *session);
119
static unsigned char *get_tmpdir(Session *session);
120
122
Variable definition list
129
131
static sys_var_chain vars = { NULL, NULL };
131
static sys_var_thd_ulong
133
static sys_var_session_uint64_t
132
134
sys_auto_increment_increment(&vars, "auto_increment_increment",
133
135
&SV::auto_increment_increment, NULL, NULL,
134
136
sys_var::SESSION_VARIABLE_IN_BINLOG);
135
static sys_var_thd_ulong
137
static sys_var_session_uint64_t
136
138
sys_auto_increment_offset(&vars, "auto_increment_offset",
137
139
&SV::auto_increment_offset, NULL, NULL,
138
140
sys_var::SESSION_VARIABLE_IN_BINLOG);
140
static sys_var_const_str sys_basedir(&vars, "basedir", mysql_home);
141
static sys_var_long_ptr sys_binlog_cache_size(&vars, "binlog_cache_size",
143
static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format",
145
static sys_var_thd_ulong sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
146
&SV::bulk_insert_buff_size);
147
static sys_var_character_set_sv
148
sys_character_set_server(&vars, "character_set_server",
149
&SV::collation_server, &default_charset_info, 0,
150
sys_var::SESSION_VARIABLE_IN_BINLOG);
151
sys_var_const_str sys_charset_system(&vars, "character_set_system",
152
(char *)my_charset_utf8_general_ci.name);
153
static sys_var_character_set_database
154
sys_character_set_database(&vars, "character_set_database",
155
sys_var::SESSION_VARIABLE_IN_BINLOG);
156
static sys_var_character_set_client
157
sys_character_set_client(&vars, "character_set_client",
158
&SV::character_set_client,
159
&default_charset_info,
160
sys_var::SESSION_VARIABLE_IN_BINLOG);
161
static sys_var_character_set_sv
162
sys_character_set_connection(&vars, "character_set_connection",
163
&SV::collation_connection,
164
&default_charset_info, 0,
165
sys_var::SESSION_VARIABLE_IN_BINLOG);
166
static sys_var_character_set_sv sys_character_set_results(&vars, "character_set_results",
167
&SV::character_set_results,
168
&default_charset_info, true);
169
static sys_var_character_set_sv sys_character_set_filesystem(&vars, "character_set_filesystem",
170
&SV::character_set_filesystem,
171
&character_set_filesystem);
172
static sys_var_thd_ulong sys_completion_type(&vars, "completion_type",
173
&SV::completion_type,
174
check_completion_type,
175
fix_completion_type);
176
static sys_var_collation_sv
177
sys_collation_connection(&vars, "collation_connection",
178
&SV::collation_connection, &default_charset_info,
179
sys_var::SESSION_VARIABLE_IN_BINLOG);
142
static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home);
143
static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
144
&SV::bulk_insert_buff_size);
145
static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type",
146
&SV::completion_type,
147
check_completion_type,
148
fix_completion_type);
180
149
static sys_var_collation_sv
181
150
sys_collation_database(&vars, "collation_database", &SV::collation_database,
182
151
&default_charset_info,
185
154
sys_collation_server(&vars, "collation_server", &SV::collation_server,
186
155
&default_charset_info,
187
156
sys_var::SESSION_VARIABLE_IN_BINLOG);
188
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
190
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
157
static sys_var_uint32_t_ptr sys_connect_timeout(&vars, "connect_timeout",
159
static sys_var_const_str sys_datadir(&vars, "datadir", drizzle_real_data_home);
191
160
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
192
161
&delay_key_write_options,
193
162
&delay_key_write_typelib,
194
163
fix_delay_key_write);
196
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
198
165
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
199
166
sys_var_str sys_init_connect(&vars, "init_connect", 0,
200
167
sys_update_init_connect,
201
168
sys_default_init_connect,0);
202
sys_var_str sys_init_slave(&vars, "init_slave", 0,
203
sys_update_init_slave,
204
sys_default_init_slave,0);
205
static sys_var_thd_ulong sys_interactive_timeout(&vars, "interactive_timeout",
206
&SV::net_interactive_timeout);
207
static sys_var_thd_ulong sys_join_buffer_size(&vars, "join_buffer_size",
208
&SV::join_buff_size);
169
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
170
&SV::join_buff_size);
209
171
static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size");
210
static sys_var_key_cache_long sys_key_cache_block_size(&vars, "key_cache_block_size",
213
static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_division_limit",
215
param_division_limit));
216
static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
218
param_age_threshold));
219
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
221
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
222
&SV::low_priority_updates,
223
fix_low_priority_updates);
224
#ifndef TO_BE_DELETED /* Alias for the low_priority_updates */
225
static sys_var_thd_bool sys_sql_low_priority_updates(&vars, "sql_low_priority_updates",
226
&SV::low_priority_updates,
227
fix_low_priority_updates);
229
static sys_var_thd_ulong sys_max_allowed_packet(&vars, "max_allowed_packet",
230
&SV::max_allowed_packet);
231
static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size",
232
&max_binlog_cache_size);
233
static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size",
235
fix_max_binlog_size);
236
static sys_var_long_ptr sys_max_connections(&vars, "max_connections",
238
fix_max_connections);
239
static sys_var_long_ptr sys_max_connect_errors(&vars, "max_connect_errors",
240
&max_connect_errors);
241
static sys_var_thd_ulong sys_max_error_count(&vars, "max_error_count",
242
&SV::max_error_count);
243
static sys_var_thd_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
244
&SV::max_heap_table_size);
245
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
172
static sys_var_key_cache_uint32_t sys_key_cache_block_size(&vars, "key_cache_block_size",
175
static sys_var_key_cache_uint32_t sys_key_cache_division_limit(&vars, "key_cache_division_limit",
177
param_division_limit));
178
static sys_var_key_cache_uint32_t sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
180
param_age_threshold));
181
static sys_var_session_uint32_t sys_max_allowed_packet(&vars, "max_allowed_packet",
182
&SV::max_allowed_packet);
183
static sys_var_uint64_t_ptr sys_max_connect_errors(&vars, "max_connect_errors",
184
&max_connect_errors);
185
static sys_var_session_uint64_t sys_max_error_count(&vars, "max_error_count",
186
&SV::max_error_count);
187
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
188
&SV::max_heap_table_size);
189
static sys_var_session_uint64_t sys_pseudo_thread_id(&vars, "pseudo_thread_id",
246
190
&SV::pseudo_thread_id,
247
check_pseudo_thread_id, 0,
191
0, check_pseudo_thread_id,
248
192
sys_var::SESSION_VARIABLE_IN_BINLOG);
249
static sys_var_thd_ha_rows sys_max_join_size(&vars, "max_join_size",
252
static sys_var_thd_ulong sys_max_seeks_for_key(&vars, "max_seeks_for_key",
253
&SV::max_seeks_for_key);
254
static sys_var_thd_ulong sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
255
&SV::max_length_for_sort_data);
256
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
258
fix_max_relay_log_size);
259
static sys_var_thd_ulong sys_max_sort_length(&vars, "max_sort_length",
260
&SV::max_sort_length);
261
static sys_var_max_user_conn sys_max_user_connections(&vars, "max_user_connections");
262
static sys_var_thd_ulong sys_max_tmp_tables(&vars, "max_tmp_tables",
263
&SV::max_tmp_tables);
264
static sys_var_long_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
265
&max_write_lock_count);
266
static sys_var_thd_ulong sys_min_examined_row_limit(&vars, "min_examined_row_limit",
267
&SV::min_examined_row_limit);
268
static sys_var_thd_uint64_t sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
269
static sys_var_thd_ulong sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
270
static sys_var_thd_ulong sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
193
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size",
196
static sys_var_session_uint64_t sys_max_seeks_for_key(&vars, "max_seeks_for_key",
197
&SV::max_seeks_for_key);
198
static sys_var_session_uint64_t sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
199
&SV::max_length_for_sort_data);
200
static sys_var_session_size_t sys_max_sort_length(&vars, "max_sort_length",
201
&SV::max_sort_length);
202
static sys_var_session_uint64_t sys_max_tmp_tables(&vars, "max_tmp_tables",
203
&SV::max_tmp_tables);
204
static sys_var_uint64_t_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
205
&max_write_lock_count);
206
static sys_var_session_uint64_t sys_min_examined_row_limit(&vars, "min_examined_row_limit",
207
&SV::min_examined_row_limit);
272
static sys_var_thd_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
273
&SV::myisam_stats_method,
274
&myisam_stats_method_typelib,
276
static sys_var_thd_ulong sys_net_buffer_length(&vars, "net_buffer_length",
277
&SV::net_buffer_length);
278
static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout",
279
&SV::net_read_timeout,
280
0, fix_net_read_timeout);
281
static sys_var_thd_ulong sys_net_write_timeout(&vars, "net_write_timeout",
282
&SV::net_write_timeout,
283
0, fix_net_write_timeout);
284
static sys_var_thd_ulong sys_net_retry_count(&vars, "net_retry_count",
285
&SV::net_retry_count,
286
0, fix_net_retry_count);
287
static sys_var_thd_bool sys_new_mode(&vars, "new", &SV::new_mode);
288
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
289
&global_system_variables.old_mode);
209
static sys_var_session_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
210
&SV::myisam_stats_method,
211
&myisam_stats_method_typelib,
213
static sys_var_session_uint32_t sys_net_buffer_length(&vars, "net_buffer_length",
214
&SV::net_buffer_length);
215
static sys_var_session_uint32_t sys_net_read_timeout(&vars, "net_read_timeout",
216
&SV::net_read_timeout,
217
0, fix_net_read_timeout);
218
static sys_var_session_uint32_t sys_net_write_timeout(&vars, "net_write_timeout",
219
&SV::net_write_timeout,
220
0, fix_net_write_timeout);
221
static sys_var_session_uint32_t sys_net_retry_count(&vars, "net_retry_count",
222
&SV::net_retry_count,
223
0, fix_net_retry_count);
290
224
/* these two cannot be static */
291
sys_var_thd_bool sys_old_alter_table(&vars, "old_alter_table",
292
&SV::old_alter_table);
293
static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prune_level",
294
&SV::optimizer_prune_level);
295
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
296
&SV::optimizer_search_depth);
225
sys_var_session_bool sys_old_alter_table(&vars, "old_alter_table",
226
&SV::old_alter_table);
227
static sys_var_session_bool sys_optimizer_prune_level(&vars, "optimizer_prune_level",
228
&SV::optimizer_prune_level);
229
static sys_var_session_uint32_t sys_optimizer_search_depth(&vars, "optimizer_search_depth",
230
&SV::optimizer_search_depth);
298
232
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
299
233
TYPELIB optimizer_use_mrr_typelib= {
301
235
optimizer_use_mrr_names, NULL
304
static sys_var_thd_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
305
&SV::optimizer_use_mrr,
306
&optimizer_use_mrr_typelib,
309
static sys_var_thd_ulong sys_preload_buff_size(&vars, "preload_buffer_size",
310
&SV::preload_buff_size);
311
static sys_var_thd_ulong sys_read_buff_size(&vars, "read_buffer_size",
312
&SV::read_buff_size);
313
static sys_var_opt_readonly sys_readonly(&vars, "read_only", &opt_readonly);
314
static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
315
&SV::read_rnd_buff_size);
316
static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
317
&SV::div_precincrement);
318
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
321
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
322
&SV::range_alloc_block_size);
323
static sys_var_thd_ulong sys_query_alloc_block_size(&vars, "query_alloc_block_size",
324
&SV::query_alloc_block_size,
325
0, fix_thd_mem_root);
326
static sys_var_thd_ulong sys_query_prealloc_size(&vars, "query_prealloc_size",
327
&SV::query_prealloc_size,
328
0, fix_thd_mem_root);
329
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
330
static sys_var_thd_ulong sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
331
&SV::trans_alloc_block_size,
332
0, fix_trans_mem_root);
333
static sys_var_thd_ulong sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
334
&SV::trans_prealloc_size,
335
0, fix_trans_mem_root);
337
static sys_var_bool_ptr sys_secure_auth(&vars, "secure_auth", &opt_secure_auth);
238
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
239
&SV::optimizer_use_mrr,
240
&optimizer_use_mrr_typelib,
243
static sys_var_session_uint64_t sys_preload_buff_size(&vars, "preload_buffer_size",
244
&SV::preload_buff_size);
245
static sys_var_session_uint32_t sys_read_buff_size(&vars, "read_buffer_size",
246
&SV::read_buff_size);
247
static sys_var_session_uint32_t sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
248
&SV::read_rnd_buff_size);
249
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment",
250
&SV::div_precincrement);
252
static sys_var_session_size_t sys_range_alloc_block_size(&vars, "range_alloc_block_size",
253
&SV::range_alloc_block_size);
254
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size",
255
&SV::query_alloc_block_size,
256
false, fix_session_mem_root);
257
static sys_var_session_uint32_t sys_query_prealloc_size(&vars, "query_prealloc_size",
258
&SV::query_prealloc_size,
259
false, fix_session_mem_root);
260
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
261
static sys_var_session_uint32_t sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
262
&SV::trans_alloc_block_size,
263
false, fix_trans_mem_root);
264
static sys_var_session_uint32_t sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
265
&SV::trans_prealloc_size,
266
false, fix_trans_mem_root);
338
268
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
339
269
&opt_secure_file_priv);
340
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
341
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
342
&opt_slave_compressed_protocol);
343
static sys_var_bool_ptr sys_slave_allow_batching(&vars, "slave_allow_batching",
344
&slave_allow_batching);
345
static sys_var_set_slave_mode slave_exec_mode(&vars,
347
&slave_exec_mode_options,
348
&slave_exec_mode_typelib,
350
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time",
352
static sys_var_thd_ulong sys_sort_buffer(&vars, "sort_buffer_size",
270
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id,
273
static sys_var_uint64_t_ptr sys_slow_launch_time(&vars, "slow_launch_time",
275
static sys_var_session_size_t sys_sort_buffer(&vars, "sort_buffer_size",
355
278
sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
356
279
even though it is written to the binlog, the slave ignores the
357
280
MODE_NO_DIR_IN_CREATE variable, so slave's value differs from
358
281
master's (see log_event.cc: Query_log_event::do_apply_event()).
360
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
361
&SV::optimizer_switch);
283
static sys_var_session_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
284
&SV::optimizer_switch);
363
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
286
static sys_var_session_storage_engine sys_storage_engine(&vars, "storage_engine",
364
287
&SV::table_plugin);
365
288
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
366
289
system_time_zone);
367
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
290
static sys_var_uint64_t_ptr sys_table_def_size(&vars, "table_definition_cache",
368
291
&table_def_size);
369
static sys_var_long_ptr sys_table_cache_size(&vars, "table_open_cache",
292
static sys_var_uint64_t_ptr sys_table_cache_size(&vars, "table_open_cache",
370
293
&table_cache_size);
371
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
294
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
372
295
&table_lock_wait_timeout);
373
static sys_var_long_ptr sys_thread_cache_size(&vars, "thread_cache_size",
375
sys_var_long_ptr sys_thread_pool_size(&vars, "thread_pool_size",
377
static sys_var_thd_enum sys_tx_isolation(&vars, "tx_isolation",
379
&tx_isolation_typelib,
382
static sys_var_thd_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
296
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation",
298
&tx_isolation_typelib,
301
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
383
302
&SV::tmp_table_size);
384
303
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
385
304
static sys_var_const_str sys_version(&vars, "version", server_version);
386
305
static sys_var_const_str sys_version_comment(&vars, "version_comment",
387
DRIZZLE_COMPILATION_COMMENT);
306
COMPILATION_COMMENT);
388
307
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
390
309
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
392
static sys_var_thd_ulong sys_net_wait_timeout(&vars, "wait_timeout",
393
&SV::net_wait_timeout);
311
static sys_var_session_uint32_t sys_net_wait_timeout(&vars, "wait_timeout",
312
&SV::net_wait_timeout);
395
314
/* Condition pushdown to storage engine */
396
static sys_var_thd_bool
315
static sys_var_session_bool
397
316
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
398
317
&SV::engine_condition_pushdown);
400
/* Time/date/datetime formats */
402
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
404
DRIZZLE_TIMESTAMP_TIME);
405
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
407
DRIZZLE_TIMESTAMP_DATE);
408
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
409
&SV::datetime_format,
410
DRIZZLE_TIMESTAMP_DATETIME);
412
/* Variables that are bits in THD */
414
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
319
/* Variables that are bits in Session */
321
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
415
322
set_option_autocommit,
416
323
OPTION_NOT_AUTOCOMMIT,
418
static sys_var_thd_bit sys_big_tables(&vars, "big_tables", 0,
421
#ifndef TO_BE_DELETED /* Alias for big_tables */
422
static sys_var_thd_bit sys_sql_big_tables(&vars, "sql_big_tables", 0,
426
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
325
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0,
428
327
OPTION_BIG_SELECTS);
429
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
433
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
328
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0,
435
330
OPTION_WARNINGS);
436
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
331
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0,
438
333
OPTION_SQL_NOTES);
439
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
334
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
441
336
OPTION_SAFE_UPDATES);
442
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
337
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
444
339
OPTION_BUFFER_RESULT);
445
static sys_var_thd_bit sys_quote_show_create(&vars, "sql_quote_show_create", 0,
447
OPTION_QUOTE_SHOW_CREATE);
448
static sys_var_thd_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
340
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
450
342
OPTION_NO_FOREIGN_KEY_CHECKS,
451
343
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
452
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
344
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0,
454
346
OPTION_RELAXED_UNIQUE_CHECKS,
456
348
sys_var::SESSION_VARIABLE_IN_BINLOG);
457
349
/* Local state variables */
459
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
351
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit",
460
352
&SV::select_limit);
461
353
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
462
354
sys_var::SESSION_VARIABLE_IN_BINLOG);
492
384
statement-based logging mode: t will be different on master and
495
static sys_var_insert_id sys_insert_id(&vars, "insert_id");
496
static sys_var_readonly sys_error_count(&vars, "error_count",
500
static sys_var_readonly sys_warning_count(&vars, "warning_count",
505
static sys_var_rand_seed1 sys_rand_seed1(&vars, "rand_seed1",
506
sys_var::SESSION_VARIABLE_IN_BINLOG);
507
static sys_var_rand_seed2 sys_rand_seed2(&vars, "rand_seed2",
508
sys_var::SESSION_VARIABLE_IN_BINLOG);
510
static sys_var_thd_ulong sys_default_week_format(&vars, "default_week_format",
511
&SV::default_week_format);
513
sys_var_thd_ulong sys_group_concat_max_len(&vars, "group_concat_max_len",
514
&SV::group_concat_max_len);
516
sys_var_thd_time_zone sys_time_zone(&vars, "time_zone",
387
static sys_var_readonly sys_error_count(&vars, "error_count",
391
static sys_var_readonly sys_warning_count(&vars, "warning_count",
396
sys_var_session_uint64_t sys_group_concat_max_len(&vars, "group_concat_max_len",
397
&SV::group_concat_max_len);
399
sys_var_session_time_zone sys_time_zone(&vars, "time_zone",
517
400
sys_var::SESSION_VARIABLE_IN_BINLOG);
519
402
/* Global read-only variable containing hostname */
520
403
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
522
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
523
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
524
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
526
static unsigned char *slave_get_report_port(THD *thd)
528
thd->sys_var_tmp.long_value= report_port;
529
return (unsigned char*) &thd->sys_var_tmp.long_value;
532
static sys_var_readonly sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
534
sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
405
sys_var_session_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
535
406
&SV::keep_files_on_create);
536
407
/* Read only variables */
538
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
539
409
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
541
411
Additional variables (not derived from sys_var class, not accessible as
547
417
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
548
418
static SHOW_VAR fixed_vars[]= {
549
{"back_log", (char*) &back_log, SHOW_LONG},
419
{"back_log", (char*) &back_log, SHOW_INT},
550
420
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
551
421
{"language", language, SHOW_CHAR},
552
422
#ifdef HAVE_MLOCKALL
553
423
{"locked_in_memory", (char*) &locked_in_memory, SHOW_MY_BOOL},
555
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
556
{"log_error", (char*) log_error_file, SHOW_CHAR},
557
425
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
558
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
559
426
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
560
427
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
561
{"port", (char*) &mysqld_port, SHOW_INT},
428
{"port", (char*) &drizzled_port, SHOW_INT},
562
429
{"protocol_version", (char*) &protocol_version, SHOW_INT},
563
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
430
{"thread_stack", (char*) &my_thread_stack_size, SHOW_INT},
567
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
433
bool sys_var::check(Session *, set_var *var)
569
435
var->save_result.uint64_t_value= var->value->val_int();
573
bool sys_var_str::check(THD *thd, set_var *var)
439
bool sys_var_str::check(Session *session, set_var *var)
579
if ((res=(*check_func)(thd, var)) < 0)
445
if ((res=(*check_func)(session, var)) < 0)
580
446
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0),
581
447
name, var->value->str_value.ptr());
595
461
'var' parameter is NULL pointer.
598
bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex,
464
bool update_sys_var_str(sys_var_str *var_str, pthread_rwlock_t *var_mutex,
601
467
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
602
468
uint32_t new_length= (var ? var->value->str_value.length() : 0);
604
470
old_value= (char*) "";
605
if (!(res= my_strndup(old_value, new_length, MYF(0))))
471
res= (char *)malloc(new_length + 1);
474
memcpy(res, old_value, new_length);
608
478
Replace the old value in such a way that the any thread using
609
479
the value will work.
611
rw_wrlock(var_mutex);
481
pthread_rwlock_wrlock(var_mutex);
612
482
old_value= var_str->value;
613
483
var_str->value= res;
614
484
var_str->value_length= new_length;
615
rw_unlock(var_mutex);
485
pthread_rwlock_unlock(var_mutex);
621
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
491
static bool sys_update_init_connect(Session *, set_var *var)
623
493
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
627
static void sys_default_init_connect(THD* thd __attribute__((unused)),
628
enum_var_type type __attribute__((unused)))
497
static void sys_default_init_connect(Session *, enum_var_type)
630
499
update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
634
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
637
return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
641
static void sys_default_init_slave(THD* thd __attribute__((unused)),
642
enum_var_type type __attribute__((unused)))
644
update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
649
If one sets the LOW_PRIORIY UPDATES flag, we also must change the
653
static void fix_low_priority_updates(THD *thd, enum_var_type type)
655
if (type == OPT_GLOBAL)
656
thr_upgraded_concurrent_insert_lock=
657
(global_system_variables.low_priority_updates ?
658
TL_WRITE_LOW_PRIORITY : TL_WRITE);
660
thd->update_lock_default= (thd->variables.low_priority_updates ?
661
TL_WRITE_LOW_PRIORITY : TL_WRITE);
666
fix_myisam_max_sort_file_size(THD *thd __attribute__((unused)),
667
enum_var_type type __attribute__((unused)))
669
myisam_max_temp_length=
670
(my_off_t) global_system_variables.myisam_max_sort_file_size;
674
504
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
677
static void fix_max_join_size(THD *thd, enum_var_type type)
507
static void fix_max_join_size(Session *session, enum_var_type type)
679
509
if (type != OPT_GLOBAL)
681
if (thd->variables.max_join_size == HA_POS_ERROR)
682
thd->options|= OPTION_BIG_SELECTS;
511
if (session->variables.max_join_size == HA_POS_ERROR)
512
session->options|= OPTION_BIG_SELECTS;
684
thd->options&= ~OPTION_BIG_SELECTS;
514
session->options&= ~OPTION_BIG_SELECTS;
772
bool sys_var_set::update(THD *thd __attribute__((unused)),
775
*value= var->save_result.ulong_value;
779
unsigned char *sys_var_set::value_ptr(THD *thd,
780
enum_var_type type __attribute__((unused)),
781
LEX_STRING *base __attribute__((unused)))
784
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
789
for (uint32_t i= 0; val; val>>= 1, i++)
793
tmp.append(enum_names->type_names[i],
794
enum_names->type_lengths[i]);
799
if ((length= tmp.length()))
801
return (unsigned char*) thd->strmake(tmp.ptr(), length);
804
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((unused)),
805
enum_var_type type __attribute__((unused)))
807
slave_exec_mode_options= 0;
808
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
811
bool sys_var_set_slave_mode::check(THD *thd, set_var *var)
813
bool rc= sys_var_set::check(thd, var);
815
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 &&
816
bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
819
my_error(ER_SLAVE_AMBIGOUS_EXEC_MODE, MYF(0), "");
824
bool sys_var_set_slave_mode::update(THD *thd, set_var *var)
827
pthread_mutex_lock(&LOCK_global_system_variables);
828
rc= sys_var_set::update(thd, var);
829
pthread_mutex_unlock(&LOCK_global_system_variables);
833
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
835
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
836
bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
838
sql_print_error(_("Ambiguous slave modes combination."
839
" STRICT will be used"));
840
bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
842
if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
843
bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
846
bool sys_var_thd_binlog_format::is_readonly() const
849
Under certain circumstances, the variable is read-only (unchangeable):
851
THD *thd= current_thd;
853
If RBR and open temporary tables, their CREATE TABLE may not be in the
854
binlog, so we can't toggle to SBR in this connection.
855
The test below will also prevent SET GLOBAL, well it was not easy to test
856
if global or not here.
857
And this test will also prevent switching from RBR to RBR (a no-op which
858
should not happen too often).
860
If we don't have row-based replication compiled in, the variable
863
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) &&
864
thd->temporary_tables)
866
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
870
if in a stored function/trigger, it's too late to change mode
872
if (thd->in_sub_stmt)
874
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
877
return sys_var_thd_enum::is_readonly();
881
void fix_binlog_format_after_update(THD *thd,
882
enum_var_type type __attribute__((unused)))
884
thd->reset_current_stmt_binlog_row_based();
888
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
889
enum_var_type type __attribute__((unused)))
891
mysql_bin_log.set_max_size(max_binlog_size);
892
if (!max_relay_log_size)
893
active_mi->rli.relay_log.set_max_size(max_binlog_size);
897
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
898
enum_var_type type __attribute__((unused)))
900
active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
901
max_relay_log_size: max_binlog_size);
905
static void fix_max_connections(THD *thd __attribute__((unused)),
906
enum_var_type type __attribute__((unused)))
908
resize_thr_alarm(max_connections + 10);
912
static void fix_thd_mem_root(THD *thd, enum_var_type type)
914
if (type != OPT_GLOBAL)
915
reset_root_defaults(thd->mem_root,
916
thd->variables.query_alloc_block_size,
917
thd->variables.query_prealloc_size);
921
static void fix_trans_mem_root(THD *thd, enum_var_type type)
923
if (type != OPT_GLOBAL)
924
reset_root_defaults(&thd->transaction.mem_root,
925
thd->variables.trans_alloc_block_size,
926
thd->variables.trans_prealloc_size);
930
static void fix_server_id(THD *thd __attribute__((unused)),
931
enum_var_type type __attribute__((unused)))
600
static void fix_session_mem_root(Session *session, enum_var_type type)
602
if (type != OPT_GLOBAL)
603
reset_root_defaults(session->mem_root,
604
session->variables.query_alloc_block_size,
605
session->variables.query_prealloc_size);
609
static void fix_trans_mem_root(Session *session, enum_var_type type)
611
if (type != OPT_GLOBAL)
612
reset_root_defaults(&session->transaction.mem_root,
613
session->variables.trans_alloc_block_size,
614
session->variables.trans_prealloc_size);
618
static void fix_server_id(Session *session, enum_var_type)
933
620
server_id_supplied = 1;
934
thd->server_id= server_id;
621
session->server_id= server_id;
938
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
625
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
939
626
const char *name, int64_t val)
950
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
637
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
951
638
ER_TRUNCATED_WRONG_VALUE,
952
639
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
957
static uint64_t fix_unsigned(THD *thd, uint64_t num,
644
static uint64_t fix_unsigned(Session *session, uint64_t num,
958
645
const struct my_option *option_limits)
960
647
bool fixed= false;
961
648
uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
963
throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
967
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
969
if (var->value->unsigned_flag)
970
var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
973
int64_t v= var->value->val_int();
974
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
981
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_arg,
982
sys_after_update_func after_update_arg)
983
:sys_var_long_ptr_global(chain, name_arg, value_ptr_arg,
984
&LOCK_global_system_variables, after_update_arg)
988
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
990
return get_unsigned(thd, var);
993
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
995
uint64_t tmp= var->save_result.uint64_t_value;
996
pthread_mutex_lock(guard);
650
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
655
static size_t fix_size_t(Session *session, size_t num,
656
const struct my_option *option_limits)
659
size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed);
661
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
665
static bool get_unsigned32(Session *, set_var *var)
667
if (var->value->unsigned_flag)
668
var->save_result.uint32_t_value= (uint32_t) var->value->val_int();
671
int64_t v= var->value->val_int();
672
var->save_result.uint32_t_value= (uint32_t) ((v < 0) ? 0 : v);
677
static bool get_unsigned64(Session *, set_var *var)
679
if (var->value->unsigned_flag)
680
var->save_result.uint64_t_value=(uint64_t) var->value->val_int();
683
int64_t v= var->value->val_int();
684
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
689
static bool get_size_t(Session *, set_var *var)
691
if (var->value->unsigned_flag)
692
var->save_result.size_t_value= (size_t) var->value->val_int();
695
ssize_t v= (ssize_t)var->value->val_int();
696
var->save_result.size_t_value= (size_t) ((v < 0) ? 0 : v);
701
bool sys_var_uint32_t_ptr::check(Session *, set_var *var)
703
var->save_result.uint32_t_value= var->value->val_int();
707
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
709
uint32_t tmp= var->save_result.uint32_t_value;
710
pthread_mutex_lock(&LOCK_global_system_variables);
997
711
if (option_limits)
998
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
1001
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1002
/* Avoid overflows on 32 bit systems */
1003
if (tmp > ULONG_MAX)
1006
throw_bounds_warning(thd, true, true, name,
1007
(int64_t) var->save_result.uint64_t_value);
1010
*value= (ulong) tmp;
713
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
1013
pthread_mutex_unlock(guard);
718
*value= (uint32_t) tmp;
719
pthread_mutex_unlock(&LOCK_global_system_variables);
1018
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
724
void sys_var_uint32_t_ptr::set_default(Session *, enum_var_type)
1021
pthread_mutex_lock(guard);
1022
*value= (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1023
option_limits, ¬_used);
1024
pthread_mutex_unlock(guard);
727
pthread_mutex_lock(&LOCK_global_system_variables);
728
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
729
option_limits, ¬_used);
730
pthread_mutex_unlock(&LOCK_global_system_variables);
1028
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
734
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
1030
736
uint64_t tmp= var->save_result.uint64_t_value;
1031
737
pthread_mutex_lock(&LOCK_global_system_variables);
1032
738
if (option_limits)
1033
*value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
740
uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits);
1035
745
*value= (uint64_t) tmp;
1036
746
pthread_mutex_unlock(&LOCK_global_system_variables);
1052
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
1054
*value= (bool) var->save_result.ulong_value;
1059
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
761
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
763
size_t tmp= var->save_result.size_t_value;
764
pthread_mutex_lock(&LOCK_global_system_variables);
766
*value= fix_size_t(session, tmp, option_limits);
769
pthread_mutex_unlock(&LOCK_global_system_variables);
774
void sys_var_size_t_ptr::set_default(Session *, enum_var_type)
777
pthread_mutex_lock(&LOCK_global_system_variables);
778
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
779
option_limits, ¬_used);
780
pthread_mutex_unlock(&LOCK_global_system_variables);
783
bool sys_var_bool_ptr::update(Session *, set_var *var)
785
*value= (bool) var->save_result.uint32_t_value;
790
void sys_var_bool_ptr::set_default(Session *, enum_var_type)
1061
792
*value= (bool) option_limits->def_value;
1065
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
796
bool sys_var_enum::update(Session *, set_var *var)
1067
*value= (uint) var->save_result.ulong_value;
798
*value= (uint32_t) var->save_result.uint32_t_value;
1072
unsigned char *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1073
enum_var_type type __attribute__((unused)),
1074
LEX_STRING *base __attribute__((unused)))
803
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, const LEX_STRING *)
1076
805
return (unsigned char*) enum_names->type_names[*value];
1080
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1081
enum_var_type type __attribute__((unused)),
1082
LEX_STRING *base __attribute__((unused)))
809
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type,
1084
812
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1087
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
816
32 bit types for session variables
818
bool sys_var_session_uint32_t::check(Session *session, set_var *var)
1089
return (get_unsigned(thd, var) ||
1090
(check_func && (*check_func)(thd, var)));
820
return (get_unsigned32(session, var) ||
821
(check_func && (*check_func)(session, var)));
1093
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
824
bool sys_var_session_uint32_t::update(Session *session, set_var *var)
1095
uint64_t tmp= var->save_result.uint64_t_value;
826
uint64_t tmp= (uint64_t) var->save_result.uint32_t_value;
1097
828
/* Don't use bigger value than given with --maximum-variable-name=.. */
1098
if ((ulong) tmp > max_system_variables.*offset)
829
if ((uint32_t) tmp > max_system_variables.*offset)
1100
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
831
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1101
832
tmp= max_system_variables.*offset;
1104
835
if (option_limits)
1105
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1106
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1107
else if (tmp > ULONG_MAX)
836
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits);
837
else if (tmp > UINT32_MAX)
1110
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
840
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value);
1114
843
if (var->type == OPT_GLOBAL)
1115
global_system_variables.*offset= (ulong) tmp;
844
global_system_variables.*offset= (uint32_t) tmp;
1117
thd->variables.*offset= (ulong) tmp;
846
session->variables.*offset= (uint32_t) tmp;
1123
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
852
void sys_var_session_uint32_t::set_default(Session *session, enum_var_type type)
1125
854
if (type == OPT_GLOBAL)
1128
857
/* We will not come here if option_limits is not set */
1129
858
global_system_variables.*offset=
1130
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
859
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value,
1131
860
option_limits, ¬_used);
1134
thd->variables.*offset= global_system_variables.*offset;
863
session->variables.*offset= global_system_variables.*offset;
1138
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
LEX_STRING *base __attribute__((unused)))
867
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session,
1141
871
if (type == OPT_GLOBAL)
1142
872
return (unsigned char*) &(global_system_variables.*offset);
1143
return (unsigned char*) &(thd->variables.*offset);
873
return (unsigned char*) &(session->variables.*offset);
1147
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
877
bool sys_var_session_ha_rows::update(Session *session, set_var *var)
1149
879
uint64_t tmp= var->save_result.uint64_t_value;
1231
963
pthread_mutex_unlock(&LOCK_global_system_variables);
1234
thd->variables.*offset= global_system_variables.*offset;
1238
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1239
LEX_STRING *base __attribute__((unused)))
1241
if (type == OPT_GLOBAL)
1242
return (unsigned char*) &(global_system_variables.*offset);
1243
return (unsigned char*) &(thd->variables.*offset);
1247
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1249
if (var->type == OPT_GLOBAL)
1250
global_system_variables.*offset= (bool) var->save_result.ulong_value;
1252
thd->variables.*offset= (bool) var->save_result.ulong_value;
1257
void sys_var_thd_bool::set_default(THD *thd, enum_var_type type)
966
session->variables.*offset= global_system_variables.*offset;
970
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session,
974
if (type == OPT_GLOBAL)
975
return (unsigned char*) &(global_system_variables.*offset);
976
return (unsigned char*) &(session->variables.*offset);
979
bool sys_var_session_size_t::check(Session *session, set_var *var)
981
return (get_size_t(session, var) ||
982
(check_func && (*check_func)(session, var)));
985
bool sys_var_session_size_t::update(Session *session, set_var *var)
987
size_t tmp= var->save_result.size_t_value;
989
if (tmp > max_system_variables.*offset)
990
tmp= max_system_variables.*offset;
993
tmp= fix_size_t(session, tmp, option_limits);
994
if (var->type == OPT_GLOBAL)
996
/* Lock is needed to make things safe on 32 bit systems */
997
pthread_mutex_lock(&LOCK_global_system_variables);
998
global_system_variables.*offset= tmp;
999
pthread_mutex_unlock(&LOCK_global_system_variables);
1002
session->variables.*offset= tmp;
1007
void sys_var_session_size_t::set_default(Session *session, enum_var_type type)
1009
if (type == OPT_GLOBAL)
1012
pthread_mutex_lock(&LOCK_global_system_variables);
1013
global_system_variables.*offset=
1014
(size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
1015
option_limits, ¬_used);
1016
pthread_mutex_unlock(&LOCK_global_system_variables);
1019
session->variables.*offset= global_system_variables.*offset;
1023
unsigned char *sys_var_session_size_t::value_ptr(Session *session,
1027
if (type == OPT_GLOBAL)
1028
return (unsigned char*) &(global_system_variables.*offset);
1029
return (unsigned char*) &(session->variables.*offset);
1033
bool sys_var_session_bool::update(Session *session, set_var *var)
1035
if (var->type == OPT_GLOBAL)
1036
global_system_variables.*offset= (bool) var->save_result.uint32_t_value;
1038
session->variables.*offset= (bool) var->save_result.uint32_t_value;
1043
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
1259
1045
if (type == OPT_GLOBAL)
1260
1046
global_system_variables.*offset= (bool) option_limits->def_value;
1262
thd->variables.*offset= global_system_variables.*offset;
1048
session->variables.*offset= global_system_variables.*offset;
1266
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1267
LEX_STRING *base __attribute__((unused)))
1052
unsigned char *sys_var_session_bool::value_ptr(Session *session,
1269
1056
if (type == OPT_GLOBAL)
1270
1057
return (unsigned char*) &(global_system_variables.*offset);
1271
return (unsigned char*) &(thd->variables.*offset);
1058
return (unsigned char*) &(session->variables.*offset);
1275
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1062
bool sys_var::check_enum(Session *,
1276
1063
set_var *var, const TYPELIB *enum_names)
1278
1065
char buff[STRING_BUFFER_USUAL_SIZE];
1492
bool sys_var_thd_enum::update(THD *thd, set_var *var)
1278
bool sys_var_session_enum::update(Session *session, set_var *var)
1494
1280
if (var->type == OPT_GLOBAL)
1495
global_system_variables.*offset= var->save_result.ulong_value;
1281
global_system_variables.*offset= var->save_result.uint32_t_value;
1497
thd->variables.*offset= var->save_result.ulong_value;
1283
session->variables.*offset= var->save_result.uint32_t_value;
1502
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
1288
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1504
1290
if (type == OPT_GLOBAL)
1505
global_system_variables.*offset= (ulong) option_limits->def_value;
1291
global_system_variables.*offset= (uint32_t) option_limits->def_value;
1507
thd->variables.*offset= global_system_variables.*offset;
1293
session->variables.*offset= global_system_variables.*offset;
1511
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1512
LEX_STRING *base __attribute__((unused)))
1297
unsigned char *sys_var_session_enum::value_ptr(Session *session,
1514
ulong tmp= ((type == OPT_GLOBAL) ?
1301
uint32_t tmp= ((type == OPT_GLOBAL) ?
1515
1302
global_system_variables.*offset :
1516
thd->variables.*offset);
1303
session->variables.*offset);
1517
1304
return (unsigned char*) enum_names->type_names[tmp];
1520
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1307
bool sys_var_session_bit::check(Session *session, set_var *var)
1522
return (check_enum(thd, var, &bool_typelib) ||
1523
(check_func && (*check_func)(thd, var)));
1309
return (check_enum(session, var, &bool_typelib) ||
1310
(check_func && (*check_func)(session, var)));
1526
bool sys_var_thd_bit::update(THD *thd, set_var *var)
1313
bool sys_var_session_bit::update(Session *session, set_var *var)
1528
int res= (*update_func)(thd, var);
1315
int res= (*update_func)(session, var);
1533
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1534
enum_var_type type __attribute__((unused)),
1535
LEX_STRING *base __attribute__((unused)))
1320
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type,
1538
1324
If reverse is 0 (default) return 1 if bit is set.
1539
1325
If reverse is 1, return 0 if bit is set
1541
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1327
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ?
1542
1328
!reverse : reverse);
1543
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1547
/** Update a date_time format variable based on given value. */
1549
void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
1550
DATE_TIME_FORMAT *new_value)
1552
DATE_TIME_FORMAT *old;
1554
if (type == OPT_GLOBAL)
1556
pthread_mutex_lock(&LOCK_global_system_variables);
1557
old= (global_system_variables.*offset);
1558
(global_system_variables.*offset)= new_value;
1559
pthread_mutex_unlock(&LOCK_global_system_variables);
1563
old= (thd->variables.*offset);
1564
(thd->variables.*offset)= new_value;
1571
bool sys_var_thd_date_time_format::update(THD *thd, set_var *var)
1573
DATE_TIME_FORMAT *new_value;
1574
/* We must make a copy of the last value to get it into normal memory */
1575
new_value= date_time_format_copy((THD*) 0,
1576
var->save_result.date_time_format);
1578
return 1; // Out of memory
1579
update2(thd, var->type, new_value); // Can't fail
1584
bool sys_var_thd_date_time_format::check(THD *thd, set_var *var)
1586
char buff[STRING_BUFFER_USUAL_SIZE];
1587
String str(buff,sizeof(buff), system_charset_info), *res;
1588
DATE_TIME_FORMAT *format;
1590
if (!(res=var->value->val_str(&str)))
1591
res= &my_empty_string;
1593
if (!(format= date_time_format_make(date_time_type,
1594
res->ptr(), res->length())))
1596
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr());
1601
We must copy result to thread space to not get a memory leak if
1604
var->save_result.date_time_format= date_time_format_copy(thd, format);
1605
free((char*) format);
1606
return var->save_result.date_time_format == 0;
1610
void sys_var_thd_date_time_format::set_default(THD *thd, enum_var_type type)
1612
DATE_TIME_FORMAT *res= 0;
1614
if (type == OPT_GLOBAL)
1617
if ((format= opt_date_time_formats[date_time_type]))
1618
res= date_time_format_make(date_time_type, format, strlen(format));
1622
/* Make copy with malloc */
1623
res= date_time_format_copy((THD *) 0, global_system_variables.*offset);
1626
if (res) // Should always be true
1627
update2(thd, type, res);
1631
unsigned char *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
1632
LEX_STRING *base __attribute__((unused)))
1634
if (type == OPT_GLOBAL)
1638
We do a copy here just to be sure things will work even if someone
1639
is modifying the original string while the copy is accessed
1640
(Can't happen now in SQL SHOW, but this is a good safety for the future)
1642
res= thd->strmake((global_system_variables.*offset)->format.str,
1643
(global_system_variables.*offset)->format.length);
1644
return (unsigned char*) res;
1646
return (unsigned char*) (thd->variables.*offset)->format.str;
1329
return (unsigned char*) &session->sys_var_tmp.bool_value;
1691
bool sys_var_character_set::check(THD *thd __attribute__((unused)),
1694
const CHARSET_INFO *tmp;
1696
if (var->value->result_type() == STRING_RESULT)
1698
char buff[STRING_BUFFER_USUAL_SIZE];
1699
String str(buff,sizeof(buff), system_charset_info), *res;
1700
if (!(res=var->value->val_str(&str)))
1704
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
1709
else if (!(tmp= get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))))
1711
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
1717
if (!(tmp=get_charset((int) var->value->val_int(),MYF(0))))
1720
int10_to_str((int) var->value->val_int(), buf, -10);
1721
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), buf);
1725
var->save_result.charset= tmp; // Save for update
1730
bool sys_var_character_set::update(THD *thd, set_var *var)
1732
ci_ptr(thd,var->type)[0]= var->save_result.charset;
1733
thd->update_charset();
1738
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1739
LEX_STRING *base __attribute__((unused)))
1741
const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1742
return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
1746
void sys_var_character_set_sv::set_default(THD *thd, enum_var_type type)
1748
if (type == OPT_GLOBAL)
1749
global_system_variables.*offset= *global_default;
1752
thd->variables.*offset= global_system_variables.*offset;
1753
thd->update_charset();
1756
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1758
if (type == OPT_GLOBAL)
1759
return &(global_system_variables.*offset);
1761
return &(thd->variables.*offset);
1765
bool sys_var_character_set_client::check(THD *thd, set_var *var)
1767
if (sys_var_character_set_sv::check(thd, var))
1769
/* Currently, UCS-2 cannot be used as a client character set */
1770
if (var->save_result.charset->mbminlen > 1)
1772
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
1773
var->save_result.charset->csname);
1780
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1783
if (type == OPT_GLOBAL)
1784
return &global_system_variables.collation_database;
1786
return &thd->variables.collation_database;
1790
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
1792
if (type == OPT_GLOBAL)
1793
global_system_variables.collation_database= default_charset_info;
1796
thd->variables.collation_database= thd->db_charset;
1797
thd->update_charset();
1802
bool sys_var_collation_sv::update(THD *thd, set_var *var)
1373
bool sys_var_collation_sv::update(Session *session, set_var *var)
1804
1375
if (var->type == OPT_GLOBAL)
1805
1376
global_system_variables.*offset= var->save_result.charset;
1808
thd->variables.*offset= var->save_result.charset;
1809
thd->update_charset();
1379
session->variables.*offset= var->save_result.charset;
1380
session->update_charset();
1815
void sys_var_collation_sv::set_default(THD *thd, enum_var_type type)
1386
void sys_var_collation_sv::set_default(Session *session, enum_var_type type)
1817
1388
if (type == OPT_GLOBAL)
1818
1389
global_system_variables.*offset= *global_default;
1821
thd->variables.*offset= global_system_variables.*offset;
1822
thd->update_charset();
1392
session->variables.*offset= global_system_variables.*offset;
1393
session->update_charset();
1827
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
LEX_STRING *base __attribute__((unused)))
1398
unsigned char *sys_var_collation_sv::value_ptr(Session *session,
1830
1402
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
global_system_variables.*offset : thd->variables.*offset);
1403
global_system_variables.*offset :
1404
session->variables.*offset);
1832
1405
return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
2003
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
2006
pthread_mutex_lock(&LOCK_global_system_variables);
2007
if (!var->save_result.ulong_value)
2011
pthread_mutex_unlock(&LOCK_global_system_variables);
2015
void sys_var_log_state::set_default(THD *thd __attribute__((unused)),
2016
enum_var_type type __attribute__((unused)))
2021
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
2022
sys_var_str *var_str,
2023
set_var *var, const char *log_ext,
2024
bool log_state, uint32_t log_type)
2026
char buff[FN_REFLEN];
2027
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2029
uint32_t str_length= (var ? var->value->str_value.length() : 0);
2033
assert(0); // Impossible
2038
old_value= make_default_log_name(buff, log_ext);
2039
str_length= strlen(old_value);
2041
if (!(res= my_strndup(old_value, str_length, MYF(MY_FAE+MY_WME))))
2047
pthread_mutex_lock(&LOCK_global_system_variables);
2048
logger.lock_exclusive();
2050
old_value= var_str->value;
2051
var_str->value= res;
2052
var_str->value_length= str_length;
2063
pthread_mutex_unlock(&LOCK_global_system_variables);
2070
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
2073
pthread_mutex_lock(&LOCK_global_system_variables);
2074
logger.lock_exclusive();
2075
*value= var->save_result.ulong_value;
2077
pthread_mutex_unlock(&LOCK_global_system_variables);
2082
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
2083
enum_var_type type __attribute__((unused)))
2085
pthread_mutex_lock(&LOCK_global_system_variables);
2086
logger.lock_exclusive();
2089
pthread_mutex_unlock(&LOCK_global_system_variables);
2093
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2094
enum_var_type type __attribute__((unused)),
2095
LEX_STRING *base __attribute__((unused)))
2098
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
2103
for (uint32_t i= 0; val; val>>= 1, i++)
2107
tmp.append(log_output_typelib.type_names[i],
2108
log_output_typelib.type_lengths[i]);
2113
if ((length= tmp.length()))
2115
return (unsigned char*) thd->strmake(tmp.ptr(), length);
2119
/*****************************************************************************
2120
Functions to handle SET NAMES and SET CHARACTER SET
2121
*****************************************************************************/
2123
int set_var_collation_client::check(THD *thd __attribute__((unused)))
2125
/* Currently, UCS-2 cannot be used as a client character set */
2126
if (character_set_client->mbminlen > 1)
2128
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "character_set_client",
2129
character_set_client->csname);
2135
int set_var_collation_client::update(THD *thd)
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);
2145
1575
/****************************************************************************/
2147
bool sys_var_timestamp::update(THD *thd, set_var *var)
1577
bool sys_var_timestamp::update(Session *session, set_var *var)
2149
thd->set_time((time_t) var->save_result.uint64_t_value);
1579
session->set_time((time_t) var->save_result.uint64_t_value);
2154
void sys_var_timestamp::set_default(THD *thd,
2155
enum_var_type type __attribute__((unused)))
2161
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2162
enum_var_type type __attribute__((unused)),
2163
LEX_STRING *base __attribute__((unused)))
2165
thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
return (unsigned char*) &thd->sys_var_tmp.long_value;
2170
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2172
thd->first_successful_insert_id_in_prev_stmt=
1584
void sys_var_timestamp::set_default(Session *session, enum_var_type)
1586
session->user_time=0;
1590
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type,
1593
session->sys_var_tmp.long_value= (long) session->start_time;
1594
return (unsigned char*) &session->sys_var_tmp.long_value;
1598
bool sys_var_last_insert_id::update(Session *session, set_var *var)
1600
session->first_successful_insert_id_in_prev_stmt=
2173
1601
var->save_result.uint64_t_value;
2178
unsigned char *sys_var_last_insert_id::value_ptr(THD *thd,
2179
enum_var_type type __attribute__((unused)),
2180
LEX_STRING *base __attribute__((unused)))
1606
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
2183
1611
this tmp var makes it robust againt change of type of
2184
1612
read_first_successful_insert_id_in_prev_stmt().
2186
thd->sys_var_tmp.uint64_t_value=
2187
thd->read_first_successful_insert_id_in_prev_stmt();
2188
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2192
bool sys_var_insert_id::update(THD *thd, set_var *var)
2194
thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
2199
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2200
enum_var_type type __attribute__((unused)),
2201
LEX_STRING *base __attribute__((unused)))
2203
thd->sys_var_tmp.uint64_t_value=
2204
thd->auto_inc_intervals_forced.minimum();
2205
return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
2209
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2211
thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
2215
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2217
thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
2222
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
1614
session->sys_var_tmp.uint64_t_value=
1615
session->read_first_successful_insert_id_in_prev_stmt();
1616
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1620
bool sys_var_session_time_zone::check(Session *session, set_var *var)
2224
1622
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
1623
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2226
1624
String *res= var->value->val_str(&str);
2228
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
1626
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2230
1628
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
2286
1684
We are guaranteed to find this time zone since its existence
2287
1685
is checked during start-up.
2289
global_system_variables.time_zone= my_tz_find(thd, &str);
1687
global_system_variables.time_zone= my_tz_find(session, &str);
2292
1690
global_system_variables.time_zone= my_tz_SYSTEM;
2295
thd->variables.time_zone= global_system_variables.time_zone;
1693
session->variables.time_zone= global_system_variables.time_zone;
2296
1694
pthread_mutex_unlock(&LOCK_global_system_variables);
2300
bool sys_var_max_user_conn::check(THD *thd, set_var *var)
2302
if (var->type == OPT_GLOBAL)
2303
return sys_var_thd::check(thd, var);
2307
Per-session values of max_user_connections can't be set directly.
2308
May be we should have a separate error message for this?
2310
my_error(ER_GLOBAL_VARIABLE, MYF(0), name);
2315
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
2318
assert(var->type == OPT_GLOBAL);
2319
pthread_mutex_lock(&LOCK_global_system_variables);
2320
max_user_connections= (uint)var->save_result.uint64_t_value;
2321
pthread_mutex_unlock(&LOCK_global_system_variables);
2326
void sys_var_max_user_conn::set_default(THD *thd __attribute__((unused)),
2327
enum_var_type type __attribute__((unused)))
2329
assert(type == OPT_GLOBAL);
2330
pthread_mutex_lock(&LOCK_global_system_variables);
2331
max_user_connections= (ulong) option_limits->def_value;
2332
pthread_mutex_unlock(&LOCK_global_system_variables);
2336
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2337
LEX_STRING *base __attribute__((unused)))
2339
if (type != OPT_GLOBAL &&
2340
thd->user_connect && thd->user_connect->user_resources.user_conn)
2341
return (unsigned char*) &(thd->user_connect->user_resources.user_conn);
2342
return (unsigned char*) &(max_user_connections);
2346
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
1698
bool sys_var_session_lc_time_names::check(Session *, set_var *var)
2349
1700
MY_LOCALE *locale_match;
2351
1702
if (var->value->result_type() == INT_RESULT)
2353
if (!(locale_match= my_locale_by_number((uint) var->value->val_int())))
1704
if (!(locale_match= my_locale_by_number((uint32_t) var->value->val_int())))
2356
1707
int10_to_str((int) var->value->val_int(), buf, -10);
2449
1800
pthread_mutex_unlock(&LOCK_global_system_variables);
2452
thd->variables.*offset= microseconds;
1803
session->variables.*offset= microseconds;
2456
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
LEX_STRING *base __attribute__((unused)))
1807
unsigned char *sys_var_microseconds::value_ptr(Session *session,
2459
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
1811
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
1812
global_system_variables.*offset :
2461
thd->variables.*offset) / 1000000.0;
2462
return (unsigned char*) &thd->tmp_double_value;
1813
session->variables.*offset) / 1000000.0;
1814
return (unsigned char*) &session->tmp_double_value;
2467
Functions to update thd->options bits
1819
Functions to update session->options bits
2470
static bool set_option_bit(THD *thd, set_var *var)
1822
static bool set_option_bit(Session *session, set_var *var)
2472
sys_var_thd_bit *sys_var= ((sys_var_thd_bit*) var->var);
2473
if ((var->save_result.ulong_value != 0) == sys_var->reverse)
2474
thd->options&= ~sys_var->bit_flag;
1824
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var);
1825
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse)
1826
session->options&= ~sys_var->bit_flag;
2476
thd->options|= sys_var->bit_flag;
1828
session->options|= sys_var->bit_flag;
2481
static bool set_option_autocommit(THD *thd, set_var *var)
1833
static bool set_option_autocommit(Session *session, set_var *var)
2483
1835
/* The test is negative as the flag we use is NOT autocommit */
2485
uint64_t org_options= thd->options;
1837
uint64_t org_options= session->options;
2487
if (var->save_result.ulong_value != 0)
2488
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
1839
if (var->save_result.uint32_t_value != 0)
1840
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2490
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
1842
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2492
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
1844
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2494
1846
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2496
1848
/* We changed to auto_commit mode */
2497
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2498
thd->transaction.all.modified_non_trans_table= false;
2499
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
1849
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
1850
session->transaction.all.modified_non_trans_table= false;
1851
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1852
if (ha_commit(session))
2505
thd->transaction.all.modified_non_trans_table= false;
2506
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1857
session->transaction.all.modified_non_trans_table= false;
1858
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2512
static int check_log_update(THD *thd __attribute__((unused)),
2513
set_var *var __attribute__((unused)))
2519
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
1864
static int check_pseudo_thread_id(Session *, set_var *var)
2522
1866
var->save_result.uint64_t_value= var->value->val_int();
2526
static unsigned char *get_warning_count(THD *thd)
1870
static unsigned char *get_warning_count(Session *session)
2528
thd->sys_var_tmp.long_value=
2529
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2530
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2531
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2532
return (unsigned char*) &thd->sys_var_tmp.long_value;
1872
session->sys_var_tmp.uint32_t_value=
1873
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
1874
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
1875
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
1876
return (unsigned char*) &session->sys_var_tmp.uint32_t_value;
2535
static unsigned char *get_error_count(THD *thd)
1879
static unsigned char *get_error_count(Session *session)
2537
thd->sys_var_tmp.long_value=
2538
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2539
return (unsigned char*) &thd->sys_var_tmp.long_value;
1881
session->sys_var_tmp.uint32_t_value=
1882
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
1883
return (unsigned char*) &session->sys_var_tmp.uint32_t_value;
2629
1960
int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options)
2633
1963
/* A write lock should be held on LOCK_system_variables_hash */
2635
1965
for (var= first; var; var= var->next)
2637
var->name_length= strlen(var->name);
2638
/* this fails if there is a conflicting variable name. see HASH_UNIQUE */
2639
if (my_hash_insert(&system_variable_hash, (unsigned char*) var))
1967
/* Make a temp string to hold this and then make it lower so that matching
1968
* happens case-insensitive.
1970
string var_name(var->name);
1971
transform(var_name.begin(), var_name.end(), var_name.begin(), ::tolower);
1972
var->name_length= var_name.length();
1974
/* this fails if there is a conflicting variable name. */
1975
if (system_variable_hash.count(var_name) == 0)
1977
system_variable_hash[var_name]= var;
1981
for (; first != var; first= first->next)
1984
* This is slightly expensive, since we have to do the transform
1985
* _again_ but should rarely happen unless there is a pretty
1986
* major problem in the code
1988
var_name= first->name;
1989
transform(var_name.begin(), var_name.end(),
1990
var_name.begin(), ::tolower);
1991
system_variable_hash.erase(var_name);
2641
1995
if (long_options)
2642
1996
var->option_limits= find_option(long_options, var->name);
2647
for (; first != var; first= first->next)
2648
hash_delete(&system_variable_hash, (unsigned char*) first);
2654
2004
Remove variables to the dynamic hash of system variables
2657
2007
mysql_del_sys_var_chain()
2658
2008
first Pointer to first system variable to remove
2662
2012
otherwise FAILURE
2665
2015
int mysql_del_sys_var_chain(sys_var *first)
2669
2020
/* A write lock should be held on LOCK_system_variables_hash */
2671
2021
for (sys_var *var= first; var; var= var->next)
2672
result|= hash_delete(&system_variable_hash, (unsigned char*) var);
2023
var_name= var->name;
2024
transform(var_name.begin(), var_name.end(),
2025
var_name.begin(), ::tolower);
2026
result|= system_variable_hash.erase(var_name);
2678
static int show_cmp(SHOW_VAR *a, SHOW_VAR *b)
2680
return strcmp(a->name, b->name);
2685
2035
Constructs an array of system variables for display to the user.
2688
2038
enumerate_sys_vars()
2039
session current thread
2690
2040
sorted If TRUE, the system variables should be sorted
2693
2043
pointer Array of SHOW_VAR elements for display
2697
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted)
2047
SHOW_VAR* enumerate_sys_vars(Session *session, bool)
2699
int count= system_variable_hash.records, i;
2700
2049
int fixed_count= fixed_show_vars.elements;
2701
int size= sizeof(SHOW_VAR) * (count + fixed_count + 1);
2702
SHOW_VAR *result= (SHOW_VAR*) thd->alloc(size);
2050
int size= sizeof(SHOW_VAR) * (system_variable_hash.size() + fixed_count + 1);
2051
SHOW_VAR *result= (SHOW_VAR*) session->alloc(size);
2706
2055
SHOW_VAR *show= result + fixed_count;
2707
2056
memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(SHOW_VAR));
2709
for (i= 0; i < count; i++)
2058
map<string, sys_var *>::iterator iter;
2059
for(iter= system_variable_hash.begin();
2060
iter != system_variable_hash.end();
2711
sys_var *var= (sys_var*) hash_element(&system_variable_hash, i);
2063
sys_var *var= (*iter).second;
2712
2064
show->name= var->name;
2713
2065
show->value= (char*) var;
2714
2066
show->type= SHOW_SYS;
2718
/* sort into order */
2720
my_qsort(result, count + fixed_count, sizeof(SHOW_VAR),
2721
(qsort_cmp) show_cmp);
2723
2070
/* make last element empty */
2724
2071
memset(show, 0, sizeof(SHOW_VAR));
3027
unsigned char *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
3028
LEX_STRING *base __attribute__((unused)))
2365
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session,
3030
2369
unsigned char* result;
2370
StorageEngine *engine;
3032
2371
LEX_STRING *engine_name;
3033
plugin_ref plugin= thd->variables.*offset;
3034
if (type == OPT_GLOBAL)
3035
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
3036
hton= plugin_data(plugin, handlerton*);
3037
engine_name= &hton2plugin[hton->slot]->name;
3038
result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
3039
if (type == OPT_GLOBAL)
3040
plugin_unlock(thd, plugin);
2372
plugin_ref plugin= session->variables.*offset;
2373
if (type == OPT_GLOBAL)
2374
plugin= plugin_lock(session, &(global_system_variables.*offset));
2375
engine= plugin_data(plugin, StorageEngine*);
2376
engine_name= ha_storage_engine_name(engine);
2377
result= (unsigned char *) session->strmake(engine_name->str, engine_name->length);
3045
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
2382
void sys_var_session_storage_engine::set_default(Session *session, enum_var_type type)
3047
2384
plugin_ref old_value, new_value, *value;
3048
2385
if (type == OPT_GLOBAL)
3050
2387
value= &(global_system_variables.*offset);
3051
new_value= ha_lock_engine(NULL, myisam_hton);
2388
new_value= ha_lock_engine(NULL, myisam_engine);
3055
value= &(thd->variables.*offset);
3056
new_value= my_plugin_lock(NULL, &(global_system_variables.*offset));
2392
value= &(session->variables.*offset);
2393
new_value= plugin_lock(NULL, &(global_system_variables.*offset));
3058
2395
assert(new_value);
3059
2396
old_value= *value;
3060
2397
*value= new_value;
3061
plugin_unlock(NULL, old_value);
3065
bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
2401
bool sys_var_session_storage_engine::update(Session *session, set_var *var)
3067
2403
plugin_ref *value= &(global_system_variables.*offset), old_value;
3068
2404
if (var->type != OPT_GLOBAL)
3069
value= &(thd->variables.*offset);
2405
value= &(session->variables.*offset);
3070
2406
old_value= *value;
3071
2407
if (old_value != var->save_result.plugin)
3073
*value= my_plugin_lock(NULL, &var->save_result.plugin);
3074
plugin_unlock(NULL, old_value);
2409
*value= plugin_lock(NULL, &var->save_result.plugin);
3080
sys_var_thd_optimizer_switch::
3081
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
2415
sys_var_session_optimizer_switch::
2416
symbolic_mode_representation(Session *session, uint32_t val, LEX_STRING *rep)
3083
2418
char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
2419
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3223
2558
while ((element= it++))
3225
2560
KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
3226
func(element->name, key_cache);
2561
func(element->name.c_str(), key_cache);
3232
bool sys_var_opt_readonly::update(THD *thd, set_var *var)
3236
/* Prevent self dead-lock */
3237
if (thd->locked_tables || thd->active_transaction())
3239
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
3243
if (thd->global_read_lock)
3246
This connection already holds the global read lock.
3247
This can be the case with:
3248
- FLUSH TABLES WITH READ LOCK
3249
- SET GLOBAL READ_ONLY = 1
3251
result= sys_var_bool_ptr::update(thd, var);
3256
Perform a 'FLUSH TABLES WITH READ LOCK'.
3257
This is a 3 step process:
3258
- [1] lock_global_read_lock()
3259
- [2] close_cached_tables()
3260
- [3] make_global_read_lock_block_commit()
3261
[1] prevents new connections from obtaining tables locked for write.
3262
[2] waits until all existing connections close their tables.
3263
[3] prevents transactions from being committed.
3266
if (lock_global_read_lock(thd))
3270
This call will be blocked by any connection holding a READ or WRITE lock.
3271
Ideally, we want to wait only for pending WRITE locks, but since:
3272
con 1> LOCK TABLE T FOR READ;
3273
con 2> LOCK TABLE T FOR WRITE; (blocked by con 1)
3274
con 3> SET GLOBAL READ ONLY=1; (blocked by con 2)
3275
can cause to wait on a read lock, it's required for the client application
3276
to unlock everything, and acceptable for the server to wait on all locks.
3278
if ((result= close_cached_tables(thd, NULL, false, true, true)) == true)
3279
goto end_with_read_lock;
3281
if ((result= make_global_read_lock_block_commit(thd)) == true)
3282
goto end_with_read_lock;
3284
/* Change the opt_readonly system variable, safe because the lock is held */
3285
result= sys_var_bool_ptr::update(thd, var);
3288
/* Release the lock */
3289
unlock_global_read_lock(thd);
3293
2566
/****************************************************************************
3295
2568
****************************************************************************/