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 set_option_bit(Session *session, set_var *var);
96
static bool set_option_autocommit(Session *session, set_var *var);
97
static int check_pseudo_thread_id(Session *session, set_var *var);
98
static int check_tx_isolation(Session *session, set_var *var);
99
static void fix_tx_isolation(Session *session, enum_var_type type);
100
static int check_completion_type(Session *session, set_var *var);
101
static void fix_completion_type(Session *session, enum_var_type type);
102
static void fix_net_read_timeout(Session *session, enum_var_type type);
103
static void fix_net_write_timeout(Session *session, enum_var_type type);
104
static void fix_net_retry_count(Session *session, enum_var_type type);
105
static void fix_max_join_size(Session *session, enum_var_type type);
106
static void fix_session_mem_root(Session *session, enum_var_type type);
107
static void fix_trans_mem_root(Session *session, enum_var_type type);
108
static void fix_server_id(Session *session, enum_var_type type);
109
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
110
static bool get_unsigned32(Session *session, set_var *var);
111
static bool get_unsigned64(Session *session, set_var *var);
112
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
113
113
const char *name, int64_t val);
114
114
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
115
static unsigned char *get_error_count(THD *thd);
116
static unsigned char *get_warning_count(THD *thd);
117
static unsigned char *get_tmpdir(THD *thd);
115
static unsigned char *get_error_count(Session *session);
116
static unsigned char *get_warning_count(Session *session);
117
static unsigned char *get_tmpdir(Session *session);
120
120
Variable definition list
129
129
static sys_var_chain vars = { NULL, NULL };
131
static sys_var_thd_ulong
131
static sys_var_session_uint64_t
132
132
sys_auto_increment_increment(&vars, "auto_increment_increment",
133
133
&SV::auto_increment_increment, NULL, NULL,
134
134
sys_var::SESSION_VARIABLE_IN_BINLOG);
135
static sys_var_thd_ulong
135
static sys_var_session_uint64_t
136
136
sys_auto_increment_offset(&vars, "auto_increment_offset",
137
137
&SV::auto_increment_offset, NULL, NULL,
138
138
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);
140
static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home);
141
static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
142
&SV::bulk_insert_buff_size);
143
static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type",
144
&SV::completion_type,
145
check_completion_type,
146
fix_completion_type);
180
147
static sys_var_collation_sv
181
148
sys_collation_database(&vars, "collation_database", &SV::collation_database,
182
149
&default_charset_info,
185
152
sys_collation_server(&vars, "collation_server", &SV::collation_server,
186
153
&default_charset_info,
187
154
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);
155
static sys_var_uint32_t_ptr sys_connect_timeout(&vars, "connect_timeout",
157
static sys_var_const_str sys_datadir(&vars, "datadir", drizzle_real_data_home);
191
158
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
192
159
&delay_key_write_options,
193
160
&delay_key_write_typelib,
194
161
fix_delay_key_write);
196
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
198
163
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
199
sys_var_str sys_init_connect(&vars, "init_connect", 0,
200
sys_update_init_connect,
201
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);
164
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
165
&SV::join_buff_size);
209
166
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",
167
static sys_var_key_cache_uint32_t sys_key_cache_block_size(&vars, "key_cache_block_size",
170
static sys_var_key_cache_uint32_t sys_key_cache_division_limit(&vars, "key_cache_division_limit",
172
param_division_limit));
173
static sys_var_key_cache_uint32_t sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
175
param_age_threshold));
176
static sys_var_session_uint32_t sys_max_allowed_packet(&vars, "max_allowed_packet",
177
&SV::max_allowed_packet);
178
static sys_var_uint64_t_ptr sys_max_connect_errors(&vars, "max_connect_errors",
179
&max_connect_errors);
180
static sys_var_session_uint64_t sys_max_error_count(&vars, "max_error_count",
181
&SV::max_error_count);
182
static sys_var_session_uint64_t sys_max_heap_table_size(&vars, "max_heap_table_size",
183
&SV::max_heap_table_size);
184
static sys_var_session_uint64_t sys_pseudo_thread_id(&vars, "pseudo_thread_id",
246
185
&SV::pseudo_thread_id,
247
check_pseudo_thread_id, 0,
186
0, check_pseudo_thread_id,
248
187
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);
188
static sys_var_session_ha_rows sys_max_join_size(&vars, "max_join_size",
191
static sys_var_session_uint64_t sys_max_seeks_for_key(&vars, "max_seeks_for_key",
192
&SV::max_seeks_for_key);
193
static sys_var_session_uint64_t sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
194
&SV::max_length_for_sort_data);
195
static sys_var_session_size_t sys_max_sort_length(&vars, "max_sort_length",
196
&SV::max_sort_length);
197
static sys_var_session_uint64_t sys_max_tmp_tables(&vars, "max_tmp_tables",
198
&SV::max_tmp_tables);
199
static sys_var_uint64_t_ptr sys_max_write_lock_count(&vars, "max_write_lock_count",
200
&max_write_lock_count);
201
static sys_var_session_uint64_t sys_min_examined_row_limit(&vars, "min_examined_row_limit",
202
&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);
204
static sys_var_session_enum sys_myisam_stats_method(&vars, "myisam_stats_method",
205
&SV::myisam_stats_method,
206
&myisam_stats_method_typelib,
208
static sys_var_session_uint32_t sys_net_buffer_length(&vars, "net_buffer_length",
209
&SV::net_buffer_length);
210
static sys_var_session_uint32_t sys_net_read_timeout(&vars, "net_read_timeout",
211
&SV::net_read_timeout,
212
0, fix_net_read_timeout);
213
static sys_var_session_uint32_t sys_net_write_timeout(&vars, "net_write_timeout",
214
&SV::net_write_timeout,
215
0, fix_net_write_timeout);
216
static sys_var_session_uint32_t sys_net_retry_count(&vars, "net_retry_count",
217
&SV::net_retry_count,
218
0, fix_net_retry_count);
290
219
/* 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);
220
static sys_var_session_bool sys_optimizer_prune_level(&vars, "optimizer_prune_level",
221
&SV::optimizer_prune_level);
222
static sys_var_session_uint32_t sys_optimizer_search_depth(&vars, "optimizer_search_depth",
223
&SV::optimizer_search_depth);
298
225
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
299
226
TYPELIB optimizer_use_mrr_typelib= {
301
228
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);
231
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
232
&SV::optimizer_use_mrr,
233
&optimizer_use_mrr_typelib,
236
static sys_var_session_uint64_t sys_preload_buff_size(&vars, "preload_buffer_size",
237
&SV::preload_buff_size);
238
static sys_var_session_uint32_t sys_read_buff_size(&vars, "read_buffer_size",
239
&SV::read_buff_size);
240
static sys_var_session_uint32_t sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
241
&SV::read_rnd_buff_size);
242
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment",
243
&SV::div_precincrement);
245
static sys_var_session_size_t sys_range_alloc_block_size(&vars, "range_alloc_block_size",
246
&SV::range_alloc_block_size);
247
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size",
248
&SV::query_alloc_block_size,
249
false, fix_session_mem_root);
250
static sys_var_session_uint32_t sys_query_prealloc_size(&vars, "query_prealloc_size",
251
&SV::query_prealloc_size,
252
false, fix_session_mem_root);
253
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
254
static sys_var_session_uint32_t sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
255
&SV::trans_alloc_block_size,
256
false, fix_trans_mem_root);
257
static sys_var_session_uint32_t sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
258
&SV::trans_prealloc_size,
259
false, fix_trans_mem_root);
338
261
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
339
262
&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",
263
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id,
266
static sys_var_session_size_t sys_sort_buffer(&vars, "sort_buffer_size",
355
269
sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
356
270
even though it is written to the binlog, the slave ignores the
357
271
MODE_NO_DIR_IN_CREATE variable, so slave's value differs from
358
272
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);
274
static sys_var_session_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
275
&SV::optimizer_switch);
363
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
277
static sys_var_session_storage_engine sys_storage_engine(&vars, "storage_engine",
278
&SV::storage_engine);
365
279
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
366
280
system_time_zone);
367
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
281
static sys_var_uint64_t_ptr sys_table_def_size(&vars, "table_definition_cache",
368
282
&table_def_size);
369
static sys_var_long_ptr sys_table_cache_size(&vars, "table_open_cache",
283
static sys_var_uint64_t_ptr sys_table_cache_size(&vars, "table_open_cache",
370
284
&table_cache_size);
371
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
285
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
372
286
&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",
287
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation",
289
&tx_isolation_typelib,
292
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
383
293
&SV::tmp_table_size);
384
294
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
385
295
static sys_var_const_str sys_version(&vars, "version", server_version);
386
296
static sys_var_const_str sys_version_comment(&vars, "version_comment",
387
DRIZZLE_COMPILATION_COMMENT);
297
COMPILATION_COMMENT);
388
298
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
390
300
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);
302
static sys_var_session_uint32_t sys_net_wait_timeout(&vars, "wait_timeout",
303
&SV::net_wait_timeout);
395
305
/* Condition pushdown to storage engine */
396
static sys_var_thd_bool
306
static sys_var_session_bool
397
307
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
398
308
&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,
310
/* Variables that are bits in Session */
312
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
415
313
set_option_autocommit,
416
314
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,
316
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0,
428
318
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,
319
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0,
435
321
OPTION_WARNINGS);
436
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
322
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0,
438
324
OPTION_SQL_NOTES);
439
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
325
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
441
327
OPTION_SAFE_UPDATES);
442
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
328
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
444
330
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,
331
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
450
333
OPTION_NO_FOREIGN_KEY_CHECKS,
451
334
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
452
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
335
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0,
454
337
OPTION_RELAXED_UNIQUE_CHECKS,
456
339
sys_var::SESSION_VARIABLE_IN_BINLOG);
457
340
/* Local state variables */
459
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
342
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit",
460
343
&SV::select_limit);
461
344
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
462
345
sys_var::SESSION_VARIABLE_IN_BINLOG);
492
375
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",
378
static sys_var_readonly sys_error_count(&vars, "error_count",
382
static sys_var_readonly sys_warning_count(&vars, "warning_count",
387
sys_var_session_uint64_t sys_group_concat_max_len(&vars, "group_concat_max_len",
388
&SV::group_concat_max_len);
390
sys_var_session_time_zone sys_time_zone(&vars, "time_zone",
517
391
sys_var::SESSION_VARIABLE_IN_BINLOG);
519
393
/* Global read-only variable containing hostname */
520
394
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",
396
sys_var_session_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
535
397
&SV::keep_files_on_create);
536
398
/* Read only variables */
538
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
539
400
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
541
402
Additional variables (not derived from sys_var class, not accessible as
547
408
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
548
409
static SHOW_VAR fixed_vars[]= {
549
{"back_log", (char*) &back_log, SHOW_LONG},
550
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
410
{"back_log", (char*) &back_log, SHOW_INT},
551
411
{"language", language, SHOW_CHAR},
552
412
#ifdef HAVE_MLOCKALL
553
413
{"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
415
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
558
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
559
416
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
560
417
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
561
{"port", (char*) &mysqld_port, SHOW_INT},
418
{"port", (char*) &drizzled_port, SHOW_INT},
562
419
{"protocol_version", (char*) &protocol_version, SHOW_INT},
563
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
420
{"thread_stack", (char*) &my_thread_stack_size, SHOW_INT},
567
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
423
bool sys_var::check(Session *, set_var *var)
569
425
var->save_result.uint64_t_value= var->value->val_int();
573
bool sys_var_str::check(THD *thd, set_var *var)
429
bool sys_var_str::check(Session *session, set_var *var)
579
if ((res=(*check_func)(thd, var)) < 0)
435
if ((res=(*check_func)(session, var)) < 0)
580
436
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0),
581
437
name, var->value->str_value.ptr());
591
Update variables 'init_connect, init_slave'.
593
In case of 'DEFAULT' value
594
(for example: 'set GLOBAL init_connect=DEFAULT')
595
'var' parameter is NULL pointer.
598
bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex,
601
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
602
uint32_t new_length= (var ? var->value->str_value.length() : 0);
604
old_value= (char*) "";
605
if (!(res= my_strndup(old_value, new_length, MYF(0))))
608
Replace the old value in such a way that the any thread using
611
rw_wrlock(var_mutex);
612
old_value= var_str->value;
614
var_str->value_length= new_length;
615
rw_unlock(var_mutex);
621
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
623
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)))
630
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
447
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)
450
static void fix_max_join_size(Session *session, enum_var_type type)
679
452
if (type != OPT_GLOBAL)
681
if (thd->variables.max_join_size == HA_POS_ERROR)
682
thd->options|= OPTION_BIG_SELECTS;
454
if (session->variables.max_join_size == HA_POS_ERROR)
455
session->options|= OPTION_BIG_SELECTS;
684
thd->options&= ~OPTION_BIG_SELECTS;
457
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)))
933
server_id_supplied = 1;
934
thd->server_id= server_id;
938
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
543
static void fix_session_mem_root(Session *session, enum_var_type type)
545
if (type != OPT_GLOBAL)
546
reset_root_defaults(session->mem_root,
547
session->variables.query_alloc_block_size,
548
session->variables.query_prealloc_size);
552
static void fix_trans_mem_root(Session *session, enum_var_type type)
554
if (type != OPT_GLOBAL)
555
reset_root_defaults(&session->transaction.mem_root,
556
session->variables.trans_alloc_block_size,
557
session->variables.trans_prealloc_size);
561
static void fix_server_id(Session *, enum_var_type)
566
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
939
567
const char *name, int64_t val)
950
push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
578
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
951
579
ER_TRUNCATED_WRONG_VALUE,
952
580
ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
957
static uint64_t fix_unsigned(THD *thd, uint64_t num,
585
static uint64_t fix_unsigned(Session *session, uint64_t num,
958
586
const struct my_option *option_limits)
960
588
bool fixed= false;
961
589
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);
591
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
596
static size_t fix_size_t(Session *session, size_t num,
597
const struct my_option *option_limits)
600
size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed);
602
throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
606
static bool get_unsigned32(Session *, set_var *var)
608
if (var->value->unsigned_flag)
609
var->save_result.uint32_t_value= (uint32_t) var->value->val_int();
612
int64_t v= var->value->val_int();
613
var->save_result.uint32_t_value= (uint32_t) ((v < 0) ? 0 : v);
618
static bool get_unsigned64(Session *, set_var *var)
620
if (var->value->unsigned_flag)
621
var->save_result.uint64_t_value=(uint64_t) var->value->val_int();
624
int64_t v= var->value->val_int();
625
var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
630
static bool get_size_t(Session *, set_var *var)
632
if (var->value->unsigned_flag)
633
var->save_result.size_t_value= (size_t) var->value->val_int();
636
ssize_t v= (ssize_t)var->value->val_int();
637
var->save_result.size_t_value= (size_t) ((v < 0) ? 0 : v);
642
bool sys_var_uint32_t_ptr::check(Session *, set_var *var)
644
var->save_result.uint32_t_value= (uint32_t)var->value->val_int();
648
bool sys_var_uint32_t_ptr::update(Session *session, set_var *var)
650
uint32_t tmp= var->save_result.uint32_t_value;
651
pthread_mutex_lock(&LOCK_global_system_variables);
997
652
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;
654
uint32_t newvalue= (uint32_t) fix_unsigned(session, tmp, option_limits);
1013
pthread_mutex_unlock(guard);
659
*value= (uint32_t) tmp;
660
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)))
665
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);
668
pthread_mutex_lock(&LOCK_global_system_variables);
669
*value= (uint32_t)getopt_ull_limit_value((uint32_t) option_limits->def_value,
670
option_limits, ¬_used);
671
pthread_mutex_unlock(&LOCK_global_system_variables);
1028
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
675
bool sys_var_uint64_t_ptr::update(Session *session, set_var *var)
1030
677
uint64_t tmp= var->save_result.uint64_t_value;
1031
678
pthread_mutex_lock(&LOCK_global_system_variables);
1032
679
if (option_limits)
1033
*value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
681
uint64_t newvalue= (uint64_t) fix_unsigned(session, tmp, option_limits);
1035
686
*value= (uint64_t) tmp;
1036
687
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)))
702
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
704
size_t tmp= var->save_result.size_t_value;
705
pthread_mutex_lock(&LOCK_global_system_variables);
707
*value= fix_size_t(session, tmp, option_limits);
710
pthread_mutex_unlock(&LOCK_global_system_variables);
715
void sys_var_size_t_ptr::set_default(Session *, enum_var_type)
718
pthread_mutex_lock(&LOCK_global_system_variables);
719
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
720
option_limits, ¬_used);
721
pthread_mutex_unlock(&LOCK_global_system_variables);
724
bool sys_var_bool_ptr::update(Session *, set_var *var)
726
*value= (bool) var->save_result.uint32_t_value;
731
void sys_var_bool_ptr::set_default(Session *, enum_var_type)
1061
733
*value= (bool) option_limits->def_value;
1065
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
737
bool sys_var_enum::update(Session *, set_var *var)
1067
*value= (uint) var->save_result.ulong_value;
739
*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)))
744
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, const LEX_STRING *)
1076
746
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)))
750
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type,
1084
753
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
1087
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
757
32 bit types for session variables
759
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)));
761
return (get_unsigned32(session, var) ||
762
(check_func && (*check_func)(session, var)));
1093
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
765
bool sys_var_session_uint32_t::update(Session *session, set_var *var)
1095
uint64_t tmp= var->save_result.uint64_t_value;
767
uint64_t tmp= (uint64_t) var->save_result.uint32_t_value;
1097
769
/* Don't use bigger value than given with --maximum-variable-name=.. */
1098
if ((ulong) tmp > max_system_variables.*offset)
770
if ((uint32_t) tmp > max_system_variables.*offset)
1100
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
772
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1101
773
tmp= max_system_variables.*offset;
1104
776
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)
777
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits);
778
else if (tmp > UINT32_MAX)
1110
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
781
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value);
1114
784
if (var->type == OPT_GLOBAL)
1115
global_system_variables.*offset= (ulong) tmp;
785
global_system_variables.*offset= (uint32_t) tmp;
1117
thd->variables.*offset= (ulong) tmp;
787
session->variables.*offset= (uint32_t) tmp;
1123
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
793
void sys_var_session_uint32_t::set_default(Session *session, enum_var_type type)
1125
795
if (type == OPT_GLOBAL)
1128
798
/* We will not come here if option_limits is not set */
1129
799
global_system_variables.*offset=
1130
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
800
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value,
1131
801
option_limits, ¬_used);
1134
thd->variables.*offset= global_system_variables.*offset;
804
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)))
808
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session,
1141
812
if (type == OPT_GLOBAL)
1142
813
return (unsigned char*) &(global_system_variables.*offset);
1143
return (unsigned char*) &(thd->variables.*offset);
814
return (unsigned char*) &(session->variables.*offset);
1147
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
818
bool sys_var_session_ha_rows::update(Session *session, set_var *var)
1149
820
uint64_t tmp= var->save_result.uint64_t_value;
1231
904
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)
907
session->variables.*offset= global_system_variables.*offset;
911
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session,
915
if (type == OPT_GLOBAL)
916
return (unsigned char*) &(global_system_variables.*offset);
917
return (unsigned char*) &(session->variables.*offset);
920
bool sys_var_session_size_t::check(Session *session, set_var *var)
922
return (get_size_t(session, var) ||
923
(check_func && (*check_func)(session, var)));
926
bool sys_var_session_size_t::update(Session *session, set_var *var)
928
size_t tmp= var->save_result.size_t_value;
930
if (tmp > max_system_variables.*offset)
931
tmp= max_system_variables.*offset;
934
tmp= fix_size_t(session, tmp, option_limits);
935
if (var->type == OPT_GLOBAL)
937
/* Lock is needed to make things safe on 32 bit systems */
938
pthread_mutex_lock(&LOCK_global_system_variables);
939
global_system_variables.*offset= tmp;
940
pthread_mutex_unlock(&LOCK_global_system_variables);
943
session->variables.*offset= tmp;
948
void sys_var_session_size_t::set_default(Session *session, enum_var_type type)
950
if (type == OPT_GLOBAL)
953
pthread_mutex_lock(&LOCK_global_system_variables);
954
global_system_variables.*offset=
955
(size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
956
option_limits, ¬_used);
957
pthread_mutex_unlock(&LOCK_global_system_variables);
960
session->variables.*offset= global_system_variables.*offset;
964
unsigned char *sys_var_session_size_t::value_ptr(Session *session,
968
if (type == OPT_GLOBAL)
969
return (unsigned char*) &(global_system_variables.*offset);
970
return (unsigned char*) &(session->variables.*offset);
974
bool sys_var_session_bool::update(Session *session, set_var *var)
976
if (var->type == OPT_GLOBAL)
977
global_system_variables.*offset= (bool) var->save_result.uint32_t_value;
979
session->variables.*offset= (bool) var->save_result.uint32_t_value;
984
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
1259
986
if (type == OPT_GLOBAL)
1260
987
global_system_variables.*offset= (bool) option_limits->def_value;
1262
thd->variables.*offset= global_system_variables.*offset;
989
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)))
993
unsigned char *sys_var_session_bool::value_ptr(Session *session,
1269
997
if (type == OPT_GLOBAL)
1270
998
return (unsigned char*) &(global_system_variables.*offset);
1271
return (unsigned char*) &(thd->variables.*offset);
999
return (unsigned char*) &(session->variables.*offset);
1275
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1003
bool sys_var::check_enum(Session *,
1276
1004
set_var *var, const TYPELIB *enum_names)
1278
1006
char buff[STRING_BUFFER_USUAL_SIZE];
1492
bool sys_var_thd_enum::update(THD *thd, set_var *var)
1223
bool sys_var_session_enum::update(Session *session, set_var *var)
1494
1225
if (var->type == OPT_GLOBAL)
1495
global_system_variables.*offset= var->save_result.ulong_value;
1226
global_system_variables.*offset= var->save_result.uint32_t_value;
1497
thd->variables.*offset= var->save_result.ulong_value;
1228
session->variables.*offset= var->save_result.uint32_t_value;
1502
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
1233
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1504
1235
if (type == OPT_GLOBAL)
1505
global_system_variables.*offset= (ulong) option_limits->def_value;
1236
global_system_variables.*offset= (uint32_t) option_limits->def_value;
1507
thd->variables.*offset= global_system_variables.*offset;
1238
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)))
1242
unsigned char *sys_var_session_enum::value_ptr(Session *session,
1514
ulong tmp= ((type == OPT_GLOBAL) ?
1246
uint32_t tmp= ((type == OPT_GLOBAL) ?
1515
1247
global_system_variables.*offset :
1516
thd->variables.*offset);
1248
session->variables.*offset);
1517
1249
return (unsigned char*) enum_names->type_names[tmp];
1520
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1252
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)));
1254
return (check_enum(session, var, &bool_typelib) ||
1255
(check_func && (*check_func)(session, var)));
1526
bool sys_var_thd_bit::update(THD *thd, set_var *var)
1258
bool sys_var_session_bit::update(Session *session, set_var *var)
1528
int res= (*update_func)(thd, var);
1260
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)))
1265
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type,
1538
1269
If reverse is 0 (default) return 1 if bit is set.
1539
1270
If reverse is 1, return 0 if bit is set
1541
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1272
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ?
1542
1273
!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;
1274
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)
1318
bool sys_var_collation_sv::update(Session *session, set_var *var)
1804
1320
if (var->type == OPT_GLOBAL)
1805
1321
global_system_variables.*offset= var->save_result.charset;
1808
thd->variables.*offset= var->save_result.charset;
1809
thd->update_charset();
1324
session->variables.*offset= var->save_result.charset;
1325
session->update_charset();
1815
void sys_var_collation_sv::set_default(THD *thd, enum_var_type type)
1331
void sys_var_collation_sv::set_default(Session *session, enum_var_type type)
1817
1333
if (type == OPT_GLOBAL)
1818
1334
global_system_variables.*offset= *global_default;
1821
thd->variables.*offset= global_system_variables.*offset;
1822
thd->update_charset();
1337
session->variables.*offset= global_system_variables.*offset;
1338
session->update_charset();
1827
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
LEX_STRING *base __attribute__((unused)))
1343
unsigned char *sys_var_collation_sv::value_ptr(Session *session,
1830
1347
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
global_system_variables.*offset : thd->variables.*offset);
1348
global_system_variables.*offset :
1349
session->variables.*offset);
1832
1350
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
1520
/****************************************************************************/
2147
bool sys_var_timestamp::update(THD *thd, set_var *var)
1522
bool sys_var_timestamp::update(Session *session, set_var *var)
2149
thd->set_time((time_t) var->save_result.uint64_t_value);
1524
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=
1529
void sys_var_timestamp::set_default(Session *session, enum_var_type)
1531
session->user_time=0;
1535
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type,
1538
session->sys_var_tmp.long_value= (long) session->start_time;
1539
return (unsigned char*) &session->sys_var_tmp.long_value;
1543
bool sys_var_last_insert_id::update(Session *session, set_var *var)
1545
session->first_successful_insert_id_in_prev_stmt=
2173
1546
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)))
1551
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
2183
1556
this tmp var makes it robust againt change of type of
2184
1557
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)
1559
session->sys_var_tmp.uint64_t_value=
1560
session->read_first_successful_insert_id_in_prev_stmt();
1561
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1565
bool sys_var_session_time_zone::check(Session *session, set_var *var)
2224
1567
char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
1568
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
2226
1569
String *res= var->value->val_str(&str);
2228
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
1571
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2230
1573
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
2286
1629
We are guaranteed to find this time zone since its existence
2287
1630
is checked during start-up.
2289
global_system_variables.time_zone= my_tz_find(thd, &str);
1632
global_system_variables.time_zone= my_tz_find(session, &str);
2292
1635
global_system_variables.time_zone= my_tz_SYSTEM;
2295
thd->variables.time_zone= global_system_variables.time_zone;
1638
session->variables.time_zone= global_system_variables.time_zone;
2296
1639
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)),
1643
bool sys_var_session_lc_time_names::check(Session *, set_var *var)
2349
1645
MY_LOCALE *locale_match;
2351
1647
if (var->value->result_type() == INT_RESULT)
2353
if (!(locale_match= my_locale_by_number((uint) var->value->val_int())))
1649
if (!(locale_match= my_locale_by_number((uint32_t) var->value->val_int())))
2356
1652
int10_to_str((int) var->value->val_int(), buf, -10);
2449
1745
pthread_mutex_unlock(&LOCK_global_system_variables);
2452
thd->variables.*offset= microseconds;
1748
session->variables.*offset= microseconds;
2456
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
LEX_STRING *base __attribute__((unused)))
1752
unsigned char *sys_var_microseconds::value_ptr(Session *session,
2459
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
1756
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
1757
global_system_variables.*offset :
2461
thd->variables.*offset) / 1000000.0;
2462
return (unsigned char*) &thd->tmp_double_value;
1758
session->variables.*offset) / 1000000.0;
1759
return (unsigned char*) &session->tmp_double_value;
2467
Functions to update thd->options bits
1764
Functions to update session->options bits
2470
static bool set_option_bit(THD *thd, set_var *var)
1767
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;
1769
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var);
1770
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse)
1771
session->options&= ~sys_var->bit_flag;
2476
thd->options|= sys_var->bit_flag;
1773
session->options|= sys_var->bit_flag;
2481
static bool set_option_autocommit(THD *thd, set_var *var)
1778
static bool set_option_autocommit(Session *session, set_var *var)
2483
1780
/* The test is negative as the flag we use is NOT autocommit */
2485
uint64_t org_options= thd->options;
1782
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;
1784
if (var->save_result.uint32_t_value != 0)
1785
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2490
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
1787
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2492
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
1789
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2494
1791
if ((org_options & OPTION_NOT_AUTOCOMMIT))
2496
1793
/* 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;
1794
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
1795
session->transaction.all.modified_non_trans_table= false;
1796
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1797
if (ha_commit(session))
2505
thd->transaction.all.modified_non_trans_table= false;
2506
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
1802
session->transaction.all.modified_non_trans_table= false;
1803
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)),
1809
static int check_pseudo_thread_id(Session *, set_var *var)
2522
1811
var->save_result.uint64_t_value= var->value->val_int();
2526
static unsigned char *get_warning_count(THD *thd)
1815
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;
1817
session->sys_var_tmp.uint32_t_value=
1818
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
1819
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
1820
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
1821
return (unsigned char*) &session->sys_var_tmp.uint32_t_value;
2535
static unsigned char *get_error_count(THD *thd)
1824
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;
1826
session->sys_var_tmp.uint32_t_value=
1827
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
1828
return (unsigned char*) &session->sys_var_tmp.uint32_t_value;
2629
1905
int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options)
2633
1908
/* A write lock should be held on LOCK_system_variables_hash */
2635
1910
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))
1912
/* Make a temp string to hold this and then make it lower so that matching
1913
* happens case-insensitive.
1915
string var_name(var->name);
1916
transform(var_name.begin(), var_name.end(), var_name.begin(), ::tolower);
1917
var->name_length= var_name.length();
1919
/* this fails if there is a conflicting variable name. */
1920
if (system_variable_hash.count(var_name) == 0)
1922
system_variable_hash[var_name]= var;
1926
for (; first != var; first= first->next)
1929
* This is slightly expensive, since we have to do the transform
1930
* _again_ but should rarely happen unless there is a pretty
1931
* major problem in the code
1933
var_name= first->name;
1934
transform(var_name.begin(), var_name.end(),
1935
var_name.begin(), ::tolower);
1936
system_variable_hash.erase(var_name);
2641
1940
if (long_options)
2642
1941
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
1949
Remove variables to the dynamic hash of system variables
2657
1952
mysql_del_sys_var_chain()
2658
1953
first Pointer to first system variable to remove
2662
1957
otherwise FAILURE
2665
1960
int mysql_del_sys_var_chain(sys_var *first)
2669
1965
/* A write lock should be held on LOCK_system_variables_hash */
2671
1966
for (sys_var *var= first; var; var= var->next)
2672
result|= hash_delete(&system_variable_hash, (unsigned char*) var);
1968
var_name= var->name;
1969
transform(var_name.begin(), var_name.end(),
1970
var_name.begin(), ::tolower);
1971
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
1980
Constructs an array of system variables for display to the user.
2688
1983
enumerate_sys_vars()
1984
session current thread
2690
1985
sorted If TRUE, the system variables should be sorted
2693
1988
pointer Array of SHOW_VAR elements for display
2697
SHOW_VAR* enumerate_sys_vars(THD *thd, bool sorted)
1992
SHOW_VAR* enumerate_sys_vars(Session *session, bool)
2699
int count= system_variable_hash.records, i;
2700
1994
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);
1995
int size= sizeof(SHOW_VAR) * (system_variable_hash.size() + fixed_count + 1);
1996
SHOW_VAR *result= (SHOW_VAR*) session->alloc(size);
2706
2000
SHOW_VAR *show= result + fixed_count;
2707
2001
memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(SHOW_VAR));
2709
for (i= 0; i < count; i++)
2003
map<string, sys_var *>::iterator iter;
2004
for(iter= system_variable_hash.begin();
2005
iter != system_variable_hash.end();
2711
sys_var *var= (sys_var*) hash_element(&system_variable_hash, i);
2008
sys_var *var= (*iter).second;
2712
2009
show->name= var->name;
2713
2010
show->value= (char*) var;
2714
2011
show->type= SHOW_SYS;
2718
/* sort into order */
2720
my_qsort(result, count + fixed_count, sizeof(SHOW_VAR),
2721
(qsort_cmp) show_cmp);
2723
2015
/* make last element empty */
2724
2016
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)))
2311
unsigned char *sys_var_session_storage_engine::value_ptr(Session *session,
3030
2315
unsigned char* result;
3032
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);
2317
StorageEngine *engine= session->variables.*offset;
2318
if (type == OPT_GLOBAL)
2319
engine= global_system_variables.*offset;
2320
engine_name= engine->getName();
2321
result= (unsigned char *) session->strmake(engine_name.c_str(),
2322
engine_name.size());
3045
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
2327
void sys_var_session_storage_engine::set_default(Session *session, enum_var_type type)
3047
plugin_ref old_value, new_value, *value;
2329
StorageEngine *old_value, *new_value, **value;
3048
2330
if (type == OPT_GLOBAL)
3050
2332
value= &(global_system_variables.*offset);
3051
new_value= ha_lock_engine(NULL, myisam_hton);
2333
new_value= myisam_engine;
3055
value= &(thd->variables.*offset);
3056
new_value= my_plugin_lock(NULL, &(global_system_variables.*offset));
2337
value= &(session->variables.*offset);
2338
new_value= global_system_variables.*offset;
3058
2340
assert(new_value);
3059
2341
old_value= *value;
3060
2342
*value= new_value;
3061
plugin_unlock(NULL, old_value);
3065
bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
2346
bool sys_var_session_storage_engine::update(Session *session, set_var *var)
3067
plugin_ref *value= &(global_system_variables.*offset), old_value;
2348
StorageEngine **value= &(global_system_variables.*offset), *old_value;
3068
2349
if (var->type != OPT_GLOBAL)
3069
value= &(thd->variables.*offset);
2350
value= &(session->variables.*offset);
3070
2351
old_value= *value;
3071
if (old_value != var->save_result.plugin)
2352
if (old_value != var->save_result.storage_engine)
3073
*value= my_plugin_lock(NULL, &var->save_result.plugin);
3074
plugin_unlock(NULL, old_value);
2354
*value= var->save_result.storage_engine;
3080
sys_var_thd_optimizer_switch::
3081
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
2360
sys_var_session_optimizer_switch::
2361
symbolic_mode_representation(Session *session, uint32_t val, LEX_STRING *rep)
3083
2363
char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
2364
String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
3223
2503
while ((element= it++))
3225
2505
KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
3226
func(element->name, key_cache);
2506
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
2511
/****************************************************************************
3295
2513
****************************************************************************/