87
73
delay_key_write_type_names, NULL
90
static bool sys_update_init_connect(Session*, set_var*);
91
static void sys_default_init_connect(Session*, enum_var_type type);
92
static bool set_option_bit(Session *session, set_var *var);
93
static bool set_option_autocommit(Session *session, set_var *var);
94
static int check_pseudo_thread_id(Session *session, set_var *var);
95
static int check_tx_isolation(Session *session, set_var *var);
96
static void fix_tx_isolation(Session *session, enum_var_type type);
97
static int check_completion_type(Session *session, set_var *var);
98
static void fix_completion_type(Session *session, enum_var_type type);
99
static void fix_net_read_timeout(Session *session, enum_var_type type);
100
static void fix_net_write_timeout(Session *session, enum_var_type type);
101
static void fix_net_retry_count(Session *session, enum_var_type type);
102
static void fix_max_join_size(Session *session, enum_var_type type);
103
static void fix_session_mem_root(Session *session, enum_var_type type);
104
static void fix_trans_mem_root(Session *session, enum_var_type type);
105
static void fix_server_id(Session *session, enum_var_type type);
106
static uint64_t fix_unsigned(Session *, uint64_t, const struct my_option *);
107
static bool get_unsigned(Session *session, set_var *var);
108
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
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,
109
113
const char *name, int64_t val);
110
114
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
111
static unsigned char *get_error_count(Session *session);
112
static unsigned char *get_warning_count(Session *session);
113
static unsigned char *get_tmpdir(Session *session);
115
static unsigned char *get_error_count(THD *thd);
116
static unsigned char *get_warning_count(THD *thd);
117
static unsigned char *get_tmpdir(THD *thd);
116
120
Variable definition list
125
129
static sys_var_chain vars = { NULL, NULL };
127
static sys_var_session_uint64_t
131
static sys_var_thd_ulong
128
132
sys_auto_increment_increment(&vars, "auto_increment_increment",
129
133
&SV::auto_increment_increment, NULL, NULL,
130
134
sys_var::SESSION_VARIABLE_IN_BINLOG);
131
static sys_var_session_uint64_t
135
static sys_var_thd_ulong
132
136
sys_auto_increment_offset(&vars, "auto_increment_offset",
133
137
&SV::auto_increment_offset, NULL, NULL,
134
138
sys_var::SESSION_VARIABLE_IN_BINLOG);
136
static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home);
137
static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
138
&SV::bulk_insert_buff_size);
139
static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type",
140
&SV::completion_type,
141
check_completion_type,
142
fix_completion_type);
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);
143
180
static sys_var_collation_sv
144
181
sys_collation_database(&vars, "collation_database", &SV::collation_database,
145
182
&default_charset_info,
149
186
&default_charset_info,
150
187
sys_var::SESSION_VARIABLE_IN_BINLOG);
151
188
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
153
static sys_var_const_str sys_datadir(&vars, "datadir", drizzle_real_data_home);
190
static sys_var_const_str sys_datadir(&vars, "datadir", mysql_real_data_home);
154
191
static sys_var_enum sys_delay_key_write(&vars, "delay_key_write",
155
192
&delay_key_write_options,
156
193
&delay_key_write_typelib,
157
194
fix_delay_key_write);
159
196
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
161
198
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
162
199
sys_var_str sys_init_connect(&vars, "init_connect", 0,
163
200
sys_update_init_connect,
164
201
sys_default_init_connect,0);
165
static sys_var_session_uint32_t sys_interactive_timeout(&vars, "interactive_timeout",
166
&SV::net_interactive_timeout);
167
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
168
&SV::join_buff_size);
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
209
static sys_var_key_buffer_size sys_key_buffer_size(&vars, "key_buffer_size");
170
210
static sys_var_key_cache_long sys_key_cache_block_size(&vars, "key_cache_block_size",
173
213
static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_division_limit",
175
param_division_limit));
215
param_division_limit));
176
216
static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold",
178
param_age_threshold));
218
param_age_threshold));
179
219
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
181
static sys_var_session_uint32_t sys_max_allowed_packet(&vars, "max_allowed_packet",
182
&SV::max_allowed_packet);
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);
183
239
static sys_var_long_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",
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",
190
246
&SV::pseudo_thread_id,
191
0, check_pseudo_thread_id,
247
check_pseudo_thread_id, 0,
192
248
sys_var::SESSION_VARIABLE_IN_BINLOG);
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_uint64_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);
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);
204
264
static sys_var_long_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);
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);
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);
224
static sys_var_session_bool sys_new_mode(&vars, "new", &SV::new_mode);
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);
225
288
static sys_var_bool_ptr_readonly sys_old_mode(&vars, "old",
226
&global_system_variables.old_mode);
289
&global_system_variables.old_mode);
227
290
/* these two cannot be static */
228
sys_var_session_bool sys_old_alter_table(&vars, "old_alter_table",
229
&SV::old_alter_table);
230
static sys_var_session_bool sys_optimizer_prune_level(&vars, "optimizer_prune_level",
231
&SV::optimizer_prune_level);
232
static sys_var_session_uint32_t sys_optimizer_search_depth(&vars, "optimizer_search_depth",
233
&SV::optimizer_search_depth);
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);
235
298
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
236
299
TYPELIB optimizer_use_mrr_typelib= {
238
301
optimizer_use_mrr_names, NULL
241
static sys_var_session_enum sys_optimizer_use_mrr(&vars, "optimizer_use_mrr",
242
&SV::optimizer_use_mrr,
243
&optimizer_use_mrr_typelib,
246
static sys_var_session_uint64_t sys_preload_buff_size(&vars, "preload_buffer_size",
247
&SV::preload_buff_size);
248
static sys_var_session_uint32_t sys_read_buff_size(&vars, "read_buffer_size",
249
&SV::read_buff_size);
250
static sys_var_session_uint32_t sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size",
251
&SV::read_rnd_buff_size);
252
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment",
253
&SV::div_precincrement);
255
static sys_var_session_size_t sys_range_alloc_block_size(&vars, "range_alloc_block_size",
256
&SV::range_alloc_block_size);
257
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size",
258
&SV::query_alloc_block_size,
259
false, fix_session_mem_root);
260
static sys_var_session_uint32_t sys_query_prealloc_size(&vars, "query_prealloc_size",
261
&SV::query_prealloc_size,
262
false, fix_session_mem_root);
263
static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
264
static sys_var_session_uint32_t sys_trans_alloc_block_size(&vars, "transaction_alloc_block_size",
265
&SV::trans_alloc_block_size,
266
false, fix_trans_mem_root);
267
static sys_var_session_uint32_t sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
268
&SV::trans_prealloc_size,
269
false, fix_trans_mem_root);
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);
271
338
static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",
272
339
&opt_secure_file_priv);
273
static sys_var_uint32_t_ptr sys_server_id(&vars, "server_id", &server_id,
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,
276
350
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time",
278
static sys_var_session_size_t sys_sort_buffer(&vars, "sort_buffer_size",
352
static sys_var_thd_ulong sys_sort_buffer(&vars, "sort_buffer_size",
281
355
sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
282
356
even though it is written to the binlog, the slave ignores the
283
357
MODE_NO_DIR_IN_CREATE variable, so slave's value differs from
284
358
master's (see log_event.cc: Query_log_event::do_apply_event()).
286
static sys_var_session_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
287
&SV::optimizer_switch);
360
static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
361
&SV::optimizer_switch);
289
static sys_var_session_storage_engine sys_storage_engine(&vars, "storage_engine",
363
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
290
364
&SV::table_plugin);
291
365
static sys_var_const_str sys_system_time_zone(&vars, "system_time_zone",
292
366
system_time_zone);
296
370
&table_cache_size);
297
371
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
298
372
&table_lock_wait_timeout);
299
static sys_var_session_enum sys_tx_isolation(&vars, "tx_isolation",
301
&tx_isolation_typelib,
304
static sys_var_session_uint64_t sys_tmp_table_size(&vars, "tmp_table_size",
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",
305
383
&SV::tmp_table_size);
306
384
static sys_var_bool_ptr sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
307
385
static sys_var_const_str sys_version(&vars, "version", server_version);
308
386
static sys_var_const_str sys_version_comment(&vars, "version_comment",
309
COMPILATION_COMMENT);
387
DRIZZLE_COMPILATION_COMMENT);
310
388
static sys_var_const_str sys_version_compile_machine(&vars, "version_compile_machine",
312
390
static sys_var_const_str sys_version_compile_os(&vars, "version_compile_os",
314
static sys_var_session_uint32_t sys_net_wait_timeout(&vars, "wait_timeout",
315
&SV::net_wait_timeout);
392
static sys_var_thd_ulong sys_net_wait_timeout(&vars, "wait_timeout",
393
&SV::net_wait_timeout);
317
395
/* Condition pushdown to storage engine */
318
static sys_var_session_bool
396
static sys_var_thd_bool
319
397
sys_engine_condition_pushdown(&vars, "engine_condition_pushdown",
320
398
&SV::engine_condition_pushdown);
322
400
/* Time/date/datetime formats */
324
static sys_var_session_date_time_format sys_time_format(&vars, "time_format",
402
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
325
403
&SV::time_format,
326
404
DRIZZLE_TIMESTAMP_TIME);
327
static sys_var_session_date_time_format sys_date_format(&vars, "date_format",
405
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
328
406
&SV::date_format,
329
407
DRIZZLE_TIMESTAMP_DATE);
330
static sys_var_session_date_time_format sys_datetime_format(&vars, "datetime_format",
408
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
331
409
&SV::datetime_format,
332
410
DRIZZLE_TIMESTAMP_DATETIME);
334
/* Variables that are bits in Session */
412
/* Variables that are bits in THD */
336
sys_var_session_bit sys_autocommit(&vars, "autocommit", 0,
414
sys_var_thd_bit sys_autocommit(&vars, "autocommit", 0,
337
415
set_option_autocommit,
338
416
OPTION_NOT_AUTOCOMMIT,
340
static sys_var_session_bit sys_big_selects(&vars, "sql_big_selects", 0,
418
static sys_var_thd_bit sys_big_tables(&vars, "big_tables", 0,
421
#ifndef TO_BE_DELETED /* Alias for big_tables */
422
static sys_var_thd_bit sys_sql_big_tables(&vars, "sql_big_tables", 0,
426
static sys_var_thd_bit sys_big_selects(&vars, "sql_big_selects", 0,
342
428
OPTION_BIG_SELECTS);
343
static sys_var_session_bit sys_sql_warnings(&vars, "sql_warnings", 0,
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,
345
435
OPTION_WARNINGS);
346
static sys_var_session_bit sys_sql_notes(&vars, "sql_notes", 0,
436
static sys_var_thd_bit sys_sql_notes(&vars, "sql_notes", 0,
348
438
OPTION_SQL_NOTES);
349
static sys_var_session_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
439
static sys_var_thd_bit sys_safe_updates(&vars, "sql_safe_updates", 0,
351
441
OPTION_SAFE_UPDATES);
352
static sys_var_session_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
442
static sys_var_thd_bit sys_buffer_results(&vars, "sql_buffer_result", 0,
354
444
OPTION_BUFFER_RESULT);
355
static sys_var_session_bit sys_foreign_key_checks(&vars, "foreign_key_checks", 0,
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,
357
450
OPTION_NO_FOREIGN_KEY_CHECKS,
358
451
1, sys_var::SESSION_VARIABLE_IN_BINLOG);
359
static sys_var_session_bit sys_unique_checks(&vars, "unique_checks", 0,
452
static sys_var_thd_bit sys_unique_checks(&vars, "unique_checks", 0,
361
454
OPTION_RELAXED_UNIQUE_CHECKS,
363
456
sys_var::SESSION_VARIABLE_IN_BINLOG);
364
457
/* Local state variables */
366
static sys_var_session_ha_rows sys_select_limit(&vars, "sql_select_limit",
459
static sys_var_thd_ha_rows sys_select_limit(&vars, "sql_select_limit",
367
460
&SV::select_limit);
368
461
static sys_var_timestamp sys_timestamp(&vars, "timestamp",
369
462
sys_var::SESSION_VARIABLE_IN_BINLOG);
399
492
statement-based logging mode: t will be different on master and
402
static sys_var_readonly sys_error_count(&vars, "error_count",
406
static sys_var_readonly sys_warning_count(&vars, "warning_count",
411
sys_var_session_uint64_t sys_group_concat_max_len(&vars, "group_concat_max_len",
412
&SV::group_concat_max_len);
414
sys_var_session_time_zone sys_time_zone(&vars, "time_zone",
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",
415
517
sys_var::SESSION_VARIABLE_IN_BINLOG);
417
519
/* Global read-only variable containing hostname */
418
520
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
420
sys_var_session_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
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",
421
535
&SV::keep_files_on_create);
422
536
/* Read only variables */
538
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
424
539
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
426
541
Additional variables (not derived from sys_var class, not accessible as
432
547
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
433
548
static SHOW_VAR fixed_vars[]= {
434
{"back_log", (char*) &back_log, SHOW_INT},
549
{"back_log", (char*) &back_log, SHOW_LONG},
435
550
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
436
551
{"language", language, SHOW_CHAR},
437
552
#ifdef HAVE_MLOCKALL
438
553
{"locked_in_memory", (char*) &locked_in_memory, SHOW_MY_BOOL},
440
555
{"log_bin", (char*) &opt_bin_log, SHOW_BOOL},
556
{"log_error", (char*) log_error_file, SHOW_CHAR},
441
557
{"myisam_recover_options", (char*) &myisam_recover_options_str, SHOW_CHAR_PTR},
558
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
442
559
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
443
560
{"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
444
{"port", (char*) &drizzled_port, SHOW_INT},
561
{"port", (char*) &mysqld_port, SHOW_INT},
445
562
{"protocol_version", (char*) &protocol_version, SHOW_INT},
446
{"thread_stack", (char*) &my_thread_stack_size, SHOW_INT},
563
{"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG},
450
bool sys_var::check(Session *, set_var *var)
567
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
452
569
var->save_result.uint64_t_value= var->value->val_int();
456
bool sys_var_str::check(Session *session, set_var *var)
573
bool sys_var_str::check(THD *thd, set_var *var)
462
if ((res=(*check_func)(session, var)) < 0)
579
if ((res=(*check_func)(thd, var)) < 0)
463
580
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0),
464
581
name, var->value->str_value.ptr());
478
595
'var' parameter is NULL pointer.
481
bool update_sys_var_str(sys_var_str *var_str, pthread_rwlock_t *var_mutex,
598
bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex,
484
601
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
485
602
uint32_t new_length= (var ? var->value->str_value.length() : 0);
487
604
old_value= (char*) "";
488
res= (char *)malloc(new_length + 1);
605
if (!(res= my_strndup(old_value, new_length, MYF(0))))
491
memcpy(res, old_value, new_length);
495
608
Replace the old value in such a way that the any thread using
496
609
the value will work.
498
pthread_rwlock_wrlock(var_mutex);
611
rw_wrlock(var_mutex);
499
612
old_value= var_str->value;
500
613
var_str->value= res;
501
614
var_str->value_length= new_length;
502
pthread_rwlock_unlock(var_mutex);
615
rw_unlock(var_mutex);
508
static bool sys_update_init_connect(Session *, set_var *var)
621
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
510
623
return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
514
static void sys_default_init_connect(Session *, enum_var_type)
627
static void sys_default_init_connect(THD* thd __attribute__((unused)),
628
enum_var_type type __attribute__((unused)))
516
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;
521
674
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
524
static void fix_max_join_size(Session *session, enum_var_type type)
677
static void fix_max_join_size(THD *thd, enum_var_type type)
526
679
if (type != OPT_GLOBAL)
528
if (session->variables.max_join_size == HA_POS_ERROR)
529
session->options|= OPTION_BIG_SELECTS;
681
if (thd->variables.max_join_size == HA_POS_ERROR)
682
thd->options|= OPTION_BIG_SELECTS;
531
session->options&= ~OPTION_BIG_SELECTS;
684
thd->options&= ~OPTION_BIG_SELECTS;
617
static void fix_session_mem_root(Session *session, enum_var_type type)
619
if (type != OPT_GLOBAL)
620
reset_root_defaults(session->mem_root,
621
session->variables.query_alloc_block_size,
622
session->variables.query_prealloc_size);
626
static void fix_trans_mem_root(Session *session, enum_var_type type)
628
if (type != OPT_GLOBAL)
629
reset_root_defaults(&session->transaction.mem_root,
630
session->variables.trans_alloc_block_size,
631
session->variables.trans_prealloc_size);
635
static void fix_server_id(Session *session, enum_var_type)
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)))
637
933
server_id_supplied = 1;
638
session->server_id= server_id;
934
thd->server_id= server_id;
642
bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
938
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
643
939
const char *name, int64_t val)
694
static bool get_size_t(Session *, set_var *var)
696
if (var->value->unsigned_flag)
697
var->save_result.uint64_t_value= (size_t) var->value->val_int();
700
ssize_t v= var->value->val_int();
701
var->save_result.uint64_t_value= (size_t) ((v < 0) ? 0 : v);
707
980
sys_var_long_ptr::
708
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
981
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_arg,
709
982
sys_after_update_func after_update_arg)
710
983
:sys_var_long_ptr_global(chain, name_arg, value_ptr_arg,
711
984
&LOCK_global_system_variables, after_update_arg)
715
bool sys_var_long_ptr_global::check(Session *session, set_var *var)
988
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
717
return get_unsigned(session, var);
990
return get_unsigned(thd, var);
720
bool sys_var_long_ptr_global::update(Session *session, set_var *var)
993
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
722
995
uint64_t tmp= var->save_result.uint64_t_value;
723
996
pthread_mutex_lock(guard);
724
997
if (option_limits)
725
*value= (uint64_t) fix_unsigned(session, tmp, option_limits);
998
*value= (ulong) fix_unsigned(thd, tmp, option_limits);
728
if (tmp > UINT32_MAX)
1001
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1002
/* Avoid overflows on 32 bit systems */
1003
if (tmp > ULONG_MAX)
731
throw_bounds_warning(session, true, true, name,
1006
throw_bounds_warning(thd, true, true, name,
732
1007
(int64_t) var->save_result.uint64_t_value);
734
*value= (uint64_t) tmp;
1010
*value= (ulong) tmp;
737
1013
pthread_mutex_unlock(guard);
797
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
799
size_t tmp= var->save_result.size_t_value;
800
pthread_mutex_lock(&LOCK_global_system_variables);
802
*value= fix_size_t(session, tmp, option_limits);
805
pthread_mutex_unlock(&LOCK_global_system_variables);
810
void sys_var_size_t_ptr::set_default(Session *, enum_var_type)
813
pthread_mutex_lock(&LOCK_global_system_variables);
814
*value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
815
option_limits, ¬_used);
816
pthread_mutex_unlock(&LOCK_global_system_variables);
819
bool sys_var_bool_ptr::update(Session *, set_var *var)
821
*value= (bool) var->save_result.uint32_t_value;
826
void sys_var_bool_ptr::set_default(Session *, enum_var_type)
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)))
828
1061
*value= (bool) option_limits->def_value;
832
bool sys_var_enum::update(Session *, set_var *var)
1065
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
834
*value= (uint) var->save_result.uint32_t_value;
1067
*value= (uint) var->save_result.ulong_value;
839
unsigned char *sys_var_enum::value_ptr(Session *, enum_var_type, const LEX_STRING *)
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)))
841
1076
return (unsigned char*) enum_names->type_names[*value];
845
unsigned char *sys_var_enum_const::value_ptr(Session *, enum_var_type,
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)))
848
1084
return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
852
32 bit types for session variables
854
bool sys_var_session_uint32_t::check(Session *session, set_var *var)
1087
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
856
return (get_unsigned(session, var) ||
857
(check_func && (*check_func)(session, var)));
1089
return (get_unsigned(thd, var) ||
1090
(check_func && (*check_func)(thd, var)));
860
bool sys_var_session_uint32_t::update(Session *session, set_var *var)
1093
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
862
1095
uint64_t tmp= var->save_result.uint64_t_value;
864
1097
/* Don't use bigger value than given with --maximum-variable-name=.. */
865
if ((uint32_t) tmp > max_system_variables.*offset)
1098
if ((ulong) tmp > max_system_variables.*offset)
867
throw_bounds_warning(session, true, true, name, (int64_t) tmp);
1100
throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
868
1101
tmp= max_system_variables.*offset;
871
1104
if (option_limits)
872
tmp= (uint32_t) fix_unsigned(session, tmp, option_limits);
873
else if (tmp > UINT32_MAX)
1105
tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
1106
#if SIZEOF_LONG < SIZEOF_LONG_LONG
1107
else if (tmp > ULONG_MAX)
876
throw_bounds_warning(session, true, true, name, (int64_t) var->save_result.uint64_t_value);
1110
throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
879
1114
if (var->type == OPT_GLOBAL)
880
global_system_variables.*offset= (uint32_t) tmp;
1115
global_system_variables.*offset= (ulong) tmp;
882
session->variables.*offset= (uint32_t) tmp;
1117
thd->variables.*offset= (ulong) tmp;
888
void sys_var_session_uint32_t::set_default(Session *session, enum_var_type type)
1123
void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type)
890
1125
if (type == OPT_GLOBAL)
893
1128
/* We will not come here if option_limits is not set */
894
1129
global_system_variables.*offset=
895
(uint32_t) getopt_ull_limit_value((uint32_t) option_limits->def_value,
1130
(ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
896
1131
option_limits, ¬_used);
899
session->variables.*offset= global_system_variables.*offset;
1134
thd->variables.*offset= global_system_variables.*offset;
903
unsigned char *sys_var_session_uint32_t::value_ptr(Session *session,
1138
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
LEX_STRING *base __attribute__((unused)))
907
1141
if (type == OPT_GLOBAL)
908
1142
return (unsigned char*) &(global_system_variables.*offset);
909
return (unsigned char*) &(session->variables.*offset);
1143
return (unsigned char*) &(thd->variables.*offset);
913
bool sys_var_session_ha_rows::update(Session *session, set_var *var)
1147
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
915
1149
uint64_t tmp= var->save_result.uint64_t_value;
999
1231
pthread_mutex_unlock(&LOCK_global_system_variables);
1002
session->variables.*offset= global_system_variables.*offset;
1006
unsigned char *sys_var_session_uint64_t::value_ptr(Session *session,
1010
if (type == OPT_GLOBAL)
1011
return (unsigned char*) &(global_system_variables.*offset);
1012
return (unsigned char*) &(session->variables.*offset);
1015
bool sys_var_session_size_t::check(Session *session, set_var *var)
1017
return (get_size_t(session, var) ||
1018
(check_func && (*check_func)(session, var)));
1021
bool sys_var_session_size_t::update(Session *session, set_var *var)
1023
size_t tmp= var->save_result.size_t_value;
1025
if (tmp > max_system_variables.*offset)
1026
tmp= max_system_variables.*offset;
1029
tmp= fix_size_t(session, tmp, option_limits);
1030
if (var->type == OPT_GLOBAL)
1032
/* Lock is needed to make things safe on 32 bit systems */
1033
pthread_mutex_lock(&LOCK_global_system_variables);
1034
global_system_variables.*offset= tmp;
1035
pthread_mutex_unlock(&LOCK_global_system_variables);
1038
session->variables.*offset= tmp;
1043
void sys_var_session_size_t::set_default(Session *session, enum_var_type type)
1045
if (type == OPT_GLOBAL)
1048
pthread_mutex_lock(&LOCK_global_system_variables);
1049
global_system_variables.*offset=
1050
getopt_ull_limit_value((size_t) option_limits->def_value,
1051
option_limits, ¬_used);
1052
pthread_mutex_unlock(&LOCK_global_system_variables);
1055
session->variables.*offset= global_system_variables.*offset;
1059
unsigned char *sys_var_session_size_t::value_ptr(Session *session,
1063
if (type == OPT_GLOBAL)
1064
return (unsigned char*) &(global_system_variables.*offset);
1065
return (unsigned char*) &(session->variables.*offset);
1069
bool sys_var_session_bool::update(Session *session, set_var *var)
1071
if (var->type == OPT_GLOBAL)
1072
global_system_variables.*offset= (bool) var->save_result.uint32_t_value;
1074
session->variables.*offset= (bool) var->save_result.uint32_t_value;
1079
void sys_var_session_bool::set_default(Session *session, enum_var_type type)
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)
1081
1259
if (type == OPT_GLOBAL)
1082
1260
global_system_variables.*offset= (bool) option_limits->def_value;
1084
session->variables.*offset= global_system_variables.*offset;
1262
thd->variables.*offset= global_system_variables.*offset;
1088
unsigned char *sys_var_session_bool::value_ptr(Session *session,
1266
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1267
LEX_STRING *base __attribute__((unused)))
1092
1269
if (type == OPT_GLOBAL)
1093
1270
return (unsigned char*) &(global_system_variables.*offset);
1094
return (unsigned char*) &(session->variables.*offset);
1271
return (unsigned char*) &(thd->variables.*offset);
1098
bool sys_var::check_enum(Session *,
1275
bool sys_var::check_enum(THD *thd __attribute__((unused)),
1099
1276
set_var *var, const TYPELIB *enum_names)
1101
1278
char buff[STRING_BUFFER_USUAL_SIZE];
1314
bool sys_var_session_enum::update(Session *session, set_var *var)
1492
bool sys_var_thd_enum::update(THD *thd, set_var *var)
1316
1494
if (var->type == OPT_GLOBAL)
1317
global_system_variables.*offset= var->save_result.uint32_t_value;
1495
global_system_variables.*offset= var->save_result.ulong_value;
1319
session->variables.*offset= var->save_result.uint32_t_value;
1497
thd->variables.*offset= var->save_result.ulong_value;
1324
void sys_var_session_enum::set_default(Session *session, enum_var_type type)
1502
void sys_var_thd_enum::set_default(THD *thd, enum_var_type type)
1326
1504
if (type == OPT_GLOBAL)
1327
global_system_variables.*offset= (uint32_t) option_limits->def_value;
1505
global_system_variables.*offset= (ulong) option_limits->def_value;
1329
session->variables.*offset= global_system_variables.*offset;
1507
thd->variables.*offset= global_system_variables.*offset;
1333
unsigned char *sys_var_session_enum::value_ptr(Session *session,
1511
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1512
LEX_STRING *base __attribute__((unused)))
1337
uint32_t tmp= ((type == OPT_GLOBAL) ?
1514
ulong tmp= ((type == OPT_GLOBAL) ?
1338
1515
global_system_variables.*offset :
1339
session->variables.*offset);
1516
thd->variables.*offset);
1340
1517
return (unsigned char*) enum_names->type_names[tmp];
1343
bool sys_var_session_bit::check(Session *session, set_var *var)
1520
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1345
return (check_enum(session, var, &bool_typelib) ||
1346
(check_func && (*check_func)(session, var)));
1522
return (check_enum(thd, var, &bool_typelib) ||
1523
(check_func && (*check_func)(thd, var)));
1349
bool sys_var_session_bit::update(Session *session, set_var *var)
1526
bool sys_var_thd_bit::update(THD *thd, set_var *var)
1351
int res= (*update_func)(session, var);
1528
int res= (*update_func)(thd, var);
1356
unsigned char *sys_var_session_bit::value_ptr(Session *session, enum_var_type,
1533
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1534
enum_var_type type __attribute__((unused)),
1535
LEX_STRING *base __attribute__((unused)))
1360
1538
If reverse is 0 (default) return 1 if bit is set.
1361
1539
If reverse is 1, return 0 if bit is set
1363
session->sys_var_tmp.bool_value= ((session->options & bit_flag) ?
1541
thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
1364
1542
!reverse : reverse);
1365
return (unsigned char*) &session->sys_var_tmp.bool_value;
1543
return (unsigned char*) &thd->sys_var_tmp.bool_value;
1369
1547
/** Update a date_time format variable based on given value. */
1371
void sys_var_session_date_time_format::update2(Session *session, enum_var_type type,
1549
void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
1372
1550
DATE_TIME_FORMAT *new_value)
1374
1552
DATE_TIME_FORMAT *old;
1513
bool sys_var_collation_sv::update(Session *session, set_var *var)
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)
1515
1804
if (var->type == OPT_GLOBAL)
1516
1805
global_system_variables.*offset= var->save_result.charset;
1519
session->variables.*offset= var->save_result.charset;
1520
session->update_charset();
1808
thd->variables.*offset= var->save_result.charset;
1809
thd->update_charset();
1526
void sys_var_collation_sv::set_default(Session *session, enum_var_type type)
1815
void sys_var_collation_sv::set_default(THD *thd, enum_var_type type)
1528
1817
if (type == OPT_GLOBAL)
1529
1818
global_system_variables.*offset= *global_default;
1532
session->variables.*offset= global_system_variables.*offset;
1533
session->update_charset();
1821
thd->variables.*offset= global_system_variables.*offset;
1822
thd->update_charset();
1538
unsigned char *sys_var_collation_sv::value_ptr(Session *session,
1827
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
LEX_STRING *base __attribute__((unused)))
1542
1830
const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1543
global_system_variables.*offset :
1544
session->variables.*offset);
1831
global_system_variables.*offset : thd->variables.*offset);
1545
1832
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);
1715
2145
/****************************************************************************/
1717
bool sys_var_timestamp::update(Session *session, set_var *var)
2147
bool sys_var_timestamp::update(THD *thd, set_var *var)
1719
session->set_time((time_t) var->save_result.uint64_t_value);
2149
thd->set_time((time_t) var->save_result.uint64_t_value);
1724
void sys_var_timestamp::set_default(Session *session, enum_var_type)
1726
session->user_time=0;
1730
unsigned char *sys_var_timestamp::value_ptr(Session *session, enum_var_type,
1733
session->sys_var_tmp.long_value= (long) session->start_time;
1734
return (unsigned char*) &session->sys_var_tmp.long_value;
1738
bool sys_var_last_insert_id::update(Session *session, set_var *var)
1740
session->first_successful_insert_id_in_prev_stmt=
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=
1741
2173
var->save_result.uint64_t_value;
1746
unsigned char *sys_var_last_insert_id::value_ptr(Session *session,
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)))
1751
2183
this tmp var makes it robust againt change of type of
1752
2184
read_first_successful_insert_id_in_prev_stmt().
1754
session->sys_var_tmp.uint64_t_value=
1755
session->read_first_successful_insert_id_in_prev_stmt();
1756
return (unsigned char*) &session->sys_var_tmp.uint64_t_value;
1760
bool sys_var_session_time_zone::check(Session *session, set_var *var)
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)
1762
2224
char buff[MAX_TIME_ZONE_NAME_LENGTH];
1763
2225
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
1764
2226
String *res= var->value->val_str(&str);
1766
if (!(var->save_result.time_zone= my_tz_find(session, res)))
2228
if (!(var->save_result.time_zone= my_tz_find(thd, res)))
1768
2230
my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
1824
2286
We are guaranteed to find this time zone since its existence
1825
2287
is checked during start-up.
1827
global_system_variables.time_zone= my_tz_find(session, &str);
2289
global_system_variables.time_zone= my_tz_find(thd, &str);
1830
2292
global_system_variables.time_zone= my_tz_SYSTEM;
1833
session->variables.time_zone= global_system_variables.time_zone;
2295
thd->variables.time_zone= global_system_variables.time_zone;
1834
2296
pthread_mutex_unlock(&LOCK_global_system_variables);
1838
bool sys_var_session_lc_time_names::check(Session *, set_var *var)
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)),
1840
2349
MY_LOCALE *locale_match;
1940
2449
pthread_mutex_unlock(&LOCK_global_system_variables);
1943
session->variables.*offset= microseconds;
2452
thd->variables.*offset= microseconds;
1947
unsigned char *sys_var_microseconds::value_ptr(Session *session,
2456
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
LEX_STRING *base __attribute__((unused)))
1951
session->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2459
thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
1952
2460
global_system_variables.*offset :
1953
session->variables.*offset) / 1000000.0;
1954
return (unsigned char*) &session->tmp_double_value;
2461
thd->variables.*offset) / 1000000.0;
2462
return (unsigned char*) &thd->tmp_double_value;
1959
Functions to update session->options bits
2467
Functions to update thd->options bits
1962
static bool set_option_bit(Session *session, set_var *var)
2470
static bool set_option_bit(THD *thd, set_var *var)
1964
sys_var_session_bit *sys_var= ((sys_var_session_bit*) var->var);
1965
if ((var->save_result.uint32_t_value != 0) == sys_var->reverse)
1966
session->options&= ~sys_var->bit_flag;
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;
1968
session->options|= sys_var->bit_flag;
2476
thd->options|= sys_var->bit_flag;
1973
static bool set_option_autocommit(Session *session, set_var *var)
2481
static bool set_option_autocommit(THD *thd, set_var *var)
1975
2483
/* The test is negative as the flag we use is NOT autocommit */
1977
uint64_t org_options= session->options;
2485
uint64_t org_options= thd->options;
1979
if (var->save_result.uint32_t_value != 0)
1980
session->options&= ~((sys_var_session_bit*) var->var)->bit_flag;
2487
if (var->save_result.ulong_value != 0)
2488
thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
1982
session->options|= ((sys_var_session_bit*) var->var)->bit_flag;
2490
thd->options|= ((sys_var_thd_bit*) var->var)->bit_flag;
1984
if ((org_options ^ session->options) & OPTION_NOT_AUTOCOMMIT)
2492
if ((org_options ^ thd->options) & OPTION_NOT_AUTOCOMMIT)
1986
2494
if ((org_options & OPTION_NOT_AUTOCOMMIT))
1988
2496
/* We changed to auto_commit mode */
1989
session->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
1990
session->transaction.all.modified_non_trans_table= false;
1991
session->server_status|= SERVER_STATUS_AUTOCOMMIT;
1992
if (ha_commit(session))
2497
thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
2498
thd->transaction.all.modified_non_trans_table= false;
2499
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
1997
session->transaction.all.modified_non_trans_table= false;
1998
session->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2505
thd->transaction.all.modified_non_trans_table= false;
2506
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2004
static int check_pseudo_thread_id(Session *, set_var *var)
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)),
2006
2522
var->save_result.uint64_t_value= var->value->val_int();
2010
static unsigned char *get_warning_count(Session *session)
2526
static unsigned char *get_warning_count(THD *thd)
2012
session->sys_var_tmp.long_value=
2013
(session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2014
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2015
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2016
return (unsigned char*) &session->sys_var_tmp.long_value;
2528
thd->sys_var_tmp.long_value=
2529
(thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2530
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2531
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2532
return (unsigned char*) &thd->sys_var_tmp.long_value;
2019
static unsigned char *get_error_count(Session *session)
2535
static unsigned char *get_error_count(THD *thd)
2021
session->sys_var_tmp.long_value=
2022
session->warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2023
return (unsigned char*) &session->sys_var_tmp.long_value;
2537
thd->sys_var_tmp.long_value=
2538
thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2539
return (unsigned char*) &thd->sys_var_tmp.long_value;
2693
3223
while ((element= it++))
2695
3225
KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
2696
func(element->name.c_str(), key_cache);
3226
func(element->name, 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);
2701
3293
/****************************************************************************
2703
3295
****************************************************************************/