104
104
array_elements(bool_type_names)-1, "", bool_type_names, NULL
107
static bool set_option_bit(Session*, set_var*);
108
static bool set_option_autocommit(Session*, set_var*);
109
static int check_pseudo_thread_id(Session*, set_var*);
110
static int check_tx_isolation(Session*, set_var*);
111
static void fix_tx_isolation(Session*, sql_var_t);
112
static int check_completion_type(Session*, set_var*);
113
static void fix_max_join_size(Session*, sql_var_t);
114
static void fix_session_mem_root(Session*, sql_var_t);
115
void throw_bounds_warning(Session*, bool fixed, bool unsignd, const std::string &name, int64_t);
116
static unsigned char *get_error_count(Session*);
117
static unsigned char *get_warning_count(Session*);
118
static unsigned char *get_tmpdir(Session*);
107
static bool set_option_bit(Session *session, set_var *var);
108
static bool set_option_autocommit(Session *session, set_var *var);
109
static int check_pseudo_thread_id(Session *session, set_var *var);
110
static int check_tx_isolation(Session *session, set_var *var);
111
static void fix_tx_isolation(Session *session, sql_var_t type);
112
static int check_completion_type(Session *session, set_var *var);
113
static void fix_completion_type(Session *session, sql_var_t type);
114
static void fix_max_join_size(Session *session, sql_var_t type);
115
static void fix_session_mem_root(Session *session, sql_var_t type);
116
static void fix_server_id(Session *session, sql_var_t type);
117
void throw_bounds_warning(Session *session, bool fixed, bool unsignd, const std::string &name, int64_t val);
118
static unsigned char *get_error_count(Session *session);
119
static unsigned char *get_warning_count(Session *session);
120
static unsigned char *get_tmpdir(Session *session);
121
123
Variable definition list
127
129
it in the constructor (see sys_var class for details).
129
131
static sys_var_session_uint64_t
130
sys_auto_increment_increment("auto_increment_increment", &drizzle_system_variables::auto_increment_increment);
132
sys_auto_increment_increment("auto_increment_increment",
133
&drizzle_system_variables::auto_increment_increment);
131
134
static sys_var_session_uint64_t
132
sys_auto_increment_offset("auto_increment_offset", &drizzle_system_variables::auto_increment_offset);
135
sys_auto_increment_offset("auto_increment_offset",
136
&drizzle_system_variables::auto_increment_offset);
134
138
static sys_var_fs_path sys_basedir("basedir", basedir);
135
139
static sys_var_fs_path sys_pid_file("pid_file", pid_file);
136
140
static sys_var_fs_path sys_plugin_dir("plugin_dir", plugin_dir);
138
static sys_var_size_t_ptr sys_thread_stack_size("thread_stack", &my_thread_stack_size);
142
static sys_var_size_t_ptr sys_thread_stack_size("thread_stack",
143
&my_thread_stack_size);
139
144
static sys_var_constrained_value_readonly<uint32_t> sys_back_log("back_log", back_log);
141
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size", &drizzle_system_variables::bulk_insert_buff_size);
142
static sys_var_session_uint32_t sys_completion_type("completion_type", &drizzle_system_variables::completion_type, check_completion_type);
146
static sys_var_session_uint64_t sys_bulk_insert_buff_size("bulk_insert_buffer_size",
147
&drizzle_system_variables::bulk_insert_buff_size);
148
static sys_var_session_uint32_t sys_completion_type("completion_type",
149
&drizzle_system_variables::completion_type,
150
check_completion_type,
151
fix_completion_type);
143
152
static sys_var_collation_sv
144
153
sys_collation_server("collation_server", &drizzle_system_variables::collation_server, &default_charset_info);
145
static sys_var_fs_path sys_datadir("datadir", getDataHome());
147
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size", &drizzle_system_variables::join_buff_size);
148
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet", &drizzle_system_variables::max_allowed_packet);
149
static sys_var_session_uint64_t sys_max_error_count("max_error_count", &drizzle_system_variables::max_error_count);
150
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size", &drizzle_system_variables::max_heap_table_size);
151
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id", &drizzle_system_variables::pseudo_thread_id, 0, check_pseudo_thread_id);
152
static sys_var_session_ha_rows sys_max_join_size("max_join_size", &drizzle_system_variables::max_join_size, fix_max_join_size);
153
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key", &drizzle_system_variables::max_seeks_for_key);
154
static sys_var_session_uint64_t sys_max_length_for_sort_data("max_length_for_sort_data", &drizzle_system_variables::max_length_for_sort_data);
155
static sys_var_session_size_t sys_max_sort_length("max_sort_length", &drizzle_system_variables::max_sort_length);
156
static sys_var_uint64_t_ptr sys_max_write_lock_count("max_write_lock_count", &max_write_lock_count);
157
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit", &drizzle_system_variables::min_examined_row_limit);
159
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level", &drizzle_system_variables::optimizer_prune_level);
160
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth", &drizzle_system_variables::optimizer_search_depth);
162
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size", &drizzle_system_variables::preload_buff_size);
163
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size", &drizzle_system_variables::read_buff_size);
164
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size", &drizzle_system_variables::read_rnd_buff_size);
165
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment", &drizzle_system_variables::div_precincrement);
167
static sys_var_session_size_t sys_range_alloc_block_size("range_alloc_block_size", &drizzle_system_variables::range_alloc_block_size);
169
static sys_var_session_bool sys_replicate_query("replicate_query", &drizzle_system_variables::replicate_query);
171
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size", &drizzle_system_variables::query_alloc_block_size, NULL, fix_session_mem_root);
172
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size", &drizzle_system_variables::query_prealloc_size, NULL, fix_session_mem_root);
154
static sys_var_fs_path sys_datadir("datadir", getDataHome());
156
static sys_var_session_uint64_t sys_join_buffer_size("join_buffer_size",
157
&drizzle_system_variables::join_buff_size);
158
static sys_var_session_uint32_t sys_max_allowed_packet("max_allowed_packet",
159
&drizzle_system_variables::max_allowed_packet);
160
static sys_var_session_uint64_t sys_max_error_count("max_error_count",
161
&drizzle_system_variables::max_error_count);
162
static sys_var_session_uint64_t sys_max_heap_table_size("max_heap_table_size",
163
&drizzle_system_variables::max_heap_table_size);
164
static sys_var_session_uint64_t sys_pseudo_thread_id("pseudo_thread_id",
165
&drizzle_system_variables::pseudo_thread_id,
166
0, check_pseudo_thread_id);
167
static sys_var_session_ha_rows sys_max_join_size("max_join_size",
168
&drizzle_system_variables::max_join_size,
170
static sys_var_session_uint64_t sys_max_seeks_for_key("max_seeks_for_key",
171
&drizzle_system_variables::max_seeks_for_key);
172
static sys_var_session_uint64_t sys_max_length_for_sort_data("max_length_for_sort_data",
173
&drizzle_system_variables::max_length_for_sort_data);
174
static sys_var_session_size_t sys_max_sort_length("max_sort_length",
175
&drizzle_system_variables::max_sort_length);
176
static sys_var_uint64_t_ptr sys_max_write_lock_count("max_write_lock_count",
177
&max_write_lock_count);
178
static sys_var_session_uint64_t sys_min_examined_row_limit("min_examined_row_limit",
179
&drizzle_system_variables::min_examined_row_limit);
181
/* these two cannot be static */
182
static sys_var_session_bool sys_optimizer_prune_level("optimizer_prune_level",
183
&drizzle_system_variables::optimizer_prune_level);
184
static sys_var_session_uint32_t sys_optimizer_search_depth("optimizer_search_depth",
185
&drizzle_system_variables::optimizer_search_depth);
187
static sys_var_session_uint64_t sys_preload_buff_size("preload_buffer_size",
188
&drizzle_system_variables::preload_buff_size);
189
static sys_var_session_uint32_t sys_read_buff_size("read_buffer_size",
190
&drizzle_system_variables::read_buff_size);
191
static sys_var_session_uint32_t sys_read_rnd_buff_size("read_rnd_buffer_size",
192
&drizzle_system_variables::read_rnd_buff_size);
193
static sys_var_session_uint32_t sys_div_precincrement("div_precision_increment",
194
&drizzle_system_variables::div_precincrement);
196
static sys_var_session_size_t sys_range_alloc_block_size("range_alloc_block_size",
197
&drizzle_system_variables::range_alloc_block_size);
199
static sys_var_session_bool sys_replicate_query("replicate_query",
200
&drizzle_system_variables::replicate_query);
202
static sys_var_session_uint32_t sys_query_alloc_block_size("query_alloc_block_size",
203
&drizzle_system_variables::query_alloc_block_size,
204
NULL, fix_session_mem_root);
205
static sys_var_session_uint32_t sys_query_prealloc_size("query_prealloc_size",
206
&drizzle_system_variables::query_prealloc_size,
207
NULL, fix_session_mem_root);
173
208
static sys_var_readonly sys_tmpdir("tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
175
static sys_var_fs_path sys_secure_file_priv("secure_file_priv", secure_file_priv);
176
static sys_var_const_str_ptr sys_scheduler("scheduler", (char**)&opt_scheduler);
178
static sys_var_uint32_t_ptr sys_server_id("server_id", &server_id);
210
static sys_var_fs_path sys_secure_file_priv("secure_file_priv",
213
static sys_var_const_str_ptr sys_scheduler("scheduler",
214
(char**)&opt_scheduler);
216
static sys_var_uint32_t_ptr sys_server_id("server_id", &server_id,
180
219
static sys_var_const_string sys_server_uuid("server_uuid", server_uuid);
182
static sys_var_session_size_t sys_sort_buffer("sort_buffer_size", &drizzle_system_variables::sortbuff_size);
184
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold", &transaction_message_threshold);
186
static sys_var_session_storage_engine sys_storage_engine("storage_engine", &drizzle_system_variables::storage_engine);
187
static sys_var_size_t_ptr sys_table_def_size("table_definition_cache", &table_def_size);
188
static sys_var_uint64_t_ptr sys_table_cache_size("table_open_cache", &table_cache_size);
189
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout("table_lock_wait_timeout", &table_lock_wait_timeout);
221
static sys_var_session_size_t sys_sort_buffer("sort_buffer_size",
222
&drizzle_system_variables::sortbuff_size);
224
static sys_var_size_t_ptr_readonly sys_transaction_message_threshold("transaction_message_threshold",
225
&transaction_message_threshold);
227
static sys_var_session_storage_engine sys_storage_engine("storage_engine",
228
&drizzle_system_variables::storage_engine);
229
static sys_var_size_t_ptr sys_table_def_size("table_definition_cache",
231
static sys_var_uint64_t_ptr sys_table_cache_size("table_open_cache",
233
static sys_var_uint64_t_ptr sys_table_lock_wait_timeout("table_lock_wait_timeout",
234
&table_lock_wait_timeout);
190
235
static sys_var_session_enum sys_tx_isolation("tx_isolation",
191
236
&drizzle_system_variables::tx_isolation,
192
237
&tx_isolation_typelib,
197
242
static sys_var_bool_ptr sys_timed_mutexes("timed_mutexes", &internal::timed_mutexes);
198
243
static sys_var_const_str sys_version("version", version().c_str());
200
static sys_var_const_str sys_version_comment("version_comment", COMPILATION_COMMENT);
201
static sys_var_const_str sys_version_compile_machine("version_compile_machine", HOST_CPU);
202
static sys_var_const_str sys_version_compile_os("version_compile_os", HOST_OS);
203
static sys_var_const_str sys_version_compile_vendor("version_compile_vendor", HOST_VENDOR);
245
static sys_var_const_str sys_version_comment("version_comment",
246
COMPILATION_COMMENT);
247
static sys_var_const_str sys_version_compile_machine("version_compile_machine",
249
static sys_var_const_str sys_version_compile_os("version_compile_os",
251
static sys_var_const_str sys_version_compile_vendor("version_compile_vendor",
205
254
/* Variables that are bits in Session */
207
sys_var_session_bit sys_autocommit("autocommit", 0, set_option_autocommit, OPTION_NOT_AUTOCOMMIT, 1);
208
static sys_var_session_bit sys_big_selects("sql_big_selects", 0, set_option_bit, OPTION_BIG_SELECTS);
209
static sys_var_session_bit sys_sql_warnings("sql_warnings", 0, set_option_bit, OPTION_WARNINGS);
210
static sys_var_session_bit sys_sql_notes("sql_notes", 0, set_option_bit, OPTION_SQL_NOTES);
211
static sys_var_session_bit sys_buffer_results("sql_buffer_result", 0, set_option_bit, OPTION_BUFFER_RESULT);
212
static sys_var_session_bit sys_foreign_key_checks("foreign_key_checks", 0, set_option_bit, OPTION_NO_FOREIGN_KEY_CHECKS, 1);
213
static sys_var_session_bit sys_unique_checks("unique_checks", 0, set_option_bit, OPTION_RELAXED_UNIQUE_CHECKS, 1);
256
sys_var_session_bit sys_autocommit("autocommit", 0,
257
set_option_autocommit,
258
OPTION_NOT_AUTOCOMMIT,
260
static sys_var_session_bit sys_big_selects("sql_big_selects", 0,
263
static sys_var_session_bit sys_sql_warnings("sql_warnings", 0,
266
static sys_var_session_bit sys_sql_notes("sql_notes", 0,
269
static sys_var_session_bit sys_buffer_results("sql_buffer_result", 0,
271
OPTION_BUFFER_RESULT);
272
static sys_var_session_bit sys_foreign_key_checks("foreign_key_checks", 0,
274
OPTION_NO_FOREIGN_KEY_CHECKS, 1);
275
static sys_var_session_bit sys_unique_checks("unique_checks", 0,
277
OPTION_RELAXED_UNIQUE_CHECKS, 1);
214
278
/* Local state variables */
216
static sys_var_session_ha_rows sys_select_limit("sql_select_limit", &drizzle_system_variables::select_limit);
280
static sys_var_session_ha_rows sys_select_limit("sql_select_limit",
281
&drizzle_system_variables::select_limit);
217
282
static sys_var_timestamp sys_timestamp("timestamp");
218
283
static sys_var_last_insert_id
219
284
sys_last_insert_id("last_insert_id");
795
888
If type is not given, return local value if exists, else global.
798
Item *sys_var::item(Session *session, sql_var_t var_type)
891
Item *sys_var::item(Session *session, sql_var_t var_type, const lex_string_t *base)
800
893
if (check_type(var_type))
802
895
if (var_type != OPT_DEFAULT)
804
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), name.c_str(), var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL");
897
my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0),
898
name.c_str(), var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL");
807
901
/* As there was no local variable, return the global value */
808
902
var_type= OPT_GLOBAL;
810
boost::mutex::scoped_lock lock(session->catalog().systemVariableLock());
904
switch (show_type()) {
816
uint32_t value= *(uint*) value_ptr(session, var_type);
909
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
910
value= *(uint*) value_ptr(session, var_type, base);
817
912
return new Item_uint((uint64_t) value);
819
914
case SHOW_LONGLONG:
821
int64_t value= *(int64_t*) value_ptr(session, var_type);
917
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
918
value= *(int64_t*) value_ptr(session, var_type, base);
822
920
return new Item_int(value);
824
922
case SHOW_DOUBLE:
826
double value= *(double*) value_ptr(session, var_type);
926
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
927
value= *(double*) value_ptr(session, var_type, base);
827
930
/* 6, as this is for now only used with microseconds */
828
931
return new Item_float(value, 6);
830
933
case SHOW_HA_ROWS:
832
ha_rows value= *(ha_rows*) value_ptr(session, var_type);
936
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
937
value= *(ha_rows*) value_ptr(session, var_type, base);
833
939
return new Item_int((uint64_t) value);
837
size_t value= *(size_t*) value_ptr(session, var_type);
944
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
945
value= *(size_t*) value_ptr(session, var_type, base);
838
947
return new Item_int((uint64_t) value);
840
949
case SHOW_MY_BOOL:
842
int32_t value= *(bool*) value_ptr(session, var_type);
843
return new Item_int(value, 1);
952
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
953
value= *(bool*) value_ptr(session, var_type, base);
954
return new Item_int(value,1);
845
956
case SHOW_CHAR_PTR:
847
if (const char *str= *(char**) value_ptr(session, var_type))
959
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
960
char *str= *(char**) value_ptr(session, var_type, base);
849
963
uint32_t length= strlen(str);
850
return new Item_string(session->mem.strdup(str, length), length, system_charset_info, DERIVATION_SYSCONST);
852
Item* tmp= new Item_null();
853
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
964
tmp= new Item_string(session->mem.strdup(str, length), length, system_charset_info, DERIVATION_SYSCONST);
968
tmp= new Item_null();
969
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
858
if (const char* str= (char*) value_ptr(session, var_type))
976
boost::mutex::scoped_lock scopedLock(session->catalog().systemVariableLock());
977
if (const char* str= (char*) value_ptr(session, var_type, base))
859
978
return new Item_string(str_ref(str), system_charset_info, DERIVATION_SYSCONST);
860
979
Item* tmp= new Item_null();
861
980
tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);